Address Contract Partially Verified
Address
0xC2966A73Bbc53f3C99268ED84D245dBE972eD89e
Balance
0 ETH
Nonce
1
Code Size
8683 bytes
Creator
0x0bb3a327...88c6 at tx 0x1eb73b3e...4574e9
Indexed Transactions
0
Contract Bytecode
8683 bytes
0x608060405234801561001057600080fd5b50600436106101e45760003560e01c806373a2f2141161010f578063a694fc3a116100a2578063f2fde38b11610071578063f2fde38b14610434578063f9f953bf14610447578063fce67e0d14610450578063ff4daf2e1461046357600080fd5b8063a694fc3a14610408578063df136d651461041b578063e5fcd6cd14610424578063eba8a2661461042c57600080fd5b80638afe540c116100de5780638afe540c146103b15780638b876347146103c45780638da5cb5b146103e457806397308753146103f557600080fd5b806373a2f214146103655780637a237b3914610378578063895d440e1461038b578063898ac82e1461039e57600080fd5b80632e17de781161018757806351cff8d91161015657806351cff8d9146103245780635c71702b146103375780636067de891461034a578063715018a61461035d57600080fd5b80632e17de78146102e35780633988a1ac146102f65780633d18b912146103095780634e73294b1461031157600080fd5b80631031ec31116101c35780631031ec311461024f578063189cffa61461026f578063246132f91461028f5780632b507df8146102a457600080fd5b80628cc262146101e95780630700037d1461020f5780630ee9e6021461022f575b600080fd5b6101fc6101f7366004611db9565b61046c565b6040519081526020015b60405180910390f35b6101fc61021d366004611db9565b60076020526000908152604090205481565b6101fc61023d366004611db9565b60096020526000908152604090205481565b6101fc61025d366004611db9565b600a6020526000908152604090205481565b6101fc61027d366004611db9565b60086020526000908152604090205481565b6102a261029d366004611dd6565b6104d3565b005b6102cb7f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff81565b6040516001600160a01b039091168152602001610206565b6102a26102f1366004611df8565b610703565b6102a2610304366004611df8565b6109c7565b6102a2610a0c565b6101fc61031f366004611db9565b610dbe565b6102a2610332366004611db9565b610e2a565b6101fc610345366004611db9565b610f0e565b6102a2610358366004611db9565b610fea565b6102a2611014565b6101fc610373366004611db9565b611028565b6102a2610386366004611e11565b6110eb565b6102a2610399366004611e7b565b611143565b6003546102cb906001600160a01b031681565b6002546102cb906001600160a01b031681565b6101fc6103d2366004611db9565b60066020526000908152604090205481565b6000546001600160a01b03166102cb565b6001546102cb906001600160a01b031681565b6102a2610416366004611df8565b6114ed565b6101fc60055481565b6102a2611617565b6102a26117bc565b6102a2610442366004611db9565b6118a6565b6101fc600b5481565b6102a261045e366004611db9565b61191f565b6101fc600c5481565b6001600160a01b0381166000908152600760209081526040808320546006909252822054600554670de0b6b3a7640000916104a691611ec1565b6104af85611958565b6104b99190611ed4565b6104c39190611eeb565b6104cd9190611f0d565b92915050565b336001600160a01b037f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff16146105355760405162461bcd60e51b81526020600482015260026024820152614e4160f01b60448201526064015b60405180910390fd5b61053d6119c7565b600003610548575050565b816000036105855760405162461bcd60e51b815260206004820152600a6024820152690616d6f756e74203d20360b41b604482015260640161052c565b806001036106ca5760007f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff6001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106119190611f20565b905061061b6119c7565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610659573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067d9190611f3d565b61068890600a612044565b6106a1856ec097ce7bc90715b34b9f1000000000611ed4565b6106ab9190611eeb565b6106b59190611eeb565b6005546106c29190611f0d565b600555505050565b6106d26119c7565b6106e483670de0b6b3a7640000611ed4565b6106ee9190611eeb565b6005546106fb9190611f0d565b6005555b5050565b600354604051637966782b60e11b815233600482015260009182916001600160a01b039091169063f2ccf05690602401608060405180830381865afa158015610750573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107749190612053565b5050915091508042101561082c5761078c8383611f0d565b6001546040516370a0823160e01b81523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156107d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f89190612089565b101561082c5760405162461bcd60e51b815260206004820152600360248201526255434560e81b604482015260640161052c565b600154604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061085e90339087906004016120a2565b6020604051808303816000875af115801561087d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a191906120bb565b506108ab33610e2a565b33600090815260086020526040902054839042101561090657336000908152600860205260409020546108df904290611ec1565b336000908152600960205260409020546108f99190611ed4565b6109039082611f0d565b90505b6109307f000000000000000000000000000000000000000000000000000000000076a70082611eeb565b3360009081526009602052604090205561096a7f000000000000000000000000000000000000000000000000000000000076a70042611f0d565b33600081815260086020526040908190209290925590517f19a9807c3e232c2af31d8a5f2cccb9a2450cd8e42cb39bba0eb97c0fec7d15cc906109b99087904290918252602082015260400190565b60405180910390a250505050565b6109cf611a3a565b611f40811115610a075760405162461bcd60e51b815260206004820152600360248201526242434560e81b604482015260640161052c565b600c55565b33610a168161046c565b6001600160a01b038216600090815260076020818152604080842094909455600554600682528484205533835252205480156106ff573360009081526007602090815260408083208390558051633558a88760e21b815290517f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff6001600160a01b03169263d562a21c92600480820193918290030181865afa158015610ac0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae49190611f20565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b529190612089565b9050600083821015610b645781610b66565b835b60405163a9059cbb60e01b81529091506001600160a01b0384169063a9059cbb90610b9790339085906004016120a2565b6020604051808303816000875af1158015610bb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bda91906120bb565b5080841115610d725760007f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff6001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c679190611f20565b90506000670de0b6b3a7640000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd69190611f3d565b610ce190600a612044565b610ceb8589611ec1565b610cf59190611ed4565b610cff9190611eeb565b9050610d156001600160a01b0383163383611a94565b6001600160a01b038216337faaa6d06ab685fb7b3a56a14a0940b262047f1bd3a5d06a27e5cc68957f7d331985610d4c818b611ec1565b604080519283526020830191909152429082015260600160405180910390a35050610db7565b604080518281526000602082018190524282840152915133917faaa6d06ab685fb7b3a56a14a0940b262047f1bd3a5d06a27e5cc68957f7d3319919081900360600190a35b5050505050565b6001600160a01b038116600090815260086020526040812054421015610e25576001600160a01b038216600090815260086020526040902054610e02904290611ec1565b6001600160a01b0383166000908152600960205260409020546104cd9190611ed4565b919050565b6000610e3582611028565b90508015610eb4576002546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990610e6f90859085906004016120a2565b6020604051808303816000875af1158015610e8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb291906120bb565b505b6001600160a01b0382166000818152600a602090815260409182902042908190558251858152918201527f53b7fda592811c2dc676ae0ee8f2236fbcf0c1664d74a8c40b3602a39274e04291015b60405180910390a25050565b600080610f1a83610dbe565b905080600003610f2d5750600092915050565b68056bc75e2d63100000620151806003610f67827f000000000000000000000000000000000000000000000000000000000076a700611eeb565b610f719190611ec1565b6001600160a01b038616600090815260086020526040902054610f95904290611ec1565b610fa8906803cb71f51fc5580000611ed4565b610fb29190611eeb565b610fbc9190611eeb565b610fcf90680410d586a20a4c0000611ec1565b610fd99083611ed4565b610fe39190611eeb565b9392505050565b610ff2611a3a565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b61101c611a3a565b6110266000611aef565b565b6001600160a01b0381166000908152600a602090815260408083205460089092528220541115610e25576001600160a01b03821660009081526008602052604090205442116110bc576001600160a01b0382166000908152600a60205260409020546110949042611ec1565b6001600160a01b0383166000908152600960205260409020546110b79190611ed4565b6104cd565b6001600160a01b0382166000908152600a6020908152604080832054600890925290912054610e029190611ec1565b6110f3611a3a565b600180546001600160a01b039586166001600160a01b0319918216179091556002805494861694821694909417909355600380549285169284169290921790915560048054919093169116179055565b67016345785d8a000082116111805760405162461bcd60e51b8152602060048201526003602482015262514d4760e81b604482015260640161052c565b81600b60008282546111929190611ec1565b9091555050600c54600090612710906111ab9085611ed4565b6111b59190611eeb565b905081156113b1576000600460009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123691906120f2565b5050509150506305f5e100818361124d9190611ed4565b6112579190611eeb565b915060007f000000000000000000000000c8353594eeedc5ce5a4544d3d9907b694c4690ff6001600160a01b0316630c742f586040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112dd9190611f20565b6001600160a01b03166323b872dd336112fe6000546001600160a01b031690565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604481018690526064016020604051808303816000875af1158015611352573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137691906120bb565b9050806113aa5760405162461bcd60e51b81526020600482015260026024820152612a2360f11b604482015260640161052c565b5050611428565b600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906113e390339085906004016120a2565b6020604051808303816000875af1158015611402573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142691906120bb565b505b6001546040516340c10f1960e01b81526001600160a01b03909116906340c10f199061145a90339087906004016120a2565b6020604051808303816000875af1158015611479573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149d91906120bb565b50604080518481526020810183905283151581830152426060820152905133917f699a9b7b7c7a7fbeb81fbe77058f2a752d46bd957e2edaee2536f20884ae1081919081900360800190a2505050565b600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061151f90339085906004016120a2565b6020604051808303816000875af115801561153e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156291906120bb565b506001546040516340c10f1960e01b81526001600160a01b03909116906340c10f199061159590339085906004016120a2565b6020604051808303816000875af11580156115b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d891906120bb565b506040805182815242602082015233917f0528cde2c67617f93e5ba994b14d34131c7027d844573ebbdb78ba556cbd94f691015b60405180910390a250565b336000908152600860205260409020546203f4806116557f000000000000000000000000000000000000000000000000000000000076a70042611f0d565b61165f9190611ec1565b116116925760405162461bcd60e51b8152602060048201526003602482015262454e5760e81b604482015260640161052c565b600061169d33610f0e565b6116a633610dbe565b6116b09190611ec1565b905060006116bd33611028565b6116c633610f0e565b6116d09190611f0d565b9050801561174f576002546040516340c10f1960e01b81526001600160a01b03909116906340c10f199061170a90339085906004016120a2565b6020604051808303816000875af1158015611729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174d91906120bb565b505b33600090815260096020908152604080832083905560089091528120819055600b8054849290611780908490611f0d565b90915550506040805182815242602082015233917f6b2717ee438263045646f147dc0e115cf1c99e02b4dfce09354682d76de6dcb79101610f02565b60006117c733611028565b6117d033610dbe565b6117da9190611f0d565b6001546040516340c10f1960e01b81529192506001600160a01b0316906340c10f199061180d90339085906004016120a2565b6020604051808303816000875af115801561182c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185091906120bb565b503360008181526009602090815260408083208390556008825280832092909255815184815242918101919091527fe2d4f7d2cbc42c0e28598ad885ea0822049fcdecbd5a05e5200be15473ccec06910161160c565b6118ae611a3a565b6001600160a01b0381166119135760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161052c565b61191c81611aef565b50565b806119298161046c565b6001600160a01b0390911660009081526007602090815260408083209390935560055460069091529190205550565b6001546040516370a0823160e01b81526001600160a01b03838116600483015260009216906370a0823190602401602060405180830381865afa1580156119a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cd9190612089565b600154604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015611a11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a359190612089565b905090565b6000546001600160a01b031633146110265760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161052c565b611aea8363a9059cbb60e01b8484604051602401611ab39291906120a2565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611b3f565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611b94826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611c149092919063ffffffff16565b9050805160001480611bb5575080806020019051810190611bb591906120bb565b611aea5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161052c565b6060611c238484600085611c2b565b949350505050565b606082471015611c8c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161052c565b600080866001600160a01b03168587604051611ca89190612166565b60006040518083038185875af1925050503d8060008114611ce5576040519150601f19603f3d011682016040523d82523d6000602084013e611cea565b606091505b5091509150611cfb87838387611d06565b979650505050505050565b60608315611d75578251600003611d6e576001600160a01b0385163b611d6e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161052c565b5081611c23565b611c238383815115611d8a5781518083602001fd5b8060405162461bcd60e51b815260040161052c9190612182565b6001600160a01b038116811461191c57600080fd5b600060208284031215611dcb57600080fd5b8135610fe381611da4565b60008060408385031215611de957600080fd5b50508035926020909101359150565b600060208284031215611e0a57600080fd5b5035919050565b60008060008060808587031215611e2757600080fd5b8435611e3281611da4565b93506020850135611e4281611da4565b92506040850135611e5281611da4565b91506060850135611e6281611da4565b939692955090935050565b801515811461191c57600080fd5b60008060408385031215611e8e57600080fd5b823591506020830135611ea081611e6d565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b818103818111156104cd576104cd611eab565b80820281158282048414176104cd576104cd611eab565b600082611f0857634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156104cd576104cd611eab565b600060208284031215611f3257600080fd5b8151610fe381611da4565b600060208284031215611f4f57600080fd5b815160ff81168114610fe357600080fd5b600181815b80851115611f9b578160001904821115611f8157611f81611eab565b80851615611f8e57918102915b93841c9390800290611f65565b509250929050565b600082611fb2575060016104cd565b81611fbf575060006104cd565b8160018114611fd55760028114611fdf57611ffb565b60019150506104cd565b60ff841115611ff057611ff0611eab565b50506001821b6104cd565b5060208310610133831016604e8410600b841016171561201e575081810a6104cd565b6120288383611f60565b806000190482111561203c5761203c611eab565b029392505050565b6000610fe360ff841683611fa3565b6000806000806080858703121561206957600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121561209b57600080fd5b5051919050565b6001600160a01b03929092168252602082015260400190565b6000602082840312156120cd57600080fd5b8151610fe381611e6d565b805169ffffffffffffffffffff81168114610e2557600080fd5b600080600080600060a0868803121561210a57600080fd5b612113866120d8565b9450602086015193506040860151925060608601519150612136608087016120d8565b90509295509295909350565b60005b8381101561215d578181015183820152602001612145565b50506000910152565b60008251612178818460208701612142565b9190910192915050565b60208152600082518060208401526121a1816040850160208701612142565b601f01601f1916919091016040019291505056fea26469706673582212200d138a322e186ef704e01110a4fcb1c148503ad9838672beaade581902bd003764736f6c63430008110033
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
ILBR.sol 9 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.17;
interface ILBR {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function mint(address user, uint256 amount) external returns(bool);
function burn(address user, uint256 amount) external returns(bool);
}
IesLBR.sol 11 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.17;
interface IesLBR {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function mint(address user, uint256 amount) external returns(bool);
function burn(address user, uint256 amount) external returns(bool);
function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
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. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
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);
}
}
Iconfigurator.sol 29 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.17;
interface Iconfigurator {
function mintVault(address pool) external view returns(bool);
function mintVaultMaxSupply(address pool) external view returns(uint256);
function vaultMintPaused(address pool) external view returns(bool);
function vaultBurnPaused(address pool) external view returns(bool);
function tokenMiner(address pool) external view returns(bool);
function getSafeCollateralRatio(address pool) external view returns(uint256);
function getBadCollateralRatio(address pool) external view returns(uint256);
function getVaultWeight(address pool) external view returns (uint256);
function vaultMintFeeApy(address pool) external view returns(uint256);
function vaultKeeperRatio(address pool) external view returns(uint256);
function redemptionFee() external view returns(uint256);
function getEUSDAddress() external view returns(address);
function peUSD() external view returns(address);
function eUSDMiningIncentives() external view returns(address);
function getProtocolRewardsPool() external view returns(address);
function flashloanFee() external view returns(uint256);
function getEUSDMaxLocked() external view returns (uint256);
function stableToken() external view returns (address);
function isRedemptionProvider(address user) external view returns (bool);
function becomeRedemptionProvider(bool _bool) external;
function refreshMintReward(address user) external;
function distributeRewards() external;
function hasRole(bytes32 role, address account) external view returns (bool);
}
ERC20.sol 365 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev 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.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev 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`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev 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.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev 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`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
ProtocolRewardsPool.sol 252 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;
/**
* @title ProtocolRewardsPool is a derivative version of Synthetix StakingRewards.sol, distributing Protocol revenue to esLBR stakers.
* Converting esLBR to LBR.
* Differences from the original contract,
* - Get `totalStaked` from totalSupply() in contract esLBR.
* - Get `stakedOf(user)` from balanceOf(user) in contract esLBR.
* - When an address esLBR balance changes, call the refreshReward method to update rewards to be claimed.
*/
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../interfaces/Iconfigurator.sol";
import "../interfaces/IesLBR.sol";
import "../interfaces/ILBR.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
interface IesLBRBoost {
function userLockStatus(
address user
) external view returns (uint256, uint256, uint256, uint256);
}
contract ProtocolRewardsPool is Ownable {
using SafeERC20 for ERC20;
Iconfigurator public immutable configurator;
IesLBR public esLBR;
ILBR public LBR;
IesLBRBoost public esLBRBoost;
AggregatorV3Interface internal lbrPriceFeed;
// Sum of (reward ratio * dt * 1e18 / total supply)
uint public rewardPerTokenStored;
// User address => rewardPerTokenStored
mapping(address => uint) public userRewardPerTokenPaid;
// User address => rewards to be claimed
mapping(address => uint) public rewards;
mapping(address => uint) public time2fullRedemption;
mapping(address => uint) public unstakeRatio;
mapping(address => uint) public lastWithdrawTime;
uint256 immutable exitCycle = 90 days;
uint256 public grabableAmount;
uint256 public grabFeeRatio = 3000;
event Restake(address indexed user, uint256 amount, uint256 time);
event StakeLBR(address indexed user, uint256 amount, uint256 time);
event UnstakeLBR(address indexed user, uint256 amount, uint256 time);
event WithdrawLBR(address indexed user, uint256 amount, uint256 time);
event UnlockPrematurely(address indexed user, uint256 amount, uint256 time);
event ClaimReward(address indexed user, uint256 eUSDAmount, address indexed token, uint256 tokenAmount, uint256 time);
event GrabEsLBR(address indexed user, uint256 esLBRAmount, uint256 payAmount, bool useEUSD, uint256 time);
constructor(address _config) {
configurator = Iconfigurator(_config);
}
function setTokenAddress(address _eslbr, address _lbr, address _boost, address _lbrOracle) external onlyOwner {
esLBR = IesLBR(_eslbr);
LBR = ILBR(_lbr);
esLBRBoost = IesLBRBoost(_boost);
lbrPriceFeed = AggregatorV3Interface(_lbrOracle);
}
function setGrabCost(uint256 _ratio) external onlyOwner {
require(_ratio <= 8000, "BCE");
grabFeeRatio = _ratio;
}
function setLBROracle(address _lbrOracle) external onlyOwner {
lbrPriceFeed = AggregatorV3Interface(_lbrOracle);
}
// Total staked
function totalStaked() internal view returns (uint256) {
return esLBR.totalSupply();
}
// User address => esLBR balance
function stakedOf(address staker) internal view returns (uint256) {
return esLBR.balanceOf(staker);
}
function stake(uint256 amount) external {
LBR.burn(msg.sender, amount);
esLBR.mint(msg.sender, amount);
emit StakeLBR(msg.sender, amount, block.timestamp);
}
/**
* @dev Unlocks esLBR and converts it to LBR.
* @param amount The amount to convert.
* Requirements:
* If the current time is less than the unlock time of the user's lock status in the esLBRBoost contract,
* the locked portion in the esLBRBoost contract cannot be unlocked.
* Effects:
* Resets the user's vesting data, entering a new vesting period, when converting to LBR.
*/
function unstake(uint256 amount) external {
(uint256 lockedAmount, uint256 unLockTime,,) = esLBRBoost.userLockStatus(msg.sender);
if(block.timestamp < unLockTime) {
require(esLBR.balanceOf(msg.sender) >= lockedAmount + amount, "UCE");
}
esLBR.burn(msg.sender, amount);
withdraw(msg.sender);
uint256 total = amount;
if (time2fullRedemption[msg.sender] > block.timestamp) {
total += unstakeRatio[msg.sender] * (time2fullRedemption[msg.sender] - block.timestamp);
}
unstakeRatio[msg.sender] = total / exitCycle;
time2fullRedemption[msg.sender] = block.timestamp + exitCycle;
emit UnstakeLBR(msg.sender, amount, block.timestamp);
}
function withdraw(address user) public {
uint256 amount = getClaimAbleLBR(user);
if (amount > 0) {
LBR.mint(user, amount);
}
lastWithdrawTime[user] = block.timestamp;
emit WithdrawLBR(user, amount, block.timestamp);
}
/**
* @dev Redeems and converts the ESLBR being claimed in advance,
* with the lost portion being recorded in the contract and available for others to purchase in LBR at a certain ratio.
*/
function unlockPrematurely() external {
require(block.timestamp + exitCycle - 3 days > time2fullRedemption[msg.sender], "ENW");
uint256 burnAmount = getReservedLBRForVesting(msg.sender) - getPreUnlockableAmount(msg.sender);
uint256 amount = getPreUnlockableAmount(msg.sender) + getClaimAbleLBR(msg.sender);
if (amount > 0) {
LBR.mint(msg.sender, amount);
}
unstakeRatio[msg.sender] = 0;
time2fullRedemption[msg.sender] = 0;
grabableAmount += burnAmount;
emit UnlockPrematurely(msg.sender, amount, block.timestamp);
}
/**
* @dev Purchase the accumulated amount of pre-claimed lost ESLBR in the contract using LBR or eUSD.
* @param amount The amount of ESLBR to be purchased.
* Requirements:
* The amount must be greater than 1e17.
*/
function grabEsLBR(uint256 amount, bool useEUSD) external {
require(amount > 1e17, "QMG");
grabableAmount -= amount;
uint256 payAmount = amount * grabFeeRatio / 10_000;
if(useEUSD) {
(, int lbrPrice, , , ) = lbrPriceFeed.latestRoundData();
payAmount = payAmount * uint256(lbrPrice) / 1e8;
bool success = ERC20(configurator.getEUSDAddress()).transferFrom(msg.sender, address(owner()), payAmount);
require(success, "TF");
} else {
LBR.burn(msg.sender, payAmount);
}
esLBR.mint(msg.sender, amount);
emit GrabEsLBR(msg.sender, amount, payAmount, useEUSD, block.timestamp);
}
/**
* @dev Convert unredeemed and converting LBR tokens back to esLBR.
*/
function reStake() external {
uint256 amount = getReservedLBRForVesting(msg.sender) + getClaimAbleLBR(msg.sender);
esLBR.mint(msg.sender, amount);
unstakeRatio[msg.sender] = 0;
time2fullRedemption[msg.sender] = 0;
emit Restake(msg.sender, amount, block.timestamp);
}
function getPreUnlockableAmount(address user) public view returns (uint256 amount) {
uint256 a = getReservedLBRForVesting(user);
if (a == 0) return 0;
amount = (a * (75e18 - ((time2fullRedemption[user] - block.timestamp) * 70e18) / (exitCycle / 1 days - 3) / 1 days)) / 100e18;
}
function getClaimAbleLBR(address user) public view returns (uint256 amount) {
if (time2fullRedemption[user] > lastWithdrawTime[user]) {
amount = block.timestamp > time2fullRedemption[user] ? unstakeRatio[user] * (time2fullRedemption[user] - lastWithdrawTime[user]) : unstakeRatio[user] * (block.timestamp - lastWithdrawTime[user]);
}
}
function getReservedLBRForVesting(address user) public view returns (uint256 amount) {
if (time2fullRedemption[user] > block.timestamp) {
amount = unstakeRatio[user] * (time2fullRedemption[user] - block.timestamp);
}
}
function earned(address _account) public view returns (uint) {
return ((stakedOf(_account) * (rewardPerTokenStored - userRewardPerTokenPaid[_account])) / 1e18) + rewards[_account];
}
/**
* @dev Call this function when deposit or withdraw ETH on Lybra and update the status of corresponding user.
*/
modifier updateReward(address account) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
_;
}
function refreshReward(address _account) external updateReward(_account) {}
/**
* @notice When claiming protocol rewards earnings,
* peUSD will be prioritized for distribution if there is a sufficient amount of peUSD in the Protocol Rewards Pool.
* If the peUSD balance is insufficient, earnings will be distributed in the order of other stablecoins such as USDC.
*/
function getReward() external updateReward(msg.sender) {
uint reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
ERC20 peUSD = ERC20(configurator.peUSD());
uint256 balance = peUSD.balanceOf(address(this));
uint256 peUSDAmount = balance >= reward ? reward : balance;
peUSD.transfer(msg.sender, peUSDAmount);
if(reward > peUSDAmount) {
ERC20 token = ERC20(configurator.stableToken());
uint256 tokenAmount = (reward - peUSDAmount) * (10 ** token.decimals()) / 1e18;
token.safeTransfer(msg.sender, tokenAmount);
emit ClaimReward(msg.sender, peUSDAmount, address(token), reward - peUSDAmount, block.timestamp);
} else {
emit ClaimReward(msg.sender, peUSDAmount, address(0), 0, block.timestamp);
}
}
}
/**
* @notice Notifies the protocol rewards pool about the amount of rewards to be distributed and the token type.
* @param amount The amount of rewards to be distributed.
* @param tokenType The type of token (0 for peUSD, 1 for other stablecoins).
* Requirements:
* - The caller must be the configurator contract.
* - There must be staked tokens in the protocol rewards pool.
* - The amount must not be zero.
* @dev When receiving stablecoin tokens other than eUSD, the decimals of the token are converted to 18 for consistent calculations.
*/
function notifyRewardAmount(uint amount, uint tokenType) external {
require(msg.sender == address(configurator), "NA");
if (totalStaked() == 0) return;
require(amount != 0, "amount = 0");
if(tokenType == 1) {
ERC20 token = ERC20(configurator.stableToken());
rewardPerTokenStored = rewardPerTokenStored + (amount * 1e36 / (10 ** token.decimals())) / totalStaked();
} else {
rewardPerTokenStored = rewardPerTokenStored + (amount * 1e18) / totalStaked();
}
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
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);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
AggregatorV3Interface.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
Read Contract
LBR 0x8afe540c → address
configurator 0x2b507df8 → address
earned 0x008cc262 → uint256
esLBR 0x97308753 → address
esLBRBoost 0x898ac82e → address
getClaimAbleLBR 0x73a2f214 → uint256
getPreUnlockableAmount 0x5c71702b → uint256
getReservedLBRForVesting 0x4e73294b → uint256
grabFeeRatio 0xff4daf2e → uint256
grabableAmount 0xf9f953bf → uint256
lastWithdrawTime 0x1031ec31 → uint256
owner 0x8da5cb5b → address
rewardPerTokenStored 0xdf136d65 → uint256
rewards 0x0700037d → uint256
time2fullRedemption 0x189cffa6 → uint256
unstakeRatio 0x0ee9e602 → uint256
userRewardPerTokenPaid 0x8b876347 → uint256
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
getReward 0x3d18b912
No parameters
grabEsLBR 0x895d440e
uint256 amount
bool useEUSD
notifyRewardAmount 0x246132f9
uint256 amount
uint256 tokenType
reStake 0xeba8a266
No parameters
refreshReward 0xfce67e0d
address _account
renounceOwnership 0x715018a6
No parameters
setGrabCost 0x3988a1ac
uint256 _ratio
setLBROracle 0x6067de89
address _lbrOracle
setTokenAddress 0x7a237b39
address _eslbr
address _lbr
address _boost
address _lbrOracle
stake 0xa694fc3a
uint256 amount
transferOwnership 0xf2fde38b
address newOwner
unlockPrematurely 0xe5fcd6cd
No parameters
unstake 0x2e17de78
uint256 amount
withdraw 0x51cff8d9
address user
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address