Address Contract Partially Verified
Address
0x23687D9d40F9Ecc86E7666DDdB820e700F954526
Balance
0 ETH
Nonce
1
Code Size
14033 bytes
Creator
0x65d103A8...0D46 at tx 0xdddaa05b...3b68cc
Indexed Transactions
0
Contract Bytecode
14033 bytes
0x6080604052600436106102b25760003560e01c80638ae458da11610175578063b2494df3116100dc578063d7f1b27c11610095578063ea0ee5591161006f578063ea0ee55914610842578063eaf993e114610862578063f77c479114610882578063f83d08ba14610897576102b9565b8063d7f1b27c146107e2578063dd62ed3e14610802578063df5e9b2914610822576102b9565b8063b2494df314610738578063c2de0e9d1461074d578063c5d574fe1461076d578063c75640171461078d578063d0ebdbe7146107ad578063d7b96d4e146107cd576102b9565b8063a457c2d71161012e578063a457c2d71461068e578063a4e2d634146106ae578063a69df4b5146106c3578063a7bdad03146106d8578063a9059cbb146106f8578063acf3f07714610718576102b9565b80638ae458da146105d75780638f6f0332146105f757806395d89b411461061757806399d50d5d1461062c5780639dc29fac1461064e578063a06324611461066e576102b9565b806340c10f191161021957806366cb8d2f116101d257806366cb8d2f146105155780636f86c8971461053557806370a08231146105555780637d96659314610575578063802758601461059557806381b2248a146105b7576102b9565b806340c10f191461045e578063481c6a751461047e5780634e353270146104a05780635230c396146104c057806353bae5f7146104d557806363a90fc1146104f5576102b9565b806323b872dd1161026b57806323b872dd1461038f57806326898fe1146103af5780632ba57d17146103cf578063313ce567146103ef57806335bc4e5214610411578063395093511461043e576102b9565b806306fdde03146102be578063095ea7b3146102e95780630ffe0f1e1461031657806318160ddd1461032d5780631ed86f191461034f57806322ebeba41461036f576102b9565b366102b957005b600080fd5b3480156102ca57600080fd5b506102d36108ac565b6040516102e09190612e5d565b60405180910390f35b3480156102f557600080fd5b50610309610304366004612bd9565b610943565b6040516102e09190612e0e565b34801561032257600080fd5b5061032b610961565b005b34801561033957600080fd5b50610342610a4b565b6040516102e09190612e84565b34801561035b57600080fd5b5061032b61036a366004612aaa565b610a51565b34801561037b57600080fd5b5061034261038a366004612ac5565b610b89565b34801561039b57600080fd5b506103096103aa366004612b99565b610ba4565b3480156103bb57600080fd5b5061032b6103ca366004612af9565b610c31565b3480156103db57600080fd5b5061032b6103ea366004612bd9565b610ccc565b3480156103fb57600080fd5b50610404610d6c565b6040516102e0919061358a565b34801561041d57600080fd5b5061043161042c366004612aaa565b610d75565b6040516102e09190612e70565b34801561044a57600080fd5b50610309610459366004612bd9565b610d8a565b34801561046a57600080fd5b5061032b610479366004612bd9565b610dde565b34801561048a57600080fd5b50610493610dfc565b6040516102e09190612cef565b3480156104ac57600080fd5b5061032b6104bb366004612aaa565b610e0b565b3480156104cc57600080fd5b50610342610e93565b3480156104e157600080fd5b506103096104f0366004612aaa565b610e99565b34801561050157600080fd5b5061032b610510366004612b5c565b610ecc565b34801561052157600080fd5b50610342610530366004612aaa565b610f73565b34801561054157600080fd5b5061032b610550366004612aaa565b610f81565b34801561056157600080fd5b50610342610570366004612aaa565b61104a565b34801561058157600080fd5b50610309610590366004612ac5565b611065565b3480156105a157600080fd5b506105aa611080565b6040516102e09190612d6a565b3480156105c357600080fd5b506104936105d2366004612c65565b61123d565b3480156105e357600080fd5b506102d36105f2366004612ac5565b611264565b34801561060357600080fd5b506102d3610612366004612c03565b611270565b34801561062357600080fd5b506102d361131e565b34801561063857600080fd5b5061064161137f565b6040516102e09190612d1d565b34801561065a57600080fd5b5061032b610669366004612bd9565b6113e0565b34801561067a57600080fd5b5061032b610689366004612aaa565b6113fa565b34801561069a57600080fd5b506103096106a9366004612bd9565b61159b565b3480156106ba57600080fd5b50610309611609565b3480156106cf57600080fd5b5061032b611612565b3480156106e457600080fd5b506106416106f3366004612aaa565b611682565b34801561070457600080fd5b50610309610713366004612bd9565b61168d565b34801561072457600080fd5b5061032b610733366004612ac5565b6116a1565b34801561074457600080fd5b5061064161177e565b34801561075957600080fd5b5061032b610768366004612c65565b6117de565b34801561077957600080fd5b50610493610788366004612c65565b61184e565b34801561079957600080fd5b5061032b6107a8366004612aaa565b61185b565b3480156107b957600080fd5b5061032b6107c8366004612aaa565b611915565b3480156107d957600080fd5b5061049361199f565b3480156107ee57600080fd5b506103096107fd366004612aaa565b6119ae565b34801561080e57600080fd5b5061034261081d366004612ac5565b6119b7565b34801561082e57600080fd5b5061030961083d366004612aaa565b6119e2565b34801561084e57600080fd5b5061032b61085d366004612ac5565b611a51565b34801561086e57600080fd5b5061034261087d366004612aaa565b611ace565b34801561088e57600080fd5b50610493611b35565b3480156108a357600080fd5b5061032b611b49565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109385780601f1061090d57610100808354040283529160200191610938565b820191906000526020600020905b81548152906001019060200180831161091b57829003601f168201915b505050505090505b90565b6000610957610950611ba1565b8484611ba5565b5060015b92915050565b600a5460ff161561098d5760405162461bcd60e51b815260040161098490613425565b60405180910390fd5b60013360009081526009602052604090205460ff1660028111156109ad57fe5b146109ca5760405162461bcd60e51b8152600401610984906134f9565b33600081815260096020526040808220805460ff19166002179055600880546001810182559083527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b03191684179055517f27b541a16df0902e262f34789782092ab25125513b8ed73608e802951771b9289190a2565b60025490565b610a59611c59565b6001600160a01b03811660009081526009602052604081205460ff166002811115610a8057fe5b14610a9d5760405162461bcd60e51b815260040161098490612f62565b6005546040516342f6e38960e01b81526101009091046001600160a01b0316906342f6e38990610ad1908490600401612cef565b60206040518083038186803b158015610ae957600080fd5b505afa158015610afd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b219190612c45565b610b3d5760405162461bcd60e51b8152600401610984906131eb565b6001600160a01b038116600081815260096020526040808220805460ff19166001179055517fead6a006345da1073a106d5f32372d2d2204f46cb0b4bca8f5ebafcbbed12b8a9190a250565b6000610b9d610b988484611c85565b611cb4565b9392505050565b6000610bb1848484611ccb565b610c2784610bbd611ba1565b610c228560405180606001604052806028815260200161364f602891396001600160a01b038a16600090815260016020526040812090610bfb611ba1565b6001600160a01b03168152602081019190915260400160002054919063ffffffff611dec16565b611ba5565b5060019392505050565b610c39611e18565b610c41611ef5565b6001600160a01b038085166000908152600c6020908152604080832093871683526002909301905220610c789060010183836128ab565b50826001600160a01b0316846001600160a01b03167fb373eedb8e9038a2dcba31f06b2735887c1a904125e5c9f0021ba41ed972318e8484604051610cbe929190612e19565b60405180910390a350505050565b610cd4611e18565b610cdc611ef5565b6000610ce782611f2a565b9050600082138015610cf7575080155b15610d145760405162461bcd60e51b815260040161098490613099565b6001600160a01b0383166000818152600c602052604090819020839055517f8133e2bf34edab764b55c59d1d41f9df637e7c22828bb6b0a9d55b429d008a9790610d5f908590612e84565b60405180910390a2505050565b60055460ff1690565b60096020526000908152604090205460ff1681565b6000610957610d97611ba1565b84610c228560016000610da8611ba1565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff611f4116565b610de6611e18565b610dee611ef5565b610df88282611f66565b5050565b6006546001600160a01b031681565b610e13611e18565b610e1b611ef5565b600b805460018101825560009182527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319166001600160a01b03841690811790915560405190917f76da6cf8b40dd2b2c223a5956831e0ff4e75522538a86782108a0bbe1577e29891a250565b600d5481565b600060015b6001600160a01b03831660009081526009602052604090205460ff166002811115610ec557fe5b1492915050565b610ed4611e18565b610edc611ef5565b6000610ee782611f2a565b9050600082138015610ef7575080155b15610f145760405162461bcd60e51b815260040161098490613099565b6001600160a01b038085166000818152600c60209081526040808320948816808452600290950190915290819020849055517f81a422e27f503e1b92cdb616a6e653aac10a8e0c3fa6832a58dc616c080fd7bd90610cbe908690612e84565b600061095b610b9883612032565b610f89611e18565b610f91611ef5565b610ffe81600b805480602002602001604051908101604052809291908181526020018280548015610feb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fcd575b505050505061204d90919063ffffffff16565b805161101291600b91602090910190612929565b506040516001600160a01b038216907fc605d0bf97f9b921340106a2e59f9428d5eb9039b16866159e0cdd2bf8e963df90600090a250565b6001600160a01b031660009081526020819052604090205490565b6000610b9d8261107485612095565b9063ffffffff61210e16565b60608061108b612124565b67ffffffffffffffff811180156110a157600080fd5b506040519080825280602002602001820160405280156110db57816020015b6110c861298a565b8152602001906001900390816110c05790505b5090506000805b600b54811015611235576000600b82815481106110fb57fe5b60009182526020822001546001600160a01b0316915061111a82612032565b1315611189576040805160a0810182526001600160a01b03831681526000602082015290810161114983610f73565b8152602001600060ff1681526020016040518060200160405280600081525081525084848151811061117757fe5b60209081029190910101526001909201915b606061119482612095565b905060005b815181101561122a5760008282815181106111b057fe5b602002602001015190506040518060a00160405280856001600160a01b03168152602001826001600160a01b031681526020016111ed8684610b89565b81526001602082015260400161120386846121a9565b81525087878151811061121257fe5b60209081029190910101525060019485019401611199565b5050506001016110e2565b509091505090565b6008818154811061124a57fe5b6000918252602090912001546001600160a01b0316905081565b6060610b9d83836121a9565b606061127a611e18565b611282611ef5565b6112cd83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050506001600160a01b03881691905086612267565b905083856001600160a01b03167f2a936dbabeaea30adc1ddad138b1958497988474bef8b09a29411f0105ab8ab285858560405161130d93929190612e2d565b60405180910390a35b949350505050565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109385780601f1061090d57610100808354040283529160200191610938565b6060600b80548060200260200160405190810160405280929190818152602001828054801561093857602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116113b9575050505050905090565b6113e8611e18565b6113f0611ef5565b610df8828261228d565b611402611c59565b600a5460ff16156114255760405162461bcd60e51b815260040161098490613425565b60026001600160a01b03821660009081526009602052604090205460ff16600281111561144e57fe5b1461146b5760405162461bcd60e51b8152600401610984906130d0565b806001600160a01b031663847ef08d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156114a657600080fd5b505af11580156114ba573d6000803e3d6000fd5b505050506001600160a01b0381166000908152600960205260408120805460ff1916600183021790555061154f816008805480602002602001604051908101604052809291908181526020018280548015610feb576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610fcd57505050505061204d90919063ffffffff16565b805161156391600891602090910190612929565b506040516001600160a01b038216907f0a1ee69f55c33d8467c69ca59ce2007a737a88603d75392972520bf67cb513b890600090a250565b60006109576115a8611ba1565b84610c228560405180606001604052806025815260200161367760259139600160006115d2611ba1565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff611dec16565b600a5460ff1681565b61161a611e18565b600a5460ff1661163c5760405162461bcd60e51b815260040161098490613269565b6007546001600160a01b031633146116665760405162461bcd60e51b8152600401610984906132f9565b600780546001600160a01b0319169055600a805460ff19169055565b606061095b82612095565b600061095761169a611ba1565b8484611ccb565b6116a9611e18565b6116b1611ef5565b6116ca816116be84612095565b9063ffffffff61204d16565b6001600160a01b0383166000908152600c6020908152604090912082516116fb936001909201929190910190612929565b506001600160a01b038083166000908152600c602090815260408083209385168352600290930190529081208181559061173860018301826129ce565b5050806001600160a01b0316826001600160a01b03167f5d0275f68d583838a7e2be68e3ef8ac2c1f9d4eeaa4b223360f4cd093a160d7560405160405180910390a35050565b60606008805480602002602001604051908101604052809291908181526020018280548015610938576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116113b9575050505050905090565b6117e6611e18565b6117ee611ef5565b6000811361180e5760405162461bcd60e51b8152600401610984906130fe565b600d8190556040517fc4e78b3245dc105eefced18655b978e194ff858545a1080f2888dc3b6ae8df0a90611843908390612e84565b60405180910390a150565b600b818154811061124a57fe5b611863611c59565b600a5460ff16156118865760405162461bcd60e51b815260040161098490613425565b60016001600160a01b03821660009081526009602052604090205460ff1660028111156118af57fe5b146118cc5760405162461bcd60e51b8152600401610984906134f9565b6001600160a01b038116600081815260096020526040808220805460ff19169055517fd6b18042563148f38d728c1c4d339ffd515b632d0ad2e1833b822412f3f4d8779190a250565b61191d611c59565b600a5460ff16156119405760405162461bcd60e51b815260040161098490613425565b600680546001600160a01b038381166001600160a01b03198316179092556040519116907f43fcfef38622d6a5b118be09c27a6ed8cbdbfca21f0ea9245412ce8031c0423c906119939084908490612d03565b60405180910390a15050565b6007546001600160a01b031681565b60006002610e9e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600061095b82600b805480602002602001604051908101604052809291908181526020018280548015611a3e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a20575b505050505061210e90919063ffffffff16565b611a59611e18565b611a61611ef5565b6001600160a01b038281166000818152600c60209081526040808320600190810180549182018155845291832090910180546001600160a01b0319169486169485179055517ff71324fa78e1894b364a1fc8d0535c4208f28c7b380f752afe00c8ce386023fb9190a35050565b600080611ada83610f73565b90506060611ae784612095565b905060005b8151811015611b2c57611b22611b1586848481518110611b0857fe5b6020026020010151610b89565b849063ffffffff61236f16565b9250600101611aec565b50909392505050565b60055461010090046001600160a01b031681565b611b51611e18565b600a5460ff1615611b745760405162461bcd60e51b815260040161098490612e8d565b600780546001600160a01b03191633179055600a805460ff19166001179055565b670de0b6b3a764000090565b3390565b6001600160a01b038316611bcb5760405162461bcd60e51b815260040161098490613366565b6001600160a01b038216611bf15760405162461bcd60e51b815260040161098490612f99565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611c4c908590612e84565b60405180910390a3505050565b6006546001600160a01b03163314611c835760405162461bcd60e51b815260040161098490613495565b565b6001600160a01b039182166000908152600c602090815260408083209390941682526002909201909152205490565b600061095b600d54836123b590919063ffffffff16565b6001600160a01b038316611cf15760405162461bcd60e51b815260040161098490613321565b6001600160a01b038216611d175760405162461bcd60e51b815260040161098490612eb9565b611d228383836123d8565b611d6581604051806060016040528060268152602001613600602691396001600160a01b038616600090815260208190526040902054919063ffffffff611dec16565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611d9a908263ffffffff611f4116565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611c4c908590612e84565b60008184841115611e105760405162461bcd60e51b81526004016109849190612e5d565b505050900390565b60023360009081526009602052604090205460ff166002811115611e3857fe5b14611e555760405162461bcd60e51b815260040161098490613173565b6005546040516342f6e38960e01b81526101009091046001600160a01b0316906342f6e38990611e89903390600401612cef565b60206040518083038186803b158015611ea157600080fd5b505afa158015611eb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed99190612c45565b611c835760405162461bcd60e51b8152600401610984906133e1565b600a5460ff1615611c83576007546001600160a01b03163314611c835760405162461bcd60e51b81526004016109849061312e565b600061095b600d54836123dd90919063ffffffff16565b600082820183811015610b9d5760405162461bcd60e51b815260040161098490612fdb565b6001600160a01b038216611f8c5760405162461bcd60e51b815260040161098490613529565b611f98600083836123d8565b600254611fab908263ffffffff611f4116565b6002556001600160a01b038216600090815260208190526040902054611fd7908263ffffffff611f4116565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612026908590612e84565b60405180910390a35050565b6001600160a01b03166000908152600c602052604090205490565b606060008061205c8585612400565b915091508061207d5760405162461bcd60e51b815260040161098490612efc565b60606120898684612466565b50935061095b92505050565b6001600160a01b0381166000908152600c602090815260409182902060010180548351818402810184019094528084526060939283018282801561210257602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120e4575b50505050509050919050565b60008061211b8484612400565b95945050505050565b600080805b600b548110156121a3576000600b828154811061214257fe5b60009182526020822001546001600160a01b0316915061216182612032565b131561216e576001909201915b606061217982612095565b80519091501561219957805161219690859063ffffffff611f4116565b93505b5050600101612129565b50905090565b6001600160a01b038281166000908152600c60209081526040808320938516835260029384018252918290206001908101805484519281161561010002600019011694909404601f81018390048302820183019093528281526060939092909183018282801561225a5780601f1061222f5761010080835404028352916020019161225a565b820191906000526020600020905b81548152906001019060200180831161223d57829003601f168201915b5050505050905092915050565b606061131684848460405180606001604052806029815260200161362660299139612595565b6001600160a01b0382166122b35760405162461bcd60e51b8152600401610984906132b8565b6122bf826000836123d8565b612302816040518060600160405280602281526020016135de602291396001600160a01b038516600090815260208190526040902054919063ffffffff611dec16565b6001600160a01b03831660009081526020819052604090205560025461232e908263ffffffff6125c316565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612026908590612e84565b60008282018183128015906123845750838112155b80612399575060008312801561239957508381125b610b9d5760405162461bcd60e51b815260040161098490613012565b6000610b9d6123ca848463ffffffff61260516565b670de0b6b3a7640000612670565b505050565b6000610b9d6123fa84670de0b6b3a764000063ffffffff61260516565b83612670565b81516000908190815b8181101561245357846001600160a01b031686828151811061242757fe5b60200260200101516001600160a01b0316141561244b5792506001915061245f9050565b600101612409565b50600019600092509250505b9250929050565b815160609060009080841061248d5760405162461bcd60e51b815260040161098490612f2b565b60606001820367ffffffffffffffff811180156124a957600080fd5b506040519080825280602002602001820160405280156124d3578160200160208202803683370190505b50905060005b85811015612521578681815181106124ed57fe5b602002602001015182828151811061250157fe5b6001600160a01b03909216602092830291909101909101526001016124d9565b50600185015b828110156125725786818151811061253b57fe5b602002602001015182600183038151811061255257fe5b6001600160a01b0390921660209283029190910190910152600101612527565b508086868151811061258057fe5b60200260200101519350935050509250929050565b6060824710156125b75760405162461bcd60e51b815260040161098490613053565b61211b85858585612704565b6000610b9d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611dec565b6000826126145750600061095b565b826000191480156126285750600160ff1b82145b156126455760405162461bcd60e51b815260040161098490613222565b8282028284828161265257fe5b0514610b9d5760405162461bcd60e51b815260040161098490613222565b60008161268f5760405162461bcd60e51b815260040161098490613560565b600160ff1b831415806126a457508160001914155b6126c05760405162461bcd60e51b815260040161098490613291565b60006126d2848463ffffffff6127c816565b905060008385181280156126ee57508284816126ea57fe5b0715155b15610b9d5761131681600163ffffffff61282c16565b606061270f85612872565b61272b5760405162461bcd60e51b8152600401610984906133aa565b60006060866001600160a01b031685876040516127489190612cd3565b60006040518083038185875af1925050503d8060008114612785576040519150601f19603f3d011682016040523d82523d6000602084013e61278a565b606091505b5091509150811561279e5791506113169050565b8051156127ae5780518082602001fd5b8360405162461bcd60e51b81526004016109849190612e5d565b6000816127e75760405162461bcd60e51b8152600401610984906134c4565b816000191480156127fb5750600160ff1b83145b156128185760405162461bcd60e51b8152600401610984906131aa565b600082848161282357fe5b05949350505050565b60008183038183128015906128415750838113155b80612856575060008312801561285657508381135b610b9d5760405162461bcd60e51b815260040161098490613451565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611316575050151592915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106128ec5782800160ff19823516178555612919565b82800160010185558215612919579182015b828111156129195782358255916020019190600101906128fe565b50612925929150612a15565b5090565b82805482825590600052602060002090810192821561297e579160200282015b8281111561297e57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612949565b50612925929150612a2f565b6040518060a0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600060ff168152602001606081525090565b50805460018160011615610100020316600290046000825580601f106129f45750612a12565b601f016020900490600052602060002090810190612a129190612a15565b50565b61094091905b808211156129255760008155600101612a1b565b61094091905b808211156129255780546001600160a01b0319168155600101612a35565b80356001600160a01b038116811461095b57600080fd5b60008083601f840112612a7b578182fd5b50813567ffffffffffffffff811115612a92578182fd5b60208301915083602082850101111561245f57600080fd5b600060208284031215612abb578081fd5b610b9d8383612a53565b60008060408385031215612ad7578081fd5b612ae18484612a53565b9150612af08460208501612a53565b90509250929050565b60008060008060608587031215612b0e578182fd5b8435612b19816135c8565b93506020850135612b29816135c8565b9250604085013567ffffffffffffffff811115612b44578283fd5b612b5087828801612a6a565b95989497509550505050565b600080600060608486031215612b70578283fd5b612b7a8585612a53565b9250612b898560208601612a53565b9150604084013590509250925092565b600080600060608486031215612bad578283fd5b8335612bb8816135c8565b92506020840135612bc8816135c8565b929592945050506040919091013590565b60008060408385031215612beb578182fd5b612bf58484612a53565b946020939093013593505050565b60008060008060608587031215612c18578384fd5b8435612c23816135c8565b935060208501359250604085013567ffffffffffffffff811115612b44578283fd5b600060208284031215612c56578081fd5b81518015158114610b9d578182fd5b600060208284031215612c76578081fd5b5035919050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60008151808452612cbf816020860160208601613598565b601f01601f19169290920160200192915050565b60008251612ce5818460208701613598565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612d5e5783516001600160a01b031683529284019291840191600101612d39565b50909695505050505050565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015612e0057888303603f19018552815180516001600160a01b039081168552888201511688850152868101518785015260608082015160ff169085015260808082015160a08287018190529190612dea83880182612ca7565b988b019896505050928801925050600101612d8e565b509098975050505050505050565b901515815260200190565b600060208252611316602083018486612c7d565b600060408252612e41604083018587612c7d565b8281036020840152612e538185612ca7565b9695505050505050565b600060208252610b9d6020830184612ca7565b6020810160038310612e7e57fe5b91905290565b90815260200190565b602080825260129082015271135d5cdd081b9bdd081899481b1bd8dad95960721b604082015260600190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526015908201527420b2323932b9b9903737ba1034b71030b93930bc9760591b604082015260600190565b60208082526018908201527f496e646578206d757374206265203c2041206c656e6774680000000000000000604082015260600190565b60208082526018908201527f4d6f64756c65206d757374206e6f742062652061646465640000000000000000604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526021908201527f5369676e6564536166654d6174683a206164646974696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601f908201527f5669727475616c20756e697420636f6e76657273696f6e20696e76616c696400604082015260600190565b602080825260149082015273135bd91d5b19481b5d5cdd08189948185919195960621b604082015260600190565b60208082526016908201527504d7573742062652067726561746572207468616e20360541b604082015260600190565b60208082526025908201527f5768656e206c6f636b65642c206f6e6c7920746865206c6f636b65722063616e6040820152640818d85b1b60da1b606082015260800190565b60208082526018908201527f4f6e6c7920746865206d6f64756c652063616e2063616c6c0000000000000000604082015260600190565b60208082526021908201527f5369676e6564536166654d6174683a206469766973696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252601d908201527f4d75737420626520656e61626c6564206f6e20436f6e74726f6c6c6572000000604082015260600190565b60208082526027908201527f5369676e6564536166654d6174683a206d756c7469706c69636174696f6e206f604082015266766572666c6f7760c81b606082015260800190565b6020808252600e908201526d135d5cdd081899481b1bd8dad95960921b604082015260600190565b6020808252600d908201526c125b9d985b1a59081a5b9c1d5d609a1b604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b6020808252600e908201526d26bab9ba103132903637b1b5b2b960911b604082015260600190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526024908201527f4d6f64756c65206d75737420626520656e61626c6564206f6e20636f6e74726f604082015263363632b960e11b606082015260800190565b60208082526012908201527113db9b1e481dda195b881d5b9b1bd8dad95960721b604082015260600190565b60208082526024908201527f5369676e6564536166654d6174683a207375627472616374696f6e206f766572604082015263666c6f7760e01b606082015260800190565b60208082526015908201527413db9b1e481b585b9859d95c8818d85b8818d85b1b605a1b604082015260600190565b6020808252818101527f5369676e6564536166654d6174683a206469766973696f6e206279207a65726f604082015260600190565b6020808252601690820152754d6f64756c65206d7573742062652070656e64696e6760501b604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b60208082526010908201526f043616e742064697669646520627920360841b604082015260600190565b60ff91909116815260200190565b60005b838110156135b357818101518382015260200161359b565b838111156135c2576000848401525b50505050565b6001600160a01b0381168114612a1257600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204d28bc809b5d46c991eebf0091f4cd889699f35ea15cd104b1b95f5b9cb506ab64736f6c634300060a0033
Verified Source Code Partial Match
Compiler: v0.6.10+commit.00c0fcaf
EVM: istanbul
Optimization: Yes (200 runs)
SetToken.sol 2367 lines
// Dependency file: @openzeppelin/contracts/utils/SafeCast.sol
// pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128) {
require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
return int128(value);
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64) {
require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
return int64(value);
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32) {
require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
return int32(value);
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16) {
require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
return int16(value);
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8) {
require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
return int8(value);
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
require(value < 2**255, "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
// Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol
// pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* // importANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// Dependency file: @openzeppelin/contracts/GSN/Context.sol
// pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// Dependency file: contracts/lib/AddressArrayUtils.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
/**
* @title AddressArrayUtils
* @author Set Protocol
*
* Utility functions to handle Address Arrays
*/
library AddressArrayUtils {
/**
* Finds the index of the first occurrence of the given element.
* @param A The input array to search
* @param a The value to find
* @return Returns (index and isIn) for the first occurrence starting from index 0
*/
function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = 0; i < length; i++) {
if (A[i] == a) {
return (i, true);
}
}
return (uint256(-1), false);
}
/**
* Returns true if the value is present in the list. Uses indexOf internally.
* @param A The input array to search
* @param a The value to find
* @return Returns isIn for the first occurrence starting from index 0
*/
function contains(address[] memory A, address a) internal pure returns (bool) {
(, bool isIn) = indexOf(A, a);
return isIn;
}
/**
* Returns true if there are 2 elements that are the same in an array
* @param A The input array to search
* @return Returns boolean for the first occurrence of a duplicate
*/
function hasDuplicate(address[] memory A) internal pure returns(bool) {
require(A.length > 0, "A is empty");
for (uint256 i = 0; i < A.length - 1; i++) {
address current = A[i];
for (uint256 j = i + 1; j < A.length; j++) {
if (current == A[j]) {
return true;
}
}
}
return false;
}
/**
* @param A The input array to search
* @param a The address to remove
* @return Returns the array with the object removed.
*/
function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
{
(uint256 index, bool isIn) = indexOf(A, a);
if (!isIn) {
revert("Address not in array.");
} else {
(address[] memory _A,) = pop(A, index);
return _A;
}
}
/**
* Removes specified index from array
* @param A The input array to search
* @param index The index to remove
* @return Returns the new array and the removed entry
*/
function pop(address[] memory A, uint256 index)
internal
pure
returns (address[] memory, address)
{
uint256 length = A.length;
require(index < A.length, "Index must be < A length");
address[] memory newAddresses = new address[](length - 1);
for (uint256 i = 0; i < index; i++) {
newAddresses[i] = A[i];
}
for (uint256 j = index + 1; j < length; j++) {
newAddresses[j - 1] = A[j];
}
return (newAddresses, A[index]);
}
}
// Dependency file: contracts/lib/PreciseUnitMath.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
// pragma experimental ABIEncoderV2;
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
// import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";
/**
* @title PreciseUnitMath
* @author Set Protocol
*
* Arithmetic for fixed-point numbers with 18 decimals of precision. Some functions taken from
* dYdX's BaseMath library.
*/
library PreciseUnitMath {
using SafeMath for uint256;
using SignedSafeMath for int256;
// The number One in precise units.
uint256 constant internal PRECISE_UNIT = 10 ** 18;
int256 constant internal PRECISE_UNIT_INT = 10 ** 18;
// Max unsigned integer value
uint256 constant internal MAX_UINT_256 = type(uint256).max;
// Max and min signed integer value
int256 constant internal MAX_INT_256 = type(int256).max;
int256 constant internal MIN_INT_256 = type(int256).min;
/**
* @dev Getter function since constants can't be read directly from libraries.
*/
function preciseUnit() internal pure returns (uint256) {
return PRECISE_UNIT;
}
/**
* @dev Getter function since constants can't be read directly from libraries.
*/
function preciseUnitInt() internal pure returns (int256) {
return PRECISE_UNIT_INT;
}
/**
* @dev Getter function since constants can't be read directly from libraries.
*/
function maxUint256() internal pure returns (uint256) {
return MAX_UINT_256;
}
/**
* @dev Getter function since constants can't be read directly from libraries.
*/
function maxInt256() internal pure returns (int256) {
return MAX_INT_256;
}
/**
* @dev Getter function since constants can't be read directly from libraries.
*/
function minInt256() internal pure returns (int256) {
return MIN_INT_256;
}
/**
* @dev Multiplies value a by value b (result is rounded down). It's assumed that the value b is the significand
* of a number with 18 decimals precision.
*/
function preciseMul(uint256 a, uint256 b) internal pure returns (uint256) {
return a.mul(b).div(PRECISE_UNIT);
}
/**
* @dev Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is the
* significand of a number with 18 decimals precision.
*/
function preciseMul(int256 a, int256 b) internal pure returns (int256) {
return a.mul(b).div(PRECISE_UNIT_INT);
}
/**
* @dev Multiplies value a by value b (result is rounded up). It's assumed that the value b is the significand
* of a number with 18 decimals precision.
*/
function preciseMulCeil(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
return a.mul(b).sub(1).div(PRECISE_UNIT).add(1);
}
/**
* @dev Divides value a by value b (result is rounded down).
*/
function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a.mul(PRECISE_UNIT).div(b);
}
/**
* @dev Divides value a by value b (result is rounded towards 0).
*/
function preciseDiv(int256 a, int256 b) internal pure returns (int256) {
return a.mul(PRECISE_UNIT_INT).div(b);
}
/**
* @dev Divides value a by value b (result is rounded up or away from 0).
*/
function preciseDivCeil(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "Cant divide by 0");
return a > 0 ? a.mul(PRECISE_UNIT).sub(1).div(b).add(1) : 0;
}
/**
* @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0).
*/
function divDown(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "Cant divide by 0");
require(a != MIN_INT_256 || b != -1, "Invalid input");
int256 result = a.div(b);
if (a ^ b < 0 && a % b != 0) {
result = result.sub(1);
}
return result;
}
/**
* @dev Multiplies value a by value b where rounding is towards the lesser number.
* (positive values are rounded towards zero and negative values are rounded away from 0).
*/
function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) {
return divDown(a.mul(b), PRECISE_UNIT_INT);
}
/**
* @dev Divides value a by value b where rounding is towards the lesser number.
* (positive values are rounded towards zero and negative values are rounded away from 0).
*/
function conservativePreciseDiv(int256 a, int256 b) internal pure returns (int256) {
return divDown(a.mul(PRECISE_UNIT_INT), b);
}
}
// Dependency file: contracts/protocol/lib/Position.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
// pragma experimental "ABIEncoderV2";
// import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
// import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
// import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";
// import { ISetToken } from "../../interfaces/ISetToken.sol";
// import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";
/**
* @title Position
* @author Set Protocol
*
* Collection of helper functions for handling and updating SetToken Positions
*/
library Position {
using SafeCast for uint256;
using SafeMath for uint256;
using SafeCast for int256;
using SignedSafeMath for int256;
using PreciseUnitMath for uint256;
/* ============ Helper ============ */
/**
* Returns whether the SetToken has a default position for a given component (if the real unit is > 0)
*/
function hasDefaultPosition(ISetToken _setToken, address _component) internal view returns(bool) {
return _setToken.getDefaultPositionRealUnit(_component) > 0;
}
/**
* Returns whether the SetToken has an external position for a given component (if # of position modules is > 0)
*/
function hasExternalPosition(ISetToken _setToken, address _component) internal view returns(bool) {
return _setToken.getExternalPositionModules(_component).length > 0;
}
/**
* Returns whether the SetToken component default position real unit is greater than or equal to units passed in.
*/
function hasSufficientDefaultUnits(ISetToken _setToken, address _component, uint256 _unit) internal view returns(bool) {
return _setToken.getDefaultPositionRealUnit(_component) >= _unit.toInt256();
}
/**
* Returns whether the SetToken component external position is greater than or equal to the real units passed in.
*/
function hasSufficientExternalUnits(
ISetToken _setToken,
address _component,
address _positionModule,
uint256 _unit
)
internal
view
returns(bool)
{
return _setToken.getExternalPositionRealUnit(_component, _positionModule) >= _unit.toInt256();
}
/**
* If the position does not exist, create a new Position and add to the SetToken. If it already exists,
* then set the position units. If the new units is 0, remove the position. Handles adding/removing of
* components where needed (in light of potential external positions).
*
* @param _setToken Address of SetToken being modified
* @param _component Address of the component
* @param _newUnit Quantity of Position units - must be >= 0
*/
function editDefaultPosition(ISetToken _setToken, address _component, uint256 _newUnit) internal {
bool isPositionFound = hasDefaultPosition(_setToken, _component);
if (!isPositionFound && _newUnit > 0) {
// If there is no Default Position and no External Modules, then component does not exist
if (!hasExternalPosition(_setToken, _component)) {
_setToken.addComponent(_component);
}
} else if (isPositionFound && _newUnit == 0) {
// If there is a Default Position and no external positions, remove the component
if (!hasExternalPosition(_setToken, _component)) {
_setToken.removeComponent(_component);
}
}
_setToken.editDefaultPositionUnit(_component, _newUnit.toInt256());
}
/**
* Update an external position and remove and external positions or components if necessary. The logic flows as follows:
* 1) If component is not already added then add component and external position.
* 2) If component is added but no existing external position using the passed module exists then add the external position.
* 3) If the existing position is being added to then just update the unit
* 4) If the position is being closed and no other external positions or default positions are associated with the component
* then untrack the component and remove external position.
* 5) If the position is being closed and other existing positions still exist for the component then just remove the
* external position.
*
* @param _setToken SetToken being updated
* @param _component Component position being updated
* @param _module Module external position is associated with
* @param _newUnit Position units of new external position
* @param _data Arbitrary data associated with the position
*/
function editExternalPosition(
ISetToken _setToken,
address _component,
address _module,
int256 _newUnit,
bytes memory _data
)
internal
{
if (!_setToken.isComponent(_component)) {
_setToken.addComponent(_component);
addExternalPosition(_setToken, _component, _module, _newUnit, _data);
} else if (!_setToken.isExternalPositionModule(_component, _module)) {
addExternalPosition(_setToken, _component, _module, _newUnit, _data);
} else if (_newUnit != 0) {
_setToken.editExternalPositionUnit(_component, _module, _newUnit);
} else {
// If no default or external position remaining then remove component from components array
if (_setToken.getDefaultPositionRealUnit(_component) == 0 && _setToken.getExternalPositionModules(_component).length == 1) {
_setToken.removeComponent(_component);
}
_setToken.removeExternalPositionModule(_component, _module);
}
}
/**
* Add a new external position from a previously untracked module.
*
* @param _setToken SetToken being updated
* @param _component Component position being updated
* @param _module Module external position is associated with
* @param _newUnit Position units of new external position
* @param _data Arbitrary data associated with the position
*/
function addExternalPosition(
ISetToken _setToken,
address _component,
address _module,
int256 _newUnit,
bytes memory _data
)
internal
{
_setToken.addExternalPositionModule(_component, _module);
_setToken.editExternalPositionUnit(_component, _module, _newUnit);
_setToken.editExternalPositionData(_component, _module, _data);
}
/**
* Get total notional amount of Default position
*
* @param _setTokenSupply Supply of SetToken in precise units (10^18)
* @param _positionUnit Quantity of Position units
*
* @return Total notional amount of units
*/
function getDefaultTotalNotional(uint256 _setTokenSupply, uint256 _positionUnit) internal pure returns (uint256) {
return _setTokenSupply.preciseMul(_positionUnit);
}
/**
* Get position unit from total notional amount
*
* @param _setTokenSupply Supply of SetToken in precise units (10^18)
* @param _totalNotional Total notional amount of component prior to
* @return Default position unit
*/
function getDefaultPositionUnit(uint256 _setTokenSupply, uint256 _totalNotional) internal pure returns (uint256) {
return _totalNotional.preciseDiv(_setTokenSupply);
}
/**
* Calculate the new position unit given total notional values pre and post executing an action that changes SetToken state
* The intention is to make updates to the units without accidentally picking up airdropped assets as well.
*
* @param _setTokenSupply Supply of SetToken in precise units (10^18)
* @param _preTotalNotional Total notional amount of component prior to executing action
* @param _postTotalNotional Total notional amount of component after the executing action
* @param _prePositionUnit Position unit of SetToken prior to executing action
* @return New position unit
*/
function calculateDefaultEditPositionUnit(
uint256 _setTokenSupply,
uint256 _preTotalNotional,
uint256 _postTotalNotional,
uint256 _prePositionUnit
)
internal
pure
returns (uint256)
{
// If pre action total notional amount is greater then subtract post action total notional and calculate new position units
if (_preTotalNotional >= _postTotalNotional) {
uint256 unitsToSub = _preTotalNotional.sub(_postTotalNotional).preciseDivCeil(_setTokenSupply);
return _prePositionUnit.sub(unitsToSub);
} else {
// Else subtract post action total notional from pre action total notional and calculate new position units
uint256 unitsToAdd = _postTotalNotional.sub(_preTotalNotional).preciseDiv(_setTokenSupply);
return _prePositionUnit.add(unitsToAdd);
}
}
}
// Dependency file: contracts/interfaces/ISetToken.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
// pragma experimental "ABIEncoderV2";
// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title ISetToken
* @author Set Protocol
*
* Interface for operating with SetTokens.
*/
interface ISetToken is IERC20 {
/* ============ Enums ============ */
enum ModuleState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Structs ============ */
/**
* The base definition of a SetToken Position
*
* @param component Address of token in the Position
* @param module If not in default state, the address of associated module
* @param unit Each unit is the # of components per 10^18 of a SetToken
* @param positionState Position ENUM. Default is 0; External is 1
* @param data Arbitrary data
*/
struct Position {
address component;
address module;
int256 unit;
uint8 positionState;
bytes data;
}
/**
* A struct that stores a component's cash position details and external positions
* This data structure allows O(1) access to a component's cash position units and
* virtual units.
*
* @param virtualUnit Virtual value of a component's DEFAULT position. Stored as virtual for efficiency
* updating all units at once via the position multiplier. Virtual units are achieved
* by dividing a "real" value by the "positionMultiplier"
* @param componentIndex
* @param externalPositionModules List of external modules attached to each external position. Each module
* maps to an external position
* @param externalPositions Mapping of module => ExternalPosition struct for a given component
*/
struct ComponentPosition {
int256 virtualUnit;
address[] externalPositionModules;
mapping(address => ExternalPosition) externalPositions;
}
/**
* A struct that stores a component's external position details including virtual unit and any
* auxiliary data.
*
* @param virtualUnit Virtual value of a component's EXTERNAL position.
* @param data Arbitrary data
*/
struct ExternalPosition {
int256 virtualUnit;
bytes data;
}
/* ============ Functions ============ */
function addComponent(address _component) external;
function removeComponent(address _component) external;
function editDefaultPositionUnit(address _component, int256 _realUnit) external;
function addExternalPositionModule(address _component, address _positionModule) external;
function removeExternalPositionModule(address _component, address _positionModule) external;
function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external;
function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external;
function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory);
function editPositionMultiplier(int256 _newMultiplier) external;
function mint(address _account, uint256 _quantity) external;
function burn(address _account, uint256 _quantity) external;
function lock() external;
function unlock() external;
function addModule(address _module) external;
function removeModule(address _module) external;
function initializeModule() external;
function setManager(address _manager) external;
function manager() external view returns (address);
function moduleStates(address _module) external view returns (ModuleState);
function getModules() external view returns (address[] memory);
function getDefaultPositionRealUnit(address _component) external view returns(int256);
function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256);
function getComponents() external view returns(address[] memory);
function getExternalPositionModules(address _component) external view returns(address[] memory);
function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory);
function isExternalPositionModule(address _component, address _module) external view returns(bool);
function isComponent(address _component) external view returns(bool);
function positionMultiplier() external view returns (int256);
function getPositions() external view returns (Position[] memory);
function getTotalComponentRealUnits(address _component) external view returns(int256);
function isInitializedModule(address _module) external view returns(bool);
function isPendingModule(address _module) external view returns(bool);
function isLocked() external view returns (bool);
}
// Dependency file: contracts/interfaces/IModule.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
/**
* @title IModule
* @author Set Protocol
*
* Interface for interacting with Modules.
*/
interface IModule {
/**
* Called by a SetToken to notify that this module was removed from the Set token. Any logic can be included
* in case checks need to be made or state needs to be cleared.
*/
function removeModule() external;
}
// Dependency file: contracts/interfaces/IController.sol
/*
Copyright 2020 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// pragma solidity 0.6.10;
interface IController {
function addSet(address _setToken) external;
function getModuleFee(address _module, uint256 _feeType) external view returns(uint256);
function resourceId(uint256 _id) external view returns(address);
function feeRecipient() external view returns(address);
function isModule(address _module) external view returns(bool);
function isSet(address _setToken) external view returns(bool);
function isSystemContract(address _contractAddress) external view returns (bool);
}
// Dependency file: @openzeppelin/contracts/math/SignedSafeMath.sol
// pragma solidity ^0.6.0;
/**
* @title SignedSafeMath
* @dev Signed math operations with safety checks that revert on error.
*/
library SignedSafeMath {
int256 constant private _INT256_MIN = -2**255;
/**
* @dev Returns the multiplication of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two signed integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
}
/**
* @dev Returns the addition of two signed integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
}
}
// Dependency file: @openzeppelin/contracts/math/SafeMath.sol
// pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// Dependency file: @openzeppelin/contracts/token/ERC20/ERC20.sol
// pragma solidity ^0.6.0;
// import "../../GSN/Context.sol";
// import "./IERC20.sol";
// import "../../math/SafeMath.sol";
// import "../../utils/Address.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
...
// [truncated — 88293 bytes total]
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
components 0xc5d574fe → address
controller 0xf77c4791 → address
decimals 0x313ce567 → uint8
getComponents 0x99d50d5d → address[]
getDefaultPositionRealUnit 0x66cb8d2f → int256
getExternalPositionData 0x8ae458da → bytes
getExternalPositionModules 0xa7bdad03 → address[]
getExternalPositionRealUnit 0x22ebeba4 → int256
getModules 0xb2494df3 → address[]
getPositions 0x80275860 → tuple[]
getTotalComponentRealUnits 0xeaf993e1 → int256
isComponent 0xdf5e9b29 → bool
isExternalPositionModule 0x7d966593 → bool
isInitializedModule 0xd7f1b27c → bool
isLocked 0xa4e2d634 → bool
isPendingModule 0x53bae5f7 → bool
locker 0xd7b96d4e → address
manager 0x481c6a75 → address
moduleStates 0x35bc4e52 → uint8
modules 0x81b2248a → address
name 0x06fdde03 → string
positionMultiplier 0x5230c396 → int256
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 23 functions
These functions modify contract state and require a wallet transaction to execute.
addComponent 0x4e353270
address _component
addExternalPositionModule 0xea0ee559
address _component
address _positionModule
addModule 0x1ed86f19
address _module
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burn 0x9dc29fac
address _account
uint256 _quantity
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
editDefaultPositionUnit 0x2ba57d17
address _component
int256 _realUnit
editExternalPositionData 0x26898fe1
address _component
address _positionModule
bytes _data
editExternalPositionUnit 0x63a90fc1
address _component
address _positionModule
int256 _realUnit
editPositionMultiplier 0xc2de0e9d
int256 _newMultiplier
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
initializeModule 0x0ffe0f1e
No parameters
invoke 0x8f6f0332
address _target
uint256 _value
bytes _data
returns: bytes
lock 0xf83d08ba
No parameters
mint 0x40c10f19
address _account
uint256 _quantity
removeComponent 0x6f86c897
address _component
removeExternalPositionModule 0xacf3f077
address _component
address _positionModule
removeModule 0xa0632461
address _module
removePendingModule 0xc7564017
address _module
setManager 0xd0ebdbe7
address _manager
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
unlock 0xa69df4b5
No parameters
Token Balances (3)
View Transfers →Recent Transactions
No transactions found for this address