Address Contract Partially Verified
Address
0xaB67DF30EC036051A07CEbDa927C98F8AbBCfa7B
Balance
0 ETH
Nonce
1
Code Size
20628 bytes
Creator
0x4904Ba31...a4bd at tx 0x85654a9e...4d43fc
Indexed Transactions
0
Contract Bytecode
20628 bytes
0x608060405234801561001057600080fd5b506004361061030b5760003560e01c8063715018a61161019d578063af465a27116100e9578063dd62ed3e116100a2578063f820f5671161007c578063f820f56714610950578063f8afaba51461096e578063f91f825d1461098a578063ffa1ad74146109a65761030b565b8063dd62ed3e146108e8578063f19c4e3b14610918578063f2fde38b146109345761030b565b8063af465a2714610838578063b609995e14610856578063b7bda68f14610872578063bfcf735514610890578063d48e4127146108ae578063d8f67851146108cc5761030b565b806395d89b4111610156578063a457c2d711610130578063a457c2d71461079e578063a476df61146107ce578063a9059cbb146107ea578063a9d866851461081a5761030b565b806395d89b41146107445780639703a19d14610762578063a32f6976146107805761030b565b8063715018a6146106a4578063883356d9146106ae5780638da5cb5b146106cc5780638dac7191146106ea5780638e8c10a21461070857806393fbda99146107265761030b565b80632fa782eb1161025c5780634a88266c116102155780635514c832116101ef5780635514c8321461061a5780635a3990ce14610638578063614d08f81461065657806370a08231146106745761030b565b80634a88266c146105ae5780634ac0bc32146105de578063542e9667146105fc5761030b565b80632fa782eb146104ea578063313ce56714610508578063378dc3dc14610526578063395093511461054457806342966c681461057457806349a602db146105905761030b565b8063111e0376116102c957806323b872dd116102a357806323b872dd1461043c57806323bbbd6a1461046c5780632d8381191461049c5780632e0ee48e146104cc5761030b565b8063111e0376146103e4578063154af8e71461040057806318160ddd1461041e5761030b565b8062af2d9d1461031057806302252c4d14610340578063044ab74e1461035c57806306fdde031461037a578063095ea7b3146103985780630bd92756146103c8575b600080fd5b61032a60048036038101906103259190613f74565b6109c4565b6040516103379190613fe2565b60405180910390f35b61035a60048036038101906103559190613f74565b610a03565b005b610364610ac5565b604051610371919061408d565b60405180910390f35b610382610b53565b60405161038f919061408d565b60405180910390f35b6103b260048036038101906103ad91906140db565b610be5565b6040516103bf9190614136565b60405180910390f35b6103e260048036038101906103dd9190614151565b610c08565b005b6103fe60048036038101906103f99190614151565b610ebe565b005b610408610ed2565b604051610415919061423c565b60405180910390f35b610426610f60565b604051610433919061426d565b60405180910390f35b61045660048036038101906104519190614288565b610f6a565b6040516104639190614136565b60405180910390f35b61048660048036038101906104819190613f74565b6110c2565b6040516104939190613fe2565b60405180910390f35b6104b660048036038101906104b19190613f74565b611101565b6040516104c3919061426d565b60405180910390f35b6104d461115f565b6040516104e19190614136565b60405180910390f35b6104f2611179565b6040516104ff919061426d565b60405180910390f35b61051061117f565b60405161051d91906142f7565b60405180910390f35b61052e6111a7565b60405161053b919061426d565b60405180910390f35b61055e600480360381019061055991906140db565b6111cb565b60405161056b9190614136565b60405180910390f35b61058e60048036038101906105899190613f74565b611202565b005b610598611255565b6040516105a5919061426d565b60405180910390f35b6105c860048036038101906105c39190614151565b61125a565b6040516105d59190614136565b60405180910390f35b6105e661127a565b6040516105f39190614136565b60405180910390f35b610604611294565b604051610611919061426d565b60405180910390f35b61062261129a565b60405161062f919061426d565b60405180910390f35b61064061129f565b60405161064d9190614136565b60405180910390f35b61065e6112b9565b60405161066b919061408d565b60405180910390f35b61068e60048036038101906106899190614151565b6112f2565b60405161069b919061426d565b60405180910390f35b6106ac611413565b005b6106b6611425565b6040516106c39190614136565b60405180910390f35b6106d461143f565b6040516106e19190613fe2565b60405180910390f35b6106f2611469565b6040516106ff9190613fe2565b60405180910390f35b61071061148d565b60405161071d9190614136565b60405180910390f35b61072e6114a7565b60405161073b919061423c565b60405180910390f35b61074c611535565b604051610759919061408d565b60405180910390f35b61076a6115c7565b604051610777919061426d565b60405180910390f35b6107886115cd565b604051610795919061426d565b60405180910390f35b6107b860048036038101906107b391906140db565b6115f1565b6040516107c59190614136565b60405180910390f35b6107e860048036038101906107e39190614447565b611668565b005b61080460048036038101906107ff91906140db565b6116f8565b6040516108119190614136565b60405180910390f35b61082261184e565b60405161082f919061408d565b60405180910390f35b6108406118dc565b60405161084d919061426d565b60405180910390f35b610870600480360381019061086b9190614151565b6118eb565b005b61087a6118ff565b6040516108879190613fe2565b60405180910390f35b610898611925565b6040516108a591906144a9565b60405180910390f35b6108b661194c565b6040516108c3919061426d565b60405180910390f35b6108e660048036038101906108e19190613f74565b611952565b005b61090260048036038101906108fd91906144c4565b611a36565b60405161090f919061426d565b60405180910390f35b610932600480360381019061092d91906140db565b611abd565b005b61094e60048036038101906109499190614151565b611c03565b005b610958611c17565b6040516109659190614136565b60405180910390f35b61098860048036038101906109839190614151565b611c31565b005b6109a4600480360381019061099f9190613f74565b611dfd565b005b6109ae611e7c565b6040516109bb919061408d565b60405180910390f35b601181815481106109d457600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610a0b6120a7565b610a1361129f565b610a49576040517f6273340f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f548111610a84576040517fa43d2d7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600f819055507f2905481c6fd1a037492016c4760435a52203d82a6f34dc3de40f464c1bf42d5981604051610aba919061426d565b60405180910390a150565b600e8054610ad290614533565b80601f0160208091040260200160405190810160405280929190818152602001828054610afe90614533565b8015610b4b5780601f10610b2057610100808354040283529160200191610b4b565b820191906000526020600020905b815481529060010190602001808311610b2e57829003601f168201915b505050505081565b606060038054610b6290614533565b80601f0160208091040260200160405190810160405280929190818152602001828054610b8e90614533565b8015610bdb5780601f10610bb057610100808354040283529160200191610bdb565b820191906000526020600020905b815481529060010190602001808311610bbe57829003601f168201915b5050505050905090565b600080610bf0612125565b9050610bfd81858561212d565b600191505092915050565b610c106120a7565b601060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610c93576040517fed68fdd600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b601180549050811015610eba578173ffffffffffffffffffffffffffffffffffffffff1660118281548110610cce57610ccd614564565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603610ea75760116001601180549050610d2891906145c2565b81548110610d3957610d38614564565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660118281548110610d7857610d77614564565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506011805480610e2a57610e296145f6565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558173ffffffffffffffffffffffffffffffffffffffff167f98bab529cae32acf2e47348750c372f438f475b15be0136f55544297ef96bd2c60405160405180910390a2610eba565b8080610eb290614625565b915050610c96565b5050565b610ec66120a7565b610ecf816122f6565b50565b6060600b805480602002602001604051908101604052809291908181526020018280548015610f5657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610f0c575b5050505050905090565b6000600254905090565b600080610f788585856125e5565b90506000610f8786868661271d565b90506000818386610f9891906145c2565b610fa291906145c2565b9050610fac61129f565b80156110025750601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561106257600f5481611014886112f2565b61101e919061466d565b111561106157856040517ff6202a8f0000000000000000000000000000000000000000000000000000000081526004016110589190613fe2565b60405180910390fd5b5b600083146110985761109787601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856127fb565b5b600082146110ab576110aa87836128cf565b5b6110b6878783612935565b93505050509392505050565b600b81815481106110d257600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060075482111561113f576040517fc91fa8bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611149612964565b9050808361115791906146d0565b915050919050565b6000601260000160059054906101000a900460ff16905090565b60145481565b60007f0000000000000000000000000000000000000000000000000000000000000012905090565b7f000000000000000000000000000000000000000000000000000000000098968081565b6000806111d6612125565b90506111f78185856111e88589611a36565b6111f2919061466d565b61212d565b600191505092915050565b61120a6120a7565b611212611425565b611248576040517f6cb5913900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61125233826128cf565b50565b606481565b60106020528060005260406000206000915054906101000a900460ff1681565b6000601260000160039054906101000a900460ff16905090565b60155481565b606481565b6000601260000160029054906101000a900460ff16905090565b6040518060400160405280601481526020017f44656669546f6b656e4669786564537570706c7900000000000000000000000081525081565b60007f00000000000000000000000000000000000000000000000000000000000000001561140257600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156113b357600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061140e565b6113fb600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611101565b905061140e565b61140b82612988565b90505b919050565b61141b6120a7565b6114236129d0565b565b6000601260000160009054906101000a900460ff16905090565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f00000000000000000000000068bb7246481f140de366fb63c0514b31df1d341b81565b6000601260000160049054906101000a900460ff16905090565b6060601180548060200260200160405190810160405280929190818152602001828054801561152b57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116114e1575b5050505050905090565b60606004805461154490614533565b80601f016020809104026020016040519081016040528092919081815260200182805461157090614533565b80156115bd5780601f10611592576101008083540402835291602001916115bd565b820191906000526020600020905b8154815290600101906020018083116115a057829003601f168201915b5050505050905090565b60095481565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806115fc612125565b9050600061160a8286611a36565b90508381101561164f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164690614773565b60405180910390fd5b61165c828686840361212d565b60019250505092915050565b6116706120a7565b611678611c17565b6116ae576040517f70a43fce00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600e90816116bd919061493f565b507f4456a0b562609d67398ddb488f136db285cd3c92343e0a7ba684925669237ade816040516116ed919061408d565b60405180910390a150565b6000806117063385856125e5565b9050600061171533868661271d565b9050600081838661172691906145c2565b61173091906145c2565b905061173a61129f565b80156117905750601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156117f057600f54816117a2886112f2565b6117ac919061466d565b11156117ef57856040517ff6202a8f0000000000000000000000000000000000000000000000000000000081526004016117e69190613fe2565b60405180910390fd5b5b600083146118265761182533601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856127fb565b5b600082146118395761183833836128cf565b5b61184386826129e4565b935050505092915050565b600d805461185b90614533565b80601f016020809104026020016040519081016040528092919081815260200182805461188790614533565b80156118d45780601f106118a9576101008083540402835291602001916118d4565b820191906000526020600020905b8154815290600101906020018083116118b757829003601f168201915b505050505081565b60006118e6610f60565b905090565b6118f36120a7565b6118fc81612a07565b50565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f692155a207810cfbcbd3a6f6814eb0342efcb0a7e2247084ac09bd76f5529c5760001b81565b600f5481565b61195a6120a7565b61196261148d565b611998576040517fcd9e529800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816009546015546119ab919061466d565b6119b5919061466d565b90506107d08111156119fe57806040517f3e474e0d0000000000000000000000000000000000000000000000000000000081526004016119f5919061426d565b60405180910390fd5b81601581905550817fc1ff65ee907dc079b64ed9913d53f4bd593bd6ebd9b2a2708db2916d49e17ec360405160405180910390a25050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611ac56120a7565b611acd61127a565b611b03576040517fc8a478a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600954601554611b16919061466d565b611b20919061466d565b90506107d0811115611b6957806040517f3e474e0d000000000000000000000000000000000000000000000000000000008152600401611b60919061426d565b60405180910390fd5b611b728361200b565b82601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601481905550818373ffffffffffffffffffffffffffffffffffffffff167facc44e32fd5ca4240f6dbe6e8cf4eb49349c17c5ce5f80f1919a9c97b50d398a60405160405180910390a3505050565b611c0b6120a7565b611c1481612024565b50565b6000601260000160019054906101000a900460ff16905090565b611c396120a7565b601060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611cbd576040517ff20d03d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606460118054905010611cfc576040517fc92787fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506011819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f94f5dc0e322a0a7c5af09958609aeb2384692e22922827ff9595db226c01dfa560405160405180910390a250565b611e056120a7565b611e0d61115f565b611e43576040517f800e34b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e4c81612d51565b807f76e1296412dac7b50002658bf9aab02d0cfe366f373222d5c14d0168ee8199e360405160405180910390a250565b6040518060400160405280601581526020017f646566695f765f315f66697865645f737570706c79000000000000000000000081525081565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611f24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1b90614a5d565b60405180910390fd5b611f3060008383612db2565b8060026000828254611f42919061466d565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611ff3919061426d565b60405180910390a361200760008383612db7565b5050565b8060601b6120215763d92e233d6000526004601cfd5b50565b61202c6120a7565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361209b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209290614aef565b60405180910390fd5b6120a481612dbc565b50565b6120af612125565b73ffffffffffffffffffffffffffffffffffffffff166120cd61143f565b73ffffffffffffffffffffffffffffffffffffffff1614612123576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211a90614b5b565b60405180910390fd5b565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361219c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219390614bed565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361220b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161220290614c7f565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516122e9919061426d565b60405180910390a3505050565b7f000000000000000000000000000000000000000000000000000000000000000061234d576040517f800e34b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156123d1576040517fe2f18de900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6064600b8054905010612410576040517ff266e36200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156124e4576124a0600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611101565b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600b819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f743dcd4a012534912a3350f3ed8937d3b4f0771c62892ed15e4373dc2c5f584a60405160405180910390a250565b600080601454141580156126475750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561269d5750601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156126f35750601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561271657612710601454836127099190614c9f565b61271391906146d0565b90505b9392505050565b6000806015541415801561277b5750601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156127d15750601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156127f457612710601554836127e79190614c9f565b6127f191906146d0565b90505b9392505050565b7f0000000000000000000000000000000000000000000000000000000000000000156128be57600081146128b9576000612833612964565b9050600081836128439190614c9f565b905061285185858384612e82565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516128ae919061426d565b60405180910390a350505b6128ca565b6128c9838383613032565b5b505050565b7f000000000000000000000000000000000000000000000000000000000000000015612927576040517f6cb5913900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61293182826132a8565b5050565b600080612940612125565b905061294d858285613475565b612958858585613501565b60019150509392505050565b6000806000612971613878565b91509150808261298191906146d0565b9250505090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6129d86120a7565b6129e26000612dbc565b565b6000806129ef612125565b90506129fc818585613501565b600191505092915050565b7f0000000000000000000000000000000000000000000000000000000000000000612a5e576040517f800e34b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612ae1576040517f1214f5e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b600b80549050811015612d4d578173ffffffffffffffffffffffffffffffffffffffff16600b8281548110612b1c57612b1b614564565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603612d3a57600b6001600b80549050612b7691906145c2565b81548110612b8757612b86614564565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600b8281548110612bc657612bc5614564565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b805480612cbd57612cbc6145f6565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558173ffffffffffffffffffffffffffffffffffffffff167f9ccbe1146da67d2d78acc466156a4860eecd4209be8b75a9370e8bf3e949ed1f60405160405180910390a2612d4d565b8080612d4590614625565b915050612ae4565b5050565b7f0000000000000000000000000000000000000000000000000000000000000000612da8576040517f800e34b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060098190555050565b505050565b505050565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015612f0f578381846040517fe450d38c000000000000000000000000000000000000000000000000000000008152600401612f0693929190614ce1565b60405180910390fd5b82600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612f5a91906145c2565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612fe8919061466d565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036130a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161309890614d8a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613110576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161310790614e1c565b60405180910390fd5b61311b838383612db2565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156131a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161319890614eae565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161328f919061426d565b60405180910390a36132a2848484612db7565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613317576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161330e90614f40565b60405180910390fd5b61332382600083612db2565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156133a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133a090614fd2565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282540392505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161345c919061426d565b60405180910390a361347083600084612db7565b505050565b60006134818484611a36565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146134fb57818110156134ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134e49061503e565b60405180910390fd5b6134fa848484840361212d565b5b50505050565b7f000000000000000000000000000000000000000000000000000000000000000015613867576135308361200b565b6135398261200b565b60008103613573576040517f76c4f5b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156136165750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561362b5761362683838361388e565b613862565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156136ce5750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156136e3576136de8383836139df565b613861565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156137875750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561379c57613797838383613b30565b613860565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561383e5750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156138535761384e838383613bf3565b61385f565b61385e838383613b30565b5b5b5b5b613873565b613872838383613032565b5b505050565b6000806007546138866118dc565b915091509091565b600061389b828585613dd2565b9050600081836138ab91906145c2565b905060008060006138bd868686613ea8565b925092509250600086146139d5576138d788888584612e82565b85600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461392291906145c2565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061396f8286613efe565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef886040516139cc919061426d565b60405180910390a35b5050505050505050565b60006139ec828585613dd2565b9050600081836139fc91906145c2565b90506000806000613a0e868686613ea8565b92509250925060008614613b2657613a2888888584612e82565b83600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a73919061466d565b600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613ac08286613efe565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef88604051613b1d919061426d565b60405180910390a35b5050505050505050565b6000613b3d828585613dd2565b905060008183613b4d91906145c2565b90506000806000613b5f868686613ea8565b92509250925060008614613be957613b7988888584612e82565b613b838286613efe565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef88604051613be0919061426d565b60405180910390a35b5050505050505050565b6000613c00828585613dd2565b905060008183613c1091906145c2565b90506000806000613c22868686613ea8565b92509250925060008614613dc857613c3c88888584612e82565b85600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c8791906145c2565b600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555083600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613d15919061466d565b600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613d628286613efe565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef88604051613dbf919061426d565b60405180910390a35b5050505050505050565b6000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680613e755750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613e835760009050613ea1565b61271060095485613e949190614c9f565b613e9e91906146d0565b90505b9392505050565b600080600080613eb6612964565b905060008188613ec69190614c9f565b905060008288613ed69190614c9f565b905060008388613ee69190614c9f565b90508282829650965096505050505093509350939050565b81600754613f0c91906145c2565b60078190555080600854613f20919061466d565b6008819055505050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b613f5181613f3e565b8114613f5c57600080fd5b50565b600081359050613f6e81613f48565b92915050565b600060208284031215613f8a57613f89613f34565b5b6000613f9884828501613f5f565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613fcc82613fa1565b9050919050565b613fdc81613fc1565b82525050565b6000602082019050613ff76000830184613fd3565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561403757808201518184015260208101905061401c565b60008484015250505050565b6000601f19601f8301169050919050565b600061405f82613ffd565b6140698185614008565b9350614079818560208601614019565b61408281614043565b840191505092915050565b600060208201905081810360008301526140a78184614054565b905092915050565b6140b881613fc1565b81146140c357600080fd5b50565b6000813590506140d5816140af565b92915050565b600080604083850312156140f2576140f1613f34565b5b6000614100858286016140c6565b925050602061411185828601613f5f565b9150509250929050565b60008115159050919050565b6141308161411b565b82525050565b600060208201905061414b6000830184614127565b92915050565b60006020828403121561416757614166613f34565b5b6000614175848285016140c6565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6141b381613fc1565b82525050565b60006141c583836141aa565b60208301905092915050565b6000602082019050919050565b60006141e98261417e565b6141f38185614189565b93506141fe8361419a565b8060005b8381101561422f57815161421688826141b9565b9750614221836141d1565b925050600181019050614202565b5085935050505092915050565b6000602082019050818103600083015261425681846141de565b905092915050565b61426781613f3e565b82525050565b6000602082019050614282600083018461425e565b92915050565b6000806000606084860312156142a1576142a0613f34565b5b60006142af868287016140c6565b93505060206142c0868287016140c6565b92505060406142d186828701613f5f565b9150509250925092565b600060ff82169050919050565b6142f1816142db565b82525050565b600060208201905061430c60008301846142e8565b92915050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61435482614043565b810181811067ffffffffffffffff821117156143735761437261431c565b5b80604052505050565b6000614386613f2a565b9050614392828261434b565b919050565b600067ffffffffffffffff8211156143b2576143b161431c565b5b6143bb82614043565b9050602081019050919050565b82818337600083830152505050565b60006143ea6143e584614397565b61437c565b90508281526020810184848401111561440657614405614317565b5b6144118482856143c8565b509392505050565b600082601f83011261442e5761442d614312565b5b813561443e8482602086016143d7565b91505092915050565b60006020828403121561445d5761445c613f34565b5b600082013567ffffffffffffffff81111561447b5761447a613f39565b5b61448784828501614419565b91505092915050565b6000819050919050565b6144a381614490565b82525050565b60006020820190506144be600083018461449a565b92915050565b600080604083850312156144db576144da613f34565b5b60006144e9858286016140c6565b92505060206144fa858286016140c6565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061454b57607f821691505b60208210810361455e5761455d614504565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006145cd82613f3e565b91506145d883613f3e565b92508282039050818111156145f0576145ef614593565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600061463082613f3e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361466257614661614593565b5b600182019050919050565b600061467882613f3e565b915061468383613f3e565b925082820190508082111561469b5761469a614593565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006146db82613f3e565b91506146e683613f3e565b9250826146f6576146f56146a1565b5b828204905092915050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b600061475d602583614008565b915061476882614701565b604082019050919050565b6000602082019050818103600083015261478c81614750565b9050919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026147f57fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826147b8565b6147ff86836147b8565b95508019841693508086168417925050509392505050565b6000819050919050565b600061483c61483761483284613f3e565b614817565b613f3e565b9050919050565b6000819050919050565b61485683614821565b61486a61486282614843565b8484546147c5565b825550505050565b600090565b61487f614872565b61488a81848461484d565b505050565b5b818110156148ae576148a3600082614877565b600181019050614890565b5050565b601f8211156148f3576148c481614793565b6148cd846147a8565b810160208510156148dc578190505b6148f06148e8856147a8565b83018261488f565b50505b505050565b600082821c905092915050565b6000614916600019846008026148f8565b1980831691505092915050565b600061492f8383614905565b9150826002028217905092915050565b61494882613ffd565b67ffffffffffffffff8111156149615761496061431c565b5b61496b8254614533565b6149768282856148b2565b600060209050601f8311600181146149a95760008415614997578287015190505b6149a18582614923565b865550614a09565b601f1984166149b786614793565b60005b828110156149df578489015182556001820191506020850194506020810190506149ba565b868310156149fc57848901516149f8601f891682614905565b8355505b6001600288020188555050505b505050505050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6000614a47601f83614008565b9150614a5282614a11565b602082019050919050565b60006020820190508181036000830152614a7681614a3a565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614ad9602683614008565b9150614ae482614a7d565b604082019050919050565b60006020820190508181036000830152614b0881614acc565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614b45602083614008565b9150614b5082614b0f565b602082019050919050565b60006020820190508181036000830152614b7481614b38565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000614bd7602483614008565b9150614be282614b7b565b604082019050919050565b60006020820190508181036000830152614c0681614bca565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000614c69602283614008565b9150614c7482614c0d565b604082019050919050565b60006020820190508181036000830152614c9881614c5c565b9050919050565b6000614caa82613f3e565b9150614cb583613f3e565b9250828202614cc381613f3e565b91508282048414831517614cda57614cd9614593565b5b5092915050565b6000606082019050614cf66000830186613fd3565b614d03602083018561425e565b614d10604083018461425e565b949350505050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000614d74602583614008565b9150614d7f82614d18565b604082019050919050565b60006020820190508181036000830152614da381614d67565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000614e06602383614008565b9150614e1182614daa565b604082019050919050565b60006020820190508181036000830152614e3581614df9565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000614e98602683614008565b9150614ea382614e3c565b604082019050919050565b60006020820190508181036000830152614ec781614e8b565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b6000614f2a602183614008565b9150614f3582614ece565b604082019050919050565b60006020820190508181036000830152614f5981614f1d565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b6000614fbc602283614008565b9150614fc782614f60565b604082019050919050565b60006020820190508181036000830152614feb81614faf565b9050919050565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b6000615028601d83614008565b915061503382614ff2565b602082019050919050565b600060208201905081810360008301526150578161501b565b905091905056fea2646970667358221220035319a43432df2554bd58c291740fee74bdb2527d53bdcdf303edd4d344204864736f6c63430008110033
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: No
DefiTokenFixedSupply.sol 470 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { LibCommon } from "./lib/LibCommon.sol";
import { ReflectiveV3ERC20 } from "./ReflectiveV3ERC20.sol";
/// @title A Defi Token implementation with extended functionalities
/// @notice Implements ERC20 standards with additional features like tax and deflation
contract DefiTokenFixedSupply is ReflectiveV3ERC20, Ownable {
// Constants
uint256 private constant MAX_BPS_AMOUNT = 10_000;
uint256 private constant MAX_ALLOWED_BPS = 2_000;
uint256 public constant MAX_EXCLUSION_LIMIT = 100;
string public constant VERSION = "defi_v_1_fixed_supply";
string public constant CONTRACT_NAME = "DefiTokenFixedSupply";
bytes32 public constant CONTRACT_HASH = 0x692155a207810cfbcbd3a6f6814eb0342efcb0a7e2247084ac09bd76f5529c57;
// State Variables
string public initialDocumentUri;
string public documentUri;
uint256 public immutable initialSupply;
uint256 public immutable initialMaxTokenAmountPerAddress;
uint256 public maxTokenAmountPerAddress;
mapping(address => bool) public isFeesAndLimitsExcluded;
address[] public feesAndLimitsExcluded;
/// @notice Configuration properties for the ERC20 token
struct ERC20ConfigProps {
bool _isBurnable;
bool _isDocumentAllowed;
bool _isMaxAmountOfTokensSet;
bool _isTaxable;
bool _isDeflationary;
bool _isReflective;
}
ERC20ConfigProps private configProps;
address public immutable initialTokenOwner;
uint8 private immutable _decimals;
address public taxAddress;
uint256 public taxBPS;
uint256 public deflationBPS;
// Events
event DocumentUriSet(string newDocUri);
event MaxTokenAmountPerSet(uint256 newMaxTokenAmount);
event TaxConfigSet(address indexed _taxAddress, uint256 indexed _taxBPS);
event DeflationConfigSet(uint256 indexed _deflationBPS);
event ReflectionConfigSet(uint256 indexed _feeBPS);
event ExcludeFromFeesAndLimits(address indexed account);
event IncludedInFeesAndLimits(address indexed account);
// Custom Errors
error InvalidMaxTokenAmount(uint256 maxTokenAmount);
error InvalidDecimals(uint8 decimals);
error MaxTokenAmountPerAddrLtPrevious();
error DestBalanceExceedsMaxAllowed(address addr);
error DocumentUriNotAllowed();
error MaxTokenAmountNotAllowed();
error TokenIsNotTaxable();
error TokenIsNotDeflationary();
error InvalidTotalBPS(uint256 bps);
error InvalidReflectiveConfig();
error AlreadyExcludedFromFeesAndLimits();
error AlreadyIncludedInFeesAndLimits();
error ReachedMaxExclusionLimit();
/// @notice Constructor to initialize the DeFi token
/// @param name_ Name of the token
/// @param symbol_ Symbol of the token
/// @param initialSupplyToSet Initial supply of tokens
/// @param decimalsToSet Number of decimals for the token
/// @param tokenOwner Address of the initial token owner
/// @param customConfigProps Configuration properties for the token
/// @param newDocumentUri URI for the document associated with the token
/// @param _taxAddress Address where tax will be sent
/// @param bpsParams array of BPS values in this order:
/// taxBPS = bpsParams[0],
/// deflationBPS = bpsParams[1],
/// rewardFeeBPS = bpsParams[2],
/// @param amountParams array of amounts for amount specific config:
/// maxTokenAmount = amountParams[0], Maximum token amount per address
constructor(
string memory name_,
string memory symbol_,
uint256 initialSupplyToSet,
uint8 decimalsToSet,
address tokenOwner,
ERC20ConfigProps memory customConfigProps,
string memory newDocumentUri,
address _taxAddress,
uint256[3] memory bpsParams,
uint256[1] memory amountParams
)
ReflectiveV3ERC20(
name_,
symbol_,
tokenOwner,
initialSupplyToSet,
decimalsToSet,
initialSupplyToSet != 0 ? bpsParams[2] : 0,
customConfigProps._isReflective
)
{
// reflection feature can't be used in combination with burning/deflation
// or reflection config is invalid if no reflection BPS amount is provided
if (
(customConfigProps._isReflective &&
(customConfigProps._isBurnable ||
customConfigProps._isDeflationary)) ||
(!customConfigProps._isReflective && bpsParams[2] != 0)
) {
revert InvalidReflectiveConfig();
}
if (customConfigProps._isMaxAmountOfTokensSet) {
if (amountParams[0] == 0) {
revert InvalidMaxTokenAmount(amountParams[0]);
}
}
if (decimalsToSet > 18) {
revert InvalidDecimals(decimalsToSet);
}
bpsInitChecks(customConfigProps, bpsParams, _taxAddress);
LibCommon.validateAddress(tokenOwner);
taxAddress = _taxAddress;
taxBPS = bpsParams[0];
deflationBPS = bpsParams[1];
initialSupply = initialSupplyToSet;
initialMaxTokenAmountPerAddress = amountParams[0];
initialDocumentUri = newDocumentUri;
initialTokenOwner = tokenOwner;
_decimals = decimalsToSet;
configProps = customConfigProps;
documentUri = newDocumentUri;
maxTokenAmountPerAddress = amountParams[0];
if (tokenOwner != msg.sender) {
transferOwnership(tokenOwner);
}
}
function bpsInitChecks(
ERC20ConfigProps memory customConfigProps,
uint256[3] memory bpsParams,
address _taxAddress
) private pure {
uint256 totalBPS = 0;
if (customConfigProps._isTaxable) {
LibCommon.validateAddress(_taxAddress);
totalBPS += bpsParams[0];
}
if (customConfigProps._isDeflationary) {
totalBPS += bpsParams[1];
}
if (customConfigProps._isReflective) {
totalBPS += bpsParams[2];
}
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
}
// Public and External Functions
function getFeesAndLimitsExclusionList() external view returns (address[] memory) {
return feesAndLimitsExcluded;
}
/// @notice Checks if the token is burnable
/// @return True if the token can be burned
function isBurnable() public view returns (bool) {
return configProps._isBurnable;
}
function getRewardsExclusionList() public view returns (address[] memory) {
return rewardsExcluded;
}
/// @notice Checks if the maximum amount of tokens per address is set
/// @return True if there is a maximum limit for token amount per address
function isMaxAmountOfTokensSet() public view returns (bool) {
return configProps._isMaxAmountOfTokensSet;
}
/// @notice Checks if setting a document URI is allowed
/// @return True if setting a document URI is allowed
function isDocumentUriAllowed() public view returns (bool) {
return configProps._isDocumentAllowed;
}
/// @notice Returns the number of decimals used for the token
/// @return The number of decimals
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
/// @notice Checks if the token is taxable
/// @return True if the token has tax applied on transfers
function isTaxable() public view returns (bool) {
return configProps._isTaxable;
}
/// @notice Checks if the token is deflationary
/// @return True if the token has deflation applied on transfers
function isDeflationary() public view returns (bool) {
return configProps._isDeflationary;
}
/// @notice Checks if the token is reflective
/// @return True if the token has reflection (ie. holder rewards) applied on transfers
function isReflective() public view returns (bool) {
return configProps._isReflective;
}
/// @notice Sets a new document URI
/// @dev Can only be called by the contract owner
/// @param newDocumentUri The new URI to be set
function setDocumentUri(string memory newDocumentUri) external onlyOwner {
if (!isDocumentUriAllowed()) {
revert DocumentUriNotAllowed();
}
documentUri = newDocumentUri;
emit DocumentUriSet(newDocumentUri);
}
/// @notice Sets a new maximum token amount per address
/// @dev Can only be called by the contract owner
/// @param newMaxTokenAmount The new maximum token amount per address
function setMaxTokenAmountPerAddress(
uint256 newMaxTokenAmount
) external onlyOwner {
if (!isMaxAmountOfTokensSet()) {
revert MaxTokenAmountNotAllowed();
}
if (newMaxTokenAmount <= maxTokenAmountPerAddress) {
revert MaxTokenAmountPerAddrLtPrevious();
}
maxTokenAmountPerAddress = newMaxTokenAmount;
emit MaxTokenAmountPerSet(newMaxTokenAmount);
}
/// @notice Sets a new reflection fee
/// @dev Can only be called by the contract owner
/// @param _feeBPS The reflection fee in basis points
function setReflectionConfig(uint256 _feeBPS) external onlyOwner {
if (!isReflective()) {
revert TokenIsNotReflective();
}
super._setReflectionFee(_feeBPS);
emit ReflectionConfigSet(_feeBPS);
}
/// @notice Sets a new tax configuration
/// @dev Can only be called by the contract owner
/// @param _taxAddress The address where tax will be sent
/// @param _taxBPS The tax rate in basis points
function setTaxConfig(
address _taxAddress,
uint256 _taxBPS
) external onlyOwner {
if (!isTaxable()) {
revert TokenIsNotTaxable();
}
uint256 totalBPS = deflationBPS + tFeeBPS + _taxBPS;
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
LibCommon.validateAddress(_taxAddress);
taxAddress = _taxAddress;
taxBPS = _taxBPS;
emit TaxConfigSet(_taxAddress, _taxBPS);
}
/// @notice Sets a new deflation configuration
/// @dev Can only be called by the contract owner
/// @param _deflationBPS The deflation rate in basis points
function setDeflationConfig(uint256 _deflationBPS) external onlyOwner {
if (!isDeflationary()) {
revert TokenIsNotDeflationary();
}
uint256 totalBPS = deflationBPS + tFeeBPS + _deflationBPS;
if (totalBPS > MAX_ALLOWED_BPS) {
revert InvalidTotalBPS(totalBPS);
}
deflationBPS = _deflationBPS;
emit DeflationConfigSet(_deflationBPS);
}
/// @notice Transfers tokens to a specified address
/// @dev Overrides the ERC20 transfer function with added tax and deflation logic
/// @param to The address to transfer tokens to
/// @param amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transfer(
address to,
uint256 amount
) public virtual override returns (bool) {
uint256 taxAmount = _taxAmount(msg.sender, to, amount);
uint256 deflationAmount = _deflationAmount(msg.sender, to, amount);
uint256 amountToTransfer = amount - taxAmount - deflationAmount;
if (isMaxAmountOfTokensSet() && !isFeesAndLimitsExcluded[to]) {
if (balanceOf(to) + amountToTransfer > maxTokenAmountPerAddress) {
revert DestBalanceExceedsMaxAllowed(to);
}
}
if (taxAmount != 0) {
_transferNonReflectedTax(msg.sender, taxAddress, taxAmount);
}
if (deflationAmount != 0) {
_burn(msg.sender, deflationAmount);
}
return super.transfer(to, amountToTransfer);
}
/// @notice Transfers tokens from one address to another
/// @dev Overrides the ERC20 transferFrom function with added tax and deflation logic
/// @param from The address which you want to send tokens from
/// @param to The address which you want to transfer to
/// @param amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
uint256 taxAmount = _taxAmount(from, to, amount);
uint256 deflationAmount = _deflationAmount(from, to, amount);
uint256 amountToTransfer = amount - taxAmount - deflationAmount;
if (isMaxAmountOfTokensSet() && !isFeesAndLimitsExcluded[to]) {
if (balanceOf(to) + amountToTransfer > maxTokenAmountPerAddress) {
revert DestBalanceExceedsMaxAllowed(to);
}
}
if (taxAmount != 0) {
_transferNonReflectedTax(from, taxAddress, taxAmount);
}
if (deflationAmount != 0) {
_burn(from, deflationAmount);
}
return super.transferFrom(from, to, amountToTransfer);
}
/// @notice Burns a specific amount of tokens
/// @dev Can only be called by the contract owner and if burning is enabled
/// @param amount The amount of tokens to be burned
function burn(uint256 amount) external onlyOwner {
if (!isBurnable()) {
revert BurningNotEnabled();
}
_burn(msg.sender, amount);
}
/// @notice Renounces ownership of the contract
/// @dev Leaves the contract without an owner, disabling any functions that require the owner's authorization
function renounceOwnership() public override onlyOwner {
super.renounceOwnership();
}
/// @notice Transfers ownership of the contract to a new account
/// @dev Can only be called by the current owner
/// @param newOwner The address of the new owner
function transferOwnership(address newOwner) public override onlyOwner {
super.transferOwnership(newOwner);
}
/// @notice method for adding a new account to the exclusion list
/// @param account account to add to the exclusion list
/// @dev only callable by owner
function excludeFromFeesAndLimits(
address account
) external onlyOwner {
if (isFeesAndLimitsExcluded[account]) {
revert AlreadyExcludedFromFeesAndLimits();
}
if (feesAndLimitsExcluded.length >= MAX_EXCLUSION_LIMIT) {
revert ReachedMaxExclusionLimit();
}
isFeesAndLimitsExcluded[account] = true;
feesAndLimitsExcluded.push(account);
emit ExcludeFromFeesAndLimits(account);
}
/// @notice method for adding a new account to the reflection exclusion list
/// @param account account to add to the exclusion list
/// @dev only callable by owner
function excludeFromRewards(address account) external onlyOwner {
super._excludeFromRewards(account);
}
/// @notice method for removing an account from the fees exclusion list
/// @param account account to remove from the exclusion list
/// @dev only callable by owner
function includeInFeesAndLimits(address account) external onlyOwner() {
if (!isFeesAndLimitsExcluded[account]) {
revert AlreadyIncludedInFeesAndLimits();
}
for (uint256 i = 0; i < feesAndLimitsExcluded.length; i++) {
if (feesAndLimitsExcluded[i] == account) {
feesAndLimitsExcluded[i] = feesAndLimitsExcluded[feesAndLimitsExcluded.length - 1];
isFeesAndLimitsExcluded[account] = false;
feesAndLimitsExcluded.pop();
emit IncludedInFeesAndLimits(account);
break;
}
}
}
/// @notice method for removing an account from the reflection exclusion list
/// @param account account to remove from the exclusion list
/// @dev only callable by owner
function includeInRewards(address account) external onlyOwner() {
super._includeInRewards(account);
}
// Internal Functions
/// @notice Calculates the tax amount for a transfer
/// @param sender The address initiating the transfer
/// @param recipient The address receiving the transfer
/// @param amount The amount of tokens being transferred
/// @return taxAmount The calculated tax amount
function _taxAmount(
address sender,
address recipient,
uint256 amount
) internal view returns (uint256 taxAmount) {
taxAmount = 0;
if (taxBPS != 0 && sender != taxAddress && !isFeesAndLimitsExcluded[sender] && !isFeesAndLimitsExcluded[recipient]) {
taxAmount = (amount * taxBPS) / MAX_BPS_AMOUNT;
}
}
/// @notice Calculates the deflation amount for a transfer
/// @param sender The address initiating the transfer
/// @param recipient The address receiving the transfer
/// @param amount The amount of tokens being transferred
/// @return deflationAmount The calculated deflation amount
function _deflationAmount(
address sender,
address recipient,
uint256 amount
) internal view returns (uint256 deflationAmount) {
deflationAmount = 0;
if (deflationBPS != 0 && !isFeesAndLimitsExcluded[sender] && !isFeesAndLimitsExcluded[recipient]) {
deflationAmount = (amount * deflationBPS) / MAX_BPS_AMOUNT;
}
}
}
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);
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
LibCommon.sol 118 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
library LibCommon {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The ETH transfer has failed.
error ETHTransferFailed();
/// @dev The address is the zero address.
error ZeroAddress();
/// @notice raised when an ERC20 transfer fails
error TransferFailed();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ETH OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice Taken from Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Sends `amount` (in wei) ETH to `to`.
/// Reverts upon failure.
function safeTransferETH(address to, uint256 amount) internal {
// solhint-disable-next-line no-inline-assembly
assembly {
// Transfer the ETH and check if it succeeded or not.
if iszero(call(gas(), to, amount, 0, 0, 0, 0)) {
// Store the function selector of `ETHTransferFailed()`.
// bytes4(keccak256(bytes("ETHTransferFailed()"))) = 0xb12d13eb
mstore(0x00, 0xb12d13eb)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
}
}
/// @notice Validates that the address is not the zero address using assembly.
/// @dev Reverts if the address is the zero address.
function validateAddress(address addr) internal pure {
// solhint-disable-next-line no-inline-assembly
assembly {
if iszero(shl(96, addr)) {
// Store the function selector of `ZeroAddress()`.
// bytes4(keccak256(bytes("ZeroAddress()"))) = 0xd92e233d
mstore(0x00, 0xd92e233d)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
}
}
/// @notice Helper function to transfer ERC20 tokens without the need for SafeERC20.
/// @dev Reverts if the ERC20 transfer fails.
/// @param tokenAddress The address of the ERC20 token.
/// @param from The address to transfer the tokens from.
/// @param to The address to transfer the tokens to.
/// @param amount The amount of tokens to transfer.
function safeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount
) internal returns (bool) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) = tokenAddress.call(
abi.encodeWithSignature(
"transferFrom(address,address,uint256)",
from,
to,
amount
)
);
if (!success) {
if (data.length != 0) {
// bubble up error
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(data)
revert(add(32, data), returndata_size)
}
} else {
revert TransferFailed();
}
}
return true;
}
/// @notice Helper function to transfer ERC20 tokens without the need for SafeERC20.
/// @dev Reverts if the ERC20 transfer fails.
/// @param tokenAddress The address of the ERC20 token.
/// @param to The address to transfer the tokens to.
/// @param amount The amount of tokens to transfer.
function safeTransfer(
address tokenAddress,
address to,
uint256 amount
) internal returns (bool) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) = tokenAddress.call(
abi.encodeWithSignature("transfer(address,uint256)", to, amount)
);
if (!success) {
if (data.length != 0) {
// bubble up error
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(data)
revert(add(32, data), returndata_size)
}
} else {
revert TransferFailed();
}
}
return true;
}
}
ReflectiveV3ERC20.sol 429 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { LibCommon } from "./lib/LibCommon.sol";
/// @title ERC20 Token with Extended Reflection Mechanism
/// @notice This contract implements ERC20 standards along with an additional reward feature for token holders
abstract contract ReflectiveV3ERC20 is ERC20 {
// Constants
uint256 private constant BPS_DIVISOR = 10_000;
uint256 public constant MAX_REWARDS_EXCLUSION_LIMIT = 100;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
uint256 private constant UINT_256_MAX = type(uint256).max;
uint256 private _rTotal;
uint256 private _tFeeTotal;
uint256 public tFeeBPS;
bool private immutable isReflective;
mapping (address => bool) private _isRewardsExcluded;
address[] public rewardsExcluded;
// events
event ExcludedFromRewards(address indexed account);
event IncludedInRewards(address indexed account);
// custom errors
error TokenIsNotReflective();
error TotalReflectionTooSmall();
error ZeroTransferError();
error BurningNotEnabled();
error ERC20InsufficientBalance(
address recipient,
uint256 fromBalance,
uint256 balance
);
error AlreadyExcludedFromRewards();
error AlreadyIncludedInRewards();
error ReachedMaxRewardExclusionLimit();
/// @notice Returns the total supply of the token
/// @return The total supply of the token
function _tTotal() public view virtual returns (uint256) {
return totalSupply();
}
/// @notice Constructor to initialize the ReflectiveV2ERC20 token
/// @param name_ The name of the token
/// @param symbol_ The symbol of the token
/// @param tokenOwner The address of the token owner
/// @param totalSupply_ The initial total supply of the token
/// @param decimalsToSet The number of decimal places for the token
/// @param tFeeBPS_ The reflection fee in basis points
/// @param isReflective_ Indicates if the token is reflective
constructor(
string memory name_,
string memory symbol_,
address tokenOwner,
uint256 totalSupply_,
uint8 decimalsToSet,
uint256 tFeeBPS_,
bool isReflective_
) ERC20(name_, symbol_) {
if (totalSupply_ != 0) {
super._mint(tokenOwner, totalSupply_ * 10 ** decimalsToSet);
_rTotal = (UINT_256_MAX - (UINT_256_MAX % totalSupply_));
}
_rOwned[tokenOwner] = _rTotal;
tFeeBPS = tFeeBPS_;
isReflective = isReflective_;
}
/// @notice Returns the balance of tokens for a specific address
/// @param account The address to query the balance of
/// @return The balance of tokens
function balanceOf(address account) public view override returns (uint256) {
if (isReflective) {
if (_isRewardsExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
} else {
return super.balanceOf(account);
}
}
/// @notice Transfers tokens from one account to another
/// @param from The address to transfer tokens from
/// @param to The address to transfer tokens to
/// @param value The amount of tokens to transfer
/// @return A boolean indicating success
function transferFrom(
address from,
address to,
uint256 value
) public virtual override returns (bool) {
address spender = super._msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/// @notice Transfers tokens to a specified address
/// @param to The address to transfer tokens to
/// @param value The amount of tokens to transfer
/// @return A boolean indicating success
function transfer(
address to,
uint256 value
) public virtual override returns (bool) {
address owner = super._msgSender();
_transfer(owner, to, value);
return true;
}
// override internal OZ standard ERC20 functions related to transfer
/// @notice Internal function to transfer tokens from one account to another
/// @param from The address to transfer tokens from
/// @param to The address to transfer tokens to
/// @param amount The amount of tokens to transfer
function _transfer(
address from,
address to,
uint256 amount
) internal override {
if (isReflective) {
LibCommon.validateAddress(from);
LibCommon.validateAddress(to);
if (amount == 0) {
revert ZeroTransferError();
}
if (_isRewardsExcluded[from] && !_isRewardsExcluded[to]) {
_transferFromExcluded(from, to, amount);
} else if (!_isRewardsExcluded[from] && _isRewardsExcluded[to]) {
_transferToExcluded(from, to, amount);
} else if (!_isRewardsExcluded[from] && !_isRewardsExcluded[to]) {
_transferStandard(from, to, amount);
} else if (_isRewardsExcluded[from] && _isRewardsExcluded[to]) {
_transferBothExcluded(from, to, amount);
} else {
_transferStandard(from, to, amount);
}
} else {
super._transfer(from, to, amount);
}
}
/// @notice Internal function to burn tokens, disallowed if reflection mechanism is used
/// @param account The account to burn tokens from
/// @param value The amount of tokens to burn
function _burn(address account, uint256 value) internal override {
if (isReflective) {
revert BurningNotEnabled();
} else {
super._burn(account, value);
}
}
/// @notice Sets a new reflection fee
/// @dev Should only be called by the contract owner
/// @param _tFeeBPS The reflection fee in basis points
function _setReflectionFee(uint256 _tFeeBPS) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
tFeeBPS = _tFeeBPS;
}
/// @notice Calculates the number of tokens from a reflection amount
/// @param rAmount The reflection amount
/// @return The number of tokens corresponding to the reflection amount
function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
if (rAmount > _rTotal) {
revert TotalReflectionTooSmall();
}
uint256 currentRate = _getRate();
return rAmount / currentRate;
}
/// @notice Excludes an account from receiving rewards
/// @param account The account to exclude from rewards
function _excludeFromRewards(
address account
) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
if (_isRewardsExcluded[account]) {
revert AlreadyExcludedFromRewards();
}
if (rewardsExcluded.length >= MAX_REWARDS_EXCLUSION_LIMIT) {
revert ReachedMaxRewardExclusionLimit();
}
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isRewardsExcluded[account] = true;
rewardsExcluded.push(account);
emit ExcludedFromRewards(account);
}
/// @notice Includes an account to receive rewards
/// @param account The account to include for rewards
function _includeInRewards(address account) internal {
if (!isReflective) {
revert TokenIsNotReflective();
}
if (!_isRewardsExcluded[account]) {
revert AlreadyIncludedInRewards();
}
for (uint256 i = 0; i < rewardsExcluded.length; i++) {
if (rewardsExcluded[i] == account) {
rewardsExcluded[i] = rewardsExcluded[rewardsExcluded.length - 1];
_isRewardsExcluded[account] = false;
_tOwned[account] = 0;
rewardsExcluded.pop();
emit IncludedInRewards(account);
break;
}
}
}
/// @notice Transfers a standard amount of tokens with reflection applied
/// @param sender The address sending the tokens
/// @param recipient The address receiving the tokens
/// @param tAmount The total token amount to transfer
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
/// @notice Transfers a token amount from an excluded account
/// @param sender The address sending the tokens
/// @param recipient The address receiving the tokens
/// @param tAmount The total token amount to transfer
function _transferFromExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[sender] = _tOwned[sender] - (tAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
/// @notice Transfers a token amount to an excluded account
/// @param sender The address sending the tokens
/// @param recipient The address receiving the tokens
/// @param tAmount The total token amount to transfer
function _transferToExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[recipient] = _tOwned[recipient] + (tTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
/// @notice Transfers a token amount between two excluded accounts
/// @param sender The address sending the tokens
/// @param recipient The address receiving the tokens
/// @param tAmount The total token amount to transfer
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 tFee = calculateFee(tAmount, sender, recipient);
uint256 tTransferAmount = tAmount - tFee;
(uint256 rAmount, uint256 rFee, uint256 rTransferAmount) = _getRValues(
tAmount,
tFee,
tTransferAmount
);
if (tAmount != 0) {
_rUpdate(sender, recipient, rAmount, rTransferAmount);
_tOwned[sender] = _tOwned[sender] - (tAmount);
_tOwned[recipient] = _tOwned[recipient] + (tTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tAmount);
}
}
/// @notice Reflects the fee to all holders by deducting it from the total reflections
/// @param rFee The reflection fee amount
/// @param tFee The token fee amount
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal - rFee;
_tFeeTotal = _tFeeTotal + tFee;
}
/// @notice Calculates the reflection fee from a token amount
/// @param amount The token amount to calculate the fee from
/// @param sender The address of the sender
/// @param recipient The address of the recipient
/// @return The calculated fee amount
function calculateFee(uint256 amount, address sender, address recipient) private view returns (uint256) {
if (_isRewardsExcluded[sender] || _isRewardsExcluded[recipient]) {
return 0;
} else {
return (amount * tFeeBPS) / BPS_DIVISOR;
}
}
/// @notice Transfers tokens without applying reflection fees
/// @param from The address to transfer tokens from
/// @param to The address to transfer tokens to
/// @param tAmount The total token amount to transfer
function _transferNonReflectedTax(
address from,
address to,
uint256 tAmount
) internal {
if (isReflective) {
if (tAmount != 0) {
uint256 currentRate = _getRate();
uint256 rAmount = tAmount * currentRate;
_rUpdate(from, to, rAmount, rAmount);
emit Transfer(from, to, tAmount);
}
} else {
super._transfer(from, to, tAmount);
}
}
/// @notice Retrieves the reflection values from token values
/// @param tAmount The token amount
/// @param tFee The token fee amount
/// @param tTransferAmount The transfer amount
/// @return The reflection values (rAmount, rFee, rTransferAmount)
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTransferAmount
) private view returns (uint256, uint256, uint256) {
uint256 currentRate = _getRate();
uint256 rAmount = tAmount * currentRate;
uint256 rFee = tFee * currentRate;
uint256 rTransferAmount = tTransferAmount * currentRate;
return (rAmount, rFee, rTransferAmount);
}
/// @notice Retrieves the current reflection rate
/// @return The current reflection rate
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply / tSupply;
}
/// @notice Retrieves the current reflection and token supplies
/// @return The current reflection and token supplies
function _getCurrentSupply() private view returns (uint256, uint256) {
return (_rTotal, _tTotal());
}
/// @notice Updates the reflection balances for a transfer
/// @param sender The address sending the tokens
/// @param recipient The address receiving the tokens
/// @param rSubAmount The amount to be deducted from the sender
/// @param rTransferAmount The amount to be added to the recipient
function _rUpdate(
address sender,
address recipient,
uint256 rSubAmount,
uint256 rTransferAmount
) private {
uint256 fromBalance = _rOwned[sender];
if (fromBalance < rSubAmount) {
revert ERC20InsufficientBalance(recipient, fromBalance, rSubAmount);
}
_rOwned[sender] = _rOwned[sender] - rSubAmount;
_rOwned[recipient] = _rOwned[recipient] + rTransferAmount;
}
}
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 {}
}
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);
}
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);
}
Read Contract
CONTRACT_HASH 0xbfcf7355 → bytes32
CONTRACT_NAME 0x614d08f8 → string
MAX_EXCLUSION_LIMIT 0x5514c832 → uint256
MAX_REWARDS_EXCLUSION_LIMIT 0x49a602db → uint256
VERSION 0xffa1ad74 → string
_tTotal 0xaf465a27 → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
deflationBPS 0x542e9667 → uint256
documentUri 0x044ab74e → string
feesAndLimitsExcluded 0x00af2d9d → address
getFeesAndLimitsExclusionList 0x93fbda99 → address[]
getRewardsExclusionList 0x154af8e7 → address[]
initialDocumentUri 0xa9d86685 → string
initialMaxTokenAmountPerAddress 0xa32f6976 → uint256
initialSupply 0x378dc3dc → uint256
initialTokenOwner 0x8dac7191 → address
isBurnable 0x883356d9 → bool
isDeflationary 0x8e8c10a2 → bool
isDocumentUriAllowed 0xf820f567 → bool
isFeesAndLimitsExcluded 0x4a88266c → bool
isMaxAmountOfTokensSet 0x5a3990ce → bool
isReflective 0x2e0ee48e → bool
isTaxable 0x4ac0bc32 → bool
maxTokenAmountPerAddress 0xd48e4127 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
rewardsExcluded 0x23bbbd6a → address
symbol 0x95d89b41 → string
tFeeBPS 0x9703a19d → uint256
taxAddress 0xb7bda68f → address
taxBPS 0x2fa782eb → uint256
tokenFromReflection 0x2d838119 → uint256
totalSupply 0x18160ddd → uint256
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burn 0x42966c68
uint256 amount
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
excludeFromFeesAndLimits 0xf8afaba5
address account
excludeFromRewards 0x111e0376
address account
includeInFeesAndLimits 0x0bd92756
address account
includeInRewards 0xb609995e
address account
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
renounceOwnership 0x715018a6
No parameters
setDeflationConfig 0xd8f67851
uint256 _deflationBPS
setDocumentUri 0xa476df61
string newDocumentUri
setMaxTokenAmountPerAddress 0x02252c4d
uint256 newMaxTokenAmount
setReflectionConfig 0xf91f825d
uint256 _feeBPS
setTaxConfig 0xf19c4e3b
address _taxAddress
uint256 _taxBPS
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address