Address Contract Verified
Address
0xba629E206dfB3C6b1B874e6f44a734EAdbE75bEF
Balance
0 ETH
Nonce
1
Code Size
13770 bytes
Creator
0x243A1833...2806 at tx 0x2f96acc1...ada9ed
Indexed Transactions
0
Contract Bytecode
13770 bytes
0x6080604052600436106100a05760003560e01c8063391cdc0811610064578063391cdc08146101a55780636b1430d6146101d05780638815eb39146101f9578063bb09d9b714610224578063cabb9e7a1461024f578063d0e30db01461028c576100a7565b806307baa84b146100ac5780631025e095146100d75780631ab0b1b1146101005780632079fb9a1461012b5780632ff2226a14610168576100a7565b366100a757005b600080fd5b3480156100b857600080fd5b506100c16102b7565b6040516100ce9190612c32565b60405180910390f35b3480156100e357600080fd5b506100fe60048036038101906100f991906120de565b6102db565b005b34801561010c57600080fd5b5061011561071c565b6040516101229190612c32565b60405180910390f35b34801561013757600080fd5b50610152600480360381019061014d91906121d5565b610740565b60405161015f9190612863565b60405180910390f35b34801561017457600080fd5b5061018f600480360381019061018a9190612067565b61077f565b60405161019c9190612930565b60405180910390f35b3480156101b157600080fd5b506101ba610832565b6040516101c79190612863565b60405180910390f35b3480156101dc57600080fd5b506101f760048036038101906101f29190611fae565b610856565b005b34801561020557600080fd5b5061020e610d58565b60405161021b9190612c32565b60405180910390f35b34801561023057600080fd5b50610239610d5e565b6040516102469190612863565b60405180910390f35b34801561025b57600080fd5b5061027660048036038101906102719190611f85565b610d82565b6040516102839190612915565b60405180910390f35b34801561029857600080fd5b506102a1610e57565b6040516102ae9190612c32565b60405180910390f35b7f0270884a62b952837f1ad48bf28559c86060990af3e63019da59dad9cdd76ed081565b60026000541415610321576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031890612bf2565b60405180910390fd5b600260008190555060028251101561036e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036590612b32565b60405180910390fd5b80518251146103b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a9906129f2565b60405180910390fd5b816001815181106103ec577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1682600081518110610444577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614156104a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049a90612bd2565b60405180910390fd5b428410156104e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104dd90612b52565b60405180910390fd5b60008787878787304660405160200161050597969594939291906127c2565b60405160208183030381529060405280519060200120905061052681611241565b905060005b83518160ff16101561069557600061058683858460ff1681518110610579577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151611271565b9050848260ff16815181106105c4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610639576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063090612a12565b60405180910390fd5b61064281610d82565b610681576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067890612a32565b60405180910390fd5b50808061068d90612fb2565b91505061052b565b506106a284898989611298565b6106cd88888873ffffffffffffffffffffffffffffffffffffffff166113f69092919063ffffffff16565b7ff8eff9ed148da048feccebca2617170aec98bea5840b0b0be8a289ec03c375fd84878a8a6040516107029493929190612c84565b60405180910390a150600160008190555050505050505050565b7f00000000000000000000000000000000000000000000000004e15fea0ec0015081565b6001818154811061075057600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156107ef578686858530466040516020016107d296959493929190612721565b604051602081830303815290604052805190602001209050610825565b8686868686304660405160200161080c97969594939291906127c2565b6040516020818303038152906040528051906020012090505b8091505095945050505050565b7f000000000000000000000000a1d5443f2fb80a5a55ac804c948b45ce4c52dcbb81565b6002600054141561089c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089390612bf2565b60405180910390fd5b60026000819055506002825110156108e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e090612b32565b60405180910390fd5b805182511461092d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610924906129f2565b60405180910390fd5b81600181518110610967577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16826000815181106109bf577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610a1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1590612bd2565b60405180910390fd5b42841015610a61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5890612b52565b60405180910390fd5b6000868686863046604051602001610a7e969594939291906126a6565b604051602081830303815290604052805190602001209050610a9f81611241565b905060005b83518160ff161015610c0e576000610aff83858460ff1681518110610af2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151611271565b9050848260ff1681518110610b3d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba990612a12565b60405180910390fd5b610bbb81610d82565b610bfa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf190612a32565b60405180910390fd5b508080610c0690612fb2565b915050610aa4565b50610c1c8488886000611298565b85471015610c5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5690612a92565b60405180910390fd5b60008773ffffffffffffffffffffffffffffffffffffffff1687604051610c859061284e565b60006040518083038185875af1925050503d8060008114610cc2576040519150601f19603f3d011682016040523d82523d6000602084013e610cc7565b606091505b5050905080610d0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0290612a52565b60405180910390fd5b7f4d7574efc376e1ee5e6eacc9b23ed30ae9f40acfddb028be515fb99a14e2290c858989604051610d3e93929190612c4d565b60405180910390a150506001600081905550505050505050565b60035481565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b600080600090505b600180549050811015610e4c578273ffffffffffffffffffffffffffffffffffffffff1660018281548110610de8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610e39576001915050610e52565b8080610e4490612f69565b915050610d8a565b50600090505b919050565b600060026000541415610e9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9690612bf2565b60405180910390fd5b600260008190555060007f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610f029190612863565b60206040518083038186803b158015610f1a57600080fd5b505afa158015610f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5291906121fe565b905060008111610f97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8e90612b12565b60405180910390fd5b6001461480610fa65750600546145b610fe5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fdc90612ad2565b60405180910390fd5b6110517f000000000000000000000000a1d5443f2fb80a5a55ac804c948b45ce4c52dcbb60007f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1661147c9092919063ffffffff16565b6110bc7f000000000000000000000000a1d5443f2fb80a5a55ac804c948b45ce4c52dcbb827f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1661147c9092919063ffffffff16565b60007f000000000000000000000000a1d5443f2fb80a5a55ac804c948b45ce4c52dcbb90508073ffffffffffffffffffffffffffffffffffffffff16639ed170847f0270884a62b952837f1ad48bf28559c86060990af3e63019da59dad9cdd76ed06003547f00000000000000000000000000000000000000000000000004e15fea0ec00150866040518563ffffffff1660e01b81526004016111629493929190612cc9565b600060405180830381600087803b15801561117c57600080fd5b505af1158015611190573d6000803e3d6000fd5b505050507f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48837f0270884a62b952837f1ad48bf28559c86060990af3e63019da59dad9cdd76ed07f00000000000000000000000000000000000000000000000004e15fea0ec0015060405161122994939291906128d0565b60405180910390a18192505050600160008190555090565b600081604051602001611254919061279c565b604051602081830303815290604052805190602001209050919050565b600080600061128085856115da565b9150915061128d8161165d565b819250505092915050565b6002600085815260200190815260200160002060020160149054906101000a900460ff16156112fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f390612b92565b60405180910390fd5b60016002600086815260200190815260200160002060020160146101000a81548160ff021916908315150217905550826002600086815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550816002600086815260200190815260200160002060010181905550806002600086815260200190815260200160002060020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b6114778363a9059cbb60e01b84846040516024016114159291906128a7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506119ae565b505050565b6000811480611515575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b81526004016114c392919061287e565b60206040518083038186803b1580156114db57600080fd5b505afa1580156114ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151391906121fe565b145b611554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154b90612c12565b60405180910390fd5b6115d58363095ea7b360e01b84846040516024016115739291906128a7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506119ae565b505050565b60008060418351141561161c5760008060006020860151925060408601519150606086015160001a905061161087828585611a75565b94509450505050611656565b60408351141561164d576000806020850151915060408501519050611642868383611b82565b935093505050611656565b60006002915091505b9250929050565b60006004811115611697577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8160048111156116d0577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b14156116db576119ab565b60016004811115611715577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b81600481111561174e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b141561178f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611786906129b2565b60405180910390fd5b600260048111156117c9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b816004811115611802577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b1415611843576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183a906129d2565b60405180910390fd5b6003600481111561187d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8160048111156118b6577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b14156118f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118ee90612a72565b60405180910390fd5b600480811115611930577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b816004811115611969577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b14156119aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a190612af2565b60405180910390fd5b5b50565b6000611a10826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611be19092919063ffffffff16565b9050600081511115611a705780806020019051810190611a3091906121ac565b611a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6690612bb2565b60405180910390fd5b5b505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115611ab0576000600391509150611b79565b601b8560ff1614158015611ac85750601c8560ff1614155b15611ada576000600491509150611b79565b600060018787878760405160008152602001604052604051611aff949392919061294b565b6020604051602081039080840390855afa158015611b21573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b7057600060019250925050611b79565b80600092509250505b94509492505050565b60008060007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60001b841690506000601b60ff8660001c901c611bc59190612df9565b9050611bd387828885611a75565b935093505050935093915050565b6060611bf08484600085611bf9565b90509392505050565b606082471015611c3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3590612ab2565b60405180910390fd5b611c4785611d0d565b611c86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7d90612b72565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611caf919061268f565b60006040518083038185875af1925050503d8060008114611cec576040519150601f19603f3d011682016040523d82523d6000602084013e611cf1565b606091505b5091509150611d01828286611d30565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60608315611d4057829050611d90565b600083511115611d535782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d879190612990565b60405180910390fd5b9392505050565b6000611daa611da584612d33565b612d0e565b90508083825260208201905082856020860282011115611dc957600080fd5b60005b85811015611df95781611ddf8882611e9e565b845260208401935060208301925050600181019050611dcc565b5050509392505050565b6000611e16611e1184612d5f565b612d0e565b9050808382526020820190508260005b85811015611e565781358501611e3c8882611f31565b845260208401935060208301925050600181019050611e26565b5050509392505050565b6000611e73611e6e84612d8b565b612d0e565b905082815260208101848484011115611e8b57600080fd5b611e96848285612ef6565b509392505050565b600081359050611ead81613538565b92915050565b600081359050611ec28161354f565b92915050565b600082601f830112611ed957600080fd5b8135611ee9848260208601611d97565b91505092915050565b600082601f830112611f0357600080fd5b8135611f13848260208601611e03565b91505092915050565b600081519050611f2b81613566565b92915050565b600082601f830112611f4257600080fd5b8135611f52848260208601611e60565b91505092915050565b600081359050611f6a8161357d565b92915050565b600081519050611f7f8161357d565b92915050565b600060208284031215611f9757600080fd5b6000611fa584828501611e9e565b91505092915050565b60008060008060008060c08789031215611fc757600080fd5b6000611fd589828a01611eb3565b9650506020611fe689828a01611f5b565b9550506040611ff789828a01611f5b565b945050606061200889828a01611f5b565b935050608087013567ffffffffffffffff81111561202557600080fd5b61203189828a01611ec8565b92505060a087013567ffffffffffffffff81111561204e57600080fd5b61205a89828a01611ef2565b9150509295509295509295565b600080600080600060a0868803121561207f57600080fd5b600061208d88828901611e9e565b955050602061209e88828901611f5b565b94505060406120af88828901611e9e565b93505060606120c088828901611f5b565b92505060806120d188828901611f5b565b9150509295509295909350565b600080600080600080600060e0888a0312156120f957600080fd5b60006121078a828b01611e9e565b97505060206121188a828b01611f5b565b96505060406121298a828b01611e9e565b955050606061213a8a828b01611f5b565b945050608061214b8a828b01611f5b565b93505060a088013567ffffffffffffffff81111561216857600080fd5b6121748a828b01611ec8565b92505060c088013567ffffffffffffffff81111561219157600080fd5b61219d8a828b01611ef2565b91505092959891949750929550565b6000602082840312156121be57600080fd5b60006121cc84828501611f1c565b91505092915050565b6000602082840312156121e757600080fd5b60006121f584828501611f5b565b91505092915050565b60006020828403121561221057600080fd5b600061221e84828501611f70565b91505092915050565b61223081612ec0565b82525050565b61224761224282612e61565b612fee565b82525050565b61225681612e4f565b82525050565b61226d61226882612e4f565b612fdc565b82525050565b61227c81612e73565b82525050565b61228b81612e7f565b82525050565b6122a261229d82612e7f565b613000565b82525050565b60006122b382612dbc565b6122bd8185612dd2565b93506122cd818560208601612f05565b80840191505092915050565b60006122e482612dc7565b6122ee8185612ddd565b93506122fe818560208601612f05565b61230781613084565b840191505092915050565b600061231f601883612ddd565b915061232a826130a2565b602082019050919050565b6000612342600583612dee565b915061234d826130cb565b600582019050919050565b6000612365601f83612ddd565b9150612370826130f4565b602082019050919050565b6000612388601c83612dee565b91506123938261311d565b601c82019050919050565b60006123ab601983612ddd565b91506123b682613146565b602082019050919050565b60006123ce600e83612ddd565b91506123d98261316f565b602082019050919050565b60006123f1601283612ddd565b91506123fc82613198565b602082019050919050565b6000612414603a83612ddd565b915061241f826131c1565b604082019050919050565b6000612437602283612ddd565b915061244282613210565b604082019050919050565b600061245a601d83612ddd565b91506124658261325f565b602082019050919050565b600061247d602683612ddd565b915061248882613288565b604082019050919050565b60006124a0601083612ddd565b91506124ab826132d7565b602082019050919050565b60006124c3602283612ddd565b91506124ce82613300565b604082019050919050565b60006124e6600583612dee565b91506124f18261334f565b600582019050919050565b6000612509601483612ddd565b915061251482613378565b602082019050919050565b600061252c601983612ddd565b9150612537826133a1565b602082019050919050565b600061254f600083612dd2565b915061255a826133ca565b600082019050919050565b6000612572601383612ddd565b915061257d826133cd565b602082019050919050565b6000612595601d83612ddd565b91506125a0826133f6565b602082019050919050565b60006125b8600e83612ddd565b91506125c38261341f565b602082019050919050565b60006125db602a83612ddd565b91506125e682613448565b604082019050919050565b60006125fe601683612ddd565b915061260982613497565b602082019050919050565b6000612621601f83612ddd565b915061262c826134c0565b602082019050919050565b6000612644603683612ddd565b915061264f826134e9565b604082019050919050565b61266381612ea9565b82525050565b61267a61267582612ea9565b61301c565b82525050565b61268981612eb3565b82525050565b600061269b82846122a8565b915081905092915050565b60006126b182612335565b91506126bd8289612236565b6014820191506126cd8288612669565b6020820191506126dd8287612669565b6020820191506126ed8286612669565b6020820191506126fd828561225c565b60148201915061270d8284612669565b602082019150819050979650505050505050565b600061272c82612335565b9150612738828961225c565b6014820191506127488288612669565b6020820191506127588287612669565b6020820191506127688286612669565b602082019150612778828561225c565b6014820191506127888284612669565b602082019150819050979650505050505050565b60006127a78261237b565b91506127b38284612291565b60208201915081905092915050565b60006127cd826124d9565b91506127d9828a61225c565b6014820191506127e98289612669565b6020820191506127f9828861225c565b6014820191506128098287612669565b6020820191506128198286612669565b602082019150612829828561225c565b6014820191506128398284612669565b60208201915081905098975050505050505050565b600061285982612542565b9150819050919050565b6000602082019050612878600083018461224d565b92915050565b6000604082019050612893600083018561224d565b6128a0602083018461224d565b9392505050565b60006040820190506128bc600083018561224d565b6128c9602083018461265a565b9392505050565b60006080820190506128e5600083018761224d565b6128f2602083018661265a565b6128ff604083018561265a565b61290c606083018461265a565b95945050505050565b600060208201905061292a6000830184612273565b92915050565b60006020820190506129456000830184612282565b92915050565b60006080820190506129606000830187612282565b61296d6020830186612680565b61297a6040830185612282565b6129876060830184612282565b95945050505050565b600060208201905081810360008301526129aa81846122d9565b905092915050565b600060208201905081810360008301526129cb81612312565b9050919050565b600060208201905081810360008301526129eb81612358565b9050919050565b60006020820190508181036000830152612a0b8161239e565b9050919050565b60006020820190508181036000830152612a2b816123c1565b9050919050565b60006020820190508181036000830152612a4b816123e4565b9050919050565b60006020820190508181036000830152612a6b81612407565b9050919050565b60006020820190508181036000830152612a8b8161242a565b9050919050565b60006020820190508181036000830152612aab8161244d565b9050919050565b60006020820190508181036000830152612acb81612470565b9050919050565b60006020820190508181036000830152612aeb81612493565b9050919050565b60006020820190508181036000830152612b0b816124b6565b9050919050565b60006020820190508181036000830152612b2b816124fc565b9050919050565b60006020820190508181036000830152612b4b8161251f565b9050919050565b60006020820190508181036000830152612b6b81612565565b9050919050565b60006020820190508181036000830152612b8b81612588565b9050919050565b60006020820190508181036000830152612bab816125ab565b9050919050565b60006020820190508181036000830152612bcb816125ce565b9050919050565b60006020820190508181036000830152612beb816125f1565b9050919050565b60006020820190508181036000830152612c0b81612614565b9050919050565b60006020820190508181036000830152612c2b81612637565b9050919050565b6000602082019050612c47600083018461265a565b92915050565b6000606082019050612c62600083018661265a565b612c6f6020830185612227565b612c7c604083018461265a565b949350505050565b6000608082019050612c99600083018761265a565b612ca6602083018661224d565b612cb3604083018561224d565b612cc0606083018461265a565b95945050505050565b6000608082019050612cde600083018761265a565b612ceb602083018661265a565b612cf8604083018561265a565b612d05606083018461265a565b95945050505050565b6000612d18612d29565b9050612d248282612f38565b919050565b6000604051905090565b600067ffffffffffffffff821115612d4e57612d4d613055565b5b602082029050602081019050919050565b600067ffffffffffffffff821115612d7a57612d79613055565b5b602082029050602081019050919050565b600067ffffffffffffffff821115612da657612da5613055565b5b612daf82613084565b9050602081019050919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000612e0482612ea9565b9150612e0f83612ea9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612e4457612e43613026565b5b828201905092915050565b6000612e5a82612e89565b9050919050565b6000612e6c82612e89565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612ecb82612ed2565b9050919050565b6000612edd82612ee4565b9050919050565b6000612eef82612e89565b9050919050565b82818337600083830152505050565b60005b83811015612f23578082015181840152602081019050612f08565b83811115612f32576000848401525b50505050565b612f4182613084565b810181811067ffffffffffffffff82111715612f6057612f5f613055565b5b80604052505050565b6000612f7482612ea9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612fa757612fa6613026565b5b600182019050919050565b6000612fbd82612eb3565b915060ff821415612fd157612fd0613026565b5b600182019050919050565b6000612fe78261300a565b9050919050565b6000612ff98261300a565b9050919050565b6000819050919050565b600061301582613095565b9050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b7f4554484552000000000000000000000000000000000000000000000000000000600082015250565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b7f696e76616c6964207369676e617475726573206c656e67746800000000000000600082015250565b7f696e76616c6964207369676e6572000000000000000000000000000000000000600082015250565b7f6e6f7420616c6c6f776564207369676e65720000000000000000000000000000600082015250565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f696e76616c696420636861696e20696400000000000000000000000000000000600082015250565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433230000000000000000000000000000000000000000000000000000000600082015250565b7f696e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b7f696e76616c696420616c6c5369676e657273206c656e67746800000000000000600082015250565b50565b7f65787069726564207472616e73616374696f6e00000000000000000000000000600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f7265706561746564206f72646572000000000000000000000000000000000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f63616e206e6f742062652073616d65207369676e657200000000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b61354181612e4f565b811461354c57600080fd5b50565b61355881612e61565b811461356357600080fd5b50565b61356f81612e73565b811461357a57600080fd5b50565b61358681612ea9565b811461359157600080fd5b5056fea26469706673582212200cbfbd8305fc7f70e1bdf6753992e355302178adfde78d12a1bc86bf14613a0b64736f6c63430008020033
Verified Source Code Full Match
Compiler: v0.8.2+commit.661d1103
EVM: istanbul
Optimization: No
IWETH.sol 9 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IWETH {
function deposit() external payable;
function approve(address to, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}
IStarkEx.sol 44 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface IStarkEx {
function getEthKey(
uint256 starkKey
) external view returns (address);
function isMsgSenderKeyOwner(
uint256 ownerKey
) external view returns (bool);
function registerEthAddress(
address ethKey,
uint256 starkKey,
bytes calldata starkSignature
) external;
function depositERC20(
uint256 starkKey,
uint256 assetType,
uint256 vaultId,
uint256 quantizedAmount
) external;
function getWithdrawalBalance(
uint256 starkKey,
uint256 assetId
) external view returns (uint256 balance);
function withdraw(
uint256 starkKey,
uint256 assetId
) external;
function forcedWithdrawalRequest(
uint256 starkKey,
uint256 vaultId,
uint256 quantizedAmount,
bool premiumCost
) external;
}
PoolRebalanceHelper.sol 269 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import "../interfaces/IAggregationRouterV4.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/IStarkEx.sol";
import "../interfaces/IFactRegister.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
/**
*
* PoolRebalanceHelper
* ============
*
* Basic multi-signer wallet designed for use in a co-signing environment where 2 signatures are require to move funds.
* Typically used in a 2-of-3 signing configuration. Uses ecrecover to allow for 2 signatures in a single transaction.
*
* The signatures are created on the operation hash and passed to withdrawETH/withdrawERC20
* The signer is determined by ECDSA.recover().
*
* The signature is created with ethereumjs-util.ecsign(operationHash).
* Like the eth_sign RPC call, it packs the values as a 65-byte array of [r, s, v].
* Unlike eth_sign, the message is not prefixed.
*
*/
contract PoolRebalanceHelper is ReentrancyGuard {
using SafeERC20 for IERC20;
using SafeMath for uint256;
// Events
event Deposit(address token, uint256 amount, uint256 starkKey, uint256 positionId);
event WithdrawETH(uint256 orderId, address to, uint256 amount);
event WithdrawERC20(uint256 orderId, address token, address to, uint256 amount);
// Public fields
address immutable public USDC_ADDRESS; // USDC contract address
address immutable public STARKEX_ADDRESS; // stark exchange adress
uint256 immutable public L2POOL_ACCOUNT_ID; // l2pool account id
uint256 immutable public L2POOL_STARK_KEY; // l2pool stark key
address[] public signers; // The addresses that can co-sign transactions on the wallet
mapping(uint256 => order) orders; // history orders
uint256 public ASSET_TYPE; // stark exchange defined USDC
struct order{
address to; // The address the transaction was sent to
uint256 amount; // Amount of Wei sent to the address
address token; // The address of the ERC20 token contract, 0 means ETH
bool executed; // If the order was executed
}
/**
* Set up a simple 2-3 multi-sig wallet by specifying the signers allowed to be used on this wallet.
* 2 signers will be require to send a transaction from this wallet.
* Note: The sender is NOT automatically added to the list of signers.
* Signers CANNOT be changed once they are set
*
* @param allowedSigners An array of signers on the wallet
* @param usdc The USDC contract address
* @param starkex The stark exchange address
* @param assetType The USDC asset type in starkex
* @param l2poolAccountId The fixed l2pool account id
* @param l2poolStarkKey The fixed l2key
*
*/
constructor(address[] memory allowedSigners, address usdc,address starkex, uint256 assetType,uint256 l2poolAccountId, uint256 l2poolStarkKey) {
require(allowedSigners.length == 3, "invalid allSigners length");
require(allowedSigners[0] != allowedSigners[1], "must be different signers");
require(allowedSigners[0] != allowedSigners[2], "must be different signers");
require(allowedSigners[1] != allowedSigners[2], "must be different signers");
require(usdc != address(0), "invalid usdc address");
require(block.chainid == 1 || block.chainid == 5, "invalid chain id");
signers = allowedSigners;
USDC_ADDRESS = usdc;
STARKEX_ADDRESS = starkex;
ASSET_TYPE = assetType;
L2POOL_ACCOUNT_ID = l2poolAccountId;
L2POOL_STARK_KEY = l2poolStarkKey;
}
/**
* Gets called when a transaction is received without calling a method
*/
receive() external payable { }
/**
* @notice Make a deposit to the Starkware Layer2.
* Funds will be transferred from this contract to starkware, and
* generate a deposit event specified by the starkKey and positionId.
*/
function deposit() public nonReentrant returns (uint256) {
uint256 balance = IERC20(USDC_ADDRESS).balanceOf(address(this));
require(balance > 0, "insufficient balance");
require(block.chainid == 1 || block.chainid == 5, "invalid chain id");
// safeApprove requires unsetting the allowance first.
IERC20(USDC_ADDRESS).safeApprove(STARKEX_ADDRESS, 0);
IERC20(USDC_ADDRESS).safeApprove(STARKEX_ADDRESS, balance);
// deposit to starkex
IStarkEx starkEx = IStarkEx(STARKEX_ADDRESS);
starkEx.depositERC20(L2POOL_STARK_KEY, ASSET_TYPE, L2POOL_ACCOUNT_ID, balance);
emit Deposit(
address(USDC_ADDRESS),
balance,
L2POOL_STARK_KEY,
L2POOL_ACCOUNT_ID
);
return balance;
}
/**
* Withdraw ETHER from this wallet using 2 signers.
*
* @param to the destination address to send an outgoing transaction
* @param amount the amount in Wei to be sent
* @param expireTime the number of seconds since 1970 for which this transaction is valid
* @param orderId the unique order id
* @param allSigners all signers who sign the tx
* @param signatures the signatures of tx
*/
function withdrawETH(
address payable to,
uint256 amount,
uint256 expireTime,
uint256 orderId,
address[] memory allSigners,
bytes[] memory signatures
) public nonReentrant {
require(allSigners.length >= 2, "invalid allSigners length");
require(allSigners.length == signatures.length, "invalid signatures length");
require(allSigners[0] != allSigners[1],"can not be same signer"); // must be different signer
require(expireTime >= block.timestamp,"expired transaction");
bytes32 operationHash = keccak256(abi.encodePacked("ETHER", to, amount, expireTime, orderId, address(this), block.chainid));
operationHash = ECDSA.toEthSignedMessageHash(operationHash);
for (uint8 index = 0; index < allSigners.length; index++) {
address signer = ECDSA.recover(operationHash, signatures[index]);
require(signer == allSigners[index], "invalid signer");
require(isAllowedSigner(signer), "not allowed signer");
}
// Try to insert the order ID. Will revert if the order id was invalid
tryInsertOrderId(orderId, to, amount, address(0));
// send ETHER
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = to.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
emit WithdrawETH(orderId, to, amount);
}
/**
* Withdraw ERC20 from this wallet using 2 signers.
*
* @param to the destination address to send an outgoing transactioni
* @param amount the amount in Wei to be sent
* @param token the address of the erc20 token contract
* @param expireTime the number of seconds since 1970 for which this transaction is valid
* @param orderId the unique order id
* @param allSigners all signer who sign the tx
* @param signatures the signatures of tx
*/
function withdrawErc20(
address to,
uint256 amount,
address token,
uint256 expireTime,
uint256 orderId,
address[] memory allSigners,
bytes[] memory signatures
) public nonReentrant {
require(allSigners.length >=2, "invalid allSigners length");
require(allSigners.length == signatures.length, "invalid signatures length");
require(allSigners[0] != allSigners[1],"can not be same signer"); // must be different signer
require(expireTime >= block.timestamp,"expired transaction");
bytes32 operationHash = keccak256(abi.encodePacked("ERC20", to, amount, token, expireTime, orderId, address(this), block.chainid));
operationHash = ECDSA.toEthSignedMessageHash(operationHash);
for (uint8 index = 0; index < allSigners.length; index++) {
address signer = ECDSA.recover(operationHash, signatures[index]);
require(signer == allSigners[index], "invalid signer");
require(isAllowedSigner(signer),"not allowed signer");
}
// Try to insert the order ID. Will revert if the order id was invalid
tryInsertOrderId(orderId, to, amount, token);
// Success, send ERC20 token
IERC20(token).safeTransfer(to, amount);
emit WithdrawERC20(orderId, token, to, amount);
}
/**
* Determine if an address is a signer on this wallet
*
* @param signer address to check
*/
function isAllowedSigner(address signer) public view returns (bool) {
// Iterate through all signers on the wallet and
for (uint i = 0; i < signers.length; i++) {
if (signers[i] == signer) {
return true;
}
}
return false;
}
/**
* Verify that the order id has not been used before and inserts it. Throws if the order ID was not accepted.
*
* @param orderId the unique order id
* @param to the destination address to send an outgoing transaction
* @param amount the amount in Wei to be sent
* @param token the address of the ERC20 contract
*/
function tryInsertOrderId(
uint256 orderId,
address to,
uint256 amount,
address token
) internal {
if (orders[orderId].executed) {
// This order ID has been excuted before. Disallow!
revert("repeated order");
}
orders[orderId].executed = true;
orders[orderId].to = to;
orders[orderId].amount = amount;
orders[orderId].token = token;
}
/**
* calcSigHash is a helper function that to help you generate the sighash needed for withdrawal.
*
* @param to the destination address
* @param amount the amount in Wei to be sent
* @param token the address of the ERC20 contract
* @param expireTime the number of seconds since 1970 for which this transaction is valid
* @param orderId the unique order id
*/
function calcSigHash(
address to,
uint256 amount,
address token,
uint256 expireTime,
uint256 orderId) public view returns (bytes32) {
bytes32 operationHash;
if (token == address(0)) {
operationHash = keccak256(abi.encodePacked("ETHER", to, amount, expireTime, orderId, address(this), block.chainid));
} else {
operationHash = keccak256(abi.encodePacked("ERC20", to, amount, token, expireTime, orderId, address(this), block.chainid));
}
return operationHash;
}
}
IFactRegister.sol 13 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFactRegister {
function isValid(bytes32 fact) external view returns (bool);
function transferERC20(
address recipient,
address erc20,
uint256 amount,
uint256 salt
) external;
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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");
(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");
(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");
(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");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
IAggregationExecutor.sol 5 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IAggregationExecutor {
function callBytes(bytes calldata data) external payable;
}
IAggregationRouterV4.sol 31 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "./IAggregationExecutor.sol";
interface IAggregationRouterV4 {
struct SwapDescription {
IERC20 srcToken;
IERC20 dstToken;
address payable srcReceiver;
address payable dstReceiver;
uint256 amount;
uint256 minReturnAmount;
uint256 flags;
bytes permit;
}
function swap(
IAggregationExecutor caller,
SwapDescription calldata desc,
bytes calldata data
)
external
payable
returns (
uint256 returnAmount,
uint256 spentAmount,
uint256 gasLeft
);
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
SafeMath.sol 227 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// 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 (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @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) {
return a + b;
}
/**
* @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 a - b;
}
/**
* @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) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting 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 a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
ECDSA.sol 230 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/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'
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
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Read Contract
ASSET_TYPE 0x8815eb39 → uint256
L2POOL_ACCOUNT_ID 0x1ab0b1b1 → uint256
L2POOL_STARK_KEY 0x07baa84b → uint256
STARKEX_ADDRESS 0x391cdc08 → address
USDC_ADDRESS 0xbb09d9b7 → address
calcSigHash 0x2ff2226a → bytes32
isAllowedSigner 0xcabb9e7a → bool
signers 0x2079fb9a → address
Write Contract 3 functions
These functions modify contract state and require a wallet transaction to execute.
deposit 0xd0e30db0
No parameters
returns: uint256
withdrawETH 0x6b1430d6
address to
uint256 amount
uint256 expireTime
uint256 orderId
address[] allSigners
bytes[] signatures
withdrawErc20 0x1025e095
address to
uint256 amount
address token
uint256 expireTime
uint256 orderId
address[] allSigners
bytes[] signatures
Recent Transactions
No transactions found for this address