Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xfAbA6f8e4a5E8Ab82F62fe7C39859FA577269BE3
Balance 0 ETH
Nonce 1
Code Size 11822 bytes
Last Active
Indexed Transactions 14 (24,589,04824,589,094)
Gas Used (indexed) 523,316
External Etherscan · Sourcify

Contract Bytecode

11822 bytes
0x608060405234801561001057600080fd5b506004361061025e5760003560e01c8063782d6fe111610146578063b4b5ea57116100c3578063e07edfdc11610087578063e07edfdc1461069f578063e09c3702146106a8578063e17ddf87146106cf578063e7a324dc146106e2578063f1127ed814610709578063f1b50c1d146107705761025e565b8063b4b5ea57146105fd578063c3cda52014610610578063d539139314610623578063d547741f1461064a578063dd62ed3e1461065d5761025e565b806394d830761161010a57806394d830761461059057806395d89b4114610598578063a217fddf146105bb578063a9059cbb146105c3578063ab65f09a146105d65761025e565b8063782d6fe1146104e35780637ecebe001461050e5780637f58b9d31461052e57806391c903a61461055657806391d148541461057d5761025e565b80632f2ff15d116101df57806344f61ab7116101a357806344f61ab714610405578063587cde1e1461040f5780635c19a95c146104505780636cde20ab146104635780636fcfff451461047657806370a08231146104b15761025e565b80632f2ff15d146103a5578063313ce567146103b857806334fec467146103d257806336568abe146103df57806340c10f19146103f25761025e565b806318160ddd1161022657806318160ddd1461031857806320606b7014610321578063206b60f91461034857806323b872dd1461036f578063248a9ca3146103825761025e565b806301ffc9a71461026357806304c981ba1461028b57806306fdde03146102a0578063095ea7b3146102d05780630f36554a146102e3575b600080fd5b61027661027136600461291a565b610778565b60405190151581526020015b60405180910390f35b61029e6102993660046128e0565b6107b1565b005b6102c3604051806040016040528060048152602001634f6e646f60e01b81525081565b6040516102829190612942565b6102766102de3660046127d9565b61085b565b61030a7fe9e4b2738f1e9267d0154d71b194ef672f39d2af6023224d4ae9de871574b6e081565b604051908152602001610282565b61030a60045481565b61030a7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b61030a7f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c81565b61027661037d36600461279e565b61091c565b61030a6103903660046128e0565b60009081526020819052604090206001015490565b61029e6103b33660046128f8565b610a63565b6103c0601281565b60405160ff9091168152602001610282565b6003546102769060ff1681565b61029e6103ed3660046128f8565b610af2565b61029e6104003660046127d9565b610b6c565b6001544211610276565b61043861041d366004612752565b6007602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610282565b61029e61045e366004612752565b610d85565b61030a610471366004612752565b610d92565b61049c610484366004612752565b60096020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610282565b61030a6104bf366004612752565b6001600160a01b03166000908152600660205260409020546001600160601b031690565b6104f66104f13660046127d9565b610dff565b6040516001600160601b039091168152602001610282565b61030a61051c366004612752565b600a6020526000908152604090205481565b61054161053c366004612752565b611086565b60408051928352602083019190915201610282565b61030a7f00000000000000000000000000000000000000000000000000000000039c2b8081565b61027661058b3660046128f8565b6111b1565b6102766111da565b6102c3604051806040016040528060048152602001634f4e444f60e01b81525081565b61030a600081565b6102766105d13660046127d9565b611211565b61030a7f0000000000000000000000000000000000000000000000000000000000f1428081565b6104f661060b366004612752565b61124d565b61029e61061e366004612844565b6112ca565b61030a7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b61029e6106583660046128f8565b6115b2565b61030a61066b36600461276c565b6001600160a01b0391821660009081526005602090815260408083209390941682529190915220546001600160601b031690565b61030a60015481565b61030a7f0000000000000000000000000000000000000000000000000000000002d3c78081565b61029e6106dd366004612802565b611632565b61030a7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b61074c6107173660046128a2565b600860209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6040805163ffffffff90931683526001600160601b03909116602083015201610282565b61029e611847565b60006001600160e01b03198216637965db0b60e01b14806107a957506301ffc9a760e01b6001600160e01b03198316145b90505b919050565b6107bc6000336111b1565b6108205760405162461bcd60e51b815260206004820152602a60248201527f4f6e646f3a3a757064617465436c69666654696d657374616d703a206e6f7420604482015269185d5d1a1bdc9a5e995960b21b60648201526084015b60405180910390fd5b60018190556040518181527f16f404ee0ddd98ae36a5041ac6ef22434c51989f6820d7ef42b67a1f8427bd709060200160405180910390a150565b60008060001983141561087657506001600160601b0361089b565b61089883604051806060016040528060258152602001612d50602591396118ec565b90505b3360008181526005602090815260408083206001600160a01b0389168085529083529281902080546001600160601b0319166001600160601b03871690811790915590519081529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a360019150505b92915050565b6001600160a01b03831660009081526005602090815260408083203380855290835281842054825160608101909352602580845291936001600160601b039091169285926109749288929190612d50908301396118ec565b9050866001600160a01b0316836001600160a01b0316141580156109a157506001600160601b0382811614155b15610a495760006109cb83836040518060600160405280603d8152602001612ca3603d913961191b565b6001600160a01b038981166000818152600560209081526040808320948a168084529482529182902080546001600160601b0319166001600160601b0387169081179091559151918252939450919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505b610a54878783611965565b600193505050505b9392505050565b600082815260208190526040902060010154610a80905b3361058b565b610ae45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526e0818591b5a5b881d1bc819dc985b9d608a1b6064820152608401610817565b610aee8282611d0a565b5050565b6001600160a01b0381163314610b625760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610817565b610aee8282611d8e565b610b967f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6336111b1565b610be25760405162461bcd60e51b815260206004820152601a60248201527f4f6e646f3a3a6d696e743a206e6f7420617574686f72697a65640000000000006044820152606401610817565b6001600160a01b038216610c385760405162461bcd60e51b815260206004820152601f60248201527f63616e6e6f74206d696e7420746f20746865207a65726f2061646472657373006044820152606401610817565b6000610c5c82604051806060016040528060228152602001612dd7602291396118ec565b90506000610c84600454604051806060016040528060278152602001612b5e602791396118ec565b9050610ca98183604051806060016040528060218152602001612d2f60219139611df3565b6001600160601b039081166004556001600160a01b038516600090815260066020908152604091829020548251808401909352601c83527f4f6e646f3a3a6d696e743a2062616c616e6365206f766572666c6f770000000091830191909152610d159216908490611df3565b6001600160a01b038516600081815260066020908152604080832080546001600160601b0319166001600160601b03968716179055519386168452919290917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a350505050565b610d8f3382611e40565b50565b6001600160a01b03811660009081526002602052604081205461010090046001600160601b031615610dd757610dc782611eca565b6001600160601b031690506107ac565b506001600160a01b0381166000908152600660205260409020546001600160601b03166107ac565b6000438210610e605760405162461bcd60e51b815260206004820152602760248201527f4f6e646f3a3a6765745072696f72566f7465733a206e6f742079657420646574604482015266195c9b5a5b995960ca1b6064820152608401610817565b6001600160a01b03831660009081526009602052604090205463ffffffff1680610e8e576000915050610916565b6001600160a01b03841660009081526008602052604081208491610eb3600185612a7e565b63ffffffff90811682526020820192909252604001600020541611610f26576001600160a01b038416600090815260086020526040812090610ef6600184612a7e565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b031691506109169050565b6001600160a01b038416600090815260086020908152604080832083805290915290205463ffffffff16831015610f61576000915050610916565b600080610f6f600184612a7e565b90505b8163ffffffff168163ffffffff1611156110415760006002610f948484612a7e565b610f9e9190612a0b565b610fa89083612a7e565b6001600160a01b038816600090815260086020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152919250871415611015576020015194506109169350505050565b805163ffffffff1687111561102c5781935061103a565b611037600183612a7e565b92505b5050610f72565b506001600160a01b038516600090815260086020908152604080832063ffffffff909416835292905220546001600160601b03600160201b9091041691505092915050565b6001600160a01b038116600090815260026020526040812054819061010090046001600160601b03166110be575060009050806111ac565b6001600160a01b03831660009081526002602081905260408083208151808301909252805491929091839160ff9091169081111561110c57634e487b7160e01b600052602160045260246000fd5b600281111561112b57634e487b7160e01b600052602160045260246000fd5b8152905461010090046001600160601b03166020909101529050600061114f6111da565b1561115f57506020810151611195565b60015442111561119157600080611179846000015161209d565b91509150611188818386612293565b92505050611195565b5060005b6020909101516001600160601b0390811693501690505b915091565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60007f00000000000000000000000000000000000000000000000000000000039c2b8060015461120a9190612995565b4211905090565b60008061123683604051806060016040528060268152602001612c7d602691396118ec565b9050611243338583611965565b5060019392505050565b6001600160a01b03811660009081526009602052604081205463ffffffff1680611278576000610a5c565b6001600160a01b03831660009081526008602052604081209061129c600184612a7e565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03169392505050565b60408051808201825260048152634f6e646f60e01b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f19edd2364024fe5ca846d8b43962322493f05d7676024f34d634b010cded750e81840152466060820152306080808301919091528351808303909101815260a0820184528051908301207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08301526001600160a01b038a1660e083015261010082018990526101208083018990528451808403909101815261014083019094528351939092019290922061190160f01b6101608401526101628301829052610182830181905290916000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015611449573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166114bb5760405162461bcd60e51b815260206004820152602660248201527f4f6e646f3a3a64656c656761746542795369673a20696e76616c6964207369676044820152656e617475726560d01b6064820152608401610817565b6001600160a01b0381166000908152600a602052604081208054916114df83612ac3565b91905055891461153c5760405162461bcd60e51b815260206004820152602260248201527f4f6e646f3a3a64656c656761746542795369673a20696e76616c6964206e6f6e604482015261636560f01b6064820152608401610817565b8742111561159b5760405162461bcd60e51b815260206004820152602660248201527f4f6e646f3a3a64656c656761746542795369673a207369676e617475726520656044820152651e1c1a5c995960d21b6064820152608401610817565b6115a5818b611e40565b505050505b505050505050565b6000828152602081905260409020600101546115cd90610a7a565b610b625760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526f2061646d696e20746f207265766f6b6560801b6064820152608401610817565b61165c7fe9e4b2738f1e9267d0154d71b194ef672f39d2af6023224d4ae9de871574b6e0336111b1565b61166557600080fd5b600082116116cc5760405162461bcd60e51b815260206004820152602e60248201527f4f6e646f3a3a7570646174655472616e63686542616c616e63653a20616d6f7560448201526d06e74206d757374206265203e20360941b6064820152608401610817565b6001600160a01b03831660009081526002602052604090205461010090046001600160601b0316156117605760405162461bcd60e51b815260206004820152603760248201527f4f6e646f3a3a7570646174655472616e63686542616c616e63653a20616c7265604482015276616479206861732074696d656c6f636b6564204f6e646f60481b6064820152608401610817565b600061178483604051806060016040528060328152602001612c15603291396118ec565b905060405180604001604052808360028111156117b157634e487b7160e01b600052602160045260246000fd5b81526001600160601b0383166020918201526001600160a01b0386166000908152600291829052604090208251815491929091839160ff1990911690600190849081111561180f57634e487b7160e01b600052602160045260246000fd5b02179055506020919091015181546001600160601b03909116610100026cffffffffffffffffffffffff001990911617905550505050565b6118526000336111b1565b6118aa5760405162461bcd60e51b8152602060048201526024808201527f4f6e646f3a3a656e61626c655472616e736665723a206e6f7420617574686f726044820152631a5e995960e21b6064820152608401610817565b6003805460ff191660011790556040513381527f5285f0ad5858236d5f2ce2ec9ff0b2d3aa04320499b71f022e64d9c7549a325c9060200160405180910390a1565b600081600160601b84106119135760405162461bcd60e51b81526004016108179190612942565b509192915050565b6000836001600160601b0316836001600160601b0316111582906119525760405162461bcd60e51b81526004016108179190612942565b5061195d8385612aa3565b949350505050565b60035460ff168061199b575061199b7f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c336111b1565b611a085760405162461bcd60e51b815260206004820152603860248201527f4f6e646f546f6b656e3a205472616e7366657273206e6f7420616c6c6f776564604482015277206f72206e6f742072696768742070726976696c6c65676560401b6064820152608401610817565b6001600160a01b038316611a845760405162461bcd60e51b815260206004820152603c60248201527f4f6e646f3a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260448201527f616e736665722066726f6d20746865207a65726f2061646472657373000000006064820152608401610817565b6001600160a01b038216611b005760405162461bcd60e51b815260206004820152603a60248201527f4f6e646f3a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260448201527f616e7366657220746f20746865207a65726f20616464726573730000000000006064820152608401610817565b6001600160a01b03831660009081526002602052604090205461010090046001600160601b031615611bb157611b3583611eca565b6001600160601b0316816001600160601b03161115611bb15760405162461bcd60e51b815260206004820152603260248201527f4f6e646f3a3a5f7472616e73666572546f6b656e733a206e6f7420656e6f75676044820152716820756e6c6f636b65642062616c616e636560701b6064820152608401610817565b6001600160a01b038316600090815260066020908152604091829020548251606081019093526036808452611bfc936001600160601b039092169285929190612c479083013961191b565b6001600160a01b03848116600090815260066020908152604080832080546001600160601b0319166001600160601b03968716179055928616825290829020548251606081019093526030808452611c649491909116928592909190612d7590830139611df3565b6001600160a01b0383811660008181526006602090815260409182902080546001600160601b0319166001600160601b03968716179055905193851684529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36001600160a01b03808416600090815260076020526040808220548584168352912054611d059291821691168361237d565b505050565b611d1482826111b1565b610aee576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055611d4a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611d9882826111b1565b15610aee576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611e0084866129d5565b9050846001600160601b0316816001600160601b031610158390611e375760405162461bcd60e51b81526004016108179190612942565b50949350505050565b6001600160a01b03808316600081815260076020818152604080842080546006845282862054949093528787166001600160a01b031984168117909155905191909516946001600160601b039092169391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4611ec482848361237d565b50505050565b6000611ed46111da565b15611f0157506001600160a01b0381166000908152600660205260409020546001600160601b03166107ac565b6001600160a01b03821660009081526002602081905260408083208151808301909252805491929091839160ff90911690811115611f4f57634e487b7160e01b600052602160045260246000fd5b6002811115611f6e57634e487b7160e01b600052602160045260246000fd5b8152905461010090046001600160601b03166020909101529050611f93600154421190565b1561204757600080611fa8836000015161209d565b915091506000611fdf8460200151611fc1848688612293565b6040518060600160405280602f8152602001612b0b602f913961191b565b905061203c60066000886001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160601b031682604051806060016040528060348152602001612be16034913961191b565b9450505050506107ac565b6001600160a01b03831660009081526006602090815260409182902054838201518351606081019094526028808552612095946001600160601b0390931693919291612bb99083013961191b565b9150506107ac565b600080600154426120ae9190612a67565b905060008360028111156120d257634e487b7160e01b600052602160045260246000fd5b1415612151577f0000000000000000000000000000000000000000000000000000000000f1428081116121055780612127565b7f0000000000000000000000000000000000000000000000000000000000f142805b90507f0000000000000000000000000000000000000000000000000000000000f1428091506111ac565b600183600281111561217357634e487b7160e01b600052602160045260246000fd5b14156121f2577f0000000000000000000000000000000000000000000000000000000002d3c78081116121a657806121c8565b7f0000000000000000000000000000000000000000000000000000000002d3c7805b90507f0000000000000000000000000000000000000000000000000000000002d3c78091506111ac565b600283600281111561221457634e487b7160e01b600052602160045260246000fd5b14156111ac577f00000000000000000000000000000000000000000000000000000000039c2b8081116122475780612269565b7f00000000000000000000000000000000000000000000000000000000039c2b805b90507f00000000000000000000000000000000000000000000000000000000039c2b809150915091565b60006002825160028111156122b857634e487b7160e01b600052602160045260246000fd5b141561235957600061231c6003858786602001516001600160601b03166122df9190612a48565b6122e991906129f7565b6122f4906002612a48565b6122fe91906129f7565b604051806060016040528060328152602001612da5603291396118ec565b905061235181600385602001516123339190612a2e565b604051806060016040528060248152602001612b3a60249139611df3565b915050610a5c565b612376838584602001516001600160601b03166122f49190612a48565b9050610a5c565b816001600160a01b0316836001600160a01b0316141580156123a857506000816001600160601b0316115b15611d05576001600160a01b0383161561246d576001600160a01b03831660009081526009602052604081205463ffffffff1690816123e8576000612434565b6001600160a01b03851660009081526008602052604081209061240c600185612a7e565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03165b9050600061245b8285604051806060016040528060288152602001612ce06028913961191b565b905061246986848484612525565b5050505b6001600160a01b03821615611d05576001600160a01b03821660009081526009602052604081205463ffffffff1690816124a85760006124f4565b6001600160a01b0384166000908152600860205260408120906124cc600185612a7e565b63ffffffff168152602081019190915260400160002054600160201b90046001600160601b03165b9050600061251b8285604051806060016040528060278152602001612d0860279139611df3565b90506115aa858484845b600061254943604051806060016040528060348152602001612b8560349139612714565b905060008463ffffffff161180156125a357506001600160a01b038516600090815260086020526040812063ffffffff831691612587600188612a7e565b63ffffffff908116825260208201929092526040016000205416145b15612617576001600160a01b038516600090815260086020526040812083916125cd600188612a7e565b63ffffffff168152602081019190915260400160002080546001600160601b0392909216600160201b026fffffffffffffffffffffffff00000000199092169190911790556126bf565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000908152600882528681208b8616825290915294909420925183549451909116600160201b026001600160801b031990941691161791909117905561268e8460016129ad565b6001600160a01b0386166000908152600960205260409020805463ffffffff191663ffffffff929092169190911790555b604080516001600160601b038086168252841660208201526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b600081600160201b84106119135760405162461bcd60e51b81526004016108179190612942565b80356001600160a01b03811681146107ac57600080fd5b600060208284031215612763578081fd5b610a5c8261273b565b6000806040838503121561277e578081fd5b6127878361273b565b91506127956020840161273b565b90509250929050565b6000806000606084860312156127b2578081fd5b6127bb8461273b565b92506127c96020850161273b565b9150604084013590509250925092565b600080604083850312156127eb578182fd5b6127f48361273b565b946020939093013593505050565b600080600060608486031215612816578283fd5b61281f8461273b565b925060208401359150604084013560038110612839578182fd5b809150509250925092565b60008060008060008060c0878903121561285c578182fd5b6128658761273b565b95506020870135945060408701359350606087013560ff81168114612888578283fd5b9598949750929560808101359460a0909101359350915050565b600080604083850312156128b4578182fd5b6128bd8361273b565b9150602083013563ffffffff811681146128d5578182fd5b809150509250929050565b6000602082840312156128f1578081fd5b5035919050565b6000806040838503121561290a578182fd5b823591506127956020840161273b565b60006020828403121561292b578081fd5b81356001600160e01b031981168114610a5c578182fd5b6000602080835283518082850152825b8181101561296e57858101830151858201604001528201612952565b8181111561297f5783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156129a8576129a8612ade565b500190565b600063ffffffff8083168185168083038211156129cc576129cc612ade565b01949350505050565b60006001600160601b038083168185168083038211156129cc576129cc612ade565b600082612a0657612a06612af4565b500490565b600063ffffffff80841680612a2257612a22612af4565b92169190910492915050565b60006001600160601b0380841680612a2257612a22612af4565b6000816000190483118215151615612a6257612a62612ade565b500290565b600082821015612a7957612a79612ade565b500390565b600063ffffffff83811690831681811015612a9b57612a9b612ade565b039392505050565b60006001600160601b0383811690831681811015612a9b57612a9b612ade565b6000600019821415612ad757612ad7612ade565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfe4f6e646f3a3a676574467265656442616c616e63653a206c6f636b65642062616c616e636520756e646572666c6f774f6e646f3a3a5f70726f706f7274696f6e417661696c61626c653a206f766572666c6f774f6e646f3a3a6d696e743a20746f74616c537570706c79206578636565647320393620626974734f6e646f3a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206578636565647320333220626974734f6e646f3a3a676574467265656442616c616e63653a2062616c616e636520756e646572666c6f774f6e646f3a3a676574467265656442616c616e63653a20746f74616c2066726565642062616c616e636520756e646572666c6f774f6e646f3a3a7570646174655472616e63686542616c616e63653a20616d6f756e74206578636565647320393620626974734f6e646f3a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e63654f6e646f3a3a7472616e736665723a20616d6f756e74206578636565647320393620626974734f6e646f3a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e63654f6e646f3a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f77734f6e646f3a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77734f6e646f3a3a6d696e743a20746f6b656e20737570706c79206f766572666c6f774f6e646f3a3a617070726f76653a20616d6f756e74206578636565647320393620626974734f6e646f3a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f77734f6e646f3a3a5f70726f706f7274696f6e417661696c61626c653a20616d6f756e74206578636565647320393620626974734f6e646f3a3a6d696e743a20616d6f756e7420657863656564732039362062697473a26469706673582212203cccd92dbab779597922d47810068ff2f92a103e33e72ca239a9f4699171550364736f6c63430008030033

Verified Source Code Full Match

Compiler: v0.8.3+commit.8d00100c EVM: istanbul Optimization: Yes (100 runs)
Ondo.sol 1031 lines
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.3;

/*
 * @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) {
    this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
    return msg.data;
  }
}

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
  /**
   * @dev Returns true if this contract implements the interface defined by
   * `interfaceId`. See the corresponding
   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
   * to learn more about how these ids are created.
   *
   * This function call must use less than 30 000 gas.
   */
  function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override
    returns (bool)
  {
    return interfaceId == type(IERC165).interfaceId;
  }
}

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
  function hasRole(bytes32 role, address account) external view returns (bool);

  function getRoleAdmin(bytes32 role) external view returns (bytes32);

  function grantRole(bytes32 role, address account) external;

  function revokeRole(bytes32 role, address account) external;

  function renounceRole(bytes32 role, address account) external;
}

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
  struct RoleData {
    mapping(address => bool) members;
    bytes32 adminRole;
  }

  mapping(bytes32 => RoleData) private _roles;

  bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

  /**
   * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
   *
   * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
   * {RoleAdminChanged} not being emitted signaling this.
   *
   * _Available since v3.1._
   */
  event RoleAdminChanged(
    bytes32 indexed role,
    bytes32 indexed previousAdminRole,
    bytes32 indexed newAdminRole
  );

  /**
   * @dev Emitted when `account` is granted `role`.
   *
   * `sender` is the account that originated the contract call, an admin role
   * bearer except when using {_setupRole}.
   */
  event RoleGranted(
    bytes32 indexed role,
    address indexed account,
    address indexed sender
  );

  /**
   * @dev Emitted when `account` is revoked `role`.
   *
   * `sender` is the account that originated the contract call:
   *   - if using `revokeRole`, it is the admin role bearer
   *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
   */
  event RoleRevoked(
    bytes32 indexed role,
    address indexed account,
    address indexed sender
  );

  /**
   * @dev See {IERC165-supportsInterface}.
   */
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override
    returns (bool)
  {
    return
      interfaceId == type(IAccessControl).interfaceId ||
      super.supportsInterface(interfaceId);
  }

  /**
   * @dev Returns `true` if `account` has been granted `role`.
   */
  function hasRole(bytes32 role, address account)
    public
    view
    override
    returns (bool)
  {
    return _roles[role].members[account];
  }

  /**
   * @dev Returns the admin role that controls `role`. See {grantRole} and
   * {revokeRole}.
   *
   * To change a role's admin, use {_setRoleAdmin}.
   */
  function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
    return _roles[role].adminRole;
  }

  /**
   * @dev Grants `role` to `account`.
   *
   * If `account` had not been already granted `role`, emits a {RoleGranted}
   * event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function grantRole(bytes32 role, address account) public virtual override {
    require(
      hasRole(getRoleAdmin(role), _msgSender()),
      "AccessControl: sender must be an admin to grant"
    );

    _grantRole(role, account);
  }

  /**
   * @dev Revokes `role` from `account`.
   *
   * If `account` had been granted `role`, emits a {RoleRevoked} event.
   *
   * Requirements:
   *
   * - the caller must have ``role``'s admin role.
   */
  function revokeRole(bytes32 role, address account) public virtual override {
    require(
      hasRole(getRoleAdmin(role), _msgSender()),
      "AccessControl: sender must be an admin to revoke"
    );

    _revokeRole(role, account);
  }

  /**
   * @dev Revokes `role` from the calling account.
   *
   * Roles are often managed via {grantRole} and {revokeRole}: this function's
   * purpose is to provide a mechanism for accounts to lose their privileges
   * if they are compromised (such as when a trusted device is misplaced).
   *
   * If the calling account had been granted `role`, emits a {RoleRevoked}
   * event.
   *
   * Requirements:
   *
   * - the caller must be `account`.
   */
  function renounceRole(bytes32 role, address account) public virtual override {
    require(
      account == _msgSender(),
      "AccessControl: can only renounce roles for self"
    );

    _revokeRole(role, account);
  }

  /**
   * @dev Grants `role` to `account`.
   *
   * If `account` had not been already granted `role`, emits a {RoleGranted}
   * event. Note that unlike {grantRole}, this function doesn't perform any
   * checks on the calling account.
   *
   * [WARNING]
   * ====
   * This function should only be called from the constructor when setting
   * up the initial roles for the system.
   *
   * Using this function in any other way is effectively circumventing the admin
   * system imposed by {AccessControl}.
   * ====
   */
  function _setupRole(bytes32 role, address account) internal virtual {
    _grantRole(role, account);
  }

  /**
   * @dev Sets `adminRole` as ``role``'s admin role.
   *
   * Emits a {RoleAdminChanged} event.
   */
  function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
    emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
    _roles[role].adminRole = adminRole;
  }

  function _grantRole(bytes32 role, address account) private {
    if (!hasRole(role, account)) {
      _roles[role].members[account] = true;
      emit RoleGranted(role, account, _msgSender());
    }
  }

  function _revokeRole(bytes32 role, address account) private {
    if (hasRole(role, account)) {
      _roles[role].members[account] = false;
      emit RoleRevoked(role, account, _msgSender());
    }
  }
}

interface IOndo {
  enum InvestorType {CoinlistTranche1, CoinlistTranche2, SeedTranche}

  // ----------- State changing api -----------

  /// @notice Called by timelock contract to initialize locked balance of coinlist/seed investor
  function updateTrancheBalance(
    address beneficiary,
    uint256 rawAmount,
    InvestorType tranche
  ) external;

  // ----------- Getters -----------

  /// @notice Gets the TOTAL amount of Ondo available for an address
  function getFreedBalance(address account) external view returns (uint96);

  /// @notice Gets the initial locked balance and unlocked Ondo for an address
  function getVestedBalance(address account)
    external
    view
    returns (uint96, uint96);
}

abstract contract LinearTimelock {
  struct InvestorParam {
    IOndo.InvestorType investorType;
    uint96 initialBalance;
  }

  /// @notice the timestamp at which releasing is allowed
  uint256 public cliffTimestamp;
  /// @notice the linear vesting period for the first tranche
  uint256 public immutable tranche1VestingPeriod;
  /// @notice the linear vesting period for the second tranche
  uint256 public immutable tranche2VestingPeriod;
  /// @notice the linear vesting period for the Seed/Series A Tranche
  uint256 public immutable seedVestingPeriod;
  /// @dev mapping of balances for each investor
  mapping(address => InvestorParam) internal investorBalances;
  /// @notice role that allows updating of tranche balances - granted to Merkle airdrop contract
  bytes32 public constant TIMELOCK_UPDATE_ROLE =
    keccak256("TIMELOCK_UPDATE_ROLE");

  constructor(
    uint256 _cliffTimestamp,
    uint256 _tranche1VestingPeriod,
    uint256 _tranche2VestingPeriod,
    uint256 _seedVestingPeriod
  ) {
    cliffTimestamp = _cliffTimestamp;
    tranche1VestingPeriod = _tranche1VestingPeriod;
    tranche2VestingPeriod = _tranche2VestingPeriod;
    seedVestingPeriod = _seedVestingPeriod;
  }

  function passedCliff() public view returns (bool) {
    return block.timestamp > cliffTimestamp;
  }

  /// @dev the seedVestingPeriod is the longest vesting period
  function passedAllVestingPeriods() public view returns (bool) {
    return block.timestamp > cliffTimestamp + seedVestingPeriod;
  }

  /**
    @notice View function to get the user's initial balance and current amount of freed balance
   */
  function getVestedBalance(address account)
    external
    view
    returns (uint256, uint256)
  {
    if (investorBalances[account].initialBalance == 0) {
      return (0, 0);
    }
    InvestorParam memory investorParam = investorBalances[account];
    uint96 amountAvailable;
    if (passedAllVestingPeriods()) {
      amountAvailable = investorParam.initialBalance;
    } else if (passedCliff()) {
      (uint256 vestingPeriod, uint256 elapsed) =
        _getTrancheInfo(investorParam.investorType);
      amountAvailable = _proportionAvailable(
        elapsed,
        vestingPeriod,
        investorParam
      );
    } else {
      amountAvailable = 0;
    }
    return (investorParam.initialBalance, amountAvailable);
  }

  function _getTrancheInfo(IOndo.InvestorType investorType)
    internal
    view
    returns (uint256 vestingPeriod, uint256 elapsed)
  {
    elapsed = block.timestamp - cliffTimestamp;
    if (investorType == IOndo.InvestorType.CoinlistTranche1) {
      elapsed = elapsed > tranche1VestingPeriod
        ? tranche1VestingPeriod
        : elapsed;
      vestingPeriod = tranche1VestingPeriod;
    } else if (investorType == IOndo.InvestorType.CoinlistTranche2) {
      elapsed = elapsed > tranche2VestingPeriod
        ? tranche2VestingPeriod
        : elapsed;
      vestingPeriod = tranche2VestingPeriod;
    } else if (investorType == IOndo.InvestorType.SeedTranche) {
      elapsed = elapsed > seedVestingPeriod ? seedVestingPeriod : elapsed;
      vestingPeriod = seedVestingPeriod;
    }
  }

  function _proportionAvailable(
    uint256 elapsed,
    uint256 vestingPeriod,
    InvestorParam memory investorParam
  ) internal pure returns (uint96) {
    if (investorParam.investorType == IOndo.InvestorType.SeedTranche) {
      // Seed/Series A Tranche Balance = proportionAvail*2/3 + x/3, where x = Balance. This allows 1/3 of the series A balance to be unlocked at cliff
      uint96 vestedAmount =
        safe96(
          (((investorParam.initialBalance * elapsed) / vestingPeriod) * 2) / 3,
          "Ondo::_proportionAvailable: amount exceeds 96 bits"
        );
      return
        add96(
          vestedAmount,
          investorParam.initialBalance / 3,
          "Ondo::_proportionAvailable: overflow"
        );
    } else {
      return
        safe96(
          (investorParam.initialBalance * elapsed) / vestingPeriod,
          "Ondo::_proportionAvailable: amount exceeds 96 bits"
        );
    }
  }

  function safe32(uint256 n, string memory errorMessage)
    internal
    pure
    returns (uint32)
  {
    require(n < 2**32, errorMessage);
    return uint32(n);
  }

  function safe96(uint256 n, string memory errorMessage)
    internal
    pure
    returns (uint96)
  {
    require(n < 2**96, errorMessage);
    return uint96(n);
  }

  function add96(
    uint96 a,
    uint96 b,
    string memory errorMessage
  ) internal pure returns (uint96) {
    uint96 c = a + b;
    require(c >= a, errorMessage);
    return c;
  }

  function sub96(
    uint96 a,
    uint96 b,
    string memory errorMessage
  ) internal pure returns (uint96) {
    require(b <= a, errorMessage);
    return a - b;
  }
}

contract Ondo is AccessControl, LinearTimelock {
  /// @notice EIP-20 token name for this token
  string public constant name = "Ondo";

  /// @notice EIP-20 token symbol for this token
  string public constant symbol = "ONDO";

  /// @notice EIP-20 token decimals for this token
  uint8 public constant decimals = 18;

  // whether token transfers are allowed
  bool public transferAllowed; // false by default

  /// @notice Total number of tokens in circulation
  uint256 public totalSupply = 10_000_000_000e18; // 10 billion Ondo

  // Allowance amounts on behalf of others
  mapping(address => mapping(address => uint96)) internal allowances;

  // Official record of token balances for each account
  mapping(address => uint96) internal balances;

  /// @notice A record of each accounts delegate
  mapping(address => address) public delegates;

  /// @notice A checkpoint for marking number of votes from a given block
  struct Checkpoint {
    uint32 fromBlock;
    uint96 votes;
  }

  /// @notice A record of votes checkpoints for each account, by index
  mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;

  /// @notice The number of checkpoints for each account
  mapping(address => uint32) public numCheckpoints;

  /// @notice The EIP-712 typehash for the contract's domain
  bytes32 public constant DOMAIN_TYPEHASH =
    keccak256(
      "EIP712Domain(string name,uint256 chainId,address verifyingContract)"
    );

  /// @notice The EIP-712 typehash for the delegation struct used by the contract
  bytes32 public constant DELEGATION_TYPEHASH =
    keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

  /// @notice The identifier of the role which allows special transfer privileges.
  bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");
  bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

  /// @notice A record of states for signing / validating signatures
  mapping(address => uint256) public nonces;

  /// @notice An event thats emitted when an account changes its delegate
  event DelegateChanged(
    address indexed delegator,
    address indexed fromDelegate,
    address indexed toDelegate
  );

  /// @notice An event thats emitted when a delegate account's vote balance changes
  event DelegateVotesChanged(
    address indexed delegate,
    uint256 previousBalance,
    uint256 newBalance
  );

  /// @notice The standard EIP-20 transfer event
  event Transfer(address indexed from, address indexed to, uint256 amount);

  /// @notice The standard EIP-20 approval event
  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 amount
  );

  event CliffTimestampUpdate(uint256 newTimestamp);

  /**
   * @dev Emitted when the transfer is enabled triggered by `account`.
   */
  event TransferEnabled(address account);

  /// @notice a modifier which checks if transfers are allowed
  modifier whenTransferAllowed() {
    require(
      transferAllowed || hasRole(TRANSFER_ROLE, msg.sender),
      "OndoToken: Transfers not allowed or not right privillege"
    );
    _;
  }

  /**
   * @notice Construct a new Ondo token
   * @param _governance The initial account to grant owner permission and all the tokens
   */
  constructor(
    address _governance,
    uint256 _cliffTimestamp,
    uint256 _tranche1VestingPeriod,
    uint256 _tranche2VestingPeriod,
    uint256 _seedVestingPeriod
  )
    LinearTimelock(
      _cliffTimestamp,
      _tranche1VestingPeriod,
      _tranche2VestingPeriod,
      _seedVestingPeriod
    )
  {
    balances[_governance] = uint96(totalSupply);
    _setupRole(DEFAULT_ADMIN_ROLE, _governance);
    _setupRole(TRANSFER_ROLE, _governance);
    _setupRole(MINTER_ROLE, _governance);
    emit Transfer(address(0), _governance, totalSupply);
  }

  /**
   * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`
   * @param account The address of the account holding the funds
   * @param spender The address of the account spending the funds
   * @return The number of tokens approved
   */
  function allowance(address account, address spender)
    external
    view
    returns (uint256)
  {
    return allowances[account][spender];
  }

  /**
   * @notice Approve `spender` to transfer up to `amount` from `src`
   * @dev This will overwrite the approval amount for `spender`
   *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
   * @param spender The address of the account which may transfer tokens
   * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
   * @return Whether or not the approval succeeded
   */
  function approve(address spender, uint256 rawAmount) external returns (bool) {
    uint96 amount;
    if (rawAmount == type(uint256).max) {
      amount = type(uint96).max;
    } else {
      amount = safe96(rawAmount, "Ondo::approve: amount exceeds 96 bits");
    }

    allowances[msg.sender][spender] = amount;

    emit Approval(msg.sender, spender, amount);
    return true;
  }

  /**
   * @notice Get the number of tokens held by the `account`
   * @param account The address of the account to get the balance of
   * @return The number of tokens held
   */
  function balanceOf(address account) external view returns (uint256) {
    return balances[account];
  }

  /**
   * @notice Get the total number of UNLOCKED tokens held by the `account`
   * @param account The address of the account to get the unlocked balance of
   * @return The number of unlocked tokens held.
   */
  function getFreedBalance(address account) external view returns (uint256) {
    if (investorBalances[account].initialBalance > 0) {
      return _getFreedBalance(account);
    } else {
      return balances[account];
    }
  }

  /**
   * @notice Transfer `amount` tokens from `msg.sender` to `dst`
   * @param dst The address of the destination account
   * @param rawAmount The number of tokens to transfer
   * @return Whether or not the transfer succeeded
   */
  function transfer(address dst, uint256 rawAmount) external returns (bool) {
    uint96 amount = safe96(rawAmount, "Ondo::transfer: amount exceeds 96 bits");
    _transferTokens(msg.sender, dst, amount);
    return true;
  }

  /**
   * @notice Transfer `amount` tokens from `src` to `dst`
   * @param src The address of the source account
   * @param dst The address of the destination account
   * @param rawAmount The number of tokens to transfer
   * @return Whether or not the transfer succeeded
   */
  function transferFrom(
    address src,
    address dst,
    uint256 rawAmount
  ) external returns (bool) {
    address spender = msg.sender;
    uint96 spenderAllowance = allowances[src][spender];
    uint96 amount = safe96(rawAmount, "Ondo::approve: amount exceeds 96 bits");

    if (spender != src && spenderAllowance != type(uint96).max) {
      uint96 newAllowance =
        sub96(
          spenderAllowance,
          amount,
          "Ondo::transferFrom: transfer amount exceeds spender allowance"
        );
      allowances[src][spender] = newAllowance;

      emit Approval(src, spender, newAllowance);
    }

    _transferTokens(src, dst, amount);
    return true;
  }

  /**
   * @notice Delegate votes from `msg.sender` to `delegatee`
   * @param delegatee The address to delegate votes to
   */
  function delegate(address delegatee) public {
    return _delegate(msg.sender, delegatee);
  }

  /**
   * @notice Delegates votes from signatory to `delegatee`
   * @param delegatee The address to delegate votes to
   * @param nonce The contract state required to match the signature
   * @param expiry The time at which to expire the signature
   * @param v The recovery byte of the signature
   * @param r Half of the ECDSA signature pair
   * @param s Half of the ECDSA signature pair
   */
  function delegateBySig(
    address delegatee,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) public {
    bytes32 domainSeparator =
      keccak256(
        abi.encode(
          DOMAIN_TYPEHASH,
          keccak256(bytes(name)),
          getChainId(),
          address(this)
        )
      );
    bytes32 structHash =
      keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));
    bytes32 digest =
      keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    address signatory = ecrecover(digest, v, r, s);
    require(signatory != address(0), "Ondo::delegateBySig: invalid signature");
    require(nonce == nonces[signatory]++, "Ondo::delegateBySig: invalid nonce");
    require(
      block.timestamp <= expiry,
      "Ondo::delegateBySig: signature expired"
    );
    return _delegate(signatory, delegatee);
  }

  /**
   * @notice Gets the current votes balance for `account`
   * @param account The address to get votes balance
   * @return The number of current votes for `account`
   */
  function getCurrentVotes(address account) external view returns (uint96) {
    uint32 nCheckpoints = numCheckpoints[account];
    return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
  }

  /**
   * @notice Determine the prior number of votes for an account as of a block number
   * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
   * @param account The address of the account to check
   * @param blockNumber The block number to get the vote balance at
   * @return The number of votes the account had as of the given block
   */
  function getPriorVotes(address account, uint256 blockNumber)
    public
    view
    returns (uint96)
  {
    require(
      blockNumber < block.number,
      "Ondo::getPriorVotes: not yet determined"
    );

    uint32 nCheckpoints = numCheckpoints[account];
    if (nCheckpoints == 0) {
      return 0;
    }

    // First check most recent balance
    if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
      return checkpoints[account][nCheckpoints - 1].votes;
    }

    // Next check implicit zero balance
    if (checkpoints[account][0].fromBlock > blockNumber) {
      return 0;
    }

    uint32 lower = 0;
    uint32 upper = nCheckpoints - 1;
    while (upper > lower) {
      uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
      Checkpoint memory cp = checkpoints[account][center];
      if (cp.fromBlock == blockNumber) {
        return cp.votes;
      } else if (cp.fromBlock < blockNumber) {
        lower = center;
      } else {
        upper = center - 1;
      }
    }
    return checkpoints[account][lower].votes;
  }

  /**
   * @notice Create `rawAmount` new tokens and assign them to `account`.
   * @param account The address to give newly minted tokens to
   * @param rawAmount Number of new tokens to mint.
   * @dev Even though total token supply is uint96, we use uint256 for the amount for consistency with other external interfaces.
   */
  function mint(address account, uint256 rawAmount) external {
    require(hasRole(MINTER_ROLE, msg.sender), "Ondo::mint: not authorized");
    require(account != address(0), "cannot mint to the zero address");

    uint96 amount = safe96(rawAmount, "Ondo::mint: amount exceeds 96 bits");
    uint96 supply =
      safe96(totalSupply, "Ondo::mint: totalSupply exceeds 96 bits");
    totalSupply = add96(supply, amount, "Ondo::mint: token supply overflow");
    balances[account] = add96(
      balances[account],
      amount,
      "Ondo::mint: balance overflow"
    );

    emit Transfer(address(0), account, amount);
  }

  function _delegate(address delegator, address delegatee) internal {
    address currentDelegate = delegates[delegator];
    uint96 delegatorBalance = balances[delegator];
    delegates[delegator] = delegatee;

    emit DelegateChanged(delegator, currentDelegate, delegatee);

    _moveDelegates(currentDelegate, delegatee, delegatorBalance);
  }

  function _transferTokens(
    address src,
    address dst,
    uint96 amount
  ) internal whenTransferAllowed {
    require(
      src != address(0),
      "Ondo::_transferTokens: cannot transfer from the zero address"
    );
    require(
      dst != address(0),
      "Ondo::_transferTokens: cannot transfer to the zero address"
    );
    if (investorBalances[src].initialBalance > 0) {
      require(
        amount <= _getFreedBalance(src),
        "Ondo::_transferTokens: not enough unlocked balance"
      );
    }

    balances[src] = sub96(
      balances[src],
      amount,
      "Ondo::_transferTokens: transfer amount exceeds balance"
    );
    balances[dst] = add96(
      balances[dst],
      amount,
      "Ondo::_transferTokens: transfer amount overflows"
    );
    emit Transfer(src, dst, amount);

    _moveDelegates(delegates[src], delegates[dst], amount);
  }

  function _moveDelegates(
    address srcRep,
    address dstRep,
    uint96 amount
  ) internal {
    if (srcRep != dstRep && amount > 0) {
      if (srcRep != address(0)) {
        uint32 srcRepNum = numCheckpoints[srcRep];
        uint96 srcRepOld =
          srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
        uint96 srcRepNew =
          sub96(srcRepOld, amount, "Ondo::_moveVotes: vote amount underflows");
        _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
      }

      if (dstRep != address(0)) {
        uint32 dstRepNum = numCheckpoints[dstRep];
        uint96 dstRepOld =
          dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
        uint96 dstRepNew =
          add96(dstRepOld, amount, "Ondo::_moveVotes: vote amount overflows");
        _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
      }
    }
  }

  function _writeCheckpoint(
    address delegatee,
    uint32 nCheckpoints,
    uint96 oldVotes,
    uint96 newVotes
  ) internal {
    uint32 blockNumber =
      safe32(
        block.number,
        "Ondo::_writeCheckpoint: block number exceeds 32 bits"
      );

    if (
      nCheckpoints > 0 &&
      checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber
    ) {
      checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
    } else {
      checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
      numCheckpoints[delegatee] = nCheckpoints + 1;
    }

    emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
  }

  function getChainId() internal view returns (uint256) {
    uint256 chainId;
    assembly {
      chainId := chainid()
    }
    return chainId;
  }

  /**
   * @notice Turn on _transferAllowed variable. Transfers are enabled
   */
  function enableTransfer() external {
    require(
      hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
      "Ondo::enableTransfer: not authorized"
    );
    transferAllowed = true;
    emit TransferEnabled(msg.sender);
  }

  /**
   * @notice Called by merkle airdrop contract to initialize locked balances
   */
  function updateTrancheBalance(
    address beneficiary,
    uint256 rawAmount,
    IOndo.InvestorType investorType
  ) external {
    require(hasRole(TIMELOCK_UPDATE_ROLE, msg.sender));
    require(rawAmount > 0, "Ondo::updateTrancheBalance: amount must be > 0");
    require(
      investorBalances[beneficiary].initialBalance == 0,
      "Ondo::updateTrancheBalance: already has timelocked Ondo"
    ); //Prevents users from being in more than 1 tranche

    uint96 amount =
      safe96(rawAmount, "Ondo::updateTrancheBalance: amount exceeds 96 bits");
    investorBalances[beneficiary] = InvestorParam(investorType, amount);
  }

  /**
   * @notice Internal function the amount of unlocked Ondo for an account that participated in Coinlist/Seed Investments
   */
  function _getFreedBalance(address account) internal view returns (uint96) {
    if (passedAllVestingPeriods()) {
      //all vesting periods are over, just return the total balance
      return balances[account];
    } else {
      InvestorParam memory investorParam = investorBalances[account];
      if (passedCliff()) {
        //we are in between the cliff timestamp and last vesting period
        (uint256 vestingPeriod, uint256 elapsed) =
          _getTrancheInfo(investorParam.investorType);
        uint96 lockedBalance =
          sub96(
            investorParam.initialBalance,
            _proportionAvailable(elapsed, vestingPeriod, investorParam),
            "Ondo::getFreedBalance: locked balance underflow"
          );
        return
          sub96(
            balances[account],
            lockedBalance,
            "Ondo::getFreedBalance: total freed balance underflow"
          );
      } else {
        //we have not hit the cliff yet, all investor balance is locked
        return
          sub96(
            balances[account],
            investorParam.initialBalance,
            "Ondo::getFreedBalance: balance underflow"
          );
      }
    }
  }

  function updateCliffTimestamp(uint256 newTimestamp) external {
    require(
      hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
      "Ondo::updateCliffTimestamp: not authorized"
    );
    cliffTimestamp = newTimestamp;
    emit CliffTimestampUpdate(newTimestamp);
  }
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
DELEGATION_TYPEHASH 0xe7a324dc → bytes32
DOMAIN_TYPEHASH 0x20606b70 → bytes32
MINTER_ROLE 0xd5391393 → bytes32
TIMELOCK_UPDATE_ROLE 0x0f36554a → bytes32
TRANSFER_ROLE 0x206b60f9 → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
checkpoints 0xf1127ed8 → uint32, uint96
cliffTimestamp 0xe07edfdc → uint256
decimals 0x313ce567 → uint8
delegates 0x587cde1e → address
getCurrentVotes 0xb4b5ea57 → uint96
getFreedBalance 0x6cde20ab → uint256
getPriorVotes 0x782d6fe1 → uint96
getRoleAdmin 0x248a9ca3 → bytes32
getVestedBalance 0x7f58b9d3 → uint256, uint256
hasRole 0x91d14854 → bool
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
numCheckpoints 0x6fcfff45 → uint32
passedAllVestingPeriods 0x94d83076 → bool
passedCliff 0x44f61ab7 → bool
seedVestingPeriod 0x91c903a6 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
tranche1VestingPeriod 0xab65f09a → uint256
tranche2VestingPeriod 0xe09c3702 → uint256
transferAllowed 0x34fec467 → bool

Write Contract 12 functions

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

approve 0x095ea7b3
address spender
uint256 rawAmount
returns: bool
delegate 0x5c19a95c
address delegatee
delegateBySig 0xc3cda520
address delegatee
uint256 nonce
uint256 expiry
uint8 v
bytes32 r
bytes32 s
enableTransfer 0xf1b50c1d
No parameters
grantRole 0x2f2ff15d
bytes32 role
address account
mint 0x40c10f19
address account
uint256 rawAmount
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
transfer 0xa9059cbb
address dst
uint256 rawAmount
returns: bool
transferFrom 0x23b872dd
address src
address dst
uint256 rawAmount
returns: bool
updateCliffTimestamp 0x04c981ba
uint256 newTimestamp
updateTrancheBalance 0xe17ddf87
address beneficiary
uint256 rawAmount
uint8 investorType

Recent Transactions

|
Hash Method Block Age From/To Value Txn Fee Type
0x1202fe12...6366cb transfer 24,589,094 IN 0x1AB4973a...8F23 0 ETH 0.000004566915 ETH EIP-1559
0xa555259c...ebfcd6 transfer 24,589,093 IN 0xD9c8d484...A72a 0 ETH 0.000004849431 ETH EIP-1559
0xfcd6447f...770dec transferFrom 24,589,092 IN 0x714B0f85...7f67 0 ETH 0.000098607511 ETH EIP-1559
0x945740b4...d35dc2 transfer 24,589,082 IN 0x8f939D59...753B 0 ETH 0.000004879558 ETH EIP-1559
0x01c43218...4cea16 transfer 24,589,081 IN 0xE57e42ee...e175 0 ETH 0.000096521896 ETH EIP-1559
0x7e5c351b...422a39 transfer 24,589,074 IN 0x91D40E48...DEbE 0 ETH 0.000131239057 ETH EIP-1559
0x0d6e303c...efb723 transfer 24,589,058 IN 0x28C6c062...1d60 0 ETH 0.000046969440 ETH EIP-1559
0x7e6e8958...599dd0 transfer 24,589,058 IN 0xb386dff3...9e31 0 ETH 0.000003474643 ETH EIP-1559
0x706d0e13...3b240c transfer 24,589,054 IN 0x78c22013...E325 0 ETH 0.000042041721 ETH EIP-1559
0x3ee1695e...9522d7 transfer 24,589,048 IN 0x15F46551...A6C7 0 ETH 0.000044441000 ETH Legacy