Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x16BEa2e63aDAdE5984298D53A4d4d9c09e278192
Balance 0 ETH
Nonce 1
Code Size 19975 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

19975 bytes
0x341561000a57600080fd5b600436101561001857614e01565b600035601c526000156101c1575b610140526009546101605260075461018052610160514210156101ae576006546101a0526008546101c0526101a051610180511115610107576101a051610180516101a0518082101561007857600080fd5b80820390509050426101c0518082101561009157600080fd5b8082039050905080820282158284830414176100ac57600080fd5b80905090509050610160516101c051808210156100c857600080fd5b8082039050905080806100da57600080fd5b8204905090508181830110156100ef57600080fd5b808201905090506000526000516101405156506101a9565b6101a0516101a051610180518082101561012057600080fd5b80820390509050426101c0518082101561013957600080fd5b80820390509050808202821582848304141761015457600080fd5b80905090509050610160516101c0518082101561017057600080fd5b80820390509050808061018257600080fd5b8204905090508082101561019557600080fd5b808203905090506000526000516101405156505b6101bf565b610180516000526000516101405156505b005b63f446c1d060005114156101f45760065801610026565b610140526101405160648082049050905060005260206000f350005b6376a2f0f0600051141561021e5760065801610026565b610140526101405160005260206000f350005b600015610333575b61014052670de0b6b3a764000061016052670de0b6b3a764000061018052670de0b6b3a76400006101a052670de0b6b3a76400006101c0526101e060006004818352015b6101606101e0516004811061027e57600080fd5b60200201516101e0516004811061029457600080fd5b600160c052602060c020015480820282158284830414176102b457600080fd5b80905090509050670de0b6b3a7640000808204905090506101606101e051600481106102df57600080fd5b60200201525b815160010180835281141561026a575b505060806101e0525b60006101e0511115156103105761032c565b60206101e05103610160015160206101e051036101e0526102fe565b6101405156005b600015610454575b6101c0526101405261016052610180526101a052670de0b6b3a76400006101e052670de0b6b3a764000061020052670de0b6b3a764000061022052670de0b6b3a76400006102405261026060006004818352015b6101e061026051600481106103a357600080fd5b602002015161014061026051600481106103bc57600080fd5b602002015180820282158284830414176103d557600080fd5b80905090509050670de0b6b3a7640000808204905090506101e0610260516004811061040057600080fd5b60200201525b815160010180835281141561038f575b50506080610260525b6000610260511115156104315761044d565b602061026051036101e00151602061026051036102605261041f565b6101c05156005b600015610764575b6101e0526101405261016052610180526101a0526101c0526040366102003761026060006004818352015b602061026051026101400151610240526102008051610240518181830110156104af57600080fd5b808201905090508152505b8151600101808352811415610487575b50506102005115156104e55760006000526000516101e05156505b61020051610240526101c0516004808202821582848304141761050757600080fd5b8090509050905061026052610280600060ff818352015b610240516102a0526102e060006004818352015b60206102e0510261014001516102c0526102a05161024051808202821582848304141761055e57600080fd5b809050905090506102c0516004808202821582848304141761057f57600080fd5b80905090509050808061059157600080fd5b8204905090506102a0525b8151600101808352811415610532575b50506102405161022052610260516102005180820282158284830414176105d257600080fd5b809050905090506064808204905090506102a051600480820282158284830414176105fc57600080fd5b8090509050905081818301101561061257600080fd5b8082019050905061024051808202821582848304141761063157600080fd5b809050905090506102605160648082101561064b57600080fd5b8082039050905061024051808202821582848304141761066a57600080fd5b8090509050905060648082049050905060056102a051808202821582848304141761069457600080fd5b809050905090508181830110156106aa57600080fd5b8082019050905080806106bc57600080fd5b82049050905061024052610220516102405111156107115760016102405161022051808210156106eb57600080fd5b8082039050905011151561070c576102405160005250506000516101e05156505b61074a565b600161022051610240518082101561072857600080fd5b80820390509050111515610749576102405160005250506000516101e05156505b5b5b815160010180835281141561051e575b505060006000fd005b60001561091d575b6101e0526101405261016052610180526101a0526101c0526101405161016051610180516101a0516101c0516101e0516101405161020052610160516102205261018051610240526101a05161026052610260516102405161022051610200516006580161033b565b6102c0526102e05261030052610320526101e0526101c0526101a0526101805261016052610140526102c080516103405280602001516103605280604001516103805280606001516103a052506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a051610340516103c052610360516103e05261038051610400526103a051610420526101c051610440526104405161042051610400516103e0516103c0516006580161045c565b6104a0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526104a0516000526000516101e0515650005b63bb7b8b806000511415610af8576101405160065801610226565b61016052610180526101a0526101c0526101405261016080516101e052806020015161020052806040015161022052806060015161024052506101405161016051610180516101a0516101c0516101e05161020051610220516102405160065801610026565b610260526102405261022052610200526101e0526101c0526101a05261018052610160526101405261026051610280526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516101e0516102a052610200516102c052610220516102e0526102405161030052610280516103205261032051610300516102e0516102c0516102a0516006580161045c565b6103805261028052610260526102405261022052610200526101e0526101c0526101a052610180526101605261014052610380516101405260206101e060046318160ddd6101805261019c6005545afa610a9857600080fd5b601f3d11610aa557600080fd5b6000506101e0516101605261014051670de0b6b3a76400008082028215828483041417610ad157600080fd5b80905090509050610160518080610ae757600080fd5b82049050905060005260206000f350005b63cf701ff76000511415610e125760843560011c15610b1657600080fd5b6101405160065801610026565b6101605261014052610160516101405260018060c052602060c020546101605260018160c052602060c02001546101805260028160c052602060c02001546101a05260038160c052602060c02001546101c052506101405161016051610180516101a0516101c0516101e051610160516102005261018051610220526101a051610240526101c05161026052610140516102805261028051610260516102405161022051610200516006580161076c565b6102e0526101e0526101c0526101a0526101805261016052610140526102e0516101e05261020060006004818352015b60843515610c5c576101606102005160048110610c2057600080fd5b60200201805160046102005160048110610c3957600080fd5b6020020135818183011015610c4d57600080fd5b80820190509050815250610ca6565b6101606102005160048110610c7057600080fd5b60200201805160046102005160048110610c8957600080fd5b602002013580821015610c9b57600080fd5b808203905090508152505b5b8151600101808352811415610c04575b50506101405161016051610180516101a0516101c0516101e05161020051610160516102205261018051610240526101a051610260526101c05161028052610140516102a0526102a051610280516102605161024051610220516006580161076c565b61030052610200526101e0526101c0526101a052610180526101605261014052610300516102005260206102a060046318160ddd6102405261025c6005545afa610d6357600080fd5b601f3d11610d7057600080fd5b6000506102a0516102205260006102405260843515610dae57610200516101e05180821015610d9e57600080fd5b8082039050905061024052610dcf565b6101e0516102005180821015610dc357600080fd5b80820390509050610240525b61024051610220518082028215828483041417610deb57600080fd5b809050905090506101e0518080610e0157600080fd5b82049050905060005260206000f350005b63029b2f3460005114156117e85762ffffff5415610e2f57600080fd5b600162ffffff55600f5415610e4357600080fd5b6101405160065801610026565b6101605261014052610160516101405260055461016052602061020060046318160ddd6101a0526101bc610160515afa610e8957600080fd5b601f3d11610e9657600080fd5b600050610200516101805260006101a05260018060c052602060c020546101c05260018160c052602060c02001546101e05260028160c052602060c02001546102005260038160c052602060c020015461022052506000610180511115610f89576101405161016051610180516101a0516101c0516101e05161020051610220516101c051610240526101e051610260526102005161028052610220516102a052610140516102c0526102c0516102a0516102805161026051610240516006580161076c565b6103205261022052610200526101e0526101c0526101a052610180526101605261014052610320516101a0525b6101c051610240526101e051610260526102005161028052610220516102a0526102c060006004818352015b610180511515610fe457600060046102c05160048110610fd457600080fd5b602002013511610fe357600080fd5b5b6101c06102c05160048110610ff857600080fd5b602002015160046102c0516004811061101057600080fd5b602002013581818301101561102457600080fd5b808201905090506102406102c0516004811061103f57600080fd5b60200201525b8151600101808352811415610fb5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c051610240516102e052610260516103005261028051610320526102a051610340526101405161036052610360516103405161032051610300516102e0516006580161076c565b6103c0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0516102c0526101a0516102c0511161112257600080fd5b6102c0516102e052608036610300376000610180511115611447576002546004808202821582848304141761115657600080fd5b80905090509050600c80820490509050610380526003546103a0526103c060006004818352015b6102c0516101c06103c0516004811061119557600080fd5b602002015180820282158284830414176111ae57600080fd5b809050905090506101a05180806111c457600080fd5b8204905090506103e0526000610400526102406103c051600481106111e857600080fd5b60200201516103e0511115611231576103e0516102406103c0516004811061120f57600080fd5b60200201518082101561122157600080fd5b8082039050905061040052611267565b6102406103c0516004811061124557600080fd5b60200201516103e0518082101561125b57600080fd5b80820390509050610400525b6103805161040051808202821582848304141761128357600080fd5b809050905090506402540be400808204905090506103006103c051600481106112ab57600080fd5b60200201526102406103c051600481106112c457600080fd5b60200201516103006103c051600481106112dd57600080fd5b60200201516103a05180820282158284830414176112fa57600080fd5b809050905090506402540be400808204905090508082101561131b57600080fd5b808203905090506103c0516004811061133357600080fd5b600160c052602060c02001556102406103c0516004811061135357600080fd5b6020020180516103006103c0516004811061136d57600080fd5b60200201518082101561137f57600080fd5b808203905090508152505b815160010180835281141561117d575b50506101406103c0525b6103c0515160206103c051016103c0526103c06103c05110156113c6576113a4565b610240516103e052610260516104005261028051610420526102a051610440526101405161046052610460516104405161042051610400516103e0516006580161076c565b6104c0526103a06103c0525b6103c0515260206103c051036103c0526101406103c05110151561143a57611417565b6104c0516102e052611474565b600160c052602060c0206102405181556102605160018201556102805160028201556102a0516003820155505b600061038052610180511515611491576102c051610380526114e6565b610180516102e0516101a051808210156114aa57600080fd5b8082039050905080820282158284830414176114c557600080fd5b809050905090506101a05180806114db57600080fd5b820490509050610380525b608435610380511015151561153a576308c379a06103a05260206103c05260146103e0527f536c697070616765207363726577656420796f75000000000000000000000000610400526103e05060646103bcfd5b6103a060006004818352015b600060046103a0516004811061155b57600080fd5b602002013511156116e45760006004610420527f23b872dd000000000000000000000000000000000000000000000000000000006104405261042060048060208461048001018260208501600060045af1505080518201915050336020826104800101526020810190503060208261048001015260208101905060046103a051600481106115e857600080fd5b6020020135602082610480010152602081019050806104805261048090508051602001806105408284600060045af161162057600080fd5b505060206106206105405161056060006103a0516004811061164157600080fd5b600060c052602060c02001545af161165857600080fd5b60203d80821115611669578061166b565b815b90509050610600526106008051602001806103c08284600060045af161169057600080fd5b505060006103c05111156116e3576103c08060200151600082518060209013156116b957600080fd5b80919012156116c757600080fd5b806020036101000a820490509050905015156116e257600080fd5b5b5b5b8151600101808352811415611546575b5050602061044060446340c10f196103a052336103c052610380516103e0526103bc6000610160515af161172857600080fd5b601f3d1161173557600080fd5b600050610440506004356103a0526024356103c0526044356103e0526064356104005261030051610420526103205161044052610340516104605261036051610480526102c0516104a052610180516103805181818301101561179757600080fd5b808201905090506104c052337f3f1915775e0c9a38a57a7bb7f1f9005f486fb904e1f84aa215364d567319a58d6101406103a0a261038051600052600062ffffff5560206000f350600062ffffff55005b600015611caa575b610220526101405261016052610180526101a0526101c0526101e0526102005261016051610140511861182257600080fd5b600061016051121561183357600080fd5b6004610160511261184357600080fd5b600061014051121561185457600080fd5b6004610140511261186457600080fd5b6101405161016051610180516101a0516101c0516101e05161020051610220516102405160065801610026565b610260526102405261022052610200526101e0526101c0526101a05261018052610160526101405261026051610240526101405161016051610180516101a0516101c0516101e051610200516102205161024051610260516101a051610280526101c0516102a0526101e0516102c052610200516102e0526102405161030052610300516102e0516102c0516102a051610280516006580161045c565b61036052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103605161026052610240516004808202821582848304141761197c57600080fd5b8090509050905061028052610260516102a0526060366102c03761032060006004818352015b610140516103205114156119bd57610180516102e0526119f3565b610160516103205118156119ed576101a061032051600481106119df57600080fd5b60200201516102e0526119f2565b611a6f565b5b6102c080516102e051818183011015611a0b57600080fd5b808201905090508152506102a051610260518082028215828483041417611a3157600080fd5b809050905090506102e05160048082028215828483041417611a5257600080fd5b809050905090508080611a6457600080fd5b8204905090506102a0525b81516001018083528114156119a2575b50506102a051610260518082028215828483041417611a9d57600080fd5b8090509050905060648082028215828483041417611aba57600080fd5b809050905090506102805160048082028215828483041417611adb57600080fd5b809050905090508080611aed57600080fd5b8204905090506102a0526102c0516102605160648082028215828483041417611b1557600080fd5b80905090509050610280518080611b2b57600080fd5b820490509050818183011015611b4057600080fd5b80820190509050610320526102605161034052610360600060ff818352015b610340516103005261034051610340518082028215828483041417611b8357600080fd5b809050905090506102a051818183011015611b9d57600080fd5b808201905090506002610340518082028215828483041417611bbe57600080fd5b8090509050905061032051818183011015611bd857600080fd5b808201905090506102605180821015611bf057600080fd5b808203905090508080611c0257600080fd5b8204905090506103405261030051610340511115611c57576001610340516103005180821015611c3157600080fd5b80820390509050111515611c52576103405160005250506000516102205156505b611c90565b6001610300516103405180821015611c6e57600080fd5b80820390509050111515611c8f576103405160005250506000516102205156505b5b5b8151600101808352811415611b5f575b505060006000fd005b635e0d443f6000511415611faa5760043580806000811215611cc857195b607f1c15611cd557600080fd5b90505060243580806000811215611ce857195b607f1c15611cf557600080fd5b9050506101405161016051610180516101a05160065801610226565b6101c0526101e05261020052610220526101a0526101805261016052610140526101c080516101405280602001516101605280604001516101805280606001516101a05250670de0b6b3a76400006101c052670de0b6b3a76400006101e052670de0b6b3a764000061020052670de0b6b3a76400006102205261014060043560048110611d9d57600080fd5b60200201516044356101c060043560048110611db857600080fd5b60200201518082028215828483041417611dd157600080fd5b80905090509050670de0b6b3a764000080820490509050818183011015611df757600080fd5b80820190509050610240526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051600435610280526024356102a052610240516102c052610140516102e052610160516103005261018051610320526101a051610340526103405161032051610300516102e0516102c0516102a05161028051600658016117f0565b6103a052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103a0516102605261014060243560048110611ecc57600080fd5b60200201516102605180821015611ee257600080fd5b80820390509050600180821015611ef857600080fd5b8082039050905061028052600254610280518082028215828483041417611f1e57600080fd5b809050905090506402540be400808204905090506102a052610280516102a05180821015611f4b57600080fd5b80820390509050670de0b6b3a76400008082028215828483041417611f6f57600080fd5b809050905090506101c060243560048110611f8957600080fd5b60200201518080611f9957600080fd5b82049050905060005260206000f350005b633df02124600051141561284d5762ffffff5415611fc757600080fd5b600162ffffff5560043580806000811215611fde57195b607f1c15611feb57600080fd5b90505060243580806000811215611ffe57195b607f1c1561200b57600080fd5b905050600f541561201b57600080fd5b60018060c052602060c020546101405260018160c052602060c02001546101605260028160c052602060c02001546101805260038160c052602060c02001546101a052506101405161016051610180516101a0516101c0516101e05161020051610220516101405161024052610160516102605261018051610280526101a0516102a0526102a0516102805161026051610240516006580161033b565b6103005261032052610340526103605261022052610200526101e0526101c0526101a05261018052610160526101405261030080516101c05280602001516101e05280604001516102005280606001516102205250670de0b6b3a764000061024052670de0b6b3a764000061026052670de0b6b3a764000061028052670de0b6b3a76400006102a0526101c06004356004811061215457600080fd5b60200201516044356102406004356004811061216f57600080fd5b6020020151808202821582848304141761218857600080fd5b80905090509050670de0b6b3a7640000808204905090508181830110156121ae57600080fd5b808201905090506102c0526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05160043561030052602435610320526102c051610340526101c051610360526101e05161038052610200516103a052610220516103c0526103c0516103a0516103805161036051610340516103205161030051600658016117f0565b610420526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610180526101605261014052610420516102e0526101c0602435600481106122a357600080fd5b60200201516102e051808210156122b957600080fd5b808203905090506001808210156122cf57600080fd5b80820390509050610300526103005160025480820282158284830414176122f557600080fd5b809050905090506402540be400808204905090506103205261030051610320518082101561232257600080fd5b80820390509050670de0b6b3a7640000808202821582848304141761234657600080fd5b809050905090506102406024356004811061236057600080fd5b6020020151808061237057600080fd5b8204905090506103005260643561030051101515156123f3576308c379a061034052602061036052602e610380527f45786368616e676520726573756c74656420696e20666577657220636f696e736103a0527f207468616e2065787065637465640000000000000000000000000000000000006103c05261038050608461035cfd5b61032051600354808202821582848304141761240e57600080fd5b809050905090506402540be400808204905090506103405261034051670de0b6b3a7640000808202821582848304141761244757600080fd5b809050905090506102406024356004811061246157600080fd5b6020020151808061247157600080fd5b820490509050610340526101406004356004811061248e57600080fd5b60200201516044358181830110156124a557600080fd5b80820190509050600435600481106124bc57600080fd5b600160c052602060c0200155610140602435600481106124db57600080fd5b602002015161030051808210156124f157600080fd5b80820390509050610340518082101561250957600080fd5b808203905090506024356004811061252057600080fd5b600160c052602060c0200155600060046103c0527f23b872dd000000000000000000000000000000000000000000000000000000006103e0526103c060048060208461042001018260208501600060045af15050805182019150503360208261042001015260208101905030602082610420010152602081019050604435602082610420010152602081019050806104205261042090508051602001806104e08284600060045af16125d157600080fd5b505060206105c06104e0516105006000600435600481106125f157600080fd5b600060c052602060c02001545af161260857600080fd5b60203d80821115612619578061261b565b815b905090506105a0526105a08051602001806103608284600060045af161264057600080fd5b505060006103605111156126935761036080602001516000825180602090131561266957600080fd5b809190121561267757600080fd5b806020036101000a8204905090509050151561269257600080fd5b5b600060046103c0527fa9059cbb000000000000000000000000000000000000000000000000000000006103e0526103c060048060208461042001018260208501600060045af15050805182019150503360208261042001015260208101905061030051602082610420010152602081019050806104205261042090508051602001806104c08284600060045af161272957600080fd5b505060206105806104c0516104e060006024356004811061274957600080fd5b600060c052602060c02001545af161276057600080fd5b60203d808211156127715780612773565b815b90509050610560526105608051602001806103608284600060045af161279857600080fd5b505060006103605111156127eb576103608060200151600082518060209013156127c157600080fd5b80919012156127cf57600080fd5b806020036101000a820490509050905015156127ea57600080fd5b5b6004356103c0526044356103e052602435610400526103005161042052337f8b3e96f2b889fa771c53c981b40daf005f63f637f1869f707052d15a3dd9714060806103c0a261030051600052600062ffffff5560206000f350600062ffffff55005b637d49d8756000511415612c4c5762ffffff541561286a57600080fd5b600162ffffff556005546101405260206101e060046318160ddd6101805261019c610140515afa61289a57600080fd5b601f3d116128a757600080fd5b6000506101e05161016052610100366101803761028060006004818352015b61028051600481106128d757600080fd5b600160c052602060c020015460043580820282158284830414176128fa57600080fd5b8090509050905061016051808061291057600080fd5b8204905090506102a0526024610280516004811061292d57600080fd5b60200201356102a051101515156129a8576308c379a06102c05260206102e0526030610300527f5769746864726177616c20726573756c74656420696e20666577657220636f69610320527f6e73207468616e20657870656374656400000000000000000000000000000000610340526103005060846102dcfd5b61028051600481106129b957600080fd5b600160c052602060c0200180546102a051808210156129d757600080fd5b808203905090508155506102a05161018061028051600481106129f957600080fd5b602002015260006004610320527fa9059cbb000000000000000000000000000000000000000000000000000000006103405261032060048060208461038001018260208501600060045af1505080518201915050336020826103800101526020810190506102a051602082610380010152602081019050806103805261038090508051602001806104208284600060045af1612a9457600080fd5b505060206104e06104205161044060006102805160048110612ab557600080fd5b600060c052602060c02001545af1612acc57600080fd5b60203d80821115612add5780612adf565b815b905090506104c0526104c08051602001806102c08284600060045af1612b0457600080fd5b505060006102c0511115612b57576102c0806020015160008251806020901315612b2d57600080fd5b8091901215612b3b57600080fd5b806020036101000a82049050905090501515612b5657600080fd5b5b5b81516001018083528114156128c6575b5050602061032060446379cc679061028052336102a0526004356102c05261029c6000610140515af1612b9a57600080fd5b601f3d11612ba757600080fd5b6000506103205061018051610280526101a0516102a0526101c0516102c0526101e0516102e05261020051610300526102205161032052610240516103405261026051610360526101605160043580821015612c0257600080fd5b8082039050905061038052337f9878ca375e106f2a43c3b599fc624568131c4c9a4ba66a14563715763be9d59d610120610280a2600062ffffff556080610180f3600062ffffff55005b6318a7bd7660005114156135815762ffffff5415612c6957600080fd5b600162ffffff55600f5415612c7d57600080fd5b6101405160065801610026565b6101605261014052610160516101405260018060c052602060c020546101605260018160c052602060c02001546101805260028160c052602060c02001546101a05260038160c052602060c02001546101c05250610160516101e05261018051610200526101a051610220526101c051610240526101405161016051610180516101a0516101c0516101e051610200516102205161024051610260516101605161028052610180516102a0526101a0516102c0526101c0516102e0526101405161030052610300516102e0516102c0516102a051610280516006580161076c565b61036052610260526102405261022052610200526101e0526101c0526101a052610180526101605261014052610360516102605261028060006004818352015b6101e06102805160048110612dbf57600080fd5b60200201805160046102805160048110612dd857600080fd5b602002013580821015612dea57600080fd5b808203905090508152505b8151600101808352811415612dab575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516101e0516102a052610200516102c052610220516102e0526102405161030052610140516103205261032051610300516102e0516102c0516102a0516006580161076c565b6103805261028052610260526102405261022052610200526101e0526101c0526101a05261018052610160526101405261038051610280526005546102a052602061034060046318160ddd6102e0526102fc6102a0515afa612ed957600080fd5b601f3d11612ee657600080fd5b600050610340516102c05260006102c05118612f0157600080fd5b60025460048082028215828483041417612f1a57600080fd5b80905090509050600c808204905090506102e05260035461030052608036610320376103a060006004818352015b610280516101606103a05160048110612f6057600080fd5b60200201518082028215828483041417612f7957600080fd5b80905090509050610260518080612f8f57600080fd5b8204905090506103c05260006103e0526101e06103a05160048110612fb357600080fd5b60200201516103c0511115612ffc576103c0516101e06103a05160048110612fda57600080fd5b602002015180821015612fec57600080fd5b808203905090506103e052613032565b6101e06103a0516004811061301057600080fd5b60200201516103c0518082101561302657600080fd5b808203905090506103e0525b6102e0516103e051808202821582848304141761304e57600080fd5b809050905090506402540be400808204905090506103206103a0516004811061307657600080fd5b60200201526101e06103a0516004811061308f57600080fd5b60200201516103206103a051600481106130a857600080fd5b60200201516103005180820282158284830414176130c557600080fd5b809050905090506402540be40080820490509050808210156130e657600080fd5b808203905090506103a051600481106130fe57600080fd5b600160c052602060c02001556101e06103a0516004811061311e57600080fd5b6020020180516103206103a0516004811061313857600080fd5b60200201518082101561314a57600080fd5b808203905090508152505b8151600101808352811415612f48575b50506101406103c0525b6103c0515160206103c051016103c0526103c06103c05110156131915761316f565b6101e0516103e0526102005161040052610220516104205261024051610440526101405161046052610460516104405161042051610400516103e0516006580161076c565b6104c0526103a06103c0525b6103c0515260206103c051036103c0526101406103c051101515613205576131e2565b6104c0516103a052610260516103a0518082101561322257600080fd5b808203905090506102c051808202821582848304141761324157600080fd5b8090509050905061026051808061325757600080fd5b8204905090506103c05260006103c0511861327157600080fd5b6103c08051600181818301101561328757600080fd5b808201905090508152506084356103c051111515156132e5576308c379a06103e0526020610400526014610420527f536c697070616765207363726577656420796f75000000000000000000000000610440526104205060646103fcfd5b602061048060446379cc67906103e05233610400526103c051610420526103fc60006102a0515af161331657600080fd5b601f3d1161332357600080fd5b600050610480506103e060006004818352015b600060046103e0516004811061334b57600080fd5b602002013518156134c45760006004610460527fa9059cbb00000000000000000000000000000000000000000000000000000000610480526104606004806020846104c001018260208501600060045af1505080518201915050336020826104c001015260208101905060046103e051600481106133c857600080fd5b60200201356020826104c0010152602081019050806104c0526104c090508051602001806105608284600060045af161340057600080fd5b505060206106206105605161058060006103e0516004811061342157600080fd5b600060c052602060c02001545af161343857600080fd5b60203d80821115613449578061344b565b815b90509050610600526106008051602001806104008284600060045af161347057600080fd5b505060006104005111156134c35761040080602001516000825180602090131561349957600080fd5b80919012156134a757600080fd5b806020036101000a820490509050905015156134c257600080fd5b5b5b5b8151600101808352811415613336575b50506004356103e05260243561040052604435610420526064356104405261032051610460526103405161048052610360516104a052610380516104c052610280516104e0526102c0516103c0518082101561353057600080fd5b8082039050905061050052337fb964b72f73f5ef5bf0fdc559b2fab9a7b12a39e47817a547f1f0aee47febd6026101406103e0a26103c051600052600062ffffff5560206000f350600062ffffff55005b6000156138f6575b610220526101405261016052610180526101a0526101c0526101e0526102005260006101605112156135ba57600080fd5b600461016051126135ca57600080fd5b61014051600480820282158284830414176135e457600080fd5b80905090509050610240526102005161026052606036610280376102e060006004818352015b610160516102e051181561363a576101806102e0516004811061362c57600080fd5b60200201516102a05261363f565b6136bb565b61028080516102a05181818301101561365757600080fd5b808201905090508152506102605161020051808202821582848304141761367d57600080fd5b809050905090506102a0516004808202821582848304141761369e57600080fd5b8090509050905080806136b057600080fd5b820490509050610260525b815160010180835281141561360a575b5050610260516102005180820282158284830414176136e957600080fd5b809050905090506064808202821582848304141761370657600080fd5b80905090509050610240516004808202821582848304141761372757600080fd5b80905090509050808061373957600080fd5b8204905090506102605261028051610200516064808202821582848304141761376157600080fd5b8090509050905061024051808061377757600080fd5b82049050905081818301101561378c57600080fd5b808201905090506102e0526102005161030052610320600060ff818352015b610300516102c052610300516103005180820282158284830414176137cf57600080fd5b80905090509050610260518181830110156137e957600080fd5b80820190509050600261030051808202821582848304141761380a57600080fd5b809050905090506102e05181818301101561382457600080fd5b80820190509050610200518082101561383c57600080fd5b80820390509050808061384e57600080fd5b820490509050610300526102c0516103005111156138a3576001610300516102c0518082101561387d57600080fd5b8082039050905011151561389e576103005160005250506000516102205156505b6138dc565b60016102c05161030051808210156138ba57600080fd5b808203905090501115156138db576103005160005250506000516102205156505b5b5b81516001018083528114156137ab575b505060006000fd005b600015613f45575b6101805261014052610160526101405161016051610180516101a05160065801610026565b6101c0526101a0526101805261016052610140526101c0516101a0526101405161016051610180516101a0516101c0516101e051610200516102205160065801610226565b6102405261026052610280526102a05261022052610200526101e0526101c0526101a05261018052610160526101405261024080516101c05280602001516101e052806040015161020052806060015161022052506101405161016051610180516101a0516101c0516101e0516102005161022051610240516101c051610260526101e05161028052610200516102a052610220516102c0526101a0516102e0526102e0516102c0516102a05161028051610260516006580161045c565b610340526102405261022052610200526101e0526101c0526101a052610180526101605261014052610340516102405260206102e060046318160ddd6102805261029c6005545afa613a7757600080fd5b601f3d11613a8457600080fd5b6000506102e051610260526102405161014051610240518082028215828483041417613aaf57600080fd5b80905090509050610260518080613ac557600080fd5b82049050905080821015613ad857600080fd5b80820390509050610280526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516101a0516102c052610160516102e0526101c051610300526101e0516103205261020051610340526102205161036052610280516103805261038051610360516103405161032051610300516102e0516102c05160065801613589565b6103e0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103e0516102a0526101c0516102c0526101e0516102e0526102005161030052610220516103205260025460048082028215828483041417613be557600080fd5b80905090509050600c808204905090506103405261036060006004818352015b60006103805261016051610360511415613c87576101c06103605160048110613c2d57600080fd5b6020020151610280518082028215828483041417613c4a57600080fd5b80905090509050610240518080613c6057600080fd5b8204905090506102a05180821015613c7757600080fd5b8082039050905061038052613d06565b6101c06103605160048110613c9b57600080fd5b60200201516101c06103605160048110613cb457600080fd5b6020020151610280518082028215828483041417613cd157600080fd5b80905090509050610240518080613ce757600080fd5b82049050905080821015613cfa57600080fd5b80820390509050610380525b6102c06103605160048110613d1a57600080fd5b60200201805161034051610380518082028215828483041417613d3c57600080fd5b809050905090506402540be4008082049050905080821015613d5d57600080fd5b808203905090508152505b8151600101808352811415613c05575b50506102c06101605160048110613d8e57600080fd5b6020020151610140610380525b61038051516020610380510161038052610380610380511015613dbd57613d9b565b6101a0516103a052610160516103c0526102c0516103e0526102e05161040052610300516104205261032051610440526102805161046052610460516104405161042051610400516103e0516103c0516103a05160065801613589565b6104c052610360610380525b6103805152602061038051036103805261014061038051101515613e4957613e26565b6104c05180821015613e5a57600080fd5b80820390509050610360526103608051600180821015613e7957600080fd5b808203905090508152506101c06101605160048110613e9757600080fd5b60200201516102a05180821015613ead57600080fd5b80820390509050610380526103a080808061036051815250506020810190508080610380516103605180821015613ee357600080fd5b80820390509050815250506020810190508080610260518152505060609050905060c05260c051610400525b600061040051111515613f2157613f3d565b602061040051036103a001516020610400510361040052613f0f565b610180515650005b63cc2b27d76000511415613fdd5760243580806000811215613f6357195b607f1c15613f7057600080fd5b90505060043561014052602435610160526101605161014051600658016138fe565b6101c0526101e052610200526101c08080808051610220525050602081019050808080516102405250506020810190508080805161026052505050506102205160005260206000f350005b631a4d01d260005114156143a35762ffffff5415613ffa57600080fd5b600162ffffff556024358080600081121561401157195b607f1c1561401e57600080fd5b905050600f541561402e57600080fd5b606036610140376101405161016051610180516004356101a0526024356101c0526101c0516101a051600658016138fe565b6102205261024052610260526101805261016052610140526102208080808051610280525050602081019050808080516102a0525050602081019050808080516102c05250505050610280805161014052806020015161016052806040015161018052506044356101405110151515614118576308c379a06101a05260206101c05260186101e0527f4e6f7420656e6f75676820636f696e732072656d6f7665640000000000000000610200526101e05060646101bcfd5b6024356004811061412857600080fd5b600160c052602060c0200180546101405161016051600354808202821582848304141761415457600080fd5b809050905090506402540be4008082049050905081818301101561417757600080fd5b808201905090508082101561418b57600080fd5b80820390509050815550602061024060446379cc67906101a052336101c0526004356101e0526101bc60006005545af16141c457600080fd5b601f3d116141d157600080fd5b6000506102405060006004610200527fa9059cbb000000000000000000000000000000000000000000000000000000006102205261020060048060208461026001018260208501600060045af15050805182019150503360208261026001015260208101905061014051602082610260010152602081019050806102605261026090508051602001806103008284600060045af161426e57600080fd5b505060206103c06103005161032060006024356004811061428e57600080fd5b600060c052602060c02001545af16142a557600080fd5b60203d808211156142b657806142b8565b815b905090506103a0526103a08051602001806101a08284600060045af16142dd57600080fd5b505060006101a0511115614330576101a080602001516000825180602090131561430657600080fd5b809190121561431457600080fd5b806020036101000a8204905090509050151561432f57600080fd5b5b600435610200526101405161022052610180516004358082101561435357600080fd5b8082039050905061024052337f5ad056f2e28a8cec232015406b843668c1e36cda598127ec3b8c59b8c72773a06060610200a261014051600052600062ffffff5560206000f350600062ffffff55005b633c157e6460005114156145475760045433146143bf57600080fd5b600854620151808181830110156143d557600080fd5b808201905090504210156143e857600080fd5b42620151808181830110156143fc57600080fd5b80820190509050602435101561441157600080fd5b6101405160065801610026565b610160526101405261016051610140526004356064808202821582848304141761444757600080fd5b80905090509050610160526000600435111561446a57620f42406004351061446d565b60005b61447657600080fd5b610140516101605110156144b9576101405161016051600a80820282158284830414176144a257600080fd5b8090509050905010156144b457600080fd5b6144ea565b61014051600a80820282158284830414176144d357600080fd5b809050905090506101605111156144e957600080fd5b5b6101405160065561016051600755426008556024356009556101405161018052610160516101a052426101c0526024356101e0527fa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c2546080610180a1005b63551a658860005114156145cc57600454331461456357600080fd5b6101405160065801610026565b6101605261014052610160516101405261014051600655610140516007554260085542600955610140516101605242610180527f46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc2019386040610160a1005b635b5a1467600051141561468a5760045433146145e857600080fd5b600a54156145f557600080fd5b64012a05f200600435111561460957600080fd5b6402540be400602435111561461d57600080fd5b426203f48081818301101561463157600080fd5b808201905090506101405261014051600a55600435600c55602435600d556004356101605260243561018052610140517f351fc5da2fbf480f2225debf3664a4bc90fa9923743aad58b4603f648e931fe06040610160a2005b634f12fe97600051141561471e5760045433146146a657600080fd5b600a544210156146b557600080fd5b6000600a54186146c457600080fd5b6000600a55600c5461014052600d546101605261014051600255610160516003556101405161018052610160516101a0527fbe12859b636aed607d5230b2cc2711f68d70e51060e6cca1f575ef5d2fcc95d16040610180a1005b63226840fb600051141561474157600454331461473a57600080fd5b6000600a55005b636b441a4060005114156147d55760043560a01c1561475f57600080fd5b600454331461476d57600080fd5b600b541561477a57600080fd5b426203f48081818301101561478e57600080fd5b808201905090506101405261014051600b55600435600e55600435610140517f181aa3aa17d4cbf99265dd4443eba009433d3cde79d60164fde1d1a192beb93560006000a3005b636a1c05ae600051141561484e5760045433146147f157600080fd5b600b5442101561480057600080fd5b6000600b541861480f57600080fd5b6000600b55600e546101405261014051600455610140517f71614071b88dee5e0b2ae578a9dd7b2ebbe9ae832ba419dc0242cd065a290b6c60006000a2005b6386fbf193600051141561487157600454331461486a57600080fd5b6000600b55005b63e2e7d264600051141561490d5760206101c060246370a0823161014052306101605261015c600435600481106148a757600080fd5b600060c052602060c02001545afa6148be57600080fd5b601f3d116148cb57600080fd5b6000506101c051600435600481106148e257600080fd5b600160c052602060c0200154808210156148fb57600080fd5b8082039050905060005260206000f350005b6330c540856000511415614b2857600454331461492957600080fd5b61014060006004818352015b610140516004811061494657600080fd5b600060c052602060c020015461016052602061022060246370a082316101a052306101c0526101bc610160515afa61497d57600080fd5b601f3d1161498a57600080fd5b6000506102205161014051600481106149a257600080fd5b600160c052602060c0200154808210156149bb57600080fd5b80820390509050610180526000610180511115614b135760006004610200527fa9059cbb000000000000000000000000000000000000000000000000000000006102205261020060048060208461026001018260208501600060045af15050805182019150503360208261026001015260208101905061018051602082610260010152602081019050806102605261026090508051602001806103008284600060045af1614a6857600080fd5b505060206103c0610300516103206000610160515af1614a8757600080fd5b60203d80821115614a985780614a9a565b815b905090506103a0526103a08051602001806101a08284600060045af1614abf57600080fd5b505060006101a0511115614b12576101a0806020015160008251806020901315614ae857600080fd5b8091901215614af657600080fd5b806020036101000a82049050905090501515614b1157600080fd5b5b5b5b8151600101808352811415614935575b5050005b63524c39016000511415614bd6576004543314614b4457600080fd5b61014060006004818352015b60206101e060246370a0823161016052306101805261017c6101405160048110614b7957600080fd5b600060c052602060c02001545afa614b9057600080fd5b601f3d11614b9d57600080fd5b6000506101e0516101405160048110614bb557600080fd5b600160c052602060c02001555b8151600101808352811415614b50575b5050005b63e36988536000511415614c07576004543314614bf257600080fd5b4260105411614c0057600080fd5b6001600f55005b633046f9726000511415614c2a576004543314614c2357600080fd5b6000600f55005b63c66106576000511415614c5f5760043560048110614c4857600080fd5b600060c052602060c020015460005260206000f350005b634903b0d16000511415614c945760043560048110614c7d57600080fd5b600160c052602060c020015460005260206000f350005b63ddca3f436000511415614cb05760025460005260206000f350005b63fee3f7f96000511415614ccc5760035460005260206000f350005b638da5cb5b6000511415614ce85760045460005260206000f350005b6382c630666000511415614d045760055460005260206000f350005b635409491a6000511415614d205760065460005260206000f350005b63b4b577ad6000511415614d3c5760075460005260206000f350005b632081066c6000511415614d585760085460005260206000f350005b63140522886000511415614d745760095460005260206000f350005b63405e28f86000511415614d9057600a5460005260206000f350005b63e0a0b5866000511415614dac57600b5460005260206000f350005b6358680d0b6000511415614dc857600c5460005260206000f350005b63e38244626000511415614de457600d5460005260206000f350005b631ec0cdc16000511415614e0057600e5460005260206000f350005b5b60006000fd

Verified Source Code Partial Match

Compiler: v0.2.8+commit.069936f
Vyper_contract.vy 900 lines
# @version 0.2.8

"""
@title ETH2SNOW
@author SnowSwap/Curve
 _____ _   _      _____  _____ _   _ _____  _    _ 
|  ___| | | |    / __  \/  ___| \ | |  _  || |  | |
| |__ | |_| |__  `' / /'\ `--.|  \| | | | || |  | |
|  __|| __| '_ \   / /   `--. \ . ` | | | || |/\| |
| |___| |_| | | |./ /___/\__/ / |\  \ \_/ /\  /\  /
\____/ \__|_| |_|\_____/\____/\_| \_/\___/  \/  \/ 
                                                   
                                                   
SnowSwap.org ETH2Snow Pool (Snowswap.org WETH/crETH/vETH2/aETH)
"""

from vyper.interfaces import ERC20

interface CurveToken:
    def mint(_to: address, _value: uint256) -> bool: nonpayable
    def burnFrom(_to: address, _value: uint256) -> bool: nonpayable


# Events
event TokenExchange:
    buyer: indexed(address)
    sold_id: int128
    tokens_sold: uint256
    bought_id: int128
    tokens_bought: uint256

event AddLiquidity:
    provider: indexed(address)
    token_amounts: uint256[N_COINS]
    fees: uint256[N_COINS]
    invariant: uint256
    token_supply: uint256

event RemoveLiquidity:
    provider: indexed(address)
    token_amounts: uint256[N_COINS]
    fees: uint256[N_COINS]
    token_supply: uint256

event RemoveLiquidityOne:
    provider: indexed(address)
    token_amount: uint256
    coin_amount: uint256
    token_supply: uint256

event RemoveLiquidityImbalance:
    provider: indexed(address)
    token_amounts: uint256[N_COINS]
    fees: uint256[N_COINS]
    invariant: uint256
    token_supply: uint256

event CommitNewAdmin:
    deadline: indexed(uint256)
    admin: indexed(address)

event NewAdmin:
    admin: indexed(address)

event CommitNewFee:
    deadline: indexed(uint256)
    fee: uint256
    admin_fee: uint256

event NewFee:
    fee: uint256
    admin_fee: uint256

event RampA:
    old_A: uint256
    new_A: uint256
    initial_time: uint256
    future_time: uint256

event StopRampA:
    A: uint256
    t: uint256


# These constants must be set prior to compiling
N_COINS: constant(int128) = 4
# PRECISION_MUL: constant(uint256[N_COINS]) = []
RATES: constant(uint256[N_COINS]) = [1000000000000000000, 1000000000000000000, 1000000000000000000, 1000000000000000000]

# fixed constants
FEE_DENOMINATOR: constant(uint256) = 10 ** 10
LENDING_PRECISION: constant(uint256) = 10 ** 18
PRECISION: constant(uint256) = 10 ** 18  # The precision to convert to

MAX_ADMIN_FEE: constant(uint256) = 10 * 10 ** 9
MAX_FEE: constant(uint256) = 5 * 10 ** 9
MAX_A: constant(uint256) = 10 ** 6
MAX_A_CHANGE: constant(uint256) = 10

ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400
MIN_RAMP_TIME: constant(uint256) = 86400

coins: public(address[N_COINS])
balances: public(uint256[N_COINS])
fee: public(uint256)  # fee * 1e10
admin_fee: public(uint256)  # admin_fee * 1e10

owner: public(address)
lp_token: public(address)

A_PRECISION: constant(uint256) = 100
initial_A: public(uint256)
future_A: public(uint256)
initial_A_time: public(uint256)
future_A_time: public(uint256)

admin_actions_deadline: public(uint256)
transfer_ownership_deadline: public(uint256)
future_fee: public(uint256)
future_admin_fee: public(uint256)
future_owner: public(address)

is_killed: bool
kill_deadline: uint256
KILL_DEADLINE_DT: constant(uint256) = 2 * 30 * 86400


@external
def __init__(
    _owner: address,
    _coins: address[N_COINS],
    _pool_token: address,
    _A: uint256,
    _fee: uint256,
    _admin_fee: uint256
):
    """
    @notice Contract constructor
    @param _owner Contract owner address
    @param _coins Addresses of ERC20 conracts of coins
    @param _pool_token Address of the token representing LP share
    @param _A Amplification coefficient multiplied by n * (n - 1)
    @param _fee Fee to charge for exchanges
    @param _admin_fee Admin fee
    """
    for i in range(N_COINS):
        assert _coins[i] != ZERO_ADDRESS
    self.coins = _coins
    self.initial_A = _A * A_PRECISION
    self.future_A = _A * A_PRECISION
    self.fee = _fee
    self.admin_fee = _admin_fee
    self.owner = _owner
    self.kill_deadline = block.timestamp + KILL_DEADLINE_DT
    self.lp_token = _pool_token


@view
@internal
def _A() -> uint256:
    """
    Handle ramping A up or down
    """
    t1: uint256 = self.future_A_time
    A1: uint256 = self.future_A

    if block.timestamp < t1:
        A0: uint256 = self.initial_A
        t0: uint256 = self.initial_A_time
        # Expressions in uint256 cannot have negative numbers, thus "if"
        if A1 > A0:
            return A0 + (A1 - A0) * (block.timestamp - t0) / (t1 - t0)
        else:
            return A0 - (A0 - A1) * (block.timestamp - t0) / (t1 - t0)

    else:  # when t1 == 0 or block.timestamp >= t1
        return A1


@view
@external
def A() -> uint256:
    return self._A() / A_PRECISION


@view
@external
def A_precise() -> uint256:
    return self._A()


@view
@internal
def _xp() -> uint256[N_COINS]:
    result: uint256[N_COINS] = RATES
    for i in range(N_COINS):
        result[i] = result[i] * self.balances[i] / LENDING_PRECISION
    return result


@pure
@internal
def _xp_mem(_balances: uint256[N_COINS]) -> uint256[N_COINS]:
    result: uint256[N_COINS] = RATES
    for i in range(N_COINS):
        result[i] = result[i] * _balances[i] / PRECISION
    return result


@pure
@internal
def get_D(xp: uint256[N_COINS], amp: uint256) -> uint256:
    S: uint256 = 0
    Dprev: uint256 = 0

    for _x in xp:
        S += _x
    if S == 0:
        return 0

    D: uint256 = S
    Ann: uint256 = amp * N_COINS
    for _i in range(255):
        D_P: uint256 = D
        for _x in xp:
            D_P = D_P * D / (_x * N_COINS)  # If division by 0, this will be borked: only withdrawal will work. And that is good
        Dprev = D
        D = (Ann * S / A_PRECISION + D_P * N_COINS) * D / ((Ann - A_PRECISION) * D / A_PRECISION + (N_COINS + 1) * D_P)
        # Equality with the precision of 1
        if D > Dprev:
            if D - Dprev <= 1:
                return D
        else:
            if Dprev - D <= 1:
                return D

    # convergence typically occurs in 4 rounds or less, this should be unreachable!
    # if it does happen the pool is borked and LPs can withdraw via `remove_liquidity`
    raise


@view
@internal
def get_D_mem(_balances: uint256[N_COINS], amp: uint256) -> uint256:
    return self.get_D(self._xp_mem(_balances), amp)


@view
@external
def get_virtual_price() -> uint256:
    """
    @notice The current virtual price of the pool LP token
    @dev Useful for calculating profits
    @return LP token virtual price normalized to 1e18
    """
    D: uint256 = self.get_D(self._xp(), self._A())
    # D is in the units similar to DAI (e.g. converted to precision 1e18)
    # When balanced, D = n * x_u - total virtual value of the portfolio
    token_supply: uint256 = ERC20(self.lp_token).totalSupply()
    return D * PRECISION / token_supply


@view
@external
def calc_token_amount(amounts: uint256[N_COINS], is_deposit: bool) -> uint256:
    """
    @notice Calculate addition or reduction in token supply from a deposit or withdrawal
    @dev This calculation accounts for slippage, but not fees.
         Needed to prevent front-running, not for precise calculations!
    @param amounts Amount of each coin being deposited
    @param is_deposit set True for deposits, False for withdrawals
    @return Expected amount of LP tokens received
    """
    amp: uint256 = self._A()
    _balances: uint256[N_COINS] = self.balances
    D0: uint256 = self.get_D_mem(_balances, amp)
    for i in range(N_COINS):
        if is_deposit:
            _balances[i] += amounts[i]
        else:
            _balances[i] -= amounts[i]
    D1: uint256 = self.get_D_mem(_balances, amp)
    token_amount: uint256 = ERC20(self.lp_token).totalSupply()
    diff: uint256 = 0
    if is_deposit:
        diff = D1 - D0
    else:
        diff = D0 - D1
    return diff * token_amount / D0


@external
@nonreentrant('lock')
def add_liquidity(amounts: uint256[N_COINS], min_mint_amount: uint256) -> uint256:
    """
    @notice Deposit coins into the pool
    @param amounts List of amounts of coins to deposit
    @param min_mint_amount Minimum amount of LP tokens to mint from the deposit
    @return Amount of LP tokens received by depositing
    """
    assert not self.is_killed  # dev: is killed

    amp: uint256 = self._A()

    _lp_token: address = self.lp_token
    token_supply: uint256 = ERC20(_lp_token).totalSupply()
    # Initial invariant
    D0: uint256 = 0
    old_balances: uint256[N_COINS] = self.balances
    if token_supply > 0:
        D0 = self.get_D_mem(old_balances, amp)
    new_balances: uint256[N_COINS] = old_balances

    for i in range(N_COINS):
        if token_supply == 0:
            assert amounts[i] > 0  # dev: initial deposit requires all coins
        # balances store amounts of c-tokens
        new_balances[i] = old_balances[i] + amounts[i]

    # Invariant after change
    D1: uint256 = self.get_D_mem(new_balances, amp)
    assert D1 > D0

    # We need to recalculate the invariant accounting for fees
    # to calculate fair user's share
    D2: uint256 = D1
    fees: uint256[N_COINS] = empty(uint256[N_COINS])

    if token_supply > 0:
        # Only account for fees if we are not the first to deposit
        _fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1))
        _admin_fee: uint256 = self.admin_fee
        for i in range(N_COINS):
            ideal_balance: uint256 = D1 * old_balances[i] / D0
            difference: uint256 = 0
            if ideal_balance > new_balances[i]:
                difference = ideal_balance - new_balances[i]
            else:
                difference = new_balances[i] - ideal_balance
            fees[i] = _fee * difference / FEE_DENOMINATOR
            self.balances[i] = new_balances[i] - (fees[i] * _admin_fee / FEE_DENOMINATOR)
            new_balances[i] -= fees[i]
        D2 = self.get_D_mem(new_balances, amp)
    else:
        self.balances = new_balances

    # Calculate, how much pool tokens to mint
    mint_amount: uint256 = 0
    if token_supply == 0:
        mint_amount = D1  # Take the dust if there was any
    else:
        mint_amount = token_supply * (D2 - D0) / D0

    assert mint_amount >= min_mint_amount, "Slippage screwed you"

    # Take coins from the sender
    for i in range(N_COINS):
        if amounts[i] > 0:
            # "safeTransferFrom" which works for ERC20s which return bool or not
            _response: Bytes[32] = raw_call(
                self.coins[i],
                concat(
                    method_id("transferFrom(address,address,uint256)"),
                    convert(msg.sender, bytes32),
                    convert(self, bytes32),
                    convert(amounts[i], bytes32),
                ),
                max_outsize=32,
            )  # dev: failed transfer
            if len(_response) > 0:
                assert convert(_response, bool)

    # Mint pool tokens
    CurveToken(_lp_token).mint(msg.sender, mint_amount)

    log AddLiquidity(msg.sender, amounts, fees, D1, token_supply + mint_amount)

    return mint_amount


@view
@internal
def get_y(i: int128, j: int128, x: uint256, xp_: uint256[N_COINS]) -> uint256:
    # x in the input is converted to the same price/precision

    assert i != j       # dev: same coin
    assert j >= 0       # dev: j below zero
    assert j < N_COINS  # dev: j above N_COINS

    # should be unreachable, but good for safety
    assert i >= 0
    assert i < N_COINS

    amp: uint256 = self._A()
    D: uint256 = self.get_D(xp_, amp)
    Ann: uint256 = amp * N_COINS
    c: uint256 = D
    S_: uint256 = 0
    _x: uint256 = 0
    y_prev: uint256 = 0

    for _i in range(N_COINS):
        if _i == i:
            _x = x
        elif _i != j:
            _x = xp_[_i]
        else:
            continue
        S_ += _x
        c = c * D / (_x * N_COINS)
    c = c * D * A_PRECISION / (Ann * N_COINS)
    b: uint256 = S_ + D * A_PRECISION / Ann  # - D
    y: uint256 = D
    for _i in range(255):
        y_prev = y
        y = (y*y + c) / (2 * y + b - D)
        # Equality with the precision of 1
        if y > y_prev:
            if y - y_prev <= 1:
                return y
        else:
            if y_prev - y <= 1:
                return y
    raise


@view
@external
def get_dy(i: int128, j: int128, dx: uint256) -> uint256:
    xp: uint256[N_COINS] = self._xp()
    rates: uint256[N_COINS] = RATES

    x: uint256 = xp[i] + (dx * rates[i] / PRECISION)
    y: uint256 = self.get_y(i, j, x, xp)
    dy: uint256 = (xp[j] - y - 1)
    _fee: uint256 = self.fee * dy / FEE_DENOMINATOR
    return (dy - _fee) * PRECISION / rates[j]


@external
@nonreentrant('lock')
def exchange(i: int128, j: int128, dx: uint256, min_dy: uint256) -> uint256:
    """
    @notice Perform an exchange between two coins
    @dev Index values can be found via the `coins` public getter method
    @param i Index value for the coin to send
    @param j Index valie of the coin to recieve
    @param dx Amount of `i` being exchanged
    @param min_dy Minimum amount of `j` to receive
    @return Actual amount of `j` received
    """
    assert not self.is_killed  # dev: is killed

    old_balances: uint256[N_COINS] = self.balances
    xp: uint256[N_COINS] = self._xp_mem(old_balances)

    rates: uint256[N_COINS] = RATES
    x: uint256 = xp[i] + dx * rates[i] / PRECISION
    y: uint256 = self.get_y(i, j, x, xp)

    dy: uint256 = xp[j] - y - 1  # -1 just in case there were some rounding errors
    dy_fee: uint256 = dy * self.fee / FEE_DENOMINATOR

    # Convert all to real units
    dy = (dy - dy_fee) * PRECISION / rates[j]
    assert dy >= min_dy, "Exchange resulted in fewer coins than expected"

    dy_admin_fee: uint256 = dy_fee * self.admin_fee / FEE_DENOMINATOR
    dy_admin_fee = dy_admin_fee * PRECISION / rates[j]

    # Change balances exactly in same way as we change actual ERC20 coin amounts
    self.balances[i] = old_balances[i] + dx
    # When rounding errors happen, we undercharge admin fee in favor of LP
    self.balances[j] = old_balances[j] - dy - dy_admin_fee

    # "safeTransferFrom" which works for ERC20s which return bool or not
    _response: Bytes[32] = raw_call(
        self.coins[i],
        concat(
            method_id("transferFrom(address,address,uint256)"),
            convert(msg.sender, bytes32),
            convert(self, bytes32),
            convert(dx, bytes32),
        ),
        max_outsize=32,
    )  # dev: failed transfer
    if len(_response) > 0:
        assert convert(_response, bool)

    _response = raw_call(
        self.coins[j],
        concat(
            method_id("transfer(address,uint256)"),
            convert(msg.sender, bytes32),
            convert(dy, bytes32),
        ),
        max_outsize=32,
    )  # dev: failed transfer
    if len(_response) > 0:
        assert convert(_response, bool)

    log TokenExchange(msg.sender, i, dx, j, dy)

    return dy


@external
@nonreentrant('lock')
def remove_liquidity(_amount: uint256, min_amounts: uint256[N_COINS]) -> uint256[N_COINS]:
    """
    @notice Withdraw coins from the pool
    @dev Withdrawal amounts are based on current deposit ratios
    @param _amount Quantity of LP tokens to burn in the withdrawal
    @param min_amounts Minimum amounts of underlying coins to receive
    @return List of amounts of coins that were withdrawn
    """
    _lp_token: address = self.lp_token
    total_supply: uint256 = ERC20(_lp_token).totalSupply()
    amounts: uint256[N_COINS] = empty(uint256[N_COINS])
    fees: uint256[N_COINS] = empty(uint256[N_COINS])  # Fees are unused but we've got them historically in event

    for i in range(N_COINS):
        value: uint256 = self.balances[i] * _amount / total_supply
        assert value >= min_amounts[i], "Withdrawal resulted in fewer coins than expected"
        self.balances[i] -= value
        amounts[i] = value
        _response: Bytes[32] = raw_call(
            self.coins[i],
            concat(
                method_id("transfer(address,uint256)"),
                convert(msg.sender, bytes32),
                convert(value, bytes32),
            ),
            max_outsize=32,
        )  # dev: failed transfer
        if len(_response) > 0:
            assert convert(_response, bool)

    CurveToken(_lp_token).burnFrom(msg.sender, _amount)  # dev: insufficient funds

    log RemoveLiquidity(msg.sender, amounts, fees, total_supply - _amount)

    return amounts


@external
@nonreentrant('lock')
def remove_liquidity_imbalance(amounts: uint256[N_COINS], max_burn_amount: uint256) -> uint256:
    """
    @notice Withdraw coins from the pool in an imbalanced amount
    @param amounts List of amounts of underlying coins to withdraw
    @param max_burn_amount Maximum amount of LP token to burn in the withdrawal
    @return Actual amount of the LP token burned in the withdrawal
    """
    assert not self.is_killed  # dev: is killed

    amp: uint256 = self._A()

    old_balances: uint256[N_COINS] = self.balances
    new_balances: uint256[N_COINS] = old_balances
    D0: uint256 = self.get_D_mem(old_balances, amp)
    for i in range(N_COINS):
        new_balances[i] -= amounts[i]
    D1: uint256 = self.get_D_mem(new_balances, amp)

    _lp_token: address = self.lp_token
    token_supply: uint256 = ERC20(_lp_token).totalSupply()
    assert token_supply != 0  # dev: zero total supply

    _fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1))
    _admin_fee: uint256 = self.admin_fee
    fees: uint256[N_COINS] = empty(uint256[N_COINS])
    for i in range(N_COINS):
        ideal_balance: uint256 = D1 * old_balances[i] / D0
        difference: uint256 = 0
        if ideal_balance > new_balances[i]:
            difference = ideal_balance - new_balances[i]
        else:
            difference = new_balances[i] - ideal_balance
        fees[i] = _fee * difference / FEE_DENOMINATOR
        self.balances[i] = new_balances[i] - (fees[i] * _admin_fee / FEE_DENOMINATOR)
        new_balances[i] -= fees[i]
    D2: uint256 = self.get_D_mem(new_balances, amp)

    token_amount: uint256 = (D0 - D2) * token_supply / D0
    assert token_amount != 0  # dev: zero tokens burned
    token_amount += 1  # In case of rounding errors - make it unfavorable for the "attacker"
    assert token_amount <= max_burn_amount, "Slippage screwed you"

    CurveToken(_lp_token).burnFrom(msg.sender, token_amount)  # dev: insufficient funds
    for i in range(N_COINS):
        if amounts[i] != 0:
            _response: Bytes[32] = raw_call(
                self.coins[i],
                concat(
                    method_id("transfer(address,uint256)"),
                    convert(msg.sender, bytes32),
                    convert(amounts[i], bytes32),
                ),
                max_outsize=32,
            )  # dev: failed transfer
            if len(_response) > 0:
                assert convert(_response, bool)


    log RemoveLiquidityImbalance(msg.sender, amounts, fees, D1, token_supply - token_amount)

    return token_amount


@view
@internal
def get_y_D(A_: uint256, i: int128, xp: uint256[N_COINS], D: uint256) -> uint256:
    """
    Calculate x[i] if one reduces D from being calculated for xp to D

    Done by solving quadratic equation iteratively.
    x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)
    x_1**2 + b*x_1 = c

    x_1 = (x_1**2 + c) / (2*x_1 + b)
    """
    # x in the input is converted to the same price/precision

    assert i >= 0  # dev: i below zero
    assert i < N_COINS  # dev: i above N_COINS

    Ann: uint256 = A_ * N_COINS
    c: uint256 = D
    S_: uint256 = 0
    _x: uint256 = 0
    y_prev: uint256 = 0

    for _i in range(N_COINS):
        if _i != i:
            _x = xp[_i]
        else:
            continue
        S_ += _x
        c = c * D / (_x * N_COINS)
    c = c * D * A_PRECISION / (Ann * N_COINS)
    b: uint256 = S_ + D * A_PRECISION / Ann

    y: uint256 = D
    for _i in range(255):
        y_prev = y
        y = (y*y + c) / (2 * y + b - D)
        # Equality with the precision of 1
        if y > y_prev:
            if y - y_prev <= 1:
                return y
        else:
            if y_prev - y <= 1:
                return y
    raise


@view
@internal
def _calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> (uint256, uint256, uint256):
    # First, need to calculate
    # * Get current D
    # * Solve Eqn against y_i for D - _token_amount
    amp: uint256 = self._A()
    xp: uint256[N_COINS] = self._xp()
    D0: uint256 = self.get_D(xp, amp)

    total_supply: uint256 = ERC20(self.lp_token).totalSupply()
    D1: uint256 = D0 - _token_amount * D0 / total_supply
    new_y: uint256 = self.get_y_D(amp, i, xp, D1)
    xp_reduced: uint256[N_COINS] = xp

    _fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1))
    for j in range(N_COINS):
        dx_expected: uint256 = 0
        if j == i:
            dx_expected = xp[j] * D1 / D0 - new_y
        else:
            dx_expected = xp[j] - xp[j] * D1 / D0
        xp_reduced[j] -= _fee * dx_expected / FEE_DENOMINATOR


    # copied from stableswap steth.vy
    dy: uint256 = xp_reduced[i] - self.get_y_D(amp, i, xp_reduced, D1)

    dy -= 1  # Withdraw less to account for rounding errors
    dy_0: uint256 = xp[i] - new_y  # w/o fees

    # dy: uint256 = xp_reduced[i] - self.get_y_D(amp, i, xp_reduced, D1)
    # precisions: uint256[N_COINS] = PRECISION_MUL
    # dy = (dy - 1) / precisions[i]  # Withdraw less to account for rounding errors
    # dy_0: uint256 = (xp[i] - new_y) / precisions[i]  # w/o fees

    return dy, dy_0 - dy, total_supply


@view
@external
def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256:
    """
    @notice Calculate the amount received when withdrawing a single coin
    @param _token_amount Amount of LP tokens to burn in the withdrawal
    @param i Index value of the coin to withdraw
    @return Amount of coin received
    """
    return self._calc_withdraw_one_coin(_token_amount, i)[0]


@external
@nonreentrant('lock')
def remove_liquidity_one_coin(_token_amount: uint256, i: int128, _min_amount: uint256) -> uint256:
    """
    @notice Withdraw a single coin from the pool
    @param _token_amount Amount of LP tokens to burn in the withdrawal
    @param i Index value of the coin to withdraw
    @param _min_amount Minimum amount of coin to receive
    @return Amount of coin received
    """
    assert not self.is_killed  # dev: is killed

    dy: uint256 = 0
    dy_fee: uint256 = 0
    total_supply: uint256 = 0
    dy, dy_fee, total_supply = self._calc_withdraw_one_coin(_token_amount, i)
    assert dy >= _min_amount, "Not enough coins removed"

    self.balances[i] -= (dy + dy_fee * self.admin_fee / FEE_DENOMINATOR)
    CurveToken(self.lp_token).burnFrom(msg.sender, _token_amount)  # dev: insufficient funds


    _response: Bytes[32] = raw_call(
        self.coins[i],
        concat(
            method_id("transfer(address,uint256)"),
            convert(msg.sender, bytes32),
            convert(dy, bytes32),
        ),
        max_outsize=32,
    )  # dev: failed transfer
    if len(_response) > 0:
        assert convert(_response, bool)

    log RemoveLiquidityOne(msg.sender, _token_amount, dy, total_supply - _token_amount)

    return dy


### Admin functions ###
@external
def ramp_A(_future_A: uint256, _future_time: uint256):
    assert msg.sender == self.owner  # dev: only owner
    assert block.timestamp >= self.initial_A_time + MIN_RAMP_TIME
    assert _future_time >= block.timestamp + MIN_RAMP_TIME  # dev: insufficient time

    _initial_A: uint256 = self._A()
    _future_A_p: uint256 = _future_A * A_PRECISION

    assert _future_A > 0 and _future_A < MAX_A
    if _future_A_p < _initial_A:
        assert _future_A_p * MAX_A_CHANGE >= _initial_A
    else:
        assert _future_A_p <= _initial_A * MAX_A_CHANGE

    self.initial_A = _initial_A
    self.future_A = _future_A_p
    self.initial_A_time = block.timestamp
    self.future_A_time = _future_time

    log RampA(_initial_A, _future_A_p, block.timestamp, _future_time)


@external
def stop_ramp_A():
    assert msg.sender == self.owner  # dev: only owner

    current_A: uint256 = self._A()
    self.initial_A = current_A
    self.future_A = current_A
    self.initial_A_time = block.timestamp
    self.future_A_time = block.timestamp
    # now (block.timestamp < t1) is always False, so we return saved A

    log StopRampA(current_A, block.timestamp)


@external
def commit_new_fee(new_fee: uint256, new_admin_fee: uint256):
    assert msg.sender == self.owner  # dev: only owner
    assert self.admin_actions_deadline == 0  # dev: active action
    assert new_fee <= MAX_FEE  # dev: fee exceeds maximum
    assert new_admin_fee <= MAX_ADMIN_FEE  # dev: admin fee exceeds maximum

    _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY
    self.admin_actions_deadline = _deadline
    self.future_fee = new_fee
    self.future_admin_fee = new_admin_fee

    log CommitNewFee(_deadline, new_fee, new_admin_fee)


@external
def apply_new_fee():
    assert msg.sender == self.owner  # dev: only owner
    assert block.timestamp >= self.admin_actions_deadline  # dev: insufficient time
    assert self.admin_actions_deadline != 0  # dev: no active action

    self.admin_actions_deadline = 0
    _fee: uint256 = self.future_fee
    _admin_fee: uint256 = self.future_admin_fee
    self.fee = _fee
    self.admin_fee = _admin_fee

    log NewFee(_fee, _admin_fee)


@external
def revert_new_parameters():
    assert msg.sender == self.owner  # dev: only owner

    self.admin_actions_deadline = 0


@external
def commit_transfer_ownership(_owner: address):
    assert msg.sender == self.owner  # dev: only owner
    assert self.transfer_ownership_deadline == 0  # dev: active transfer

    _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY
    self.transfer_ownership_deadline = _deadline
    self.future_owner = _owner

    log CommitNewAdmin(_deadline, _owner)


@external
def apply_transfer_ownership():
    assert msg.sender == self.owner  # dev: only owner
    assert block.timestamp >= self.transfer_ownership_deadline  # dev: insufficient time
    assert self.transfer_ownership_deadline != 0  # dev: no active transfer

    self.transfer_ownership_deadline = 0
    _owner: address = self.future_owner
    self.owner = _owner

    log NewAdmin(_owner)


@external
def revert_transfer_ownership():
    assert msg.sender == self.owner  # dev: only owner

    self.transfer_ownership_deadline = 0


@view
@external
def admin_balances(i: uint256) -> uint256:
    return ERC20(self.coins[i]).balanceOf(self) - self.balances[i]


@external
def withdraw_admin_fees():
    assert msg.sender == self.owner  # dev: only owner

    for i in range(N_COINS):
        coin: address = self.coins[i]
        value: uint256 = ERC20(coin).balanceOf(self) - self.balances[i]
        if value > 0:
            _response: Bytes[32] = raw_call(
                coin,
                concat(
                    method_id("transfer(address,uint256)"),
                    convert(msg.sender, bytes32),
                    convert(value, bytes32),
                ),
                max_outsize=32,
            )  # dev: failed transfer
            if len(_response) > 0:
                assert convert(_response, bool)



@external
def donate_admin_fees():
    assert msg.sender == self.owner  # dev: only owner
    for i in range(N_COINS):
        self.balances[i] = ERC20(self.coins[i]).balanceOf(self)


@external
def kill_me():
    assert msg.sender == self.owner  # dev: only owner
    assert self.kill_deadline > block.timestamp  # dev: deadline has passed
    self.is_killed = True


@external
def unkill_me():
    assert msg.sender == self.owner  # dev: only owner
    self.is_killed = False

Read Contract

A 0xf446c1d0 → uint256
A_precise 0x76a2f0f0 → uint256
admin_actions_deadline 0x405e28f8 → uint256
admin_balances 0xe2e7d264 → uint256
admin_fee 0xfee3f7f9 → uint256
balances 0x4903b0d1 → uint256
calc_token_amount 0xcf701ff7 → uint256
calc_withdraw_one_coin 0xcc2b27d7 → uint256
coins 0xc6610657 → address
fee 0xddca3f43 → uint256
future_A 0xb4b577ad → uint256
future_A_time 0x14052288 → uint256
future_admin_fee 0xe3824462 → uint256
future_fee 0x58680d0b → uint256
future_owner 0x1ec0cdc1 → address
get_dy 0x5e0d443f → uint256
get_virtual_price 0xbb7b8b80 → uint256
initial_A 0x5409491a → uint256
initial_A_time 0x2081066c → uint256
lp_token 0x82c63066 → address
owner 0x8da5cb5b → address
transfer_ownership_deadline 0xe0a0b586 → uint256

Write Contract 17 functions

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

add_liquidity 0x029b2f34
uint256[4] amounts
uint256 min_mint_amount
returns: uint256
apply_new_fee 0x4f12fe97
No parameters
apply_transfer_ownership 0x6a1c05ae
No parameters
commit_new_fee 0x5b5a1467
uint256 new_fee
uint256 new_admin_fee
commit_transfer_ownership 0x6b441a40
address _owner
donate_admin_fees 0x524c3901
No parameters
exchange 0x3df02124
int128 i
int128 j
uint256 dx
uint256 min_dy
returns: uint256
kill_me 0xe3698853
No parameters
ramp_A 0x3c157e64
uint256 _future_A
uint256 _future_time
remove_liquidity 0x7d49d875
uint256 _amount
uint256[4] min_amounts
returns: uint256[4]
remove_liquidity_imbalance 0x18a7bd76
uint256[4] amounts
uint256 max_burn_amount
returns: uint256
remove_liquidity_one_coin 0x1a4d01d2
uint256 _token_amount
int128 i
uint256 _min_amount
returns: uint256
revert_new_parameters 0x226840fb
No parameters
revert_transfer_ownership 0x86fbf193
No parameters
stop_ramp_A 0x551a6588
No parameters
unkill_me 0x3046f972
No parameters
withdraw_admin_fees 0x30c54085
No parameters

Recent Transactions

No transactions found for this address