Address Contract Partially Verified
Address
0xD52Ca71AAfa4d2590aac1E35e3005242dd31e5eD
Balance
0 ETH
Nonce
1
Code Size
15464 bytes
Creator
0x0b987182...9372 at tx 0x4ac941db...5091ed
Indexed Transactions
0
Contract Bytecode
15464 bytes
0x6080604052600436106102135760003560e01c80637ec5508a11610118578063a72bcc3a116100a0578063dc98c03a1161006f578063dc98c03a146106b6578063ddd2c684146106d6578063f12aa09a146106f6578063f2fde38b14610716578063f5dab7111461073657600080fd5b8063a72bcc3a1461062b578063b61d27f61461064b578063c70eddff14610679578063d8697a50146106a157600080fd5b806393516676116100e75780639351667614610573578063961deefe1461059b5780639687fc32146105c35780639b0fe088146105e3578063a350bee01461060357600080fd5b80637ec5508a146104f85780638757b15b1461052057806388dcc3fe146105355780638da5cb5b1461055557600080fd5b8063316f244d1161019b5780636945c5ea1161016a5780636945c5ea146104665780636acabc2e146104865780636ae38e8d1461049b578063715018a6146104bb5780637506ceb9146104d057600080fd5b8063316f244d14610397578063455c3eb5146103bf5780634bde38c814610424578063657428a31461044457600080fd5b806315d89591116101e257806315d89591146102fe5780631857b3081461031e5780631a316fbc1461034157806326232a2e1461036157806328c34c081461037757600080fd5b80630303f1e2146102575780630960b7fa1461027957806310e79426146102be57806312e8e2c3146102de57600080fd5b3661025257604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b34801561026357600080fd5b506102776102723660046131ec565b6107a9565b005b34801561028557600080fd5b506102a1734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b81565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102ca57600080fd5b506102776102d9366004613245565b610aed565b3480156102ea57600080fd5b506102776102f9366004613262565b610b87565b34801561030a57600080fd5b5061027761031936600461327b565b610bed565b34801561032a57600080fd5b50610333600081565b6040519081526020016102b5565b34801561034d57600080fd5b506005546102a1906001600160a01b031681565b34801561036d57600080fd5b5061033360085481565b34801561038357600080fd5b506102a1610392366004613262565b610d63565b3480156103a357600080fd5b506102a17392e6e43f99809df84ed2d533e1fd8017eb966ee281565b3480156103cb57600080fd5b506104026103da366004613245565b600c602052600090815260409020546001600160a01b03811690600160a01b900461ffff1682565b604080516001600160a01b03909316835261ffff9091166020830152016102b5565b34801561043057600080fd5b506007546102a1906001600160a01b031681565b34801561045057600080fd5b506102a1600080516020613c1383398151915281565b34801561047257600080fd5b50610277610481366004613245565b610d8d565b34801561049257600080fd5b50610333600181565b3480156104a757600080fd5b506102776104b63660046132ea565b610e29565b3480156104c757600080fd5b5061027761111a565b3480156104dc57600080fd5b506102a173971add32ea87f10bd192671630be3be8a11b862381565b34801561050457600080fd5b506102a17362b9c7356a2dc64a1969e19c23e4f579f9810aa781565b34801561052c57600080fd5b5061027761118e565b34801561054157600080fd5b5061027761055036600461338a565b6113a3565b34801561056157600080fd5b506000546001600160a01b03166102a1565b34801561057f57600080fd5b50610588600181565b604051600f9190910b81526020016102b5565b3480156105a757600080fd5b506102a173b576491f1e6e5e62f1d8f26062ee822b40b0e0d481565b3480156105cf57600080fd5b506102776105de3660046133cb565b611490565b3480156105ef57600080fd5b506102776105fe366004613245565b611539565b34801561060f57600080fd5b506102a1734ebdf703948ddcea3b11f675b4d1fba9d2414a1481565b34801561063757600080fd5b506102776106463660046134d9565b6115d8565b34801561065757600080fd5b5061066b610666366004613585565b6119bc565b6040516102b5929190613665565b34801561068557600080fd5b506102a1733fe65692bfcd0e6cf84cb1e7d24108e434a7587e81565b3480156106ad57600080fd5b50610588600081565b3480156106c257600080fd5b506102776106d1366004613680565b611a5a565b3480156106e257600080fd5b506102776106f1366004613245565b611bbe565b34801561070257600080fd5b506102776107113660046131ec565b611c6a565b34801561072257600080fd5b50610277610731366004613245565b611d2f565b34801561074257600080fd5b5061077f610751366004613245565b600b602052600090815260409020805460018201546002909201546001600160a01b03918216928216911683565b604080516001600160a01b03948516815292841660208401529216918101919091526060016102b5565b6000546001600160a01b031633146107dc5760405162461bcd60e51b81526004016107d3906136b3565b60405180910390fd5b6006548290829081146108015760405162461bcd60e51b81526004016107d3906136e8565b6000805b828110156108565783838281811061081f5761081f613717565b9050602002016020810190610834919061372d565b6108449063ffffffff1683613769565b915061084f81613781565b9050610805565b50633b9aca00811461089c5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964207765696768747360881b60448201526064016107d3565b60005b84811015610ae55760008686838181106108bb576108bb613717565b90506020020160208101906108d0919061372d565b63ffffffff161115610ad5576000600682815481106108f1576108f1613717565b60009182526020808320909101546001600160a01b03908116808452600b90925260408084206002015481516362a5af3b60e01b815291519395509091169283926362a5af3b92600480820193929182900301818387803b15801561095557600080fd5b505af1158015610969573d6000803e3d6000fd5b505050506001600160a01b038216600080516020613c1383398151915214156109a4577362b9c7356a2dc64a1969e19c23e4f579f9810aa791505b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b1580156109e657600080fd5b505afa1580156109fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1e919061379c565b9050610a346001600160a01b0384168383611e19565b816001600160a01b0316633a4b66f16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610a6f57600080fd5b505af1158015610a83573d6000803e3d6000fd5b5050604080518481526001600160a01b03878116602083015286168183015290517fb179589fa30b7c4b3fa2f0fea8a9569c3b70801bbbdb4f7846a76fd2924b21669350908190036060019150a15050505b610ade81613781565b905061089f565b505050505050565b6000546001600160a01b03163314610b175760405162461bcd60e51b81526004016107d3906136b3565b604051632a47b83760e21b81526001600160a01b03821660048201527392e6e43f99809df84ed2d533e1fd8017eb966ee29063a91ee0dc90602401600060405180830381600087803b158015610b6c57600080fd5b505af1158015610b80573d6000803e3d6000fd5b5050505050565b6000546001600160a01b03163314610bb15760405162461bcd60e51b81526004016107d3906136b3565b60088190556040518181527f45610d581145924dd7090a5017e5f2b1d6f42213bb2e95707ff86846bbfcb1ca906020015b60405180910390a150565b6000546001600160a01b03163314610c175760405162461bcd60e51b81526004016107d3906136b3565b806001600160a01b038116610c3e5760405162461bcd60e51b81526004016107d3906137b5565b60005b83811015610b80576000858583818110610c5d57610c5d613717565b9050602002016020810190610c729190613245565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b158015610cb757600080fd5b505afa158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef919061379c565b9050610d056001600160a01b0383168683611e19565b604080516001600160a01b038085168252871660208201529081018290527fe28922b10f7326500f50066b3f57b135330212ae30fe5332cd9200e09917ecad9060600160405180910390a1505080610d5c90613781565b9050610c41565b60068181548110610d7357600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b03163314610db75760405162461bcd60e51b81526004016107d3906136b3565b806001600160a01b038116610dde5760405162461bcd60e51b81526004016107d3906137b5565b600780546001600160a01b0319166001600160a01b0384169081179091556040517f38703bc9e5fbfe6a4ab89353328531fd2a9b9b0a4953c587bd38e559da9c29cf90600090a25050565b6000546001600160a01b03163314610e535760405162461bcd60e51b81526004016107d3906136b3565b6006548114610e745760405162461bcd60e51b81526004016107d3906136e8565b8415610e8457610e848888611c6a565b60005b87811015611097576000898983818110610ea357610ea3613717565b9050602002810190610eb591906137df565b610ec3906020810190613245565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b158015610f0857600080fd5b505afa158015610f1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f40919061379c565b905060018111610f51575050611087565b610f5c6001826137ff565b90506001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415610fed57604051632e1a7d4d60e01b81526004810182905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b158015610fd057600080fd5b505af1158015610fe4573d6000803e3d6000fd5b50505050611084565b610ff8828686611e81565b15611004575050611087565b600789166004811061101f5761101a8383611f1e565b61107b565b600281106110565761101a8383600a600061103b6002876137ff565b815260208101919091526040016000205462ffffff16612039565b60008181526009602052604090205461107b90849084906001600160a01b0316612246565b60038a901c9950505b50505b61109081613781565b9050610e87565b508347116110a7576110a7613816565b604051600090329085908381818185875af1925050503d80600081146110e9576040519150601f19603f3d011682016040523d82523d6000602084013e6110ee565b606091505b505090508061110f5760405162461bcd60e51b81526004016107d39061382c565b505050505050505050565b6000546001600160a01b031633146111445760405162461bcd60e51b81526004016107d3906136b3565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146111b85760405162461bcd60e51b81526004016107d3906136b3565b6111e6600080516020613c1383398151915273971add32ea87f10bd192671630be3be8a11b862360006123b6565b611215600080516020613c1383398151915273971add32ea87f10bd192671630be3be8a11b86236000196123b6565b611243600080516020613c13833981519152734ebdf703948ddcea3b11f675b4d1fba9d2414a1460006123b6565b611272600080516020613c13833981519152734ebdf703948ddcea3b11f675b4d1fba9d2414a146000196123b6565b6112a0600080516020613c13833981519152738014595f2ab54cd7c604b00e9fb932176fdc86ae60006123b6565b6112cf600080516020613c13833981519152738014595f2ab54cd7c604b00e9fb932176fdc86ae6000196123b6565b6113037362b9c7356a2dc64a1969e19c23e4f579f9810aa773971add32ea87f10bd192671630be3be8a11b862360006123b6565b6113387362b9c7356a2dc64a1969e19c23e4f579f9810aa773971add32ea87f10bd192671630be3be8a11b86236000196123b6565b61136c7362b9c7356a2dc64a1969e19c23e4f579f9810aa7733fe65692bfcd0e6cf84cb1e7d24108e434a7587e60006123b6565b6113a17362b9c7356a2dc64a1969e19c23e4f579f9810aa7733fe65692bfcd0e6cf84cb1e7d24108e434a7587e6000196123b6565b565b6000546001600160a01b031633146113cd5760405162461bcd60e51b81526004016107d3906136b3565b6001600160a01b0382166000908152600c6020526040902081906113f18282613879565b5061141690506114046020830183613245565b6001600160a01b0384169060006123b6565b6114396114266020830183613245565b6001600160a01b038416906000196123b6565b7f8fca21c5d308d0debabdfc9dddde40c80ec0ad3e7fac4a6e5f72f038c3aef82d826114686020840184613245565b604080516001600160a01b039384168152929091166020830152015b60405180910390a15050565b6000546001600160a01b031633146114ba5760405162461bcd60e51b81526004016107d3906136b3565b60065481146115015760405162461bcd60e51b8152602060048201526013602482015272496e76616c6964206d696e20616d6f756e747360681b60448201526064016107d3565b6115128c8c8c8c60008c8c8c610e29565b611521888787878787876115d8565b61152b86866107a9565b505050505050505050505050565b6000546001600160a01b031633146115635760405162461bcd60e51b81526004016107d3906136b3565b806001600160a01b03811661158a5760405162461bcd60e51b81526004016107d3906137b5565b600580546001600160a01b0319166001600160a01b0384169081179091556040519081527f4b48019cf12488379bc34913029e96e839bb3dd7639c97b9adabc7566975a2a090602001611484565b6000546001600160a01b031633146116025760405162461bcd60e51b81526004016107d3906136b3565b6006548690869081146116275760405162461bcd60e51b81526004016107d3906136e8565b6000805b8281101561167c5783838281811061164557611645613717565b905060200201602081019061165a919061372d565b61166a9063ffffffff1683613769565b915061167581613781565b905061162b565b50633b9aca0081146116c25760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964207765696768747360881b60448201526064016107d3565b60065484146117095760405162461bcd60e51b8152602060048201526013602482015272496e76616c6964206d696e20616d6f756e747360681b60448201526064016107d3565b60065486146117515760405162461bcd60e51b8152602060048201526014602482015273092dcecc2d8d2c840dee4c8cae440d8cadccee8d60631b60448201526064016107d3565b60065447906000906001600160401b03811115611770576117706138c1565b604051908082528060200260200182016040528015611799578160200160208202803683370190505b506006549091506000906001600160401b038111156117ba576117ba6138c1565b6040519080825280602002602001820160405280156117e3578160200160208202803683370190505b5090506000805b8c811015611984576006818154811061180557611805613717565b60009182526020822001546040516370a0823160e01b81523060048201526001600160a01b03909116935083906370a082319060240160206040518083038186803b15801561185357600080fd5b505afa158015611867573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061188b919061379c565b905060008f8f848181106118a1576118a1613717565b90506020020160208101906118b6919061372d565b63ffffffff161180156118c95750600181115b15611973576118d7836124da565b8583815181106118e9576118e9613717565b602002602001018181525050670de0b6b3a764000085838151811061191057611910613717565b60200260200101518261192391906138d7565b61192d91906138f6565b84838151811061193f5761193f613717565b60200260200101818152505083828151811061195d5761195d613717565b6020026020010151866119709190613769565b95505b5061197d81613781565b90506117ea565b5061198e846126b5565b61199890856137ff565b93506119ac8e8e8e8e8e8e8e8a8a8d612761565b5050505050505050505050505050565b600080546060906001600160a01b031633146119ea5760405162461bcd60e51b81526004016107d3906136b3565b600080876001600160a01b0316878787604051611a08929190613918565b60006040518083038185875af1925050503d8060008114611a45576040519150601f19603f3d011682016040523d82523d6000602084013e611a4a565b606091505b5090999098509650505050505050565b6000546001600160a01b03163314611a845760405162461bcd60e51b81526004016107d3906136b3565b6000611a936020830183613245565b6001600160a01b03161415611aaa57611aaa613816565b6001600160a01b038281166000908152600b602052604090205416611b1557600680546001810182556000919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b0382166000908152600b602052604090208190611b398282613928565b507ffc260b7a3d067aeaaa22aa8e7a5ab9515eb55312990d6a40193dd2ebc8564319905082611b6b6020840184613245565b611b7b6040850160208601613245565b611b8b6060860160408701613245565b604080516001600160a01b0395861681529385166020850152918416918301919091529091166060820152608001611484565b6000546001600160a01b03163314611be85760405162461bcd60e51b81526004016107d3906136b3565b6001600160a01b038082166000818152600c6020526040812054611c0d9316906123b6565b6001600160a01b0381166000818152600c6020908152604080832080546001600160b01b03191690558051938452908301919091527f8fca21c5d308d0debabdfc9dddde40c80ec0ad3e7fac4a6e5f72f038c3aef82d9101610be2565b6000546001600160a01b03163314611c945760405162461bcd60e51b81526004016107d3906136b3565b80611ccd5760405162461bcd60e51b81526020600482015260096024820152684e6f20636c61696d7360b81b60448201526064016107d3565b600554604051631067326f60e11b81526001600160a01b03909116906320ce64de90611d01903090869086906004016139ab565b600060405180830381600087803b158015611d1b57600080fd5b505af1158015610ae5573d6000803e3d6000fd5b6000546001600160a01b03163314611d595760405162461bcd60e51b81526004016107d3906136b3565b6001600160a01b038116611dbe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107d3565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6040516001600160a01b038316602482015260448101829052611e7c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a22565b505050565b6000805b82811015611f115760068181548110611ea057611ea0613717565b6000918252602090912001546001600160a01b038681169116148015611ef257506000848483818110611ed557611ed5613717565b9050602002016020810190611eea919061372d565b63ffffffff16115b15611f01576001915050611f17565b611f0a81613781565b9050611e85565b50600090505b9392505050565b6001600160a01b038281166000908152600c6020908152604091829020825180840190935254928316808352600160a01b90930461ffff169082015290611f6457600080fd5b8051611f7c906001600160a01b0385169060006123b6565b8051611f93906001600160a01b03851690846123b6565b805160208201516040516365b2489b60e01b815261ffff6001831881166004830152909116602482015260448101849052600060648201526001600160a01b03909116906365b2489b906084015b602060405180830381600087803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612033919061379c565b50505050565b6120626001600160a01b03841673e592427a0aece92de3edee1f18e0157c0586156460006123b6565b61208a6001600160a01b03841673e592427a0aece92de3edee1f18e0157c05861564846123b6565b60408051610100810182526001600160a01b038516815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2602082015262ffffff831691810191909152306060820152600090608081016120e0426001613769565b81526020808201869052600160408084019190915260006060938401819052815163414bf38960e01b815285516001600160a01b03908116600483015293860151841660248201529185015162ffffff16604483015292840151821660648201526080840151608482015260a084015160a482015260c084015160c482015260e084015190911660e48201529192509073e592427a0aece92de3edee1f18e0157c058615649063414bf3899061010401602060405180830381600087803b1580156121aa57600080fd5b505af11580156121be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e2919061379c565b604051632e1a7d4d60e01b81526004810182905290915073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b15801561223257600080fd5b505af115801561110f573d6000803e3d6000fd5b806001600160a01b03811661226d5760405162461bcd60e51b81526004016107d3906137b5565b60408051600280825260608201835260009260208301908036833701905050905084816000815181106122a2576122a2613717565b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2816001815181106122ea576122ea613717565b6001600160a01b03928316602091820292909201015261230e9086168460006123b6565b6123226001600160a01b03861684866123b6565b6001600160a01b0383166318cbafe585600184306123404284613769565b6040518663ffffffff1660e01b8152600401612360959493929190613aa2565b600060405180830381600087803b15801561237a57600080fd5b505af115801561238e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae59190810190613b13565b80158061243f5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561240557600080fd5b505afa158015612419573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243d919061379c565b155b6124aa5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016107d3565b6040516001600160a01b038316602482015260448101829052611e7c90849063095ea7b360e01b90606401611e45565b60006001600160a01b038216600080516020613c1383398151915214612589576001600160a01b038083166000908152600b60209081526040918290205482516386fc88d360e01b815292519316926386fc88d3926004808201939291829003018186803b15801561254b57600080fd5b505afa15801561255f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612583919061379c565b92915050565b6001600160a01b038083166000908152600b6020526040808220549051636872765360e01b815292169182916368727653916125cc919060040190815260200190565b60206040518083038186803b1580156125e457600080fd5b505afa1580156125f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261c919061379c565b604051636872765360e01b8152600160048201526001600160a01b0383169063687276539060240160206040518083038186803b15801561265c57600080fd5b505afa158015612670573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612694919061379c565b6126a690670de0b6b3a76400006138d7565b611f1791906138f6565b919050565b600080633b9aca00600854846126cb91906138d7565b6126d591906138f6565b9050804710612758576007546040516000916001600160a01b03169083908381818185875af1925050503d806000811461272b576040519150601f19603f3d011682016040523d82523d6000602084013e612730565b606091505b50509050806127515760405162461bcd60e51b81526004016107d39061382c565b5092915050565b50600092915050565b60008060005b88811015612a135789898281811061278157612781613717565b9050602002016020810190612796919061372d565b63ffffffff16915060008c8c848181106127b2576127b2613717565b90506020020160208101906127c7919061372d565b63ffffffff161115612a0357600682815481106127e6576127e6613717565b60009182526020822001546001600160a01b03169350633b9aca008d8d8581811061281357612813613717565b9050602002016020810190612828919061372d565b6128389063ffffffff16876138d7565b61284291906138f6565b90508086848151811061285757612857613717565b602002602001015111156128ce576128c98488858151811061287b5761287b613717565b60200260200101518389878151811061289657612896613717565b60200260200101516128a891906137ff565b6128ba90670de0b6b3a76400006138d7565b6128c491906138f6565b612af4565b612918565b60008684815181106128e2576128e2613717565b6020026020010151826128f591906137ff565b905061290260018c6137ff565b83141561290c5750475b6129168582612c09565b505b6001600160a01b038416600080516020613c13833981519152141561295f5761295989898581811061294c5761294c613717565b905060200201358f612d2a565b50612a01565b88888481811061297157612971613717565b6040516370a0823160e01b815230600482015260209091029290920135916001600160a01b03871691506370a082319060240160206040518083038186803b1580156129bc57600080fd5b505afa1580156129d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f4919061379c565b11612a0157612a01613816565b505b612a0c81613781565b9050612767565b50505050505050505050505050565b6000612a77826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e489092919063ffffffff16565b805190915015611e7c5780806020019051810190612a959190613bd0565b611e7c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107d3565b6001600160a01b038216600080516020613c138339815191521415612b1e57611e7c816000612e5f565b6001600160a01b038216734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b1415612b5157612b4d8282611f1e565b5050565b6001600160a01b038083166000818152600b6020526040902060010154612b79921683611e19565b6001600160a01b038281166000908152600b6020526040908190206001015490516372424d9960e11b81526004810184905291169063e4849b3290602401602060405180830381600087803b158015612bd157600080fd5b505af1158015612be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7c919061379c565b6001600160a01b038216600080516020613c138339815191521415612c3357611e7c816000612efd565b6001600160a01b038216734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b1415612c6357611e7c816000612f4d565b6001600160a01b038281166000908152600b60205260408082206001015490519192169083908381818185875af1925050503d8060008114612cc1576040519150601f19603f3d011682016040523d82523d6000602084013e612cc6565b606091505b5050905080612ce75760405162461bcd60e51b81526004016107d39061382c565b6001600160a01b038381166000908152600b602052604090819020600101549051636cb504a560e11b81526004810185905291169063d96a094a90602401611fe1565b6040516370a0823160e01b81523060048201526000908190600080516020613c13833981519152906370a082319060240160206040518083038186803b158015612d7357600080fd5b505afa158015612d87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dab919061379c565b905082612dc557612dbd813086612f96565b915050612583565b838111612dd457612dd4613816565b604051639a40832160e01b81526004810182905260016024820152738014595f2ab54cd7c604b00e9fb932176fdc86ae90639a40832190604401600060405180830381600087803b158015612e2857600080fd5b505af1158015612e3c573d6000803e3d6000fd5b50929695505050505050565b6060612e578484600085612fa3565b949350505050565b60035460405163394747c560e01b815260026004820152600160248201819052604482018590526064820184905260848201526000916001600160a01b03169063394747c590839060a4015b6020604051808303818588803b158015612ec457600080fd5b505af1158015612ed8573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f17919061379c565b60035460405163394747c560e01b815260016004820181905260026024830152604482018590526064820184905260848201526000916001600160a01b03169063394747c590859060a401612eab565b6002546040516365b2489b60e01b8152600060048201819052600160248301526044820185905260648201849052916001600160a01b0316906365b2489b908590608401612eab565b6000612e578484846130cb565b6060824710156130045760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107d3565b843b6130525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107d3565b600080866001600160a01b0316858760405161306e9190613bed565b60006040518083038185875af1925050503d80600081146130ab576040519150601f19603f3d011682016040523d82523d6000602084013e6130b0565b606091505b50915091506130c0828286613168565b979650505050505050565b6004805460405163ddc1f59d60e01b815260009281018390526001602482015260448101869052606481018490526001600160a01b0385811660848301529091169063ddc1f59d9060a401602060405180830381600087803b15801561313057600080fd5b505af1158015613144573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e57919061379c565b60608315613177575081611f17565b8251156131875782518084602001fd5b8160405162461bcd60e51b81526004016107d39190613bff565b60008083601f8401126131b357600080fd5b5081356001600160401b038111156131ca57600080fd5b6020830191508360208260051b85010111156131e557600080fd5b9250929050565b600080602083850312156131ff57600080fd5b82356001600160401b0381111561321557600080fd5b613221858286016131a1565b90969095509350505050565b6001600160a01b038116811461324257600080fd5b50565b60006020828403121561325757600080fd5b8135611f178161322d565b60006020828403121561327457600080fd5b5035919050565b60008060006040848603121561329057600080fd5b83356001600160401b038111156132a657600080fd5b6132b2868287016131a1565b90945092505060208401356132c68161322d565b809150509250925092565b801515811461324257600080fd5b80356126b0816132d1565b60008060008060008060008060c0898b03121561330657600080fd5b88356001600160401b038082111561331d57600080fd5b6133298c838d016131a1565b909a50985060208b0135975060408b01359150613345826132d1565b90955060608a0135945060808a0135935060a08a0135908082111561336957600080fd5b506133768b828c016131a1565b999c989b5096995094979396929594505050565b600080828403606081121561339e57600080fd5b83356133a98161322d565b92506040601f19820112156133bd57600080fd5b506020830190509250929050565b6000806000806000806000806000806000806101008d8f0312156133ee57600080fd5b6001600160401b038d35111561340357600080fd5b6134108e8e358f016131a1565b909c509a5060208d0135995061342860408e016132df565b985061343660608e016132df565b975060808d013596506001600160401b0360a08e0135111561345757600080fd5b6134678e60a08f01358f016131a1565b90965094506001600160401b0360c08e0135111561348457600080fd5b6134948e60c08f01358f016131a1565b90945092506001600160401b0360e08e013511156134b157600080fd5b6134c18e60e08f01358f016131a1565b81935080925050509295989b509295989b509295989b565b60008060008060008060006080888a0312156134f457600080fd5b87356134ff816132d1565b965060208801356001600160401b038082111561351b57600080fd5b6135278b838c016131a1565b909850965060408a013591508082111561354057600080fd5b61354c8b838c016131a1565b909650945060608a013591508082111561356557600080fd5b506135728a828b016131a1565b989b979a50959850939692959293505050565b6000806000806060858703121561359b57600080fd5b84356135a68161322d565b93506020850135925060408501356001600160401b03808211156135c957600080fd5b818701915087601f8301126135dd57600080fd5b8135818111156135ec57600080fd5b8860208285010111156135fe57600080fd5b95989497505060200194505050565b60005b83811015613628578181015183820152602001613610565b838111156120335750506000910152565b6000815180845261365181602086016020860161360d565b601f01601f19169290920160200192915050565b8215158152604060208201526000612e576040830184613639565b600080828403608081121561369457600080fd5b833561369f8161322d565b92506060601f19820112156133bd57600080fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260159082015274092dcecc2d8d2c840eecad2ced0e840d8cadccee8d605b1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561373f57600080fd5b813563ffffffff81168114611f1757600080fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561377c5761377c613753565b500190565b600060001982141561379557613795613753565b5060010190565b6000602082840312156137ae57600080fd5b5051919050565b60208082526010908201526f496e76616c696420616464726573732160801b604082015260600190565b60008235607e198336030181126137f557600080fd5b9190910192915050565b60008282101561381157613811613753565b500390565b634e487b7160e01b600052600160045260246000fd5b602080825260139082015272115512081d1c985b9cd9995c8819985a5b1959606a1b604082015260600190565b80546001600160a01b0319166001600160a01b0392909216919091179055565b81356138848161322d565b61388e8183613859565b50602082013561ffff811681146138a457600080fd5b815461ffff60a01b191660a09190911b61ffff60a01b1617905550565b634e487b7160e01b600052604160045260246000fd5b60008160001904831182151516156138f1576138f1613753565b500290565b60008261391357634e487b7160e01b600052601260045260246000fd5b500490565b8183823760009101908152919050565b81356139338161322d565b61393d8183613859565b50602082013561394c8161322d565b6139598160018401613859565b5060408201356139688161322d565b611e7c8160028401613859565b81835260006001600160fb1b0383111561398e57600080fd5b8260051b8083602087013760009401602001938452509192915050565b6001600160a01b03848116825260406020808401829052838201859052600092606091828601600588811b880185018a885b8b811015613a90578a8303605f190185528135368e9003607e19018112613a0357600080fd5b8d0160808135613a128161322d565b8916855281880135888601528a8201358b8601528982013536839003601e19018112613a3d57600080fd5b820180356001600160401b03811115613a5557600080fd5b80881b3603841315613a6657600080fd5b828c880152613a7a838801828c8501613975565b988a0198965050509287019250506001016139dd565b50909c9b505050505050505050505050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015613af25784516001600160a01b031683529383019391830191600101613acd565b50506001600160a01b03969096166060850152505050608001529392505050565b60006020808385031215613b2657600080fd5b82516001600160401b0380821115613b3d57600080fd5b818501915085601f830112613b5157600080fd5b815181811115613b6357613b636138c1565b8060051b604051601f19603f83011681018181108582111715613b8857613b886138c1565b604052918252848201925083810185019188831115613ba657600080fd5b938501935b82851015613bc457845184529385019392850192613bab565b98975050505050505050565b600060208284031215613be257600080fd5b8151611f17816132d1565b600082516137f581846020870161360d565b602081526000611f17602083018461363956fe000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52a26469706673582212203281c326d869f7e0737e478a7088b9dd4ebcd3191cedf2668f26f2fbcbc2455d64736f6c63430008090033
Verified Source Code Partial Match
Compiler: v0.8.9+commit.e5eed63a
EVM: london
Optimization: Yes (200 runs)
IWETH.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.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);
}
Address.sol 189 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
Ownable.sol 68 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
ISwapper.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface ISwapper {
function buy(uint256 amount) external returns (uint256);
function sell(uint256 amount) external returns (uint256);
}
UnionZap.sol 661 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "Ownable.sol";
import "SafeERC20.sol";
import "IMultiMerkleStash.sol";
import "IMerkleDistributorV2.sol";
import "IUniV2Router.sol";
import "IWETH.sol";
import "ICvxCrvDeposit.sol";
import "IVotiumRegistry.sol";
import "IUniV3Router.sol";
import "ICurveV2Pool.sol";
import "ISwapper.sol";
import "UnionBase.sol";
contract UnionZap is Ownable, UnionBase {
using SafeERC20 for IERC20;
address public votiumDistributor =
0x378Ba9B73309bE80BF4C2c027aAD799766a7ED5A;
address private constant SUSHI_ROUTER =
0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F;
address private constant CVXCRV_DEPOSIT =
0x8014595F2AB54cD7c604B00E9fb932176fDc86Ae;
address public constant VOTIUM_REGISTRY =
0x92e6E43f99809dF84ed2D533e1FD8017eb966ee2;
address private constant T_TOKEN =
0xCdF7028ceAB81fA0C6971208e83fa7872994beE5;
address private constant T_ETH_POOL =
0x752eBeb79963cf0732E9c0fec72a49FD1DEfAEAC;
address private constant UNISWAP_ROUTER =
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private constant UNIV3_ROUTER =
0xE592427A0AEce92De3Edee1F18E0157C05861564;
address private constant WETH_TOKEN =
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address[] public outputTokens;
address public platform = 0x9Bc7c6ad7E7Cf3A6fCB58fb21e27752AC1e53f99;
uint256 private constant DECIMALS = 1e9;
uint256 public platformFee = 2e7;
mapping(uint256 => address) private routers;
mapping(uint256 => uint24) private fees;
struct tokenContracts {
address pool;
address swapper;
address distributor;
}
struct curveSwapParams {
address pool;
uint16 ethIndex;
}
mapping(address => tokenContracts) public tokenInfo;
mapping(address => curveSwapParams) public curveRegistry;
event Received(address sender, uint256 amount);
event Distributed(uint256 amount, address token, address distributor);
event VotiumDistributorUpdated(address distributor);
event FundsRetrieved(address token, address to, uint256 amount);
event CurvePoolUpdated(address token, address pool);
event OutputTokenUpdated(
address token,
address pool,
address swapper,
address distributor
);
event PlatformFeeUpdated(uint256 _fee);
event PlatformUpdated(address indexed _platform);
constructor() {
routers[0] = SUSHI_ROUTER;
routers[1] = UNISWAP_ROUTER;
fees[0] = 3000;
fees[1] = 10000;
curveRegistry[CVX_TOKEN] = curveSwapParams(CURVE_CVX_ETH_POOL, 0);
curveRegistry[T_TOKEN] = curveSwapParams(T_ETH_POOL, 0);
}
/// @notice Add a pool and its swap params to the registry
/// @param token - Address of the token to swap on Curve
/// @param params - Address of the pool and WETH index there
function addCurvePool(address token, curveSwapParams calldata params)
external
onlyOwner
{
curveRegistry[token] = params;
IERC20(token).safeApprove(params.pool, 0);
IERC20(token).safeApprove(params.pool, type(uint256).max);
emit CurvePoolUpdated(token, params.pool);
}
/// @notice Add or update contracts used for distribution of output tokens
/// @param token - Address of the output token
/// @param params - The Curve pool and distributor associated w/ the token
/// @dev No removal options to avoid indexing errors with swaps, pass 0 weight for unused assets
/// @dev Pool needs to be Curve v2 pool with price oracle
function updateOutputToken(address token, tokenContracts calldata params)
external
onlyOwner
{
assert(params.pool != address(0));
// if we don't have any pool info, it's an addition
if (tokenInfo[token].pool == address(0)) {
outputTokens.push(token);
}
tokenInfo[token] = params;
emit OutputTokenUpdated(
token,
params.pool,
params.swapper,
params.distributor
);
}
/// @notice Remove a pool from the registry
/// @param token - Address of token associated with the pool
function removeCurvePool(address token) external onlyOwner {
IERC20(token).safeApprove(curveRegistry[token].pool, 0);
delete curveRegistry[token];
emit CurvePoolUpdated(token, address(0));
}
/// @notice Change forwarding address in Votium registry
/// @param _to - address that will be forwarded to
/// @dev To be used in case of migration, rewards can be forwarded to
/// new contracts
function setForwarding(address _to) external onlyOwner {
IVotiumRegistry(VOTIUM_REGISTRY).setRegistry(_to);
}
/// @notice Updates the part of incentives redirected to the platform
/// @param _fee - the amount of the new platform fee (in BIPS)
function setPlatformFee(uint256 _fee) external onlyOwner {
platformFee = _fee;
emit PlatformFeeUpdated(_fee);
}
/// @notice Updates the address to which platform fees are paid out
/// @param _platform - the new platform wallet address
function setPlatform(address _platform)
external
onlyOwner
notToZeroAddress(_platform)
{
platform = _platform;
emit PlatformUpdated(_platform);
}
/// @notice Update the votium contract address to claim for
/// @param _distributor - Address of the new contract
function updateVotiumDistributor(address _distributor)
external
onlyOwner
notToZeroAddress(_distributor)
{
votiumDistributor = _distributor;
emit VotiumDistributorUpdated(_distributor);
}
/// @notice Withdraws specified ERC20 tokens to the multisig
/// @param tokens - the tokens to retrieve
/// @param to - address to send the tokens to
/// @dev This is needed to handle tokens that don't have ETH pairs on sushi
/// or need to be swapped on other chains (NBST, WormholeLUNA...)
function retrieveTokens(address[] calldata tokens, address to)
external
onlyOwner
notToZeroAddress(to)
{
for (uint256 i; i < tokens.length; ++i) {
address token = tokens[i];
uint256 tokenBalance = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransfer(to, tokenBalance);
emit FundsRetrieved(token, to, tokenBalance);
}
}
/// @notice Execute calls on behalf of contract in case of emergency
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyOwner returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value: _value}(_data);
return (success, result);
}
/// @notice Set approvals for the tokens used when swapping
function setApprovals() external onlyOwner {
IERC20(CRV_TOKEN).safeApprove(CURVE_CVXCRV_CRV_POOL, 0);
IERC20(CRV_TOKEN).safeApprove(CURVE_CVXCRV_CRV_POOL, type(uint256).max);
IERC20(CRV_TOKEN).safeApprove(CURVE_TRICRV_POOL, 0);
IERC20(CRV_TOKEN).safeApprove(CURVE_TRICRV_POOL, type(uint256).max);
IERC20(CRV_TOKEN).safeApprove(CVXCRV_DEPOSIT, 0);
IERC20(CRV_TOKEN).safeApprove(CVXCRV_DEPOSIT, type(uint256).max);
IERC20(CVXCRV_TOKEN).safeApprove(CURVE_CVXCRV_CRV_POOL, 0);
IERC20(CVXCRV_TOKEN).safeApprove(
CURVE_CVXCRV_CRV_POOL,
type(uint256).max
);
IERC20(CVXCRV_TOKEN).safeApprove(CVXCRV_STAKING_CONTRACT, 0);
IERC20(CVXCRV_TOKEN).safeApprove(
CVXCRV_STAKING_CONTRACT,
type(uint256).max
);
}
/// @notice Swap a token for ETH on Curve
/// @dev Needs the token to have been added to the registry with params
/// @param token - address of the token to swap
/// @param amount - amount of the token to swap
function _swapToETHCurve(address token, uint256 amount) internal {
curveSwapParams memory params = curveRegistry[token];
require(params.pool != address(0));
IERC20(token).safeApprove(params.pool, 0);
IERC20(token).safeApprove(params.pool, amount);
ICurveV2Pool(params.pool).exchange_underlying(
params.ethIndex ^ 1,
params.ethIndex,
amount,
0
);
}
/// @notice Swap a token for ETH
/// @param token - address of the token to swap
/// @param amount - amount of the token to swap
/// @dev Swaps are executed via Sushi or UniV2 router, will revert if pair
/// does not exist. Tokens must have a WETH pair.
function _swapToETH(
address token,
uint256 amount,
address router
) internal notToZeroAddress(router) {
address[] memory _path = new address[](2);
_path[0] = token;
_path[1] = WETH_TOKEN;
IERC20(token).safeApprove(router, 0);
IERC20(token).safeApprove(router, amount);
IUniV2Router(router).swapExactTokensForETH(
amount,
1,
_path,
address(this),
block.timestamp + 1
);
}
/// @notice Swap a token for ETH on UniSwap V3
/// @param token - address of the token to swap
/// @param amount - amount of the token to swap
/// @param fee - the pool's fee
function _swapToETHUniV3(
address token,
uint256 amount,
uint24 fee
) internal {
IERC20(token).safeApprove(UNIV3_ROUTER, 0);
IERC20(token).safeApprove(UNIV3_ROUTER, amount);
IUniV3Router.ExactInputSingleParams memory _params = IUniV3Router
.ExactInputSingleParams(
token,
WETH_TOKEN,
fee,
address(this),
block.timestamp + 1,
amount,
1,
0
);
uint256 _wethReceived = IUniV3Router(UNIV3_ROUTER).exactInputSingle(
_params
);
IWETH(WETH_TOKEN).withdraw(_wethReceived);
}
function _isEffectiveOutputToken(address _token, uint32[] calldata _weights)
internal
returns (bool)
{
for (uint256 j; j < _weights.length; ++j) {
if (_token == outputTokens[j] && _weights[j] > 0) {
return true;
}
}
return false;
}
/// @notice Claims all specified rewards from Votium
/// @param claimParams - an array containing the info necessary to claim for
/// each available token
/// @dev Used to retrieve tokens that need to be transferred
function claim(IMultiMerkleStash.claimParam[] calldata claimParams)
public
onlyOwner
{
require(claimParams.length > 0, "No claims");
// claim all from votium
IMultiMerkleStash(votiumDistributor).claimMulti(
address(this),
claimParams
);
}
/// @notice Claims all specified rewards and swaps them to ETH
/// @param claimParams - an array containing the info necessary to claim
/// @param routerChoices - the router to use for the swap
/// @param claimBeforeSwap - whether to claim on Votium or not
/// @param minAmountOut - min output amount in ETH value
/// @param gasRefund - tx gas cost to refund to caller (ETH amount)
/// @param weights - weight of output assets (cvxCRV, FXS, CVX...) in bips
/// @dev routerChoices is a 3-bit bitmap such that
/// 0b000 (0) - Sushi
/// 0b001 (1) - UniV2
/// 0b010 (2) - UniV3 0.3%
/// 0b011 (3) - UniV3 1%
/// 0b100 (4) - Curve
/// Ex: 136 = 010 001 000 will swap token 1 on UniV3, 2 on UniV3, last on Sushi
/// Passing 0 will execute all swaps on sushi
/// @dev claimBeforeSwap is used in case 3rd party already claimed on Votium
/// @dev weights must sum to 10000
/// @dev gasRefund is computed off-chain w/ tenderly
function swap(
IMultiMerkleStash.claimParam[] calldata claimParams,
uint256 routerChoices,
bool claimBeforeSwap,
uint256 minAmountOut,
uint256 gasRefund,
uint32[] calldata weights
) public onlyOwner {
require(weights.length == outputTokens.length, "Invalid weight length");
// claim if applicable
if (claimBeforeSwap) {
claim(claimParams);
}
// swap all claims to ETH
for (uint256 i; i < claimParams.length; ++i) {
address _token = claimParams[i].token;
uint256 _balance = IERC20(_token).balanceOf(address(this));
// avoid wasting gas / reverting if no balance
if (_balance <= 1) {
continue;
} else {
// leave one gwei to lower future claim gas costs
// https://twitter.com/libevm/status/1474870670429360129?s=21
_balance -= 1;
}
// unwrap WETH
if (_token == WETH_TOKEN) {
IWETH(WETH_TOKEN).withdraw(_balance);
}
// we handle swaps for output tokens later when distributing
// so any non-zero output token will be skipped here
else {
// skip if output token
if (_isEffectiveOutputToken(_token, weights)) {
continue;
}
// otherwise execute the swaps
uint256 _choice = routerChoices & 7;
if (_choice >= 4) {
_swapToETHCurve(_token, _balance);
} else if (_choice >= 2) {
_swapToETHUniV3(_token, _balance, fees[_choice - 2]);
} else {
_swapToETH(_token, _balance, routers[_choice]);
}
routerChoices = routerChoices >> 3;
}
}
// slippage check
assert(address(this).balance > minAmountOut);
(bool success, ) = (tx.origin).call{value: gasRefund}("");
require(success, "ETH transfer failed");
}
/// @notice Internal function used to sell output tokens for ETH
/// @param _token - the token to sell
/// @param _amount - how much of that token to sell
function _sell(address _token, uint256 _amount) internal {
if (_token == CRV_TOKEN) {
_crvToEth(_amount, 0);
} else if (_token == CVX_TOKEN) {
_swapToETHCurve(_token, _amount);
} else {
IERC20(_token).safeTransfer(tokenInfo[_token].swapper, _amount);
ISwapper(tokenInfo[_token].swapper).sell(_amount);
}
}
/// @notice Internal function used to buy output tokens from ETH
/// @param _token - the token to sell
/// @param _amount - how much of that token to sell
function _buy(address _token, uint256 _amount) internal {
if (_token == CRV_TOKEN) {
_ethToCrv(_amount, 0);
} else if (_token == CVX_TOKEN) {
_ethToCvx(_amount, 0);
} else {
(bool success, ) = tokenInfo[_token].swapper.call{value: _amount}(
""
);
require(success, "ETH transfer failed");
ISwapper(tokenInfo[_token].swapper).buy(_amount);
}
}
/// @notice Swap or lock all CRV for cvxCRV
/// @param _minAmountOut - the min amount of cvxCRV expected
/// @param _lock - whether to lock or swap
/// @return the amount of cvxCrv obtained
function _toCvxCrv(uint256 _minAmountOut, bool _lock)
internal
returns (uint256)
{
uint256 _crvBalance = IERC20(CRV_TOKEN).balanceOf(address(this));
// swap on Curve if there is a premium for doing so
if (!_lock) {
return _swapCrvToCvxCrv(_crvBalance, address(this), _minAmountOut);
}
// otherwise deposit & lock
// slippage check
assert(_crvBalance > _minAmountOut);
ICvxCrvDeposit(CVXCRV_DEPOSIT).deposit(_crvBalance, true);
return _crvBalance;
}
/// @notice Compute and takes fees if possible
/// @dev If not enough ETH to take fees, can be applied on merkle distribution
/// @param _totalEthBalance - the total ETH value of assets in the contract
/// @return the ETH value of fees
function _levyFees(uint256 _totalEthBalance) internal returns (uint256) {
uint256 _feeAmount = (_totalEthBalance * platformFee) / DECIMALS;
if (address(this).balance >= _feeAmount) {
(bool success, ) = (platform).call{value: _feeAmount}("");
require(success, "ETH transfer failed");
return _feeAmount;
}
return 0;
}
function _balanceSalesAndBuy(
bool lock,
uint32[] calldata weights,
uint32[] calldata adjustOrder,
uint256[] calldata minAmounts,
uint256[] memory prices,
uint256[] memory amounts,
uint256 _totalEthBalance
) internal {
address _outputToken;
uint256 _orderIndex;
for (uint256 i; i < adjustOrder.length; ++i) {
_orderIndex = adjustOrder[i];
// if weight == 0, the token would have been swapped already so no balance
if (weights[_orderIndex] > 0) {
_outputToken = outputTokens[_orderIndex];
// amount adjustments
uint256 _desired = (_totalEthBalance * weights[_orderIndex]) /
DECIMALS;
if (amounts[_orderIndex] > _desired) {
_sell(
_outputToken,
(((amounts[_orderIndex] - _desired) * 1e18) /
prices[_orderIndex])
);
} else {
uint256 _swapAmount = _desired - amounts[_orderIndex];
if (i == adjustOrder.length - 1) {
_swapAmount = address(this).balance;
}
_buy(_outputToken, _swapAmount);
}
// we need an edge case here since it's too late
// to update the cvxCRV distributor's stake function
if (_outputToken == CRV_TOKEN) {
// convert all CRV to cvxCRV
_toCvxCrv(minAmounts[_orderIndex], lock);
} else {
// slippage check
assert(
IERC20(_outputToken).balanceOf(address(this)) >
minAmounts[_orderIndex]
);
}
}
}
}
/// @notice Gets ETH token price from curve pools with edge case for CRV pool
/// @param _outputToken the token to get a price for
/// @return the ETH price of the token
function _getPriceFromOracle(address _outputToken)
internal
returns (uint256)
{
if (_outputToken != CRV_TOKEN) {
return ICurveV2Pool(tokenInfo[_outputToken].pool).price_oracle();
} else {
ICurveTriCryptoFactoryNG _pool = ICurveTriCryptoFactoryNG(
tokenInfo[_outputToken].pool
);
return (_pool.price_oracle(1) * 1e18) / _pool.price_oracle(0);
}
}
/// @notice Splits contract balance into output tokens as per weights
/// @param lock - whether to lock or swap crv to cvxcrv
/// @param weights - weight of output assets (cvxCRV, FXS, CVX) in bips
/// @param adjustOrder - order in which to process output tokens when adjusting
/// @param minAmounts - min amount out of each output token (cvxCRV for CRV)
/// @dev weights must sum to 10000
/// @dev for adjustOrder token to be processed first should have smallest weight
/// but largest balance in contract.
function adjust(
bool lock,
uint32[] calldata weights,
uint32[] calldata adjustOrder,
uint256[] calldata minAmounts
) public onlyOwner validWeights(weights) {
require(
minAmounts.length == outputTokens.length,
"Invalid min amounts"
);
require(
adjustOrder.length == outputTokens.length,
"Invalid order length"
);
// start calculating the allocations of output tokens
uint256 _totalEthBalance = address(this).balance;
uint256[] memory prices = new uint256[](outputTokens.length);
uint256[] memory amounts = new uint256[](outputTokens.length);
address _outputToken;
// first loop to calculate total ETH amounts and store oracle prices
for (uint256 i; i < weights.length; ++i) {
_outputToken = outputTokens[i];
uint256 _curBalance = IERC20(_outputToken).balanceOf(address(this));
if ((weights[i] > 0) && (_curBalance > 1)) {
prices[i] = _getPriceFromOracle(_outputToken);
// compute ETH value of current token balance
amounts[i] = (_curBalance * prices[i]) / 1e18;
// add the ETH value of token to current ETH value in contract
_totalEthBalance += amounts[i];
}
}
// deduce fees if applicable
_totalEthBalance -= _levyFees(_totalEthBalance);
// second loop to balance the amounts with buys and sells before distribution
// according to order of liquidation specified in adjustOrder
_balanceSalesAndBuy(
lock,
weights,
adjustOrder,
minAmounts,
prices,
amounts,
_totalEthBalance
);
}
/// @notice Deposits rewards to their respective merkle distributors
/// @param weights - weights of output assets (cvxCRV, FXS, CVX...)
function distribute(uint32[] calldata weights)
public
onlyOwner
validWeights(weights)
{
for (uint256 i; i < weights.length; ++i) {
if (weights[i] > 0) {
address _outputToken = outputTokens[i];
address _distributor = tokenInfo[_outputToken].distributor;
IMerkleDistributorV2(_distributor).freeze();
// edge case for CRV as we gotta keep using existing distributor
if (_outputToken == CRV_TOKEN) {
_outputToken = CVXCRV_TOKEN;
}
uint256 _balance = IERC20(_outputToken).balanceOf(
address(this)
);
// transfer to distributor
IERC20(_outputToken).safeTransfer(_distributor, _balance);
// stake
IMerkleDistributorV2(_distributor).stake();
emit Distributed(_balance, _outputToken, _distributor);
}
}
}
/// @notice Swaps all bribes, adjust according to output token weights and distribute
/// @dev Wrapper over the swap, adjust & distribute function
/// @param claimParams - an array containing the info necessary to claim
/// @param routerChoices - the router to use for the swap
/// @param claimBeforeSwap - whether to claim on Votium or not
/// @param gasRefund - tx gas cost to refund to caller (ETH amount)
/// @param weights - weight of output assets (cvxCRV, FXS, CVX...) in bips
/// @param adjustOrder - order in which to process output tokens when adjusting
/// @param minAmounts - min amount out of each output token (cvxCRV for CRV)
function processIncentives(
IMultiMerkleStash.claimParam[] calldata claimParams,
uint256 routerChoices,
bool claimBeforeSwap,
bool lock,
uint256 gasRefund,
uint32[] calldata weights,
uint32[] calldata adjustOrder,
uint256[] calldata minAmounts
) external onlyOwner {
require(
minAmounts.length == outputTokens.length,
"Invalid min amounts"
);
swap(
claimParams,
routerChoices,
claimBeforeSwap,
0,
gasRefund,
weights
);
adjust(lock, weights, adjustOrder, minAmounts);
distribute(weights);
}
receive() external payable {
emit Received(msg.sender, msg.value);
}
modifier validWeights(uint32[] calldata _weights) {
require(
_weights.length == outputTokens.length,
"Invalid weight length"
);
uint256 _totalWeights;
for (uint256 i; i < _weights.length; ++i) {
_totalWeights += _weights[i];
}
require(_totalWeights == DECIMALS, "Invalid weights");
_;
}
}
SafeERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "IERC20.sol";
import "Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
UnionBase.sol 239 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "ICurveV2Pool.sol";
import "ICurveFactoryPool.sol";
import "IBasicRewards.sol";
import "ICurveTriCryptoFactoryNG.sol";
// Common variables and functions
contract UnionBase {
address public constant CVXCRV_STAKING_CONTRACT =
0x3Fe65692bfCD0e6CF84cB1E7d24108E434A7587e;
address public constant CURVE_TRICRV_POOL =
0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14;
address public constant CURVE_CVX_ETH_POOL =
0xB576491F1E6e5E62f1d8F26062Ee822B40B0E0d4;
address public constant CURVE_CVXCRV_CRV_POOL =
0x971add32Ea87f10bD192671630be3BE8A11b8623;
address public constant CRV_TOKEN =
0xD533a949740bb3306d119CC777fa900bA034cd52;
address public constant CVXCRV_TOKEN =
0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7;
address public constant CVX_TOKEN =
0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;
uint256 private constant TRICRV_ETH_INDEX = 1;
uint256 private constant TRICRV_CRV_INDEX = 2;
int128 public constant CVXCRV_CRV_INDEX = 0;
int128 public constant CVXCRV_CVXCRV_INDEX = 1;
uint256 public constant CVXETH_ETH_INDEX = 0;
uint256 public constant CVXETH_CVX_INDEX = 1;
IBasicRewards cvxCrvStaking = IBasicRewards(CVXCRV_STAKING_CONTRACT);
ICurveV2Pool cvxEthSwap = ICurveV2Pool(CURVE_CVX_ETH_POOL);
ICurveTriCryptoFactoryNG crvEthSwap =
ICurveTriCryptoFactoryNG(CURVE_TRICRV_POOL);
ICurveFactoryPool crvCvxCrvSwap = ICurveFactoryPool(CURVE_CVXCRV_CRV_POOL);
/// @notice Swap CRV for cvxCRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @return amount of CRV obtained after the swap
function _swapCrvToCvxCrv(uint256 amount, address recipient)
internal
returns (uint256)
{
return _crvToCvxCrv(amount, recipient, 0);
}
/// @notice Swap CRV for cvxCRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _swapCrvToCvxCrv(
uint256 amount,
address recipient,
uint256 minAmountOut
) internal returns (uint256) {
return _crvToCvxCrv(amount, recipient, minAmountOut);
}
/// @notice Swap CRV for cvxCRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _crvToCvxCrv(
uint256 amount,
address recipient,
uint256 minAmountOut
) internal returns (uint256) {
return
crvCvxCrvSwap.exchange(
CVXCRV_CRV_INDEX,
CVXCRV_CVXCRV_INDEX,
amount,
minAmountOut,
recipient
);
}
/// @notice Swap cvxCRV for CRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @return amount of CRV obtained after the swap
function _swapCvxCrvToCrv(uint256 amount, address recipient)
internal
returns (uint256)
{
return _cvxCrvToCrv(amount, recipient, 0);
}
/// @notice Swap cvxCRV for CRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _swapCvxCrvToCrv(
uint256 amount,
address recipient,
uint256 minAmountOut
) internal returns (uint256) {
return _cvxCrvToCrv(amount, recipient, minAmountOut);
}
/// @notice Swap cvxCRV for CRV on Curve
/// @param amount - amount to swap
/// @param recipient - where swapped tokens will be sent to
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _cvxCrvToCrv(
uint256 amount,
address recipient,
uint256 minAmountOut
) internal returns (uint256) {
return
crvCvxCrvSwap.exchange(
CVXCRV_CVXCRV_INDEX,
CVXCRV_CRV_INDEX,
amount,
minAmountOut,
recipient
);
}
/// @notice Swap CRV for native ETH on Curve
/// @param amount - amount to swap
/// @return amount of ETH obtained after the swap
function _swapCrvToEth(uint256 amount) internal returns (uint256) {
return _crvToEth(amount, 0);
}
/// @notice Swap CRV for native ETH on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of ETH obtained after the swap
function _swapCrvToEth(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return _crvToEth(amount, minAmountOut);
}
/// @notice Swap CRV for native ETH on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of ETH obtained after the swap
function _crvToEth(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return
crvEthSwap.exchange{value: 0}(
TRICRV_CRV_INDEX,
TRICRV_ETH_INDEX,
amount,
minAmountOut,
true
);
}
/// @notice Swap native ETH for CRV on Curve
/// @param amount - amount to swap
/// @return amount of CRV obtained after the swap
function _swapEthToCrv(uint256 amount) internal returns (uint256) {
return _ethToCrv(amount, 0);
}
/// @notice Swap native ETH for CRV on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _swapEthToCrv(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return _ethToCrv(amount, minAmountOut);
}
/// @notice Swap native ETH for CRV on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _ethToCrv(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return
crvEthSwap.exchange{value: amount}(
TRICRV_ETH_INDEX,
TRICRV_CRV_INDEX,
amount,
minAmountOut,
true
);
}
/// @notice Swap native ETH for CVX on Curve
/// @param amount - amount to swap
/// @return amount of CRV obtained after the swap
function _swapEthToCvx(uint256 amount) internal returns (uint256) {
return _ethToCvx(amount, 0);
}
/// @notice Swap native ETH for CVX on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _swapEthToCvx(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return _ethToCvx(amount, minAmountOut);
}
/// @notice Swap native ETH for CVX on Curve
/// @param amount - amount to swap
/// @param minAmountOut - minimum expected amount of output tokens
/// @return amount of CRV obtained after the swap
function _ethToCvx(uint256 amount, uint256 minAmountOut)
internal
returns (uint256)
{
return
cvxEthSwap.exchange_underlying{value: amount}(
CVXETH_ETH_INDEX,
CVXETH_CVX_INDEX,
amount,
minAmountOut
);
}
modifier notToZeroAddress(address _to) {
require(_to != address(0), "Invalid address!");
_;
}
}
ICurveV2Pool.sol 62 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface ICurveV2Pool {
function get_dy(
uint256 i,
uint256 j,
uint256 dx
) external view returns (uint256);
function calc_token_amount(uint256[2] calldata amounts)
external
view
returns (uint256);
function exchange_underlying(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy
) external payable returns (uint256);
function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount)
external
returns (uint256);
function lp_price() external view returns (uint256);
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy
) external payable returns (uint256);
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy,
bool use_eth
) external payable returns (uint256);
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy,
bool use_eth,
address receiver
) external payable returns (uint256);
function price_oracle() external view returns (uint256);
function remove_liquidity_one_coin(
uint256 token_amount,
uint256 i,
uint256 min_amount,
bool use_eth,
address receiver
) external returns (uint256);
}
IUniV2Router.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IUniV2Router {
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function getAmountsOut(uint256 amountIn, address[] memory path)
external
view
returns (uint256[] memory amounts);
}
IUniV3Router.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IUniV3Router {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
function exactInputSingle(ExactInputSingleParams calldata params)
external
payable
returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
function exactInput(ExactInputParams calldata params)
external
payable
returns (uint256 amountOut);
}
IBasicRewards.sol 26 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.9;
interface IBasicRewards {
function stakeFor(address, uint256) external returns (bool);
function balanceOf(address) external view returns (uint256);
function earned(address) external view returns (uint256);
function withdrawAll(bool) external returns (bool);
function withdraw(uint256, bool) external returns (bool);
function withdrawAndUnwrap(uint256 amount, bool claim)
external
returns (bool);
function getReward() external returns (bool);
function stake(uint256) external returns (bool);
function extraRewards(uint256) external view returns (address);
function exit() external returns (bool);
}
ICvxCrvDeposit.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface ICvxCrvDeposit {
function deposit(uint256, bool) external;
}
IVotiumRegistry.sol 17 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IVotiumRegistry {
struct Registry {
uint256 start;
address to;
uint256 expiration;
}
function registry(address _from)
external
view
returns (Registry memory registry);
function setRegistry(address _to) external;
}
ICurveFactoryPool.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface ICurveFactoryPool {
function get_dy(
int128 i,
int128 j,
uint256 dx
) external view returns (uint256);
function get_balances() external view returns (uint256[2] memory);
function add_liquidity(
uint256[2] memory _amounts,
uint256 _min_mint_amount,
address _receiver
) external returns (uint256);
function exchange(
int128 i,
int128 j,
uint256 _dx,
uint256 _min_dy,
address _receiver
) external returns (uint256);
}
IMultiMerkleStash.sol 41 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IMultiMerkleStash {
struct claimParam {
address token;
uint256 index;
uint256 amount;
bytes32[] merkleProof;
}
function isClaimed(address token, uint256 index)
external
view
returns (bool);
function claim(
address token,
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
function claimMulti(address account, claimParam[] calldata claims) external;
function updateMerkleRoot(address token, bytes32 _merkleRoot) external;
event Claimed(
address indexed token,
uint256 index,
uint256 amount,
address indexed account,
uint256 indexed update
);
event MerkleRootUpdated(
address indexed token,
bytes32 indexed merkleRoot,
uint256 indexed update
);
}
IMerkleDistributorV2.sol 81 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IMerkleDistributorV2 {
enum Option {
Claim,
ClaimAsETH,
ClaimAsCRV,
ClaimAsCVX,
ClaimAndStake
}
function vault() external view returns (address);
function merkleRoot() external view returns (bytes32);
function week() external view returns (uint32);
function frozen() external view returns (bool);
function isClaimed(uint256 index) external view returns (bool);
function setApprovals() external;
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
function claimAs(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof,
Option option
) external;
function claimAs(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof,
Option option,
uint256 minAmountOut
) external;
function freeze() external;
function unfreeze() external;
function stake() external;
function updateMerkleRoot(bytes32 newMerkleRoot, bool unfreeze) external;
function updateDepositor(address newDepositor) external;
function updateAdmin(address newAdmin) external;
function updateVault(address newVault) external;
event Claimed(
uint256 index,
uint256 amount,
address indexed account,
uint256 indexed week,
Option option
);
event DepositorUpdated(
address indexed oldDepositor,
address indexed newDepositor
);
event AdminUpdated(address indexed oldAdmin, address indexed newAdmin);
event VaultUpdated(address indexed oldVault, address indexed newVault);
event MerkleRootUpdated(bytes32 indexed merkleRoot, uint32 indexed week);
}
ICurveTriCryptoFactoryNG.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface ICurveTriCryptoFactoryNG {
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy,
bool use_eth
) external payable returns (uint256);
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy,
bool use_eth,
address receiver
) external payable returns (uint256);
function get_dy(
uint256 i,
uint256 j,
uint256 dx
) external view returns (uint256);
function price_oracle(uint256 k) external view returns (uint256);
}
Read Contract
CRV_TOKEN 0x657428a3 → address
CURVE_CVXCRV_CRV_POOL 0x7506ceb9 → address
CURVE_CVX_ETH_POOL 0x961deefe → address
CURVE_TRICRV_POOL 0xa350bee0 → address
CVXCRV_CRV_INDEX 0xd8697a50 → int128
CVXCRV_CVXCRV_INDEX 0x93516676 → int128
CVXCRV_STAKING_CONTRACT 0xc70eddff → address
CVXCRV_TOKEN 0x7ec5508a → address
CVXETH_CVX_INDEX 0x6acabc2e → uint256
CVXETH_ETH_INDEX 0x1857b308 → uint256
CVX_TOKEN 0x0960b7fa → address
VOTIUM_REGISTRY 0x316f244d → address
curveRegistry 0x455c3eb5 → address, uint16
outputTokens 0x28c34c08 → address
owner 0x8da5cb5b → address
platform 0x4bde38c8 → address
platformFee 0x26232a2e → uint256
tokenInfo 0xf5dab711 → address, address, address
votiumDistributor 0x1a316fbc → address
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
addCurvePool 0x1712ed2b
address token
tuple params
adjust 0xa72bcc3a
bool lock
uint32[] weights
uint32[] adjustOrder
uint256[] minAmounts
claim 0x750d96bf
tuple[] claimParams
distribute 0x0303f1e2
uint32[] weights
execute 0xb61d27f6
address _to
uint256 _value
bytes _data
returns: bool, bytes
processIncentives 0x8a1d281b
tuple[] claimParams
uint256 routerChoices
bool claimBeforeSwap
bool lock
uint256 gasRefund
uint32[] weights
uint32[] adjustOrder
uint256[] minAmounts
removeCurvePool 0xddd2c684
address token
renounceOwnership 0x715018a6
No parameters
retrieveTokens 0x15d89591
address[] tokens
address to
setApprovals 0x8757b15b
No parameters
setForwarding 0x10e79426
address _to
setPlatform 0x6945c5ea
address _platform
setPlatformFee 0x12e8e2c3
uint256 _fee
swap 0x3030119b
tuple[] claimParams
uint256 routerChoices
bool claimBeforeSwap
uint256 minAmountOut
uint256 gasRefund
uint32[] weights
transferOwnership 0xf2fde38b
address newOwner
updateOutputToken 0x63496898
address token
tuple params
updateVotiumDistributor 0x9b0fe088
address _distributor
Recent Transactions
No transactions found for this address