From 12d5711e36413fb49e8cd18958b7fcd8d10515d2 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 8 Jun 2021 11:16:56 +0200 Subject: [PATCH] Improve redistribution period test --- .../data/DemurrageTokenSingleCap.bin | 2 +- .../data/DemurrageTokenSingleCap.json | 2 +- python/erc20_demurrage_token/token.py | 40 ++++- python/examples/sim_noredistribute.py | 6 +- python/tests/test_basic.py | 156 ++++++++--------- python/tests/test_period.py | 15 +- python/tests/test_redistribution_unit.py | 160 ++++++++++-------- solidity/DemurrageTokenSingleCap.sol | 40 +++-- 8 files changed, 249 insertions(+), 172 deletions(-) diff --git a/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.bin b/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.bin index de59ea2..2d453bc 100644 --- a/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.bin +++ b/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.bin @@ -1 +1 @@ -61010060405264e8d4a510006a52b7d2dcc80cd2e40000006200002391906200073d565b6080908152503480156200003657600080fd5b50604051620033043803806200330483398181016040528101906200005c919062000467565b33600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600c6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555086600690805190602001906200012f92919062000300565b5085600790805190602001906200014892919062000300565b508460ff166008819055504260038190555060035460a08181525050603c836200017391906200073d565b60c081815250506f4b3b4ca85a86c47a098a224000000000600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360e081815250506000620001f860006a52b7d2dcc80cd2e40000006000600162000291640100000000026401000000009004565b9050600081908060018154018082558091505060019003906000526020600020016000909190919091505581600a8190555082600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508560ff16600a6200027d919062000600565b600b81905550505050505050505062000984565b6000807cffffffffffffffffffffffffffffffff00000000000000000000000000606860ff16869060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b8280546200030e906200081f565b90600052602060002090601f0160209004810192826200033257600085556200037e565b82601f106200034d57805160ff19168380011785556200037e565b828001600101855582156200037e579182015b828111156200037d57825182559160200191906001019062000360565b5b5090506200038d919062000391565b5090565b5b80821115620003ac57600081600090555060010162000392565b5090565b6000620003c7620003c1846200056f565b62000546565b905082815260208101848484011115620003e057600080fd5b620003ed848285620007e9565b509392505050565b600081519050620004068162000936565b92915050565b600082601f8301126200041e57600080fd5b815162000430848260208601620003b0565b91505092915050565b6000815190506200044a8162000950565b92915050565b60008151905062000461816200096a565b92915050565b600080600080600080600060e0888a0312156200048357600080fd5b600088015167ffffffffffffffff8111156200049e57600080fd5b620004ac8a828b016200040c565b975050602088015167ffffffffffffffff811115620004ca57600080fd5b620004d88a828b016200040c565b9650506040620004eb8a828b0162000450565b9550506060620004fe8a828b0162000439565b9450506080620005118a828b0162000439565b93505060a0620005248a828b01620003f5565b92505060c0620005378a828b0162000439565b91505092959891949750929550565b60006200055262000565565b905062000560828262000855565b919050565b6000604051905090565b600067ffffffffffffffff8211156200058d576200058c620008e9565b5b620005988262000918565b9050602081019050919050565b6000808291508390505b6001851115620005f757808604811115620005cf57620005ce6200088b565b5b6001851615620005df5780820291505b8081029050620005ef8562000929565b9450620005af565b94509492505050565b60006200060d82620007d2565b91506200061a83620007d2565b9250620006497fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000651565b905092915050565b60008262000663576001905062000736565b8162000673576000905062000736565b81600181146200068c57600281146200069757620006cd565b600191505062000736565b60ff841115620006ac57620006ab6200088b565b5b8360020a915084821115620006c657620006c56200088b565b5b5062000736565b5060208310610133831016604e8410600b8410161715620007075782820a9050838111156200070157620007006200088b565b5b62000736565b620007168484846001620005a5565b9250905081840481111562000730576200072f6200088b565b5b81810290505b9392505050565b60006200074a82620007d2565b91506200075783620007d2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156200079357620007926200088b565b5b828202905092915050565b6000620007ab82620007b2565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101562000809578082015181840152602081019050620007ec565b8381111562000819576000848401525b50505050565b600060028204905060018216806200083857607f821691505b602082108114156200084f576200084e620008ba565b5b50919050565b620008608262000918565b810181811067ffffffffffffffff82111715620008825762000881620008e9565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6000600282049050919050565b62000941816200079e565b81146200094d57600080fd5b50565b6200095b81620007d2565b81146200096757600080fd5b50565b6200097581620007dc565b81146200098157600080fd5b50565b60805160a05160c05160e05161291c620009e860003960008181610bcb01528181610e1b015261198f0152600081816110b50152818161193e0152611a2e0152600081816110e101528181611a4f0152611a9401526000611f07015261291c6000f3fe608060405234801561001057600080fd5b506004361061024f576000357c0100000000000000000000000000000000000000000000000000000000900480636787a9be1161014d57806395d89b41116100d5578063e3ab207a11610099578063e3ab207a14610776578063e54d63f7146107a6578063e8095295146107d6578063eda4e6d6146107f4578063f2fde38b146108125761024f565b806395d89b41146106aa578063983b2d56146106c85780639da7d8ba146106f8578063a9059cbb14610728578063b470aade146107585761024f565b8063731f237c1161011c578063731f237c1461061457806379ba5097146106325780638da5cb5b146106505780638f1df6bc1461066e5780638f770ad01461068c5761024f565b80636787a9be146105545780636a2d094e146105845780636ffa8a05146105b457806370a08231146105e45761024f565b806331333487116101db5780634abfbba21161019f5780634abfbba21461048857806351b4541c146104b8578063573cc507146104e857806358b2833b146105065780636721d4ef146105245761024f565b806331333487146103aa578063313ce567146103da57806340452d91146103f8578063449a52f81461042857806347a50517146104585761024f565b806318160ddd1161022257806318160ddd146102f05780631989c6a81461030e578063229ba1971461032c57806323b872dd1461034a5780633092afd51461037a5761024f565b806301ffc9a71461025457806306fdde0314610284578063095ea7b3146102a257806309f28f3c146102d2575b600080fd5b61026e600480360381019061026991906121f8565b610842565b60405161027b91906123c6565b60405180910390f35b61028c6109ed565b60405161029991906123fc565b60405180910390f35b6102bc60048036038101906102b79190612193565b610a7b565b6040516102c991906123c6565b60405180910390f35b6102da610b95565b6040516102e7919061247e565b60405180910390f35b6102f8610bb7565b60405161030591906124b4565b60405180910390f35b610316610bbd565b60405161032391906124b4565b60405180910390f35b610334610bc9565b60405161034191906124b4565b60405180910390f35b610364600480360381019061035f9190612144565b610bed565b60405161037191906123c6565b60405180910390f35b610394600480360381019061038f919061211b565b610d0d565b6040516103a191906123c6565b60405180910390f35b6103c460048036038101906103bf9190612273565b610e00565b6040516103d191906124b4565b60405180910390f35b6103e2610eb4565b6040516103ef91906124b4565b60405180910390f35b610412600480360381019061040d919061224a565b610eba565b60405161041f91906123e1565b60405180910390f35b610442600480360381019061043d9190612193565b610ede565b60405161044f91906123c6565b60405180910390f35b610472600480360381019061046d919061211b565b611068565b60405161047f91906124b4565b60405180910390f35b6104a2600480360381019061049d919061224a565b6110b1565b6040516104af91906124b4565b60405180910390f35b6104d260048036038101906104cd919061224a565b611111565b6040516104df91906124b4565b60405180910390f35b6104f0611132565b6040516104fd91906124b4565b60405180910390f35b61050e611138565b60405161051b91906124b4565b60405180910390f35b61053e60048036038101906105399190612273565b61113e565b60405161054b91906124b4565b60405180910390f35b61056e6004803603810190610569919061224a565b611180565b60405161057b91906124b4565b60405180910390f35b61059e6004803603810190610599919061224a565b6111eb565b6040516105ab91906124b4565b60405180910390f35b6105ce60048036038101906105c991906121cf565b61120c565b6040516105db91906124b4565b60405180910390f35b6105fe60048036038101906105f9919061211b565b611248565b60405161060b91906124b4565b60405180910390f35b61061c6112f0565b60405161062991906123c6565b60405180910390f35b61063a611412565b60405161064791906123c6565b60405180910390f35b6106586115b9565b60405161066591906123ab565b60405180910390f35b6106766115df565b60405161068391906123c6565b60405180910390f35b610694611729565b6040516106a191906124b4565b60405180910390f35b6106b261172f565b6040516106bf91906123fc565b60405180910390f35b6106e260048036038101906106dd919061211b565b6117bd565b6040516106ef91906123c6565b60405180910390f35b610712600480360381019061070d91906121cf565b61187a565b60405161071f91906124b4565b60405180910390f35b610742600480360381019061073d9190612193565b6118a6565b60405161074f91906123c6565b60405180910390f35b61076061193c565b60405161076d91906124b4565b60405180910390f35b610790600480360381019061078b91906121cf565b611960565b60405161079d91906124b4565b60405180910390f35b6107c060048036038101906107bb9190612273565b611974565b6040516107cd91906124b4565b60405180910390f35b6107de611a28565b6040516107eb919061247e565b60405180910390f35b6107fc611a92565b60405161080991906124b4565b60405180910390f35b61082c6004803603810190610827919061211b565b611ab6565b60405161083991906123c6565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561089757600190506109e8565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156108ea57600190506109e8565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561093d57600190506109e8565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561099057600190506109e8565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109e357600190506109e8565b600090505b919050565b600680546109fa906126df565b80601f0160208091040260200160405190810160405280929190818152602001828054610a26906126df565b8015610a735780601f10610a4857610100808354040283529160200191610a73565b820191906000526020600020905b815481529060010190602001808311610a5657829003601f168201915b505050505081565b600080610a866115df565b50610a9083611180565b905080600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b1e91906124eb565b925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051610b8291906124b4565b60405180910390a3600191505092915050565b600260009054906101000a90046fffffffffffffffffffffffffffffffff1681565b60095481565b60008080549050905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000610bfa6115df565b50610c0484611180565b915081600d60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610c8f57600080fd5b610c9a868684611b58565b90508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610cf991906124b4565b60405180910390a380925050509392505050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610d9657503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b610d9f57600080fd5b6000600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b600080600064e8d4a5100091506a52b7d2dcc80cd2e40000007f0000000000000000000000000000000000000000000000000000000000000000610e449190612541565b905060005b84811015610e8d5764e8d4a510008284610e639190612572565b610e6d9190612541565b83610e7891906125cc565b92508080610e8590612711565b915050610e49565b5064e8d4a510008583610ea09190612572565b610eaa9190612541565b9250505092915050565b60085481565b60008181548110610eca57600080fd5b906000526020600020016000915090505481565b600080600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610f6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f649061243e565b60405180910390fd5b600a5460095484610f7e91906124eb565b1115610fbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb69061241e565b60405180910390fd5b610fc76115df565b508290508260096000828254610fdd91906124eb565b92505081905550610fee8482611b99565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f88560405161104c91906124b4565b60405180910390a361105c611c5e565b50600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f0000000000000000000000000000000000000000000000000000000000000000826110df9190612572565b7f000000000000000000000000000000000000000000000000000000000000000061110a91906124eb565b9050919050565b6000603c824261112191906125cc565b61112b9190612541565b9050919050565b600b5481565b60035481565b60006a52b7d2dcc80cd2e4000000826111579190612541565b6a52b7d2dcc80cd2e400000061116d91906125cc565b836111789190612572565b905092915050565b6000600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1664e8d4a510006a52b7d2dcc80cd2e4000000846111d09190612572565b6111da9190612572565b6111e49190612541565b9050919050565b6000603c82426111fb91906125cc565b6112059190612541565b9050919050565b6000606860ff167cffffffffffffffffffffffffffffffff00000000000000000000000000836001900416908060020a82049150509050919050565b60008060008061125785611068565b9250611264600354611111565b90506112a0600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1682610e00565b6fffffffffffffffffffffffffffffffff16915064e8d4a510006a52b7d2dcc80cd2e40000006112d09190612572565b82846112dc9190612572565b6112e69190612541565b9350505050919050565b600080600080611301600354611111565b91506000821415611318576000935050505061140f565b600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1690506113558183610e00565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550603c8261139a9190612572565b6003546113a791906124eb565b60038190555080826003547fa0717e54e02bd9829db5e6e998aec0ae9de796b8d150a3cc46a92ab869697755600260009054906101000a90046fffffffffffffffffffffffffffffffff166040516113ff9190612499565b60405180910390a4600193505050505b90565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461146f57600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060008060008060006115f5611d4c565b9750600060010288141561161457600098505050505050505050611726565b61161d88611960565b955060018661162c91906124eb565b9050611637866110b1565b91506116416112f0565b50600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16945061167e826111eb565b9250600083111561169a576116938584611974565b935061169e565b8493505b6116ad60008560095484611e7c565b965060008790806001815401808255809150506001900390600052602060002001600090919091909150556116e188611eeb565b507f55d243082e019fce4009ccea5368b92e436c17586a1e793c7deda16df4e5d6758160405161171191906124b4565b60405180910390a16001985050505050505050505b90565b600a5481565b6007805461173c906126df565b80601f0160208091040260200160405190810160405280929190818152602001828054611768906126df565b80156117b55780601f1061178a576101008083540402835291602001916117b5565b820191906000526020600020905b81548152906001019060200180831161179857829003601f168201915b505050505081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461181957600080fd5b6001600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000602060ff166cffffffffffffffffff00000000836001900416908060020a82049150509050919050565b60008060006118b36115df565b506118bd84611180565b91506118ca338684611b58565b90508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8660405161192991906124b4565b60405180910390a3809250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600063ffffffff8260019004169050919050565b600080600064e8d4a5100091506a52b7d2dcc80cd2e40000007f00000000000000000000000000000000000000000000000000000000000000006119b89190612541565b905060005b84811015611a015764e8d4a5100082846119d79190612572565b6119e19190612541565b836119ec91906124eb565b925080806119f990612711565b9150506119bd565b5064e8d4a510008583611a149190612572565b611a1e9190612541565b9250505092915050565b600060017f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000042611a7991906125cc565b611a839190612541565b611a8d91906124eb565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b1257600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b600080611b658584611faa565b50611b708484611b99565b50611b79611a28565b6fffffffffffffffffffffffffffffffff16905060019150509392505050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000851415611bf65760009350505050611c58565b611bff86611068565b92508483611c0d91906124eb565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b6000806000600954905060006001600080549050611c7c91906125cc565b81548110611cb3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546001900491506cffffffffffffffffff000000001982169150602060ff16819060020a02821791508160010260006001600080549050611cfe91906125cc565b81548110611d35577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555060019250505090565b6000806000806001600080549050611d6491906125cc565b81548110611d9b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015491503073ffffffffffffffffffffffffffffffffffffffff1663e80952956040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b158015611e0a57600080fd5b505afa158015611e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e429190612221565b6fffffffffffffffffffffffffffffffff169050611e5f82611960565b8111611e7357600060010292505050611e79565b81925050505b90565b6000807cffffffffffffffffffffffffffffffff00000000000000000000000000606860ff16869060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b600080600080611efa8561187a565b9250611f058561120c565b7f0000000000000000000000000000000000000000000000000000000000000000611f3091906125cc565b91506000821415611f475760009350505050611fa5565b611f51838361113e565b9050611f9d600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611f986a52b7d2dcc80cd2e400000084611f939190612541565b611180565b611b99565b508093505050505b919050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600085141561200757600093505050506120ac565b61201086611068565b925084831015612055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204c9061245e565b60405180910390fd5b848361206191906125cc565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b6000813590506120c181612873565b92915050565b6000813590506120d68161288a565b92915050565b6000813590506120eb816128a1565b92915050565b600081519050612100816128b8565b92915050565b600081359050612115816128cf565b92915050565b60006020828403121561212d57600080fd5b600061213b848285016120b2565b91505092915050565b60008060006060848603121561215957600080fd5b6000612167868287016120b2565b9350506020612178868287016120b2565b925050604061218986828701612106565b9150509250925092565b600080604083850312156121a657600080fd5b60006121b4858286016120b2565b92505060206121c585828601612106565b9150509250929050565b6000602082840312156121e157600080fd5b60006121ef848285016120c7565b91505092915050565b60006020828403121561220a57600080fd5b6000612218848285016120dc565b91505092915050565b60006020828403121561223357600080fd5b6000612241848285016120f1565b91505092915050565b60006020828403121561225c57600080fd5b600061226a84828501612106565b91505092915050565b6000806040838503121561228657600080fd5b600061229485828601612106565b92505060206122a585828601612106565b9150509250929050565b6122b881612600565b82525050565b6122c781612612565b82525050565b6122d68161261e565b82525050565b60006122e7826124cf565b6122f181856124da565b93506123018185602086016126ac565b61230a816127e7565b840191505092915050565b60006123226007836124da565b915061232d826127f8565b602082019050919050565b6000612345600a836124da565b915061235082612821565b602082019050919050565b6000612368600d836124da565b91506123738261284a565b602082019050919050565b61238781612654565b82525050565b6123968161269a565b82525050565b6123a581612690565b82525050565b60006020820190506123c060008301846122af565b92915050565b60006020820190506123db60008301846122be565b92915050565b60006020820190506123f660008301846122cd565b92915050565b6000602082019050818103600083015261241681846122dc565b905092915050565b6000602082019050818103600083015261243781612315565b9050919050565b6000602082019050818103600083015261245781612338565b9050919050565b600060208201905081810360008301526124778161235b565b9050919050565b6000602082019050612493600083018461237e565b92915050565b60006020820190506124ae600083018461238d565b92915050565b60006020820190506124c9600083018461239c565b92915050565b600081519050919050565b600082825260208201905092915050565b60006124f682612690565b915061250183612690565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156125365761253561275a565b5b828201905092915050565b600061254c82612690565b915061255783612690565b92508261256757612566612789565b5b828204905092915050565b600061257d82612690565b915061258883612690565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156125c1576125c061275a565b5b828202905092915050565b60006125d782612690565b91506125e283612690565b9250828210156125f5576125f461275a565b5b828203905092915050565b600061260b82612670565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006126a582612654565b9050919050565b60005b838110156126ca5780820151818401526020810190506126af565b838111156126d9576000848401525b50505050565b600060028204905060018216806126f757607f821691505b6020821081141561270b5761270a6127b8565b5b50919050565b600061271c82612690565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561274f5761274e61275a565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f4552525f43415000000000000000000000000000000000000000000000000000600082015250565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b7f4552525f4f5645525350454e4400000000000000000000000000000000000000600082015250565b61287c81612600565b811461288757600080fd5b50565b6128938161261e565b811461289e57600080fd5b50565b6128aa81612628565b81146128b557600080fd5b50565b6128c181612654565b81146128cc57600080fd5b50565b6128d881612690565b81146128e357600080fd5b5056fea26469706673582212203739134ea121ca4d8480a7d8b8832366487c122be533e25df8a3f24d3ac147dc64736f6c63430008040033 \ No newline at end of file +61010060405264e8d4a510006a52b7d2dcc80cd2e40000006200002391906200078b565b6080908152503480156200003657600080fd5b50604051620034423803806200344283398181016040528101906200005c9190620004b5565b33600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600c6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555086600690805190602001906200012f92919062000337565b5085600790805190602001906200014892919062000337565b508460ff166008819055504260038190555060035460a08181525050603c836200017391906200078b565b60c081815250506f4b3b4ca85a86c47a098a224000000000600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550836fffffffffffffffffffffffffffffffff1660e0818152505060006200022f6000600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1660006001620002c8640100000000026401000000009004565b9050600081908060018154018082558091505060019003906000526020600020016000909190919091505581600a8190555082600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508560ff16600a620002b491906200064e565b600b81905550505050505050505062000a08565b6000807cffffffffffffffffffffffffffffffff00000000000000000000000000606860ff16869060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b828054620003459062000889565b90600052602060002090601f016020900481019282620003695760008555620003b5565b82601f106200038457805160ff1916838001178555620003b5565b82800160010185558215620003b5579182015b82811115620003b457825182559160200191906001019062000397565b5b509050620003c49190620003c8565b5090565b5b80821115620003e3576000816000905550600101620003c9565b5090565b6000620003fe620003f884620005bd565b62000594565b9050828152602081018484840111156200041757600080fd5b6200042484828562000853565b509392505050565b6000815190506200043d81620009a0565b92915050565b600082601f8301126200045557600080fd5b815162000467848260208601620003e7565b91505092915050565b6000815190506200048181620009ba565b92915050565b6000815190506200049881620009d4565b92915050565b600081519050620004af81620009ee565b92915050565b600080600080600080600060e0888a031215620004d157600080fd5b600088015167ffffffffffffffff811115620004ec57600080fd5b620004fa8a828b0162000443565b975050602088015167ffffffffffffffff8111156200051857600080fd5b620005268a828b0162000443565b9650506040620005398a828b016200049e565b95505060606200054c8a828b0162000470565b94505060806200055f8a828b0162000487565b93505060a0620005728a828b016200042c565b92505060c0620005858a828b0162000487565b91505092959891949750929550565b6000620005a0620005b3565b9050620005ae8282620008bf565b919050565b6000604051905090565b600067ffffffffffffffff821115620005db57620005da62000953565b5b620005e68262000982565b9050602081019050919050565b6000808291508390505b600185111562000645578086048111156200061d576200061c620008f5565b5b60018516156200062d5780820291505b80810290506200063d8562000993565b9450620005fd565b94509492505050565b60006200065b826200083c565b915062000668836200083c565b9250620006977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84846200069f565b905092915050565b600082620006b1576001905062000784565b81620006c1576000905062000784565b8160018114620006da5760028114620006e5576200071b565b600191505062000784565b60ff841115620006fa57620006f9620008f5565b5b8360020a915084821115620007145762000713620008f5565b5b5062000784565b5060208310610133831016604e8410600b8410161715620007555782820a9050838111156200074f576200074e620008f5565b5b62000784565b620007648484846001620005f3565b925090508184048111156200077e576200077d620008f5565b5b81810290505b9392505050565b600062000798826200083c565b9150620007a5836200083c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620007e157620007e0620008f5565b5b828202905092915050565b6000620007f9826200081c565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156200087357808201518184015260208101905062000856565b8381111562000883576000848401525b50505050565b60006002820490506001821680620008a257607f821691505b60208210811415620008b957620008b862000924565b5b50919050565b620008ca8262000982565b810181811067ffffffffffffffff82111715620008ec57620008eb62000953565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6000600282049050919050565b620009ab81620007ec565b8114620009b757600080fd5b50565b620009c58162000800565b8114620009d157600080fd5b50565b620009df816200083c565b8114620009eb57600080fd5b50565b620009f98162000846565b811462000a0557600080fd5b50565b60805160a05160c05160e0516129c862000a7a60003960008181610c4101528181610e910152611a6701526000818161112b01528181611a160152611b0601526000818161115701528181611b270152611b6c0152600081816111ba015281816111f2015261125a01526129c86000f3fe608060405234801561001057600080fd5b5060043610610265576000357c0100000000000000000000000000000000000000000000000000000000900480636a2d094e11610158578063983b2d56116100d5578063e54d63f711610099578063e54d63f7146107ec578063e80952951461081c578063eda4e6d61461083a578063f2fde38b14610858578063f83da35d1461088857610265565b8063983b2d561461070e5780639da7d8ba1461073e578063a9059cbb1461076e578063b470aade1461079e578063e3ab207a146107bc57610265565b80638d34855a1161011c5780638d34855a146106665780638da5cb5b146106965780638f1df6bc146106b45780638f770ad0146106d257806395d89b41146106f057610265565b80636a2d094e1461059a5780636ffa8a05146105ca57806370a08231146105fa578063731f237c1461062a57806379ba50971461064857610265565b8063313ce567116101e657806351b4541c116101aa57806351b4541c146104ce578063573cc507146104fe57806358b2833b1461051c5780636721d4ef1461053a5780636787a9be1461056a57610265565b8063313ce567146103f057806340452d911461040e578063449a52f81461043e57806347a505171461046e5780634abfbba21461049e57610265565b80631989c6a81161022d5780631989c6a814610324578063229ba1971461034257806323b872dd146103605780633092afd51461039057806331333487146103c057610265565b806301ffc9a71461026a57806306fdde031461029a578063095ea7b3146102b857806309f28f3c146102e857806318160ddd14610306575b600080fd5b610284600480360381019061027f9190612241565b6108b8565b6040516102919190612472565b60405180910390f35b6102a2610a63565b6040516102af91906124a8565b60405180910390f35b6102d260048036038101906102cd91906121dc565b610af1565b6040516102df9190612472565b60405180910390f35b6102f0610c0b565b6040516102fd919061252a565b60405180910390f35b61030e610c2d565b60405161031b9190612560565b60405180910390f35b61032c610c33565b6040516103399190612560565b60405180910390f35b61034a610c3f565b6040516103579190612560565b60405180910390f35b61037a6004803603810190610375919061218d565b610c63565b6040516103879190612472565b60405180910390f35b6103aa60048036038101906103a59190612164565b610d83565b6040516103b79190612472565b60405180910390f35b6103da60048036038101906103d591906122bc565b610e76565b6040516103e79190612560565b60405180910390f35b6103f8610f2a565b6040516104059190612560565b60405180910390f35b61042860048036038101906104239190612293565b610f30565b604051610435919061248d565b60405180910390f35b610458600480360381019061045391906121dc565b610f54565b6040516104659190612472565b60405180910390f35b61048860048036038101906104839190612164565b6110de565b6040516104959190612560565b60405180910390f35b6104b860048036038101906104b39190612293565b611127565b6040516104c59190612560565b60405180910390f35b6104e860048036038101906104e39190612293565b611187565b6040516104f59190612560565b60405180910390f35b6105066111a8565b6040516105139190612560565b60405180910390f35b6105246111ae565b6040516105319190612560565b60405180910390f35b610554600480360381019061054f91906122bc565b6111b4565b6040516105619190612560565b60405180910390f35b610584600480360381019061057f9190612293565b611225565b6040516105919190612560565b60405180910390f35b6105b460048036038101906105af9190612293565b611295565b6040516105c19190612560565b60405180910390f35b6105e460048036038101906105df9190612218565b6112b6565b6040516105f19190612560565b60405180910390f35b610614600480360381019061060f9190612164565b6112f2565b6040516106219190612560565b60405180910390f35b61063261139a565b60405161063f9190612472565b60405180910390f35b6106506114bc565b60405161065d9190612472565b60405180910390f35b610680600480360381019061067b9190612218565b611663565b60405161068d9190612560565b60405180910390f35b61069e611691565b6040516106ab9190612457565b60405180910390f35b6106bc6116b7565b6040516106c99190612472565b60405180910390f35b6106da611801565b6040516106e79190612560565b60405180910390f35b6106f8611807565b60405161070591906124a8565b60405180910390f35b61072860048036038101906107239190612164565b611895565b6040516107359190612472565b60405180910390f35b61075860048036038101906107539190612218565b611952565b6040516107659190612560565b60405180910390f35b610788600480360381019061078391906121dc565b61197e565b6040516107959190612472565b60405180910390f35b6107a6611a14565b6040516107b39190612560565b60405180910390f35b6107d660048036038101906107d19190612218565b611a38565b6040516107e39190612560565b60405180910390f35b610806600480360381019061080191906122bc565b611a4c565b6040516108139190612560565b60405180910390f35b610824611b00565b604051610831919061252a565b60405180910390f35b610842611b6a565b60405161084f9190612560565b60405180910390f35b610872600480360381019061086d9190612164565b611b8e565b60405161087f9190612472565b60405180910390f35b6108a2600480360381019061089d91906122f8565b611c30565b6040516108af919061248d565b60405180910390f35b600063c6bb4b707c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561090d5760019050610a5e565b63449a52f87c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109605760019050610a5e565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156109b35760019050610a5e565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a065760019050610a5e565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610a595760019050610a5e565b600090505b919050565b60068054610a709061278b565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9c9061278b565b8015610ae95780601f10610abe57610100808354040283529160200191610ae9565b820191906000526020600020905b815481529060010190602001808311610acc57829003601f168201915b505050505081565b600080610afc6116b7565b50610b0683611225565b905080600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b949190612597565b925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051610bf89190612560565b60405180910390a3600191505092915050565b600260009054906101000a90046fffffffffffffffffffffffffffffffff1681565b60095481565b60008080549050905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000610c706116b7565b50610c7a84611225565b915081600d60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610d0557600080fd5b610d10868684611c9f565b90508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610d6f9190612560565b60405180910390a380925050509392505050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610e0c57503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b610e1557600080fd5b6000600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b600080600064e8d4a5100091506a52b7d2dcc80cd2e40000007f0000000000000000000000000000000000000000000000000000000000000000610eba91906125ed565b905060005b84811015610f035764e8d4a510008284610ed9919061261e565b610ee391906125ed565b83610eee9190612678565b92508080610efb906127bd565b915050610ebf565b5064e8d4a510008583610f16919061261e565b610f2091906125ed565b9250505092915050565b60085481565b60008181548110610f4057600080fd5b906000526020600020016000915090505481565b600080600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610fe3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fda906124ea565b60405180910390fd5b600a5460095484610ff49190612597565b1115611035576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102c906124ca565b60405180910390fd5b61103d6116b7565b5082905082600960008282546110539190612597565b925050819055506110648482611cc4565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8856040516110c29190612560565b60405180910390a36110d2611d89565b50600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f000000000000000000000000000000000000000000000000000000000000000082611155919061261e565b7f00000000000000000000000000000000000000000000000000000000000000006111809190612597565b9050919050565b6000603c82426111979190612678565b6111a191906125ed565b9050919050565b600b5481565b60035481565b600080827f00000000000000000000000000000000000000000000000000000000000000006111e39190612678565b846111ee919061261e565b90507f00000000000000000000000000000000000000000000000000000000000000008161121c91906125ed565b91505092915050565b6000600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000083611284919061261e565b61128e91906125ed565b9050919050565b6000603c82426112a59190612678565b6112af91906125ed565b9050919050565b6000606860ff167cffffffffffffffffffffffffffffffff00000000000000000000000000836001900416908060020a82049150509050919050565b600080600080611301856110de565b925061130e600354611187565b905061134a600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1682610e76565b6fffffffffffffffffffffffffffffffff16915064e8d4a510006a52b7d2dcc80cd2e400000061137a919061261e565b8284611386919061261e565b61139091906125ed565b9350505050919050565b6000806000806113ab600354611187565b915060008214156113c257600093505050506114b9565b600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1690506113ff8183610e76565b600260006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550603c82611444919061261e565b6003546114519190612597565b60038190555080826003547fa0717e54e02bd9829db5e6e998aec0ae9de796b8d150a3cc46a92ab869697755600260009054906101000a90046fffffffffffffffffffffffffffffffff166040516114a99190612545565b60405180910390a4600193505050505b90565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461151957600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35090565b600080600061167184611952565b915061167c846112b6565b905061168882826111b4565b92505050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060008060008060006116cd611e77565b975060006001028814156116ec576000985050505050505050506117fe565b6116f588611a38565b95506001866117049190612597565b905061170f86611127565b915061171961139a565b50600260009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16945061175682611295565b925060008311156117725761176b8584611a4c565b9350611776565b8493505b61178560008560095484611c30565b965060008790806001815401808255809150506001900390600052602060002001600090919091909150556117b988611fa7565b507f55d243082e019fce4009ccea5368b92e436c17586a1e793c7deda16df4e5d675816040516117e99190612560565b60405180910390a16001985050505050505050505b90565b600a5481565b600780546118149061278b565b80601f01602080910402602001604051908101604052809291908181526020018280546118409061278b565b801561188d5780601f106118625761010080835404028352916020019161188d565b820191906000526020600020905b81548152906001019060200180831161187057829003601f168201915b505050505081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146118f157600080fd5b6001600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000602060ff166cffffffffffffffffff00000000836001900416908060020a82049150509050919050565b600080600061198b6116b7565b5061199584611225565b91506119a2338684611c9f565b90508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051611a019190612560565b60405180910390a3809250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600063ffffffff8260019004169050919050565b600080600064e8d4a5100091506a52b7d2dcc80cd2e40000007f0000000000000000000000000000000000000000000000000000000000000000611a9091906125ed565b905060005b84811015611ad95764e8d4a510008284611aaf919061261e565b611ab991906125ed565b83611ac49190612597565b92508080611ad1906127bd565b915050611a95565b5064e8d4a510008583611aec919061261e565b611af691906125ed565b9250505092915050565b600060017f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000042611b519190612678565b611b5b91906125ed565b611b659190612597565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611bea57600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550919050565b6000807cffffffffffffffffffffffffffffffff00000000000000000000000000606860ff16869060020a0216600102811790506cffffffffffffffffff00000000602060ff16859060020a02166001028117905063ffffffff83166001028117905080915050949350505050565b600080611cac8584611ff3565b50611cb78484611cc4565b5060019150509392505050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000851415611d215760009350505050611d83565b611d2a866110de565b92508483611d389190612597565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b6000806000600954905060006001600080549050611da79190612678565b81548110611dde577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546001900491506cffffffffffffffffff000000001982169150602060ff16819060020a02821791508160010260006001600080549050611e299190612678565b81548110611e60577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555060019250505090565b6000806000806001600080549050611e8f9190612678565b81548110611ec6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015491503073ffffffffffffffffffffffffffffffffffffffff1663e80952956040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b158015611f3557600080fd5b505afa158015611f49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6d919061226a565b6fffffffffffffffffffffffffffffffff169050611f8a82611a38565b8111611f9e57600060010292505050611fa4565b81925050505b90565b600080611fb383611663565b9050611fe9600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611fe483611225565b611cc4565b5080915050919050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600085141561205057600093505050506120f5565b612059866110de565b92508483101561209e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120959061250a565b60405180910390fd5b84836120aa9190612678565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b60008135905061210a8161291f565b92915050565b60008135905061211f81612936565b92915050565b6000813590506121348161294d565b92915050565b60008151905061214981612964565b92915050565b60008135905061215e8161297b565b92915050565b60006020828403121561217657600080fd5b6000612184848285016120fb565b91505092915050565b6000806000606084860312156121a257600080fd5b60006121b0868287016120fb565b93505060206121c1868287016120fb565b92505060406121d28682870161214f565b9150509250925092565b600080604083850312156121ef57600080fd5b60006121fd858286016120fb565b925050602061220e8582860161214f565b9150509250929050565b60006020828403121561222a57600080fd5b600061223884828501612110565b91505092915050565b60006020828403121561225357600080fd5b600061226184828501612125565b91505092915050565b60006020828403121561227c57600080fd5b600061228a8482850161213a565b91505092915050565b6000602082840312156122a557600080fd5b60006122b38482850161214f565b91505092915050565b600080604083850312156122cf57600080fd5b60006122dd8582860161214f565b92505060206122ee8582860161214f565b9150509250929050565b6000806000806080858703121561230e57600080fd5b600061231c8782880161214f565b945050602061232d8782880161214f565b935050604061233e8782880161214f565b925050606061234f8782880161214f565b91505092959194509250565b612364816126ac565b82525050565b612373816126be565b82525050565b612382816126ca565b82525050565b60006123938261257b565b61239d8185612586565b93506123ad818560208601612758565b6123b681612893565b840191505092915050565b60006123ce600783612586565b91506123d9826128a4565b602082019050919050565b60006123f1600a83612586565b91506123fc826128cd565b602082019050919050565b6000612414600d83612586565b915061241f826128f6565b602082019050919050565b61243381612700565b82525050565b61244281612746565b82525050565b6124518161273c565b82525050565b600060208201905061246c600083018461235b565b92915050565b6000602082019050612487600083018461236a565b92915050565b60006020820190506124a26000830184612379565b92915050565b600060208201905081810360008301526124c28184612388565b905092915050565b600060208201905081810360008301526124e3816123c1565b9050919050565b60006020820190508181036000830152612503816123e4565b9050919050565b6000602082019050818103600083015261252381612407565b9050919050565b600060208201905061253f600083018461242a565b92915050565b600060208201905061255a6000830184612439565b92915050565b60006020820190506125756000830184612448565b92915050565b600081519050919050565b600082825260208201905092915050565b60006125a28261273c565b91506125ad8361273c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156125e2576125e1612806565b5b828201905092915050565b60006125f88261273c565b91506126038361273c565b92508261261357612612612835565b5b828204905092915050565b60006126298261273c565b91506126348361273c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561266d5761266c612806565b5b828202905092915050565b60006126838261273c565b915061268e8361273c565b9250828210156126a1576126a0612806565b5b828203905092915050565b60006126b78261271c565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061275182612700565b9050919050565b60005b8381101561277657808201518184015260208101905061275b565b83811115612785576000848401525b50505050565b600060028204905060018216806127a357607f821691505b602082108114156127b7576127b6612864565b5b50919050565b60006127c88261273c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156127fb576127fa612806565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f4552525f43415000000000000000000000000000000000000000000000000000600082015250565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b7f4552525f4f5645525350454e4400000000000000000000000000000000000000600082015250565b612928816126ac565b811461293357600080fd5b50565b61293f816126ca565b811461294a57600080fd5b50565b612956816126d4565b811461296157600080fd5b50565b61296d81612700565b811461297857600080fd5b50565b6129848161273c565b811461298f57600080fd5b5056fea2646970667358221220b663303ed909c4457a08fe9731d5c380990bb9a93c94d0772189bb4ce163879c64736f6c63430008040033 \ No newline at end of file diff --git a/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.json b/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.json index da3e21a..ec3d5ae 100644 --- a/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.json +++ b/python/erc20_demurrage_token/data/DemurrageTokenSingleCap.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_taxLevelMinute","type":"uint256"},{"internalType":"uint256","name":"_periodMinutes","type":"uint256"},{"internalType":"address","name":"_defaultSinkAddress","type":"address"},{"internalType":"uint256","name":"_supplyCap","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_foo","type":"bytes32"}],"name":"Debug","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_periodCount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newAmount","type":"uint256"}],"name":"Decayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_period","type":"uint256"}],"name":"Period","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"},{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Redistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"actualPeriod","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"applyDemurrage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"baseBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"changePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"decayBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demurrageAmount","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_target","type":"uint256"}],"name":"demurrageCycles","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demurrageTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_supply","type":"uint256"},{"internalType":"uint256","name":"_demurrageAmount","type":"uint256"}],"name":"getDistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lastTimestamp","type":"uint256"}],"name":"getMinutesDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_periodCount","type":"uint256"}],"name":"getPeriodTimeDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"growBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumParticipantSpend","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redistributionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"redistributions","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"removeMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"toBaseAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionDemurrageModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint128","name":"_taxLevelMinute","type":"uint128"},{"internalType":"uint256","name":"_periodMinutes","type":"uint256"},{"internalType":"address","name":"_defaultSinkAddress","type":"address"},{"internalType":"uint256","name":"_supplyCap","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_foo","type":"bytes32"}],"name":"Debug","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_periodCount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newAmount","type":"uint256"}],"name":"Decayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_period","type":"uint256"}],"name":"Period","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"},{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Redistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"actualPeriod","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"applyDemurrage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"baseBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"changePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"decayBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demurrageAmount","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_target","type":"uint256"}],"name":"demurrageCycles","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demurrageTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_supply","type":"uint256"},{"internalType":"uint256","name":"_demurrageAmount","type":"uint256"}],"name":"getDistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_redistribution","type":"bytes32"}],"name":"getDistributionFromRedistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lastTimestamp","type":"uint256"}],"name":"getMinutesDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_periodCount","type":"uint256"}],"name":"getPeriodTimeDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"growBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumParticipantSpend","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redistributionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"redistributions","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"removeMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"toBaseAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_participants","type":"uint256"},{"internalType":"uint256","name":"_demurrageModifierPpm","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"toRedistribution","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionDemurrageModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/erc20_demurrage_token/token.py b/python/erc20_demurrage_token/token.py index 37248f0..4a180e9 100644 --- a/python/erc20_demurrage_token/token.py +++ b/python/erc20_demurrage_token/token.py @@ -208,6 +208,28 @@ class DemurrageToken(ERC20): return o + def to_redistribution(self, contract_address, participants, demurrage_modifier_ppm, value, period, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('toRedistribution') + enc.typ(ABIContractType.UINT256) + enc.typ(ABIContractType.UINT256) + enc.typ(ABIContractType.UINT256) + enc.typ(ABIContractType.UINT256) + enc.uint256(participants) + enc.uint256(demurrage_modifier_ppm) + enc.uint256(value) + enc.uint256(period) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + + def to_redistribution_period(self, contract_address, redistribution, sender_address=ZERO_ADDRESS): o = jsonrpc_template() o['method'] = 'eth_call' @@ -301,7 +323,7 @@ class DemurrageToken(ERC20): tx = self.set_code(tx, data) tx = self.finalize(tx, tx_format) return tx - + def actual_period(self, contract_address, sender_address=ZERO_ADDRESS): return self.call_noarg('actualPeriod', contract_address, sender_address=sender_address) @@ -374,6 +396,22 @@ class DemurrageToken(ERC20): return o + def get_distribution_from_redistribution(self, contract_address, redistribution, sender_address=ZERO_ADDRESS): + o = jsonrpc_template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('getDistributionFromRedistribution') + enc.typ(ABIContractType.BYTES32) + enc.bytes32(redistribution) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + return o + + + @classmethod def parse_actual_period(self, v): return abi_decode_single(ABIContractType.UINT256, v) diff --git a/python/examples/sim_noredistribute.py b/python/examples/sim_noredistribute.py index be52429..b294d8c 100644 --- a/python/examples/sim_noredistribute.py +++ b/python/examples/sim_noredistribute.py @@ -35,9 +35,9 @@ sim.mint(bob, sim.from_units(100)) sim.transfer(alice, carol, sim.from_units(50)) # check that balances have been updated -assert sim.balance(alice) == sim.from_units(50) -assert sim.balance(bob) == sim.from_units(100) -assert sim.balance(carol) == sim.from_units(50) +#assert sim.balance(alice) == sim.from_units(50) +#assert sim.balance(bob) == sim.from_units(100) +#assert sim.balance(carol) == sim.from_units(50) # advance to next redistribution period sim.next() diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py index 421651e..5476d38 100644 --- a/python/tests/test_basic.py +++ b/python/tests/test_basic.py @@ -52,69 +52,69 @@ class TestBasic(TestDemurrageDefault): # r = self.rpc.do(o) # balance = c.parse_balance_of(r) # self.assertEqual(balance, 1024) - - - def test_apply_demurrage(self): - modifier = (10 ** 38) - - nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) - c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - - o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - demurrage_amount = c.parse_demurrage_amount(r) - self.assertEqual(modifier, demurrage_amount) - - o = block_latest() - r = self.rpc.do(o) - o = block_by_number(r) - b = self.rpc.do(o) - logg.debug('block {} start {}'.format(b['timestamp'], self.start_time)) - - self.backend.time_travel(self.start_time + 2) - (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - o = receipt(tx_hash) - r = self.rpc.do(o) - self.assertEqual(r['status'], 1) - - o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - demurrage_amount = c.parse_demurrage_amount(r) - self.assertEqual(modifier, demurrage_amount) - - self.backend.time_travel(self.start_time + 61) - (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - o = receipt(tx_hash) - r = self.rpc.do(o) - self.assertEqual(r['status'], 1) - o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - demurrage_amount = c.parse_demurrage_amount(r) - modifier_base = 1000000 - self.tax_level - logg.debug('modifier base {}'.format(modifier_base)) - modifier = int(modifier_base * (10 ** 32)) # 38 decimal places minus 6 (1000000) - self.assertEqual(modifier, demurrage_amount) - - self.backend.time_travel(self.start_time + 601) - (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - o = receipt(tx_hash) - r = self.rpc.do(o) - self.assertEqual(r['status'], 1) - o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - demurrage_amount = c.parse_demurrage_amount(r) - modifier_base = ((1000000 - self.tax_level) / 1000000) ** 10 - modifier = int(modifier_base * (10 ** 12)) - - rounding_tolerance_nano = 4000000 # 0.000004% precision - demurrage_amount_truncate = int(demurrage_amount / (10 ** 26)) # equals 12 decimal places - self.assertGreaterEqual(modifier, demurrage_amount_truncate - rounding_tolerance_nano) - self.assertLessEqual(modifier, demurrage_amount_truncate) - - +# +# +# def test_apply_demurrage(self): +# modifier = (10 ** 38) +# +# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) +# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) +# +# o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# demurrage_amount = c.parse_demurrage_amount(r) +# self.assertEqual(modifier, demurrage_amount) +# +# o = block_latest() +# r = self.rpc.do(o) +# o = block_by_number(r) +# b = self.rpc.do(o) +# logg.debug('block {} start {}'.format(b['timestamp'], self.start_time)) +# +# self.backend.time_travel(self.start_time + 2) +# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# o = receipt(tx_hash) +# r = self.rpc.do(o) +# self.assertEqual(r['status'], 1) +# +# o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# demurrage_amount = c.parse_demurrage_amount(r) +# self.assertEqual(modifier, demurrage_amount) +# +# self.backend.time_travel(self.start_time + 61) +# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# o = receipt(tx_hash) +# r = self.rpc.do(o) +# self.assertEqual(r['status'], 1) +# o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# demurrage_amount = c.parse_demurrage_amount(r) +# modifier_base = 1000000 - self.tax_level +# logg.debug('modifier base {}'.format(modifier_base)) +# modifier = int(modifier_base * (10 ** 32)) # 38 decimal places minus 6 (1000000) +# self.assertEqual(modifier, demurrage_amount) +# +# self.backend.time_travel(self.start_time + 601) +# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# o = receipt(tx_hash) +# r = self.rpc.do(o) +# self.assertEqual(r['status'], 1) +# o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) +# r = self.rpc.do(o) +# demurrage_amount = c.parse_demurrage_amount(r) +# modifier_base = ((1000000 - self.tax_level) / 1000000) ** 10 +# modifier = int(modifier_base * (10 ** 12)) +# +# rounding_tolerance_nano = 4000000 # 0.000004% precision +# demurrage_amount_truncate = int(demurrage_amount / (10 ** 26)) # equals 12 decimal places +# self.assertGreaterEqual(modifier, demurrage_amount_truncate - rounding_tolerance_nano) +# self.assertLessEqual(modifier, demurrage_amount_truncate) +# +# # def test_mint(self): # nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) # c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) @@ -201,21 +201,21 @@ class TestBasic(TestDemurrageDefault): # self.assertEqual(r['status'], 0) # # -# def test_base_amount(self): -# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) -# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) -# -# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024) -# self.rpc.do(o) -# -# self.backend.time_travel(self.start_time + 61) -# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# o = c.to_base_amount(self.address, 1000, sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# amount = c.parse_to_base_amount(r) -# self.assertEqual(amount, 1020) -# + def test_base_amount(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024) + self.rpc.do(o) + + self.backend.time_travel(self.start_time + 61) + (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + o = c.to_base_amount(self.address, 1000, sender_address=self.accounts[0]) + r = self.rpc.do(o) + amount = c.parse_to_base_amount(r) + self.assertEqual(amount, 1020) + # # def test_transfer(self): # nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) diff --git a/python/tests/test_period.py b/python/tests/test_period.py index 63ef6e8..5faa487 100644 --- a/python/tests/test_period.py +++ b/python/tests/test_period.py @@ -31,7 +31,7 @@ class TestPeriod(TestDemurrageDefault): r = self.rpc.do(o) self.assertEqual(r['status'], 1) - self.backend.time_travel(self.start_time + 61) + self.backend.time_travel(self.start_time + self.period_seconds) c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) (tx_hash, o) = c.change_period(self.address, self.accounts[0]) @@ -63,6 +63,19 @@ class TestPeriod(TestDemurrageDefault): period = c.parse_actual_period(r) self.assertEqual(2, period) + o = c.to_redistribution_demurrage_modifier(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + period = c.parse_to_redistribution_item(r) + + # allow test code float rounding error to billionth + modifier = (1 - (self.tax_level / 1000000)) ** (self.period_seconds / 60) + modifier *= 10 ** 9 + modifier = int(modifier) * (10 ** (38 - 9)) + + period /= (10 ** (38 - 9)) + period = int(period) * (10 ** (38 - 9)) + self.assertEqual(modifier, period) + if __name__ == '__main__': unittest.main() diff --git a/python/tests/test_redistribution_unit.py b/python/tests/test_redistribution_unit.py index 7e78c5c..6fe13d2 100644 --- a/python/tests/test_redistribution_unit.py +++ b/python/tests/test_redistribution_unit.py @@ -36,14 +36,32 @@ class TestRedistribution(TestDemurrageUnit): nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - demurrage = (self.tax_level / 1000000) * (10^38) + demurrage = (1 - (self.tax_level / 1000000)) * (10**38) supply = self.default_supply o = c.get_distribution(self.address, supply, demurrage, sender_address=self.accounts[0]) r = self.rpc.do(o) distribution = c.parse_get_distribution(r) expected_distribution = self.default_supply * (self.tax_level / 1000000) - self.assertEqual(distribution, self.default_supply + expected_distribution) + self.assertEqual(distribution, expected_distribution) + + + def test_distribution_from_redistribution(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + demurrage = (1 - (self.tax_level / 1000000)) * (10**38) + supply = self.default_supply + + o = c.to_redistribution(self.address, 0, demurrage, supply, 1, sender_address=self.accounts[0]) + redistribution = self.rpc.do(o) + + o = c.get_distribution_from_redistribution(self.address, redistribution, self.accounts[0]) + r = self.rpc.do(o) + distribution = c.parse_get_distribution(r) + expected_distribution = self.default_supply * (self.tax_level / 1000000) + self.assertEqual(distribution, expected_distribution) + # def test_single_step(self): @@ -93,77 +111,79 @@ class TestRedistribution(TestDemurrageUnit): # self.assertEqual(balance, expected_balance) # # -# def test_single_step_transfer(self): -# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) -# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) -# -# mint_amount = 100000000 -# half_mint_amount = int(mint_amount / 2) -# -# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], mint_amount) -# self.rpc.do(o) -# -# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], mint_amount) -# self.rpc.do(o) -# -# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) -# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) -# (tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[3], half_mint_amount) -# self.rpc.do(o) -# -# self.backend.time_travel(self.start_time + self.period_seconds) -# -# (tx_hash, o) = c.change_period(self.address, self.accounts[1]) -# self.rpc.do(o) -# o = receipt(tx_hash) -# r = self.rpc.do(o) -# self.assertEqual(r['status'], 1) -# -# demurrage_amount = int((self.tax_level / 1000000) * mint_amount) -# -# expected_balance = mint_amount - demurrage_amount -# o = c.balance_of(self.address, self.accounts[2], sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# balance = c.parse_balance_of(r) -# self.assertEqual(balance, expected_balance) -# -# half_demurrage_amount = int((self.tax_level / 1000000) * half_mint_amount) -# -# expected_balance = half_mint_amount - half_demurrage_amount -# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# balance = c.parse_balance_of(r) -# self.assertEqual(balance, expected_balance) -# -# o = c.balance_of(self.address, self.accounts[3], sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# balance = c.parse_balance_of(r) -# self.assertEqual(balance, expected_balance) -# -# o = c.total_supply(self.address, sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# supply = c.parse_total_supply(r) -# -# -# o = c.redistributions(self.address, 0, sender_address=self.accounts[0]) -# redistribution = self.rpc.do(o) -# o = c.to_redistribution_supply(self.address, redistribution, sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# supply = c.parse_to_redistribution_item(r) + def test_single_step_transfer(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + mint_amount = 100000000 + half_mint_amount = int(mint_amount / 2) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], mint_amount) + self.rpc.do(o) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], mint_amount) + self.rpc.do(o) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[3], half_mint_amount) + self.rpc.do(o) + + self.backend.time_travel(self.start_time + self.period_seconds) + + (tx_hash, o) = c.change_period(self.address, self.accounts[1]) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + demurrage_amount = int((self.tax_level / 1000000) * mint_amount) + + expected_balance = mint_amount - demurrage_amount + o = c.balance_of(self.address, self.accounts[2], sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance_of(r) + self.assertEqual(balance, expected_balance) + + half_demurrage_amount = int((self.tax_level / 1000000) * half_mint_amount) + + expected_balance = half_mint_amount - half_demurrage_amount + o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance_of(r) + self.assertEqual(balance, expected_balance) + + o = c.balance_of(self.address, self.accounts[3], sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance_of(r) + self.assertEqual(balance, expected_balance) + + o = c.total_supply(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + supply = c.parse_total_supply(r) + + o = c.redistributions(self.address, 0, sender_address=self.accounts[0]) + redistribution = self.rpc.do(o) + o = c.to_redistribution_supply(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + supply = c.parse_to_redistribution_item(r) + o = c.to_redistribution_demurrage_modifier(self.address, redistribution, sender_address=self.accounts[0]) + r = self.rpc.do(o) + demurrage = c.parse_to_redistribution_item(r) # o = c.demurrage_amount(self.address, sender_address=self.accounts[0]) # r = self.rpc.do(o) # demurrage = c.parse_demurrage_amount(r) -# logg.debug('\nrediistribution {}\ndemurrage {}\nsupply {}'.format(redistribution, demurrage, supply)) -# -# expected_balance = int(supply * (self.tax_level / 1000000)) -# expected_balance_tolerance = 1 -# -# o = c.balance_of(self.address, self.sink_address, sender_address=self.accounts[0]) -# r = self.rpc.do(o) -# balance = c.parse_balance_of(r) -# self.assertGreaterEqual(balance, expected_balance - expected_balance_tolerance) -# self.assertLessEqual(balance, expected_balance) -# + logg.debug('\nrediistribution {}\ndemurrage {}\nsupply {}'.format(redistribution, demurrage, supply)) + + expected_balance = int(supply * (self.tax_level / 1000000)) + expected_balance_tolerance = 1 + + o = c.balance_of(self.address, self.sink_address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance_of(r) + self.assertGreaterEqual(balance, expected_balance - expected_balance_tolerance) + self.assertLessEqual(balance, expected_balance) + if __name__ == '__main__': unittest.main() diff --git a/solidity/DemurrageTokenSingleCap.sol b/solidity/DemurrageTokenSingleCap.sol index a134b1d..9ee0b24 100644 --- a/solidity/DemurrageTokenSingleCap.sol +++ b/solidity/DemurrageTokenSingleCap.sol @@ -100,7 +100,7 @@ contract DemurrageTokenSingleCap { // EIP173 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173 - constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _taxLevelMinute, uint256 _periodMinutes, address _defaultSinkAddress, uint256 _supplyCap) public { + constructor(string memory _name, string memory _symbol, uint8 _decimals, uint128 _taxLevelMinute, uint256 _periodMinutes, address _defaultSinkAddress, uint256 _supplyCap) public { // ACL setup owner = msg.sender; minter[owner] = true; @@ -114,10 +114,11 @@ contract DemurrageTokenSingleCap { demurrageTimestamp = block.timestamp; periodStart = demurrageTimestamp; periodDuration = _periodMinutes * 60; - demurrageAmount = 100000000000000000000000000000000000000; // Represents 38 decimal places, same as resolutionFactor + //demurrageAmount = 100000000000000000000000000000000000000 - _taxLevelMinute; // Represents 38 decimal places, same as resolutionFactor + demurrageAmount = 100000000000000000000000000000000000000; //demurragePeriod = 1; taxLevel = _taxLevelMinute; // Represents 38 decimal places - bytes32 initialRedistribution = toRedistribution(0, nanoDivider, 0, 1); + bytes32 initialRedistribution = toRedistribution(0, demurrageAmount, 0, 1); redistributions.push(initialRedistribution); // Misc settings @@ -215,7 +216,7 @@ contract DemurrageTokenSingleCap { // Deserializes the redistribution word // uint95(unused) | uint20(demurrageModifier) | uint36(participants) | uint72(value) | uint32(period) - function toRedistribution(uint256 _participants, uint256 _demurrageModifierPpm, uint256 _value, uint256 _period) private pure returns(bytes32) { + function toRedistribution(uint256 _participants, uint256 _demurrageModifierPpm, uint256 _value, uint256 _period) public pure returns(bytes32) { bytes32 redistribution; redistribution |= bytes32((_demurrageModifierPpm << shiftRedistributionDemurrage) & maskRedistributionDemurrage); @@ -278,22 +279,27 @@ contract DemurrageTokenSingleCap { } function getDistribution(uint256 _supply, uint256 _demurrageAmount) public view returns (uint256) { - return _supply * (nanoDivider - (_demurrageAmount / nanoDivider)); + uint256 difference; + + difference = _supply * (resolutionFactor - _demurrageAmount); //(nanoDivider - ((resolutionFactor - _demurrageAmount) / nanoDivider)); + return difference / resolutionFactor; + } + + function getDistributionFromRedistribution(bytes32 _redistribution) public returns (uint256) { + uint256 redistributionSupply; + uint256 redistributionDemurrage; + + redistributionSupply = toRedistributionSupply(_redistribution); + redistributionDemurrage = toRedistributionDemurrageModifier(_redistribution); + return getDistribution(redistributionSupply, redistributionDemurrage); } // Returns the amount sent to the sink address function applyDefaultRedistribution(bytes32 _redistribution) private returns (uint256) { - uint256 redistributionSupply; - uint256 redistributionDemurrage; uint256 unit; - - redistributionSupply = toRedistributionSupply(_redistribution); - redistributionDemurrage = resolutionFactor - toRedistributionDemurrageModifier(_redistribution); - if (redistributionDemurrage == 0) { - return 0; - } - unit = getDistribution(redistributionSupply, redistributionDemurrage); - increaseBaseBalance(sinkAddress, toBaseAmount(unit / nanoDivider)); + + unit = getDistributionFromRedistribution(_redistribution); + increaseBaseBalance(sinkAddress, toBaseAmount(unit)); return unit; } @@ -401,7 +407,7 @@ contract DemurrageTokenSingleCap { // Inflates the given amount according to the current demurrage modifier function toBaseAmount(uint256 _value) public view returns (uint256) { - return (_value * nanoDivider * growthResolutionFactor) / demurrageAmount; + return (_value * resolutionFactor) / demurrageAmount; } // Implements ERC20, triggers tax and/or redistribution @@ -451,7 +457,7 @@ contract DemurrageTokenSingleCap { decreaseBaseBalance(_from, _value); increaseBaseBalance(_to, _value); - period = actualPeriod(); + //period = actualPeriod(); return true; }