Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xDeBF20617708857ebe4F679508E7b7863a8A8EeE
Balance 0 ETH
Nonce 1
Code Size 21909 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

21909 bytes
0x341561000a57600080fd5b60043610156100185761558f565b600035601c526000156101c1575b61014052600d5461016052600b5461018052610160514210156101ae57600a546101a052600c546101c0526101a051610180511115610107576101a051610180516101a0518082101561007857600080fd5b80820390509050426101c0518082101561009157600080fd5b8082039050905080820282158284830414176100ac57600080fd5b80905090509050610160516101c051808210156100c857600080fd5b8082039050905080806100da57600080fd5b8204905090508181830110156100ef57600080fd5b808201905090506000526000516101405156506101a9565b6101a0516101a051610180518082101561012057600080fd5b80820390509050426101c0518082101561013957600080fd5b80820390509050808202821582848304141761015457600080fd5b80905090509050610160516101c0518082101561017057600080fd5b80820390509050808061018257600080fd5b8204905090508082101561019557600080fd5b808203905090506000526000516101405156505b6101bf565b610180516000526000516101405156505b005b63f446c1d060005114156101f45760065801610026565b610140526101405160648082049050905060005260206000f350005b6376a2f0f0600051141561021e5760065801610026565b610140526101405160005260206000f350005b600015610396575b6101c0526101405261016052610180526101a0526402540be4006101a05111151561026057610180516000526000516101c0515650610394565b610140516101605181818301101561027757600080fd5b808201905090506101e0526101e080516101e051808202821582848304141761029f57600080fd5b809050905090508152506101a0516101805180820282158284830414176102c557600080fd5b809050905090506101a0516402540be400808210156102e357600080fd5b808203905090506004808202821582848304141761030057600080fd5b8090509050905061014051808202821582848304141761031f57600080fd5b8090509050905061016051808202821582848304141761033e57600080fd5b809050905090506101e051808061035457600080fd5b8204905090506402540be40081818301101561036f57600080fd5b80820190509050808061038157600080fd5b8204905090506000526000516101c05156505b005b6376a9cd3e60005114156105e457600435808060008112156103b457195b607f1c156103c157600080fd5b905050602435808060008112156103d457195b607f1c156103e157600080fd5b90505060016101405264e8d4a510006101605264e8d4a5100061018052602061024060246370a082316101c052306101e0526101dc6004356003811061042657600080fd5b600060c052602060c02001545afa61043d57600080fd5b601f3d1161044a57600080fd5b600050610240516004356003811061046157600080fd5b600260c052602060c02001548082101561047a57600080fd5b808203905090506101406004356003811061049457600080fd5b602002015180820282158284830414176104ad57600080fd5b809050905090506101a052602061026060246370a082316101e05230610200526101fc602435600381106104e057600080fd5b600060c052602060c02001545afa6104f757600080fd5b601f3d1161050457600080fd5b600050610260516024356003811061051b57600080fd5b600260c052602060c02001548082101561053457600080fd5b808203905090506101406024356003811061054e57600080fd5b6020020151808202821582848304141761056757600080fd5b809050905090506101c0526101405161016051610180516101a0516101c0516101a0516101e0526101c0516102005260035461022052600454610240526102405161022051610200516101e05160065801610226565b6102a0526101c0526101a0526101805261016052610140526102a05160005260206000f350005b634903b0d160005114156106805760206101c060246370a0823161014052306101605261015c6004356003811061061a57600080fd5b600060c052602060c02001545afa61063157600080fd5b601f3d1161063e57600080fd5b6000506101c0516004356003811061065557600080fd5b600260c052602060c02001548082101561066e57600080fd5b8082039050905060005260206000f350005b60001561078c575b61014052606036610160376101c060006003818352015b602061026060246370a082316101e05230610200526101fc6101c051600381106106c857600080fd5b600060c052602060c02001545afa6106df57600080fd5b601f3d116106ec57600080fd5b600050610260516101c0516003811061070457600080fd5b600260c052602060c02001548082101561071d57600080fd5b808203905090506101606101c0516003811061073857600080fd5b60200201525b815160010180835281141561069f575b505060606101c0525b60006101c05111151561076957610785565b60206101c05103610160015160206101c051036101c052610757565b6101405156005b600015610ab5575b6101c0526101405261016052610180526101a05260006101e05261022060006003818352015b602061022051026101400151610200526101e08051610200518181830110156107e257600080fd5b808201905090508152505b81516001018083528114156107ba575b50506101e05115156108185760006000526000516101c05156505b6000610200526101e051610220526101a0516003808202821582848304141761084057600080fd5b8090509050905061024052610260600060ff818352015b61022051610280526102c060006003818352015b60206102c0510261014001516102a0526102805161022051808202821582848304141761089757600080fd5b809050905090506102a051600380820282158284830414176108b857600080fd5b8090509050905060018181830110156108d057600080fd5b8082019050905080806108e257600080fd5b820490509050610280525b815160010180835281141561086b575b50506102205161020052610240516101e051808202821582848304141761092357600080fd5b80905090509050606480820490509050610280516003808202821582848304141761094d57600080fd5b8090509050905081818301101561096357600080fd5b8082019050905061022051808202821582848304141761098257600080fd5b809050905090506102405160648082101561099c57600080fd5b808203905090506102205180820282158284830414176109bb57600080fd5b8090509050905060648082049050905060046102805180820282158284830414176109e557600080fd5b809050905090508181830110156109fb57600080fd5b808201905090508080610a0d57600080fd5b8204905090506102205261020051610220511115610a62576001610220516102005180821015610a3c57600080fd5b80820390509050111515610a5d576102205160005250506000516101c05156505b610a9b565b6001610200516102205180821015610a7957600080fd5b80820390509050111515610a9a576102205160005250506000516101c05156505b5b5b8151600101808352811415610857575b505060006000fd005b600015610bea575b6101c0526101405261016052610180526101a05260016101e05264e8d4a510006102005264e8d4a510006102205261024060006003818352015b6101e06102405160038110610b0b57600080fd5b6020020180516101406102405160038110610b2557600080fd5b60200201518082028215828483041417610b3e57600080fd5b809050905090508152505b8151600101808352811415610af7575b50506101405161016051610180516101a0516101c0516101e05161020051610220516101e05161024052610200516102605261022051610280526101a0516102a0526102a05161028051610260516102405160065801610794565b6103005261022052610200526101e0526101c0526101a052610180526101605261014052610300516000526000516101c0515650005b63bb7b8b806000511415610d8c576101405160065801610688565b61016052610180526101a0526101405261016080516101c05280602001516101e052806040015161020052506101405161016051610180516101a0516101c0516101e0516102005160065801610026565b61022052610200526101e0526101c0526101a05261018052610160526101405261022051610240526101405161016051610180516101a0516101c0516101e0516102005161022051610240516101c051610260526101e05161028052610200516102a052610240516102c0526102c0516102a051610280516102605160065801610abd565b610320526102405261022052610200526101e0526101c0526101a052610180526101605261014052610320516101405260206101e060046318160ddd6101805261019c6007545afa610d2c57600080fd5b601f3d11610d3957600080fd5b6000506101e0516101605261014051670de0b6b3a76400008082028215828483041417610d6557600080fd5b80905090509050610160518080610d7b57600080fd5b82049050905060005260206000f350005b633883e119600051141561109b5760643560011c15610daa57600080fd5b61014051610160516101805160065801610688565b6101a0526101c0526101e0526101805261016052610140526101a0805161014052806020015161016052806040015161018052506101405161016051610180516101a05160065801610026565b6101c0526101a0526101805261016052610140526101c0516101a0526101405161016051610180516101a0516101c051610140516101e052610160516102005261018051610220526101a051610240526102405161022051610200516101e05160065801610abd565b6102a0526101c0526101a0526101805261016052610140526102a0516101c0526101e060006003818352015b60643515610ef9576101406101e05160038110610ebd57600080fd5b60200201805160046101e05160038110610ed657600080fd5b6020020135818183011015610eea57600080fd5b80820190509050815250610f43565b6101406101e05160038110610f0d57600080fd5b60200201805160046101e05160038110610f2657600080fd5b602002013580821015610f3857600080fd5b808203905090508152505b5b8151600101808352811415610ea1575b50506101405161016051610180516101a0516101c0516101e0516101405161020052610160516102205261018051610240526101a051610260526102605161024051610220516102005160065801610abd565b6102c0526101e0526101c0526101a0526101805261016052610140526102c0516101e052602061028060046318160ddd6102205261023c6007545afa610fec57600080fd5b601f3d11610ff957600080fd5b600050610280516102005260006102205260643515611037576101e0516101c0518082101561102757600080fd5b8082039050905061022052611058565b6101c0516101e0518082101561104c57600080fd5b80820390509050610220525b6102205161020051808202821582848304141761107457600080fd5b809050905090506101c051808061108a57600080fd5b82049050905060005260206000f350005b634515cef360005114156110b4576000610140526110ea565b632b6e993a60005114156110e25760843560011c156110d257600080fd5b60206084610140376000506110ea565b600015611ca7575b62ffffff54156110f957600080fd5b600162ffffff556014541561110d57600080fd5b610140516101605160065801610026565b61018052610160526101405261018051610160526101405161016051610180516101a0516101c05160065801610688565b6101e05261020052610220526101c0526101a0526101805261016052610140526101e080516101805280602001516101a05280604001516101c052506007546101e052602061028060046318160ddd6102205261023c6101e0515afa6111b457600080fd5b601f3d116111c157600080fd5b60005061028051610200526000610220526000610200511815611264576101405161016051610180516101a0516101c0516101e051610200516102205161018051610240526101a051610260526101c05161028052610160516102a0526102a05161028051610260516102405160065801610abd565b6103005261022052610200526101e0526101c0526101a05261018052610160526101405261030051610220525b61018051610240526101a051610260526101c051610280526102a060006003818352015b6102005115156112b757600060046102a051600381106112a757600080fd5b6020020135186112b657600080fd5b5b6102406102a051600381106112cb57600080fd5b60200201805160046102a051600381106112e457600080fd5b60200201358181830110156112f857600080fd5b808201905090508152505b8151600101808352811415611288575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a051610240516102c052610260516102e0526102805161030052610160516103205261032051610300516102e0516102c05160065801610abd565b610380526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610180526101605261014052610380516102a052610220516102a051116113cc57600080fd5b6080366102c037600061020051181561180457610220516102a0518181830110156113f657600080fd5b80820190509050600380820490509050610340526003546003808202821582848304141761142357600080fd5b8090509050905060088082049050905061036052600454610380526005546103a05260006103c0526103e060006003818352015b6102a0516101806103e0516003811061146f57600080fd5b6020020151808202821582848304141761148857600080fd5b8090509050905061022051808061149e57600080fd5b820490509050610400526102406103e051600381106114bc57600080fd5b602002015161042052610420516104005111156114f8576104005161042051808210156114e857600080fd5b808203905090506103c052611519565b61042051610400518082101561150d57600080fd5b808203905090506103c0525b6101806103e0516003811061152d57600080fd5b60200201516104205181818301101561154557600080fd5b8082019050905061044052610140610460525b6104605151602061046051016104605261046061046051101561157a57611558565b6104405161048052610340516104a052610360516104c052610380516104e0526104e0516104c0516104a0516104805160065801610226565b61054052610440610460525b61046051526020610460510361046052610140610460511015156115e2576115bf565b610540516103c05180820282158284830414176115fe57600080fd5b809050905090506402540be400808204905090506102c06103e0516003811061162657600080fd5b602002015260006103a05118156116b4576103e0516003811061164857600080fd5b600260c052602060c0200180546102c06103e0516003811061166957600080fd5b60200201516103a051808202821582848304141761168657600080fd5b809050905090506402540be400808204905090508181830110156116a957600080fd5b808201905090508155505b610420516102c06103e051600381106116cc57600080fd5b6020020151808210156116de57600080fd5b808203905090506102406103e051600381106116f957600080fd5b60200201525b8151600101808352811415611457575b5050610140610400525b6104005151602061040051016104005261040061040051101561173b57611719565b61024051610420526102605161044052610280516104605261016051610480526104805161046051610440516104205160065801610abd565b6104e0526103e0610400525b61040051526020610400510361040052610140610400511015156117a357611780565b6104e0516103e052610200516103e05161022051808210156117c457600080fd5b8082039050905080820282158284830414176117df57600080fd5b809050905090506102205180806117f557600080fd5b8204905090506103205261180d565b6102a051610320525b6064356103205110151515611861576308c379a0610340526020610360526014610380527f536c697070616765207363726577656420796f750000000000000000000000006103a05261038050606461035cfd5b6101405115611b1057600854610340526009546103605261038060006003818352015b6004610380516003811061189757600080fd5b60200201356103a05260006103a0511815611af85761038051600381106118bd57600080fd5b600160c052602060c02001546103c05260006004610440527f23b872dd00000000000000000000000000000000000000000000000000000000610460526104406004806020846104a001018260208501600060045af1505080518201915050336020826104a0010152602081019050306020826104a00101526020810190506103a0516020826104a0010152602081019050806104a0526104a090508051602001806105608284600060045af161197357600080fd5b505060206106406105605161058060006103c0515af161199257600080fd5b60203d808211156119a357806119a5565b815b90509050610620526106208051602001806103e08284600060045af16119ca57600080fd5b505060006103e0511815611a1d576103e08060200151600082518060209013156119f357600080fd5b8091901215611a0157600080fd5b806020036101000a82049050905090501515611a1c57600080fd5b5b60006004610440527fe8eda9df00000000000000000000000000000000000000000000000000000000610460526104406004806020846104a001018260208501600060045af15050805182019150506103c0516020826104a00101526020810190506103a0516020826104a0010152602081019050306020826104a0010152602081019050610360516020826104a0010152602081019050806104a0526104a090508051602001806105808284600060045af1611ad957600080fd5b505060006000610580516105a06000610340515af1611af757600080fd5b5b5b8151600101808352811415611884575b5050611bc5565b61034060006003818352015b60046103405160038110611b2f57600080fd5b6020020135610360526000610360511815611bb157602061044060646323b872dd61038052336103a052306103c052610360516103e05261039c60006103405160038110611b7c57600080fd5b600060c052602060c02001545af1611b9357600080fd5b601f3d11611ba057600080fd5b60005061044051611bb057600080fd5b5b5b8151600101808352811415611b1c575b50505b60206103e060446340c10f19610340523361036052610320516103805261035c60006101e0515af1611bf657600080fd5b601f3d11611c0357600080fd5b6000506103e0506004356103405260243561036052604435610380526102c0516103a0526102e0516103c052610300516103e0526102a051610400526102005161032051818183011015611c5657600080fd5b8082019050905061042052337f423f6495a08fc652425cf4ed0d1f9e37e571d9b9529b1c1c23cce780b2e7df0d610100610340a261032051600052600062ffffff5560206000f350600062ffffff55005b600015612149575b610200526101405261016052610180526101a0526101c0526101e052610160516101405118611cdd57600080fd5b6000610160511215611cee57600080fd5b60036101605112611cfe57600080fd5b6000610140511215611d0f57600080fd5b60036101405112611d1f57600080fd5b6101405161016051610180516101a0516101c0516101e051610200516102205160065801610026565b6102405261022052610200526101e0526101c0526101a05261018052610160526101405261024051610220526101405161016051610180516101a0516101c0516101e0516102005161022051610240516101a051610260526101c051610280526101e0516102a052610220516102c0526102c0516102a051610280516102605160065801610794565b610320526102405261022052610200526101e0526101c0526101a05261018052610160526101405261032051610240526102205160038082028215828483041417611e1b57600080fd5b809050905090506102605261024051610280526060366102a03761030060006003818352015b61014051610300511415611e5c57610180516102c052611e92565b61016051610300511815611e8c576101a06103005160038110611e7e57600080fd5b60200201516102c052611e91565b611f0e565b5b6102a080516102c051818183011015611eaa57600080fd5b8082019050905081525061028051610240518082028215828483041417611ed057600080fd5b809050905090506102c05160038082028215828483041417611ef157600080fd5b809050905090508080611f0357600080fd5b820490509050610280525b8151600101808352811415611e41575b505061028051610240518082028215828483041417611f3c57600080fd5b8090509050905060648082028215828483041417611f5957600080fd5b809050905090506102605160038082028215828483041417611f7a57600080fd5b809050905090508080611f8c57600080fd5b820490509050610280526102a0516102405160648082028215828483041417611fb457600080fd5b80905090509050610260518080611fca57600080fd5b820490509050818183011015611fdf57600080fd5b80820190509050610300526102405161032052610340600060ff818352015b610320516102e0526103205161032051808202821582848304141761202257600080fd5b809050905090506102805181818301101561203c57600080fd5b80820190509050600261032051808202821582848304141761205d57600080fd5b809050905090506103005181818301101561207757600080fd5b80820190509050610240518082101561208f57600080fd5b8082039050905080806120a157600080fd5b820490509050610320526102e0516103205111156120f6576001610320516102e051808210156120d057600080fd5b808203905090501115156120f1576103205160005250506000516102005156505b61212f565b60016102e051610320518082101561210d57600080fd5b8082039050905011151561212e576103205160005250506000516102005156505b5b5b8151600101808352811415611ffe575b505060006000fd005b600015612554575b6101a0526101405261016052610180526101405161016051610180516101a0516101c0516101e0516102005160065801610688565b610220526102405261026052610200526101e0526101c0526101a05261018052610160526101405261022080516101c05280602001516101e0528060400151610200525060016102205264e8d4a510006102405264e8d4a510006102605261028060006003818352015b6101c0610280516003811061220457600080fd5b602002018051610220610280516003811061221e57600080fd5b6020020151808202821582848304141761223757600080fd5b809050905090508152505b81516001018083528114156121f0575b50506101c0610140516003811061226857600080fd5b602002015161018051610220610140516003811061228557600080fd5b6020020151808202821582848304141761229e57600080fd5b809050905090508181830110156122b457600080fd5b80820190509050610280526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a051610140516102c052610160516102e05261028051610300526101c051610320526101e051610340526102005161036052610360516103405161032051610300516102e0516102c05160065801611caf565b6103c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0516102a0526101c0610160516003811061239057600080fd5b60200201516102a051808210156123a657600080fd5b8082039050905061022061016051600381106123c157600080fd5b602002015180806123d157600080fd5b8204905090506102c0526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e0516101c0610140516003811061242757600080fd5b60200201516102805181818301101561243f57600080fd5b80820190509050600280820490509050610300526101c0610160516003811061246757600080fd5b60200201516102a05181818301101561247f57600080fd5b808201905090506002808204905090506103205260035461034052600454610360526103605161034051610320516103005160065801610226565b6103c0526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0516102c051808202821582848304141761251257600080fd5b809050905090506402540be400808204905090506102e0526102c0516102e0518082101561253f57600080fd5b808203905090506000526000516101a0515650005b635e0d443f60005114156125df576004358080600081121561257257195b607f1c1561257f57600080fd5b9050506024358080600081121561259257195b607f1c1561259f57600080fd5b90505060043561014052602435610160526044356101805261018051610160516101405160065801612151565b6101e0526101e05160005260206000f350005b6307211ef7600051141561266a57600435808060008112156125fd57195b607f1c1561260a57600080fd5b9050506024358080600081121561261d57195b607f1c1561262a57600080fd5b90505060043561014052602435610160526044356101805261018051610160516101405160065801612151565b6101e0526101e05160005260206000f350005b600015612b3c575b6101a0526101405261016052610180526014541561268f57600080fd5b6101405161016051610180516101a0516101c0516101e0516102005160065801610688565b610220526102405261026052610200526101e0526101c0526101a05261018052610160526101405261022080516101c05280602001516101e0528060400151610200525060016102205264e8d4a510006102405264e8d4a510006102605261028060006003818352015b6101c0610280516003811061273257600080fd5b602002018051610220610280516003811061274c57600080fd5b6020020151808202821582848304141761276557600080fd5b809050905090508152505b815160010180835281141561271e575b50506101c0610140516003811061279657600080fd5b60200201516101805161022061014051600381106127b357600080fd5b602002015180820282158284830414176127cc57600080fd5b809050905090508181830110156127e257600080fd5b80820190509050610280526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a051610140516102c052610160516102e05261028051610300526101c051610320526101e051610340526102005161036052610360516103405161032051610300516102e0516102c05160065801611caf565b6103c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0516102a0526101c061016051600381106128be57600080fd5b60200201516102a051808210156128d457600080fd5b808203905090506102c0526102c0516101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e0516101c0610140516003811061292f57600080fd5b60200201516102805181818301101561294757600080fd5b80820190509050600280820490509050610300526101c0610160516003811061296f57600080fd5b60200201516102a05181818301101561298757600080fd5b808201905090506002808204905090506103205260035461034052600454610360526103605161034051610320516103005160065801610226565b6103c0526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0518082028215828483041417612a1657600080fd5b809050905090506402540be400808204905090506102e052600554610300526000610300511815612ae8576102e051610300518082028215828483041417612a5d57600080fd5b809050905090506402540be40080820490509050610320526000610320511815612ae7576101605160038110612a9257600080fd5b600260c052602060c020018054610320516102206101605160038110612ab757600080fd5b60200201518080612ac757600080fd5b820490509050818183011015612adc57600080fd5b808201905090508155505b5b6102c0516102e05180821015612afd57600080fd5b808203905090506102206101605160038110612b1857600080fd5b60200201518080612b2857600080fd5b8204905090506000526000516101a0515650005b633df021246000511415612d895762ffffff5415612b5957600080fd5b600162ffffff5560043580806000811215612b7057195b607f1c15612b7d57600080fd5b90505060243580806000811215612b9057195b607f1c15612b9d57600080fd5b9050506101405160043561016052602435610180526044356101a0526101a051610180516101605160065801612672565b610200526101405261020051610140526064356101405110151515612c57576308c379a061016052602061018052602e6101a0527f45786368616e676520726573756c74656420696e20666577657220636f696e736101c0527f207468616e2065787065637465640000000000000000000000000000000000006101e0526101a050608461017cfd5b602061022060646323b872dd610160523361018052306101a0526044356101c05261017c600060043560038110612c8d57600080fd5b600060c052602060c02001545af1612ca457600080fd5b601f3d11612cb157600080fd5b60005061022051612cc157600080fd5b6020610200604463a9059cbb610160523361018052610140516101a05261017c600060243560038110612cf357600080fd5b600060c052602060c02001545af1612d0a57600080fd5b601f3d11612d1757600080fd5b60005061020051612d2757600080fd5b60043561016052604435610180526024356101a052610140516101c052337f8b3e96f2b889fa771c53c981b40daf005f63f637f1869f707052d15a3dd971406080610160a261014051600052600062ffffff5560206000f350600062ffffff55005b63a6417ed660005114156131b25762ffffff5415612da657600080fd5b600162ffffff5560043580806000811215612dbd57195b607f1c15612dca57600080fd5b90505060243580806000811215612ddd57195b607f1c15612dea57600080fd5b9050506101405160043561016052602435610180526044356101a0526101a051610180516101605160065801612672565b610200526101405261020051610140526064356101405110151515612ea4576308c379a061016052602061018052602e6101a0527f45786368616e676520726573756c74656420696e20666577657220636f696e736101c0527f207468616e2065787065637465640000000000000000000000000000000000006101e0526101a050608461017cfd5b60043560038110612eb457600080fd5b600160c052602060c0200154610160526008546101805260006004610200527f23b872dd000000000000000000000000000000000000000000000000000000006102205261020060048060208461026001018260208501600060045af15050805182019150503360208261026001015260208101905030602082610260010152602081019050604435602082610260010152602081019050806102605261026090508051602001806103208284600060045af1612f7057600080fd5b50506020610400610320516103406000610160515af1612f8f57600080fd5b60203d80821115612fa05780612fa2565b815b905090506103e0526103e08051602001806101a08284600060045af1612fc757600080fd5b505060006101a051181561301a576101a0806020015160008251806020901315612ff057600080fd5b8091901215612ffe57600080fd5b806020036101000a8204905090509050151561301957600080fd5b5b60006004610200527fe8eda9df000000000000000000000000000000000000000000000000000000006102205261020060048060208461026001018260208501600060045af15050805182019150506101605160208261026001015260208101905060443560208261026001015260208101905030602082610260010152602081019050600954602082610260010152602081019050806102605261026090508051602001806103408284600060045af16130d457600080fd5b505060006000610340516103606000610180515af16130f257600080fd5b610180513b61310057600080fd5b6000600060646369328dec610200526024356003811061311f57600080fd5b600160c052602060c0200154610220526101405161024052336102605261021c6000610180515af161315057600080fd5b6004356102005260443561022052602435610240526101405161026052337fd013ca23e77a65003c2c659c5442c00c805371b7fc1ebd4c206c41d1536bd90b6080610200a261014051600052600062ffffff5560206000f350600062ffffff55005b63ecb586a560005114156131cb57600061014052613201565b63fce6473660005114156131f95760843560011c156131e957600080fd5b6020608461014037600050613201565b60001561356f575b62ffffff541561321057600080fd5b600162ffffff556101405161016051610180516101a05160065801610688565b6101c0526101e052610200526101a0526101805261016052610140526101c080516101605280602001516101805280604001516101a052506007546101c052602061026060046318160ddd6102005261021c6101c0515afa61329157600080fd5b601f3d1161329e57600080fd5b600050610260516101e05260206102a060446379cc67906102005233610220526004356102405261021c60006101c0515af16132d957600080fd5b601f3d116132e657600080fd5b6000506102a050600061020052610140511561330457600854610200525b61022060006003818352015b610160610220516003811061332457600080fd5b6020020151600435808202821582848304141761334057600080fd5b809050905090506101e051808061335657600080fd5b820490509050610240526024610220516003811061337357600080fd5b602002013561024051101515156133ee576308c379a06102605260206102805260306102a0527f5769746864726177616c20726573756c74656420696e20666577657220636f696102c0527f6e73207468616e206578706563746564000000000000000000000000000000006102e0526102a050608461027cfd5b61024051610160610220516003811061340657600080fd5b6020020152610140511561347857610200513b61342257600080fd5b6000600060646369328dec61026052610220516003811061344257600080fd5b600160c052602060c020015461028052610240516102a052336102c05261027c6000610200515af161347357600080fd5b6134e0565b6020610300604463a9059cbb610260523361028052610240516102a05261027c600061022051600381106134ab57600080fd5b600060c052602060c02001545af16134c257600080fd5b601f3d116134cf57600080fd5b600050610300516134df57600080fd5b5b5b8151600101808352811415613310575b5050610160516102205261018051610240526101a05161026052606036610280376101e0516004358082101561352657600080fd5b808203905090506102e052337fa49d4cf02656aebf8c771f5a8585638a2a15ee6c97cf7205d4208ed7c1df252d60e0610220a2600062ffffff556060610160f3600062ffffff55005b639fdaea0c6000511415613588576000610140526135be565b635b8369f560005114156135b65760843560011c156135a657600080fd5b60206084610140376000506135be565b600015613ed9575b62ffffff54156135cd57600080fd5b600162ffffff55601454156135e157600080fd5b610140516101605160065801610026565b61018052610160526101405261018051610160526101405161016051610180516101a0516101c05160065801610688565b6101e05261020052610220526101c0526101a0526101805261016052610140526101e080516101805280602001516101a05280604001516101c052506101405161016051610180516101a0516101c0516101e05161018051610200526101a051610220526101c0516102405261016051610260526102605161024051610220516102005160065801610abd565b6102c0526101e0526101c0526101a0526101805261016052610140526102c0516101e05261018051610200526101a051610220526101c0516102405261026060006003818352015b610200610260516003811061370c57600080fd5b6020020180516004610260516003811061372557600080fd5b60200201358082101561373757600080fd5b808203905090508152505b81516001018083528114156136f8575b50506101405161016051610180516101a0516101c0516101e051610200516102205161024051610260516102005161028052610220516102a052610240516102c052610160516102e0526102e0516102c0516102a0516102805160065801610abd565b61034052610260526102405261022052610200526101e0526101c0526101a05261018052610160526101405261034051610260526101e0516102605181818301101561380057600080fd5b80820190509050600380820490509050610280526007546102a052602061034060046318160ddd6102e0526102fc6102a0515afa61383d57600080fd5b601f3d1161384a57600080fd5b600050610340516102c05260006102c0511861386557600080fd5b6003546003808202821582848304141761387e57600080fd5b809050905090506008808204905090506102e0526004546103005260055461032052606036610340376103a060006003818352015b610260516101806103a051600381106138cb57600080fd5b602002015180820282158284830414176138e457600080fd5b809050905090506101e05180806138fa57600080fd5b8204905090506103c0526102006103a0516003811061391857600080fd5b60200201516103e0526000610400526103e0516103c051111561395a576103c0516103e0518082101561394a57600080fd5b808203905090506104005261397b565b6103e0516103c0518082101561396f57600080fd5b80820390509050610400525b6103e0516101806103a0516003811061399357600080fd5b60200201518181830110156139a757600080fd5b8082019050905061042052610140610440525b610440515160206104405101610440526104406104405110156139dc576139ba565b610420516104605261028051610480526102e0516104a052610300516104c0526104c0516104a051610480516104605160065801610226565b61052052610420610440525b6104405152602061044051036104405261014061044051101515613a4457613a21565b61052051610400518082028215828483041417613a6057600080fd5b809050905090506402540be400808204905090506103406103a05160038110613a8857600080fd5b60200201526000610320511815613b16576103a05160038110613aaa57600080fd5b600260c052602060c0200180546103406103a05160038110613acb57600080fd5b6020020151610320518082028215828483041417613ae857600080fd5b809050905090506402540be40080820490509050818183011015613b0b57600080fd5b808201905090508155505b6102006103a05160038110613b2a57600080fd5b6020020180516103406103a05160038110613b4457600080fd5b602002015180821015613b5657600080fd5b808203905090508152505b81516001018083528114156138b3575b50506101406103c0525b6103c0515160206103c051016103c0526103c06103c0511015613b9d57613b7b565b610200516103e0526102205161040052610240516104205261016051610440526104405161042051610400516103e05160065801610abd565b6104a0526103a06103c0525b6103c0515260206103c051036103c0526101406103c051101515613c0557613be2565b6104a0516103a0526101e0516103a05180821015613c2257600080fd5b808203905090506102c0518082028215828483041417613c4157600080fd5b809050905090506101e0518080613c5757600080fd5b8204905090506103c05260006103c05118613c7157600080fd5b6064356103c05111151515613cc5576308c379a06103e0526020610400526014610420527f536c697070616765207363726577656420796f75000000000000000000000000610440526104205060646103fcfd5b602061048060446379cc67906103e05233610400526103c051610420526103fc60006102a0515af1613cf657600080fd5b601f3d11613d0357600080fd5b6000506104805060006103e0526101405115613d21576008546103e0525b61040060006003818352015b60046104005160038110613d4057600080fd5b6020020135610420526000610420511815613e2b576101405115613dc2576103e0513b613d6c57600080fd5b6000600060646369328dec610440526104005160038110613d8c57600080fd5b600160c052602060c0200154610460526104205161048052336104a05261045c60006103e0515af1613dbd57600080fd5b613e2a565b60206104e0604463a9059cbb610440523361046052610420516104805261045c60006104005160038110613df557600080fd5b600060c052602060c02001545af1613e0c57600080fd5b601f3d11613e1957600080fd5b6000506104e051613e2957600080fd5b5b5b5b8151600101808352811415613d2d575b505060043561040052602435610420526044356104405261034051610460526103605161048052610380516104a052610260516104c0526102c0516103c05180821015613e8857600080fd5b808203905090506104e052337f173599dbf9c6ca6f7c3b590df07ae98a45d74ff54065505141e7de6c46a624c2610100610400a26103c051600052600062ffffff5560206000f350600062ffffff55005b60001561424a575b610200526101405261016052610180526101a0526101c0526101e0526000610160511215613f0e57600080fd5b60036101605112613f1e57600080fd5b6101405160038082028215828483041417613f3857600080fd5b80905090509050610220526101e05161024052606036610260376102c060006003818352015b610160516102c0511815613f8e576101806102c05160038110613f8057600080fd5b602002015161028052613f93565b61400f565b610260805161028051818183011015613fab57600080fd5b80820190509050815250610240516101e0518082028215828483041417613fd157600080fd5b809050905090506102805160038082028215828483041417613ff257600080fd5b80905090509050808061400457600080fd5b820490509050610240525b8151600101808352811415613f5e575b5050610240516101e051808202821582848304141761403d57600080fd5b809050905090506064808202821582848304141761405a57600080fd5b80905090509050610220516003808202821582848304141761407b57600080fd5b80905090509050808061408d57600080fd5b82049050905061024052610260516101e051606480820282158284830414176140b557600080fd5b809050905090506102205180806140cb57600080fd5b8204905090508181830110156140e057600080fd5b808201905090506102c0526101e0516102e052610300600060ff818352015b6102e0516102a0526102e0516102e051808202821582848304141761412357600080fd5b809050905090506102405181818301101561413d57600080fd5b8082019050905060026102e051808202821582848304141761415e57600080fd5b809050905090506102c05181818301101561417857600080fd5b808201905090506101e0518082101561419057600080fd5b8082039050905080806141a257600080fd5b8204905090506102e0526102a0516102e05111156141f75760016102e0516102a051808210156141d157600080fd5b808203905090501115156141f2576102e05160005250506000516102005156505b614230565b60016102a0516102e0518082101561420e57600080fd5b8082039050905011151561422f576102e05160005250506000516102005156505b5b5b81516001018083528114156140ff575b505060006000fd005b600015614986575b6101805261014052610160526101405161016051610180516101a05160065801610026565b6101c0526101a0526101805261016052610140526101c0516101a0526101405161016051610180516101a0516101c0516101e0516102005160065801610688565b610220526102405261026052610200526101e0526101c0526101a05261018052610160526101405261022080516101c05280602001516101e0528060400151610200525060016102205264e8d4a510006102405264e8d4a510006102605261028060006003818352015b6101c0610280516003811061433657600080fd5b602002018051610220610280516003811061435057600080fd5b6020020151808202821582848304141761436957600080fd5b809050905090508152505b8151600101808352811415614322575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516101c0516102a0526101e0516102c052610200516102e0526101a05161030052610300516102e0516102c0516102a05160065801610794565b6103605261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103605161028052610280516101405161028051808202821582848304141761444357600080fd5b80905090509050602061032060046318160ddd6102c0526102dc6007545afa61446b57600080fd5b601f3d1161447857600080fd5b60005061032051808061448a57600080fd5b8204905090508082101561449d57600080fd5b808203905090506102a0526101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516101a0516102e05261016051610300526101c051610320526101e0516103405261020051610360526102a0516103805261038051610360516103405161032051610300516102e05160065801613ee1565b6103e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103e0516102c0526101c0516102e0526101e051610300526102005161032052610280516102a05181818301101561459c57600080fd5b8082019050905060068082049050905061034052600354600380820282158284830414176145c957600080fd5b8090509050905060088082049050905061036052600454610380526103a060006003818352015b6040366103c037610160516103a05114156146b3576101c06103a0516003811061461957600080fd5b60200201516102a051808202821582848304141761463657600080fd5b8090509050905061028051808061464c57600080fd5b8204905090506102c0518082101561466357600080fd5b808203905090506103c0526101c06103a0516003811061468257600080fd5b60200201516102c05181818301101561469a57600080fd5b808201905090506002808204905090506103e05261474f565b6101c06103a051600381106146c757600080fd5b60200201516101c06103a051600381106146e057600080fd5b60200201516102a05180820282158284830414176146fd57600080fd5b8090509050905061028051808061471357600080fd5b8204905090508082101561472657600080fd5b808203905090506103c0526101c06103a0516003811061474557600080fd5b60200201516103e0525b6102e06103a0516003811061476357600080fd5b602002018051610140610400525b6104005151602061040051016104005261040061040051101561479357614771565b6103e051610420526103405161044052610360516104605261038051610480526104805161046051610440516104205160065801610226565b6104e0526103e0610400525b61040051526020610400510361040052610140610400511015156147fb576147d8565b6104e0516103c051808202821582848304141761481757600080fd5b809050905090506402540be400808204905090508082101561483857600080fd5b808203905090508152505b81516001018083528114156145f0575b50506102e0610160516003811061486957600080fd5b60200201516101406103c0525b6103c0515160206103c051016103c0526103c06103c051101561489857614876565b6101a0516103e05261016051610400526102e05161042052610300516104405261032051610460526102a0516104805261048051610460516104405161042051610400516103e05160065801613ee1565b6104e0526103a06103c0525b6103c0515260206103c051036103c0526101406103c051101515614918576148f5565b6104e0518082101561492957600080fd5b808203905090506103a0526103a05160018082101561494757600080fd5b80820390509050610220610160516003811061496257600080fd5b6020020151808061497257600080fd5b820490509050600052600051610180515650005b63cc2b27d760005114156149e657602435808060008112156149a457195b607f1c156149b157600080fd5b9050506004356101405260243561016052610160516101405160065801614252565b6101c0526101c05160005260206000f350005b631a4d01d260005114156149ff57600061014052614a35565b63517a55a36000511415614a2d5760643560011c15614a1d57600080fd5b6020606461014037600050614a35565b600015614c6f575b62ffffff5415614a4457600080fd5b600162ffffff5560243580806000811215614a5b57195b607f1c15614a6857600080fd5b90505060145415614a7857600080fd5b6101405161016051600435610180526024356101a0526101a0516101805160065801614252565b61020052610160526101405261020051610160526044356101605110151515614b07576308c379a06101805260206101a05260186101c0527f4e6f7420656e6f75676820636f696e732072656d6f76656400000000000000006101e0526101c050606461019cfd5b602061022060446379cc679061018052336101a0526004356101c05261019c60006007545af1614b3657600080fd5b601f3d11614b4357600080fd5b600050610220506101405115614bb4576008543b614b6057600080fd5b6000600060646369328dec6101805260243560038110614b7f57600080fd5b600160c052602060c02001546101a052610160516101c052336101e05261019c60006008545af1614baf57600080fd5b614c1b565b6020610220604463a9059cbb61018052336101a052610160516101c05261019c600060243560038110614be657600080fd5b600060c052602060c02001545af1614bfd57600080fd5b601f3d11614c0a57600080fd5b60005061022051614c1a57600080fd5b5b60043561018052610160516101a052337f9e96dd3b997a2a257eec4df9bb6eaf626e206df5f543bd963682d143300be3106040610180a261016051600052600062ffffff5560206000f350600062ffffff55005b633c157e646000511415614e13576006543314614c8b57600080fd5b600c5462015180818183011015614ca157600080fd5b80820190509050421015614cb457600080fd5b4262015180818183011015614cc857600080fd5b808201905090506024351015614cdd57600080fd5b6101405160065801610026565b6101605261014052610160516101405260043560648082028215828483041417614d1357600080fd5b809050905090506101605260006004351115614d3657620f424060043510614d39565b60005b614d4257600080fd5b61014051610160511015614d85576101405161016051600a8082028215828483041417614d6e57600080fd5b809050905090501015614d8057600080fd5b614db6565b61014051600a8082028215828483041417614d9f57600080fd5b80905090509050610160511115614db557600080fd5b5b61014051600a5561016051600b5542600c55602435600d556101405161018052610160516101a052426101c0526024356101e0527fa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c2546080610180a1005b63551a65886000511415614e98576006543314614e2f57600080fd5b6101405160065801610026565b6101605261014052610160516101405261014051600a5561014051600b5542600c5542600d55610140516101605242610180527f46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc2019386040610160a1005b630746dd5a6000511415614f99576006543314614eb457600080fd5b600e5415614ec157600080fd5b64012a05f2006004351115614ed557600080fd5b6402540be4006024351115614ee957600080fd5b6802b5e3af16b18800006044356004358082028215828483041417614f0d57600080fd5b809050905090501115614f1f57600080fd5b426203f480818183011015614f3357600080fd5b808201905090506101405261014051600e5560043560105560243560115560443560125560043561016052602435610180526044356101a052610140517fe347cde074ab87e09449fa2b03e8f2cf79094cb1265f4c914365d2247d4147a36060610160a2005b634f12fe976000511415615043576006543314614fb557600080fd5b600e54421015614fc457600080fd5b6000600e5418614fd357600080fd5b6000600e55601054610140526011546101605260125461018052610140516003556101605160055561018051600455610140516101a052610160516101c052610180516101e0527fcfca96e0fef3432146913b2a5a2268a55d3f475fe057e7ffde1082b77693f4f360606101a0a1005b63226840fb600051141561506657600654331461505f57600080fd5b6000600e55005b636b441a4060005114156150fa5760043560a01c1561508457600080fd5b600654331461509257600080fd5b600f541561509f57600080fd5b426203f4808181830110156150b357600080fd5b808201905090506101405261014051600f55600435601355600435610140517f181aa3aa17d4cbf99265dd4443eba009433d3cde79d60164fde1d1a192beb93560006000a3005b636a1c05ae600051141561517357600654331461511657600080fd5b600f5442101561512557600080fd5b6000600f541861513457600080fd5b6000600f556013546101405261014051600655610140517f71614071b88dee5e0b2ae578a9dd7b2ebbe9ae832ba419dc0242cd065a290b6c60006000a2005b6386fbf193600051141561519657600654331461518f57600080fd5b6000600f55005b6330c5408560005114156152875760065433146151b257600080fd5b61014060006003818352015b61014051600381106151cf57600080fd5b600260c052602060c0200154610160526000610160511815615272576020610220604463a9059cbb61018052336101a052610160516101c05261019c6000610140516003811061521e57600080fd5b600060c052602060c02001545af161523557600080fd5b601f3d1161524257600080fd5b6000506102205161525257600080fd5b6000610140516003811061526557600080fd5b600260c052602060c02001555b5b81516001018083528114156151be575b5050005b63524c390160005114156152c25760065433146152a357600080fd5b600260c052602060c02060008155600060018201556000600282015550005b63e369885360005114156152f35760065433146152de57600080fd5b42601554116152ec57600080fd5b6001601455005b633046f972600051141561531657600654331461530f57600080fd5b6000601455005b63b6aa64c5600051141561534b57600654331461533257600080fd5b620100006004351061534357600080fd5b600435600955005b63c66106576000511415615380576004356003811061536957600080fd5b600060c052602060c020015460005260206000f350005b63b9947eb060005114156153b5576004356003811061539e57600080fd5b600160c052602060c020015460005260206000f350005b63e2e7d26460005114156153ea57600435600381106153d357600080fd5b600260c052602060c020015460005260206000f350005b63ddca3f4360005114156154065760035460005260206000f350005b638edfdd5f60005114156154225760045460005260206000f350005b63fee3f7f9600051141561543e5760055460005260206000f350005b638da5cb5b600051141561545a5760065460005260206000f350005b6382c6306660005114156154765760075460005260206000f350005b635409491a600051141561549257600a5460005260206000f350005b63b4b577ad60005114156154ae57600b5460005260206000f350005b632081066c60005114156154ca57600c5460005260206000f350005b631405228860005114156154e657600d5460005260206000f350005b63405e28f8600051141561550257600e5460005260206000f350005b63e0a0b586600051141561551e57600f5460005260206000f350005b6358680d0b600051141561553a5760105460005260206000f350005b63e382446260005114156155565760115460005260206000f350005b631e4c4ef860005114156155725760125460005260206000f350005b631ec0cdc1600051141561558e5760135460005260206000f350005b5b60006000fd

Verified Source Code Partial Match

Compiler: v0.2.8+commit.069936f
Vyper_contract.vy 1053 lines
# @version 0.2.8
"""
@title Curve aPool
@author Curve.Fi
@license Copyright (c) Curve.Fi, 2020 - all rights reserved
@notice Pool implementation with aToken-style lending
"""

from vyper.interfaces import ERC20


interface LendingPool:
    def withdraw(_underlying_asset: address, _amount: uint256, _receiver: address): nonpayable

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 TokenExchangeUnderlying:
    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

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
    offpeg_fee_multiplier: uint256

event NewFee:
    fee: uint256
    admin_fee: uint256
    offpeg_fee_multiplier: 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) = 3
PRECISION_MUL: constant(uint256[N_COINS]) = [1, 1000000000000, 1000000000000]

# fixed constants
FEE_DENOMINATOR: constant(uint256) = 10 ** 10
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
A_PRECISION: constant(uint256) = 100

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

coins: public(address[N_COINS])
underlying_coins: public(address[N_COINS])
admin_balances: public(uint256[N_COINS])

fee: public(uint256)  # fee * 1e10
offpeg_fee_multiplier: public(uint256)  # * 1e10
admin_fee: public(uint256)  # admin_fee * 1e10

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

aave_lending_pool: address
aave_referral: uint256

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_offpeg_fee_multiplier: public(uint256)  # * 1e10
future_owner: public(address)

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


@external
def __init__(
    _coins: address[N_COINS],
    _underlying_coins: address[N_COINS],
    _pool_token: address,
    _aave_lending_pool: address,
    _A: uint256,
    _fee: uint256,
    _admin_fee: uint256,
    _offpeg_fee_multiplier: uint256,
):
    """
    @notice Contract constructor
    @param _coins List of wrapped coin addresses
    @param _underlying_coins List of underlying coin addresses
    @param _pool_token Pool LP token address
    @param _aave_lending_pool Aave lending pool address
    @param _A Amplification coefficient multiplied by n * (n - 1)
    @param _fee Swap fee expressed as an integer with 1e10 precision
    @param _admin_fee Percentage of fee taken as an admin fee,
                      expressed as an integer with 1e10 precision
    @param _offpeg_fee_multiplier Offpeg fee multiplier
    """
    for i in range(N_COINS):
        assert _coins[i] != ZERO_ADDRESS
        assert _underlying_coins[i] != ZERO_ADDRESS

    self.coins = _coins
    self.underlying_coins = _underlying_coins
    self.initial_A = _A * A_PRECISION
    self.future_A = _A * A_PRECISION
    self.fee = _fee
    self.admin_fee = _admin_fee
    self.offpeg_fee_multiplier = _offpeg_fee_multiplier
    self.owner = msg.sender
    self.kill_deadline = block.timestamp + KILL_DEADLINE_DT
    self.lp_token = _pool_token
    self.aave_lending_pool = _aave_lending_pool

    # approve transfer of underlying coin to aave lending pool
    for coin in _underlying_coins:
        _response: Bytes[32] = raw_call(
            coin,
            concat(
                method_id("approve(address,uint256)"),
                convert(_aave_lending_pool, bytes32),
                convert(MAX_UINT256, bytes32)
            ),
            max_outsize=32
        )
        if len(_response) != 0:
            assert convert(_response, bool)



@view
@internal
def _A() -> uint256:
    t1: uint256 = self.future_A_time
    A1: uint256 = self.future_A

    if block.timestamp < t1:
        # handle ramping up and down of A
        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()


@pure
@internal
def _dynamic_fee(xpi: uint256, xpj: uint256, _fee: uint256, _feemul: uint256) -> uint256:
    if _feemul <= FEE_DENOMINATOR:
        return _fee
    else:
        xps2: uint256 = (xpi + xpj)
        xps2 *= xps2  # Doing just ** 2 can overflow apparently
        return (_feemul * _fee) / (
            (_feemul - FEE_DENOMINATOR) * 4 * xpi * xpj / xps2 + \
            FEE_DENOMINATOR)


@view
@external
def dynamic_fee(i: int128, j: int128) -> uint256:
    """
    @notice Return the fee for swapping between `i` and `j`
    @param i Index value for the coin to send
    @param j Index value of the coin to recieve
    @return Swap fee expressed as an integer with 1e10 precision
    """
    precisions: uint256[N_COINS] = PRECISION_MUL
    xpi: uint256 = (ERC20(self.coins[i]).balanceOf(self) - self.admin_balances[i]) * precisions[i]
    xpj: uint256 = (ERC20(self.coins[j]).balanceOf(self) - self.admin_balances[j]) * precisions[j]
    return self._dynamic_fee(xpi, xpj, self.fee, self.offpeg_fee_multiplier)


@view
@external
def balances(i: uint256) -> uint256:
    """
    @notice Get the current balance of a coin within the
            pool, less the accrued admin fees
    @param i Index value for the coin to query balance of
    @return Token balance
    """
    return ERC20(self.coins[i]).balanceOf(self) - self.admin_balances[i]


@view
@internal
def _balances() -> uint256[N_COINS]:
    result: uint256[N_COINS] = empty(uint256[N_COINS])
    for i in range(N_COINS):
        result[i] = ERC20(self.coins[i]).balanceOf(self) - self.admin_balances[i]
    return result


@pure
@internal
def get_D(xp: uint256[N_COINS], amp: uint256) -> uint256:
    """
    D invariant calculation in non-overflowing integer operations
    iteratively

    A * sum(x_i) * n**n + D = A * D * n**n + D**(n+1) / (n**n * prod(x_i))

    Converging solution:
    D[j+1] = (A * n**n * sum(x_i) - D[j]**(n+1) / (n**n prod(x_i))) / (A * n**n - 1)
    """
    S: uint256 = 0

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

    Dprev: uint256 = 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 + 1)  # +1 is to prevent /0
        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_precisions(coin_balances: uint256[N_COINS], amp: uint256) -> uint256:
    xp: uint256[N_COINS] = PRECISION_MUL
    for i in range(N_COINS):
        xp[i] *= coin_balances[i]
    return self.get_D(xp, 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_precisions(self._balances(), 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
    """
    coin_balances: uint256[N_COINS] = self._balances()
    amp: uint256 = self._A()
    D0: uint256 = self.get_D_precisions(coin_balances, amp)
    for i in range(N_COINS):
        if is_deposit:
            coin_balances[i] += _amounts[i]
        else:
            coin_balances[i] -= _amounts[i]
    D1: uint256 = self.get_D_precisions(coin_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, _use_underlying: bool = False) -> 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
    @param _use_underlying If True, deposit underlying assets instead of aTokens
    @return Amount of LP tokens received by depositing
    """

    assert not self.is_killed  # dev: is killed

    # Initial invariant
    amp: uint256 = self._A()
    old_balances: uint256[N_COINS] = self._balances()
    lp_token: address = self.lp_token
    token_supply: uint256 = ERC20(lp_token).totalSupply()
    D0: uint256 = 0
    if token_supply != 0:
        D0 = self.get_D_precisions(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
        new_balances[i] += _amounts[i]

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

    # We need to recalculate the invariant accounting for fees
    # to calculate fair user's share
    fees: uint256[N_COINS] = empty(uint256[N_COINS])
    mint_amount: uint256 = 0
    if token_supply != 0:
        # Only account for fees if we are not the first to deposit
        ys: uint256 = (D0 + D1) / N_COINS
        _fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1))
        _feemul: uint256 = self.offpeg_fee_multiplier
        _admin_fee: uint256 = self.admin_fee
        difference: uint256 = 0
        for i in range(N_COINS):
            ideal_balance: uint256 = D1 * old_balances[i] / D0
            new_balance: uint256 = new_balances[i]
            if ideal_balance > new_balance:
                difference = ideal_balance - new_balance
            else:
                difference = new_balance - ideal_balance
            xs: uint256 = old_balances[i] + new_balance
            fees[i] = self._dynamic_fee(xs, ys, _fee, _feemul) * difference / FEE_DENOMINATOR
            if _admin_fee != 0:
                self.admin_balances[i] += fees[i] * _admin_fee / FEE_DENOMINATOR
            new_balances[i] = new_balance - fees[i]
        D2: uint256 = self.get_D_precisions(new_balances, amp)
        mint_amount = token_supply * (D2 - D0) / D0
    else:
        mint_amount = D1  # Take the dust if there was any

    assert mint_amount >= _min_mint_amount, "Slippage screwed you"

    # Take coins from the sender
    if _use_underlying:
        lending_pool: address = self.aave_lending_pool
        aave_referral: bytes32 = convert(self.aave_referral, bytes32)

        # Take coins from the sender
        for i in range(N_COINS):
            amount: uint256 = _amounts[i]
            if amount != 0:
                coin: address = self.underlying_coins[i]
                # transfer underlying coin from msg.sender to self
                _response: Bytes[32] = raw_call(
                    coin,
                    concat(
                        method_id("transferFrom(address,address,uint256)"),
                        convert(msg.sender, bytes32),
                        convert(self, bytes32),
                        convert(amount, bytes32)
                    ),
                    max_outsize=32
                )
                if len(_response) != 0:
                    assert convert(_response, bool)

                # deposit to aave lending pool
                raw_call(
                    lending_pool,
                    concat(
                        method_id("deposit(address,uint256,address,uint16)"),
                        convert(coin, bytes32),
                        convert(amount, bytes32),
                        convert(self, bytes32),
                        aave_referral,
                    )
                )
    else:
        for i in range(N_COINS):
            amount: uint256 = _amounts[i]
            if amount != 0:
                assert ERC20(self.coins[i]).transferFrom(msg.sender, self, amount) # dev: failed transfer

    # 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:
    """
    Calculate x[j] if one makes x[i] = x

    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 != 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
@internal
def _get_dy(i: int128, j: int128, dx: uint256) -> uint256:
    xp: uint256[N_COINS] = self._balances()
    precisions: uint256[N_COINS] = PRECISION_MUL
    for k in range(N_COINS):
        xp[k] *= precisions[k]

    x: uint256 = xp[i] + dx * precisions[i]
    y: uint256 = self.get_y(i, j, x, xp)
    dy: uint256 = (xp[j] - y) / precisions[j]
    _fee: uint256 = self._dynamic_fee(
            (xp[i] + x) / 2, (xp[j] + y) / 2, self.fee, self.offpeg_fee_multiplier
        ) * dy / FEE_DENOMINATOR
    return dy - _fee


@view
@external
def get_dy(i: int128, j: int128, dx: uint256) -> uint256:
    return self._get_dy(i, j, dx)


@view
@external
def get_dy_underlying(i: int128, j: int128, dx: uint256) -> uint256:
    return self._get_dy(i, j, dx)


@internal
def _exchange(i: int128, j: int128, dx: uint256) -> uint256:
    assert not self.is_killed  # dev: is killed
    # dx and dy are in aTokens

    xp: uint256[N_COINS] = self._balances()
    precisions: uint256[N_COINS] = PRECISION_MUL
    for k in range(N_COINS):
        xp[k] *= precisions[k]

    x: uint256 = xp[i] + dx * precisions[i]
    y: uint256 = self.get_y(i, j, x, xp)
    dy: uint256 = xp[j] - y
    dy_fee: uint256 = dy * self._dynamic_fee(
            (xp[i] + x) / 2, (xp[j] + y) / 2, self.fee, self.offpeg_fee_multiplier
        ) / FEE_DENOMINATOR

    admin_fee: uint256 = self.admin_fee
    if admin_fee != 0:
        dy_admin_fee: uint256 = dy_fee * admin_fee / FEE_DENOMINATOR
        if dy_admin_fee != 0:
            self.admin_balances[j] += dy_admin_fee / precisions[j]

    return (dy - dy_fee) / precisions[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
    """
    dy: uint256 = self._exchange(i, j, dx)
    assert dy >= min_dy, "Exchange resulted in fewer coins than expected"

    assert ERC20(self.coins[i]).transferFrom(msg.sender, self, dx)
    assert ERC20(self.coins[j]).transfer(msg.sender, dy)

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

    return dy


@external
@nonreentrant('lock')
def exchange_underlying(i: int128, j: int128, dx: uint256, min_dy: uint256) -> uint256:
    """
    @notice Perform an exchange between two underlying coins
    @dev Index values can be found via the `underlying_coins` public getter method
    @param i Index value for the underlying coin to send
    @param j Index valie of the underlying 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
    """
    dy: uint256 = self._exchange(i, j, dx)
    assert dy >= min_dy, "Exchange resulted in fewer coins than expected"

    u_coin_i: address = self.underlying_coins[i]
    lending_pool: address = self.aave_lending_pool

    # transfer underlying coin from msg.sender to self
    _response: Bytes[32] = raw_call(
        u_coin_i,
        concat(
            method_id("transferFrom(address,address,uint256)"),
            convert(msg.sender, bytes32),
            convert(self, bytes32),
            convert(dx, bytes32)
        ),
        max_outsize=32
    )
    if len(_response) != 0:
        assert convert(_response, bool)

    # deposit to aave lending pool
    raw_call(
        lending_pool,
        concat(
            method_id("deposit(address,uint256,address,uint16)"),
            convert(u_coin_i, bytes32),
            convert(dx, bytes32),
            convert(self, bytes32),
            convert(self.aave_referral, bytes32),
        )
    )
    # withdraw `j` underlying from lending pool and transfer to caller
    LendingPool(lending_pool).withdraw(self.underlying_coins[j], dy, msg.sender)

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

    return dy


@external
@nonreentrant('lock')
def remove_liquidity(
    _amount: uint256,
    _min_amounts: uint256[N_COINS],
    _use_underlying: bool = False,
) -> 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
    @param _use_underlying If True, withdraw underlying assets instead of aTokens
    @return List of amounts of coins that were withdrawn
    """
    amounts: uint256[N_COINS] = self._balances()
    lp_token: address = self.lp_token
    total_supply: uint256 = ERC20(lp_token).totalSupply()
    CurveToken(lp_token).burnFrom(msg.sender, _amount)  # dev: insufficient funds

    lending_pool: address = ZERO_ADDRESS
    if _use_underlying:
        lending_pool = self.aave_lending_pool

    for i in range(N_COINS):
        value: uint256 = amounts[i] * _amount / total_supply
        assert value >= _min_amounts[i], "Withdrawal resulted in fewer coins than expected"
        amounts[i] = value
        if _use_underlying:
            LendingPool(lending_pool).withdraw(self.underlying_coins[i], value, msg.sender)
        else:
            assert ERC20(self.coins[i]).transfer(msg.sender, value)

    log RemoveLiquidity(msg.sender, amounts, empty(uint256[N_COINS]), total_supply - _amount)

    return amounts


@external
@nonreentrant('lock')
def remove_liquidity_imbalance(
    _amounts: uint256[N_COINS],
    _max_burn_amount: uint256,
    _use_underlying: bool = False
) -> 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
    @param _use_underlying If True, withdraw underlying assets instead of aTokens
    @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()
    D0: uint256 = self.get_D_precisions(old_balances, amp)
    new_balances: uint256[N_COINS] = old_balances
    for i in range(N_COINS):
        new_balances[i] -= _amounts[i]
    D1: uint256 = self.get_D_precisions(new_balances, amp)
    ys: uint256 = (D0 + D1) / N_COINS

    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))
    _feemul: uint256 = self.offpeg_fee_multiplier
    _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
        new_balance: uint256 = new_balances[i]
        difference: uint256 = 0
        if ideal_balance > new_balance:
            difference = ideal_balance - new_balance
        else:
            difference = new_balance - ideal_balance
        xs: uint256 = new_balance + old_balances[i]
        fees[i] = self._dynamic_fee(xs, ys, _fee, _feemul) * difference / FEE_DENOMINATOR
        if _admin_fee != 0:
            self.admin_balances[i] += fees[i] * _admin_fee / FEE_DENOMINATOR
        new_balances[i] -= fees[i]
    D2: uint256 = self.get_D_precisions(new_balances, amp)

    token_amount: uint256 = (D0 - D2) * token_supply / D0
    assert token_amount != 0  # dev: zero tokens burned
    assert token_amount <= _max_burn_amount, "Slippage screwed you"

    CurveToken(lp_token).burnFrom(msg.sender, token_amount)  # dev: insufficient funds

    lending_pool: address = ZERO_ADDRESS
    if _use_underlying:
        lending_pool = self.aave_lending_pool

    for i in range(N_COINS):
        amount: uint256 = _amounts[i]
        if amount != 0:
            if _use_underlying:
                LendingPool(lending_pool).withdraw(self.underlying_coins[i], amount, msg.sender)
            else:
                assert ERC20(self.coins[i]).transfer(msg.sender, amount)

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

    return token_amount


@pure
@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:
    # 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._balances()
    precisions: uint256[N_COINS] = PRECISION_MUL

    for j in range(N_COINS):
        xp[j] *= precisions[j]

    D0: uint256 = self.get_D(xp, amp)
    D1: uint256 = D0 - _token_amount * D0 / ERC20(self.lp_token).totalSupply()
    new_y: uint256 = self.get_y_D(amp, i, xp, D1)

    xp_reduced: uint256[N_COINS] = xp
    ys: uint256 = (D0 + D1) / (2 * N_COINS)

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

    dy: uint256 = xp_reduced[i] - self.get_y_D(amp, i, xp_reduced, D1)

    return (dy - 1) / precisions[i]


@view
@external
def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256:
    """
    @notice Calculate the amount received when withdrawing a single coin
    @dev Result is the same for underlying or wrapped asset withdrawals
    @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)


@external
@nonreentrant('lock')
def remove_liquidity_one_coin(
    _token_amount: uint256,
    i: int128,
    _min_amount: uint256,
    _use_underlying: bool = False
) -> 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
    @param _use_underlying If True, withdraw underlying assets instead of aTokens
    @return Amount of coin received
    """
    assert not self.is_killed  # dev: is killed

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

    CurveToken(self.lp_token).burnFrom(msg.sender, _token_amount)  # dev: insufficient funds

    if _use_underlying:
        LendingPool(self.aave_lending_pool).withdraw(self.underlying_coins[i], dy, msg.sender)
    else:
        assert ERC20(self.coins[i]).transfer(msg.sender, dy)

    log RemoveLiquidityOne(msg.sender, _token_amount, dy)

    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, new_offpeg_fee_multiplier: 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
    assert new_offpeg_fee_multiplier * new_fee <= MAX_FEE * FEE_DENOMINATOR  # dev: offpeg multiplier 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
    self.future_offpeg_fee_multiplier = new_offpeg_fee_multiplier

    log CommitNewFee(_deadline, new_fee, new_admin_fee, new_offpeg_fee_multiplier)


@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
    _fml: uint256 = self.future_offpeg_fee_multiplier
    self.fee = _fee
    self.admin_fee = _admin_fee
    self.offpeg_fee_multiplier = _fml

    log NewFee(_fee, _admin_fee, _fml)


@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


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

    for i in range(N_COINS):
        value: uint256 = self.admin_balances[i]
        if value != 0:
            assert ERC20(self.coins[i]).transfer(msg.sender, value)
            self.admin_balances[i] = 0


@external
def donate_admin_fees():
    """
    Just in case admin balances somehow become higher than total (rounding error?)
    this can be used to fix the state, too
    """
    assert msg.sender == self.owner  # dev: only owner
    self.admin_balances = empty(uint256[N_COINS])


@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


@external
def set_aave_referral(referral_code: uint256):
    assert msg.sender == self.owner  # dev: only owner
    assert referral_code < 2 ** 16  # dev: uint16 overflow
    self.aave_referral = referral_code

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 0x3883e119 → uint256
calc_withdraw_one_coin 0xcc2b27d7 → uint256
coins 0xc6610657 → address
dynamic_fee 0x76a9cd3e → uint256
fee 0xddca3f43 → uint256
future_A 0xb4b577ad → uint256
future_A_time 0x14052288 → uint256
future_admin_fee 0xe3824462 → uint256
future_fee 0x58680d0b → uint256
future_offpeg_fee_multiplier 0x1e4c4ef8 → uint256
future_owner 0x1ec0cdc1 → address
get_dy 0x5e0d443f → uint256
get_dy_underlying 0x07211ef7 → uint256
get_virtual_price 0xbb7b8b80 → uint256
initial_A 0x5409491a → uint256
initial_A_time 0x2081066c → uint256
lp_token 0x82c63066 → address
offpeg_fee_multiplier 0x8edfdd5f → uint256
owner 0x8da5cb5b → address
transfer_ownership_deadline 0xe0a0b586 → uint256
underlying_coins 0xb9947eb0 → address

Write Contract 23 functions

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

add_liquidity 0x4515cef3
uint256[3] _amounts
uint256 _min_mint_amount
returns: uint256
add_liquidity 0x2b6e993a
uint256[3] _amounts
uint256 _min_mint_amount
bool _use_underlying
returns: uint256
apply_new_fee 0x4f12fe97
No parameters
apply_transfer_ownership 0x6a1c05ae
No parameters
commit_new_fee 0x0746dd5a
uint256 new_fee
uint256 new_admin_fee
uint256 new_offpeg_fee_multiplier
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
exchange_underlying 0xa6417ed6
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 0xecb586a5
uint256 _amount
uint256[3] _min_amounts
returns: uint256[3]
remove_liquidity 0xfce64736
uint256 _amount
uint256[3] _min_amounts
bool _use_underlying
returns: uint256[3]
remove_liquidity_imbalance 0x9fdaea0c
uint256[3] _amounts
uint256 _max_burn_amount
returns: uint256
remove_liquidity_imbalance 0x5b8369f5
uint256[3] _amounts
uint256 _max_burn_amount
bool _use_underlying
returns: uint256
remove_liquidity_one_coin 0x1a4d01d2
uint256 _token_amount
int128 i
uint256 _min_amount
returns: uint256
remove_liquidity_one_coin 0x517a55a3
uint256 _token_amount
int128 i
uint256 _min_amount
bool _use_underlying
returns: uint256
revert_new_parameters 0x226840fb
No parameters
revert_transfer_ownership 0x86fbf193
No parameters
set_aave_referral 0xb6aa64c5
uint256 referral_code
stop_ramp_A 0x551a6588
No parameters
unkill_me 0x3046f972
No parameters
withdraw_admin_fees 0x30c54085
No parameters

Token Balances (1)

View Transfers →
USDT 20

Recent Transactions

No transactions found for this address