Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xfa3f6f36e3D178A538B2B1Fa5f1a5291C901A884
Balance 0 ETH
Nonce 1
Code Size 11467 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

11467 bytes
0x608060405234801561000f575f80fd5b506004361061016d575f3560e01c80638456cb59116100d9578063b187bd2611610093578063c76f771e1161006e578063c76f771e146103c4578063ef481887146103d7578063f2fde38b146103ea578063fe575a87146103fd575f80fd5b8063b187bd261461038a578063bf16f65a1461039e578063c690908a146103b1575f80fd5b80638456cb59146102955780638c2de1a51461029d5780638da5cb5b146102b05780638dc10776146102c15780639cf160f61461033c578063ab37f4861461034f575f80fd5b80634487db301161012a5780634487db301461020b578063455772f91461021e578063537df3b61461023f57806353b9ed171461025257806354cf2aeb146102655780635ed7453e1461026e575f80fd5b8063046f7da21461017157806316f0115b1461017b57806323e27a64146101bf5780633268cc56146101d257806343bf50e3146101e557806344337ea1146101f8575b5f80fd5b61017961041f565b005b6101a27f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c2181565b6040516001600160a01b0390911681526020015b60405180910390f35b6101796101cd3660046125a6565b6104ba565b6006546101a2906001600160a01b031681565b6101796101f33660046126b7565b6105a7565b6101796102063660046125a6565b610616565b6101796102193660046125a6565b6106cb565b61023161022c366004612890565b6107a0565b6040519081526020016101b6565b61017961024d3660046125a6565b610b6d565b61017961026036600461293f565b610bc8565b61023160045481565b6101a27f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a8881565b610179610d55565b6101796102ab36600461293f565b610dce565b6001546001600160a01b03166101a2565b6103096102cf3660046129ae565b60036020525f90815260409020805460019091015460ff808316926101008104909116916001600160a01b03620100009092048216911684565b6040805160ff909516855292151560208501526001600160a01b03918216928401929092521660608201526080016101b6565b6005546101a2906001600160a01b031681565b61037a61035d3660046125a6565b6001600160a01b03165f9081526002602052604090205460ff1690565b60405190151581526020016101b6565b60055461037a90600160a01b900460ff1681565b6101796103ac3660046129c7565b611000565b6101796103bf3660046125a6565b6110b0565b6102316103d23660046129de565b611190565b6102316103e5366004612a0f565b61130e565b6101796103f83660046125a6565b6118ba565b61037a61040b3660046125a6565b60076020525f908152604090205460ff1681565b6104276118f6565b6001546001600160a01b0316331461045257604051630b2db9b760e31b815260040160405180910390fd5b600554600160a01b900460ff166104a25760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e481c995cdd5b5959608a1b60448201526064015b60405180910390fd5b6005805460ff60a01b191690556104b860015f55565b565b6104c26118f6565b6001546001600160a01b031633146104ed57604051630b2db9b760e31b815260040160405180910390fd5b6001600160a01b0381165f9081526002602052604090205460ff166105475760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e48191a5cd8589b195960821b6044820152606401610499565b6001600160a01b0381165f81815260026020908152604091829020805460ff1916905590519182527f8c70f523aa5b049969418995ff0d34c0ff19203f1e2f82028904a69433b8426091015b60405180910390a16105a460015f55565b50565b6105af6118f6565b6001546001600160a01b031633146105da57604051630b2db9b760e31b815260040160405180910390fd5b600554600160a01b900460ff16156106045760405162461bcd60e51b815260040161049990612afb565b61060d8161191e565b6105a460015f55565b61061e6118f6565b6001546001600160a01b0316331461064957604051630b2db9b760e31b815260040160405180910390fd5b6001546001600160a01b03908116908216036106a05760405162461bcd60e51b815260206004820152601660248201527521b0b73737ba10313630b1b5b634b9ba1037bbb732b960511b6044820152606401610499565b6001600160a01b0381165f908152600760205260409020805460ff191660011790556105a460015f55565b6106d36118f6565b6001546001600160a01b031633146106fe57604051630b2db9b760e31b815260040160405180910390fd5b600554600160a01b900460ff16156107285760405162461bcd60e51b815260040161049990612afb565b6001600160a01b03811661077e5760405162461bcd60e51b815260206004820152601760248201527f4665657320636f6c6c6563746f722072657175697265640000000000000000006044820152606401610499565b600580546001600160a01b0319166001600160a01b03831617905560015f5550565b5f6107a96118f6565b600554600160a01b900460ff16156107d35760405162461bcd60e51b815260040161049990612afb565b5f8251116108155760405162461bcd60e51b815260206004820152600f60248201526e151bdad95b9cc81c995c5d5a5c9959608a1b6044820152606401610499565b335f9081526007602052604090205460ff161561086a5760405162461bcd60e51b81526020600482015260136024820152721059191c995cdcc8189b1858dadb1a5cdd1959606a1b6044820152606401610499565b6005546040516370a0823160e01b8152306004820152610903917f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88916001600160a01b03918216918316906370a08231906024015b602060405180830381865afa1580156108da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108fe9190612b24565b611b37565b5f5b8251811015610a2c577f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a886001600160a01b031683828151811061094a5761094a612b3b565b6020026020010151604001516001600160a01b03160361099c5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a5908185cdcd95d609a1b6044820152606401610499565b7f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a888382815181106109cf576109cf612b3b565b6020026020010151606001906001600160a01b031690816001600160a01b031681525050610a24838281518110610a0857610a08612b3b565b60209081029190910101516005546001600160a01b0316611b9f565b600101610905565b505f610a36612024565b9050610a837f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a887f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c2183612195565b604051636e553f6560e01b8152600481018290523360248201527f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c216001600160a01b031690636e553f65906044016020604051808303815f875af1158015610aed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b119190612b24565b9150610b5e7f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a887f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c215f612195565b50610b6860015f55565b919050565b610b756118f6565b6001546001600160a01b03163314610ba057604051630b2db9b760e31b815260040160405180910390fd5b6001600160a01b0381165f908152600760205260409020805460ff191690556105a460015f55565b610bd06118f6565b6001546001600160a01b03163314610bfb57604051630b2db9b760e31b815260040160405180910390fd5b5f5b81811015610d475760025f848484818110610c1a57610c1a612b3b565b9050602002016020810190610c2f91906125a6565b6001600160a01b0316815260208101919091526040015f205460ff16610c8a5760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e48191a5cd8589b195960821b6044820152606401610499565b5f60025f858585818110610ca057610ca0612b3b565b9050602002016020810190610cb591906125a6565b6001600160a01b0316815260208101919091526040015f20805460ff19169115159190911790557f8c70f523aa5b049969418995ff0d34c0ff19203f1e2f82028904a69433b84260838383818110610d0f57610d0f612b3b565b9050602002016020810190610d2491906125a6565b6040516001600160a01b03909116815260200160405180910390a1600101610bfd565b50610d5160015f55565b5050565b610d5d6118f6565b6001546001600160a01b03163314610d8857604051630b2db9b760e31b815260040160405180910390fd5b600554600160a01b900460ff1615610db25760405162461bcd60e51b815260040161049990612afb565b6005805460ff60a01b1916600160a01b1790556104b860015f55565b610dd66118f6565b6001546001600160a01b03163314610e0157604051630b2db9b760e31b815260040160405180910390fd5b80610e435760405162461bcd60e51b81526020600482015260126024820152711059191c995cdcd95cc81c995c5d5a5c995960721b6044820152606401610499565b5f5b81811015610d47575f838383818110610e6057610e60612b3b565b9050602002016020810190610e7591906125a6565b6001600160a01b031603610ebd5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610499565b60025f848484818110610ed257610ed2612b3b565b9050602002016020810190610ee791906125a6565b6001600160a01b0316815260208101919091526040015f205460ff1615610f425760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e48195b98589b1959608a1b6044820152606401610499565b600160025f858585818110610f5957610f59612b3b565b9050602002016020810190610f6e91906125a6565b6001600160a01b0316815260208101919091526040015f20805460ff19169115159190911790557fa237d7744f842765533370fdefa96a57810536bac49191f2aeed4a70ec756e12838383818110610fc857610fc8612b3b565b9050602002016020810190610fdd91906125a6565b6040516001600160a01b03909116815260200160405180910390a1600101610e45565b6110086118f6565b6001546001600160a01b0316331461103357604051630b2db9b760e31b815260040160405180910390fd5b600554600160a01b900460ff161561105d5760405162461bcd60e51b815260040161049990612afb565b61271081106110a25760405162461bcd60e51b81526020600482015260116024820152700a6eec2e040cccaca40e8dede40d0d2ced607b1b6044820152606401610499565b60048190556105a460015f55565b6110b86118f6565b6001546001600160a01b031633146110e357604051630b2db9b760e31b815260040160405180910390fd5b6001600160a01b0381165f9081526002602052604090205460ff161561113d5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e48195b98589b1959608a1b6044820152606401610499565b6001600160a01b0381165f81815260026020908152604091829020805460ff1916600117905590519182527fa237d7744f842765533370fdefa96a57810536bac49191f2aeed4a70ec756e129101610593565b5f6111996118f6565b600554600160a01b900460ff16156111c35760405162461bcd60e51b815260040161049990612afb565b7f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a886001600160a01b031682604001516001600160a01b0316036112385760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a5908185cdcd95d609a1b6044820152606401610499565b335f9081526007602052604090205460ff161561128d5760405162461bcd60e51b81526020600482015260136024820152721059191c995cdcc8189b1858dadb1a5cdd1959606a1b6044820152606401610499565b6001600160a01b037f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88818116606085018190526005546040516370a0823160e01b81523060048201526112ee949190911691906370a08231906024016108bf565b6005546113059083906001600160a01b0316611b9f565b5f610a36612024565b5f6113176118f6565b600554600160a01b900460ff16156113415760405162461bcd60e51b815260040161049990612afb565b6006546001600160a01b031661136a5760405163179ce99f60e01b815260040160405180910390fd5b6005546040516370a0823160e01b81523060048201526113c3917f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88916001600160a01b03918216918316906370a08231906024016108bf565b5f805b835181101561177d5760025f8583815181106113e4576113e4612b3b565b6020908102919091018101516040908101516001600160a01b0316835290820192909252015f205460ff1661142c576040516307c241ad60e51b815260040160405180910390fd5b7f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a886001600160a01b031684828151811061146857611468612b3b565b6020026020010151604001516001600160a01b03160361149b57604051632dc600a760e01b815260040160405180910390fd5b6114e08482815181106114b0576114b0612b3b565b60200260200101516040015133308785815181106114d0576114d0612b3b565b60200260200101515f01516122a8565b6115388482815181106114f5576114f5612b3b565b60200260200101516040015160065f9054906101000a90046001600160a01b031686848151811061152857611528612b3b565b60200260200101515f0151612195565b5f60405180610100016040528086848151811061155757611557612b3b565b6020026020010151604001516001600160a01b031681526020017f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a886001600160a01b031681526020018684815181106115b2576115b2612b3b565b60200260200101516060015162ffffff168152602001306001600160a01b031681526020014281526020018684815181106115ef576115ef612b3b565b60200260200101515f0151815260200186848151811061161157611611612b3b565b602002602001015160200151815260200186848151811061163457611634612b3b565b6020908102919091010151608001516001600160a01b0390811690915260065460405163414bf38960e01b8152929350169063414bf3899061167a908490600401612b4f565b6020604051808303815f875af1158015611696573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116ba9190612b24565b508482815181106116cd576116cd612b3b565b602090810291909101015160409081015190516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611720573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117449190612b24565b925082156117745761177485838151811061176157611761612b3b565b6020026020010151604001513385611b37565b506001016113c6565b505f611787612024565b90506117d47f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a887f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c2183612195565b604051636e553f6560e01b8152600481018290523360248201527f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c216001600160a01b031690636e553f65906044016020604051808303815f875af115801561183e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118629190612b24565b92506118af7f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a887f0000000000000000000000008aca0841993ef4c87244d519166e767f49362c215f612195565b5050610b6860015f55565b6118c26118f6565b6001546001600160a01b031633146118ed57604051630b2db9b760e31b815260040160405180910390fd5b61060d816122e6565b60025f5403611918576040516306fda65d60e31b815260040160405180910390fd5b60025f55565b5f5b8151811015610d51575f82828151811061193c5761193c612b3b565b60200260200101515f015160ff161161198e5760405162461bcd60e51b8152602060048201526014602482015273141c9bdd9a59195c881251081c995c5d5a5c995960621b6044820152606401610499565b5f6001600160a01b03168282815181106119aa576119aa612b3b565b6020026020010151604001516001600160a01b0316036119fe5760405162461bcd60e51b815260206004820152600f60248201526e149bdd5d195c881c995c5d5a5c9959608a1b6044820152606401610499565b5f6001600160a01b0316828281518110611a1a57611a1a612b3b565b6020026020010151606001516001600160a01b031603611a7c5760405162461bcd60e51b815260206004820152601a60248201527f5472616e7366657220636f6e74726163742072657175697265640000000000006044820152606401610499565b818181518110611a8e57611a8e612b3b565b602002602001015160035f848481518110611aab57611aab612b3b565b6020908102919091018101515160ff90811683528282019390935260409182015f20845181549286015193860151941661ffff1990921691909117610100921515929092029190911762010000600160b01b031916620100006001600160a01b0393841602178155606090920151600192830180546001600160a01b0319169190921617905501611920565b6040516001600160a01b038316602482015260448101829052611b9a90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612337565b505050565b608082015160ff9081165f90815260036020526040902054610100900416611bfa5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642062726964676560901b6044820152606401610499565b6040808301516001600160a01b03165f9081526002602052205460ff16611c5b5760405162461bcd60e51b8152602060048201526015602482015274151bdad95b881b9bdd081dda1a5d195b1a5cdd1959605a1b6044820152606401610499565b60608201516040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015611ca3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cc79190612b24565b60408085015190516370a0823160e01b81523060048201529192505f916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d14573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d389190612b24565b90505f81118015611d5157506001600160a01b03831615155b15611d6557611d6584604001518483611b37565b611d7884604001513330875f01516122a8565b60808401805160ff9081165f90815260036020526040808220549351909216815281902060010154908601518651620100009093046001600160a01b0390811693921691611dc891908390612195565b5f826001600160a01b03165f8860a00151604051611de69190612bcc565b5f6040518083038185875af1925050503d805f8114611e20576040519150601f19603f3d011682016040523d82523d5f602084013e611e25565b606091505b5050905080611e645760405162461bcd60e51b815260206004820152600b60248201526a14ddd85c0819985a5b195960aa1b6044820152606401610499565b60608701516040516370a0823160e01b81523060048201525f9187916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611eb0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ed49190612b24565b611ede9190612bf6565b90508760200151811015611f2c5760405162461bcd60e51b815260206004820152601560248201527414db1a5c1c1859d94818da1958dac819985a5b1959605a1b6044820152606401610499565b611f3b8860400151845f612195565b60408089015190516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015611f83573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fa79190612b24565b90508015611fbe57611fbe89604001513383611b37565b6040898101516060808c01518c5184516001600160a01b03948516815293909116602084015282840152810184905290517ff0aa99fb508b05ad92832e7a1e8a1d381919f315c53cfcde052458465f62f9159181900360800190a1505050505050505050565b6040516370a0823160e01b81523060048201525f9081906001600160a01b037f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a8816906370a0823190602401602060405180830381865afa15801561208a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120ae9190612b24565b90505f80600454116120c0575f6120db565b612710826004546120d19190612c0f565b6120db9190612c26565b90506120e78183612bf6565b9250801561219057600554612127907f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88906001600160a01b031683611b37565b60408051838152602081018390527f00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a886001600160a01b03168183015290517f5abd633af75662005d1fca2f04d28c63a25707416f65c658e7d96d3476e18a599181900360600190a15b505090565b80158061220d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156121e7573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061220b9190612b24565b155b6122785760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610499565b6040516001600160a01b038316602482015260448101829052611b9a90849063095ea7b360e01b90606401611b63565b6040516001600160a01b03808516602483015283166044820152606481018290526122e09085906323b872dd60e01b90608401611b63565b50505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f61238b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124089092919063ffffffff16565b805190915015611b9a57808060200190518101906123a99190612c45565b611b9a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610499565b606061241684845f8561241e565b949350505050565b60608247101561247f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610499565b5f80866001600160a01b0316858760405161249a9190612bcc565b5f6040518083038185875af1925050503d805f81146124d4576040519150601f19603f3d011682016040523d82523d5f602084013e6124d9565b606091505b50915091506124ea878383876124f5565b979650505050505050565b606083156125635782515f0361255c576001600160a01b0385163b61255c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610499565b5081612416565b61241683838151156125785781518083602001fd5b8060405162461bcd60e51b81526004016104999190612c60565b6001600160a01b03811681146105a4575f80fd5b5f602082840312156125b6575f80fd5b81356125c181612592565b9392505050565b634e487b7160e01b5f52604160045260245ffd5b604051608081016001600160401b03811182821017156125fe576125fe6125c8565b60405290565b60405160c081016001600160401b03811182821017156125fe576125fe6125c8565b60405160a081016001600160401b03811182821017156125fe576125fe6125c8565b604051601f8201601f191681016001600160401b0381118282101715612670576126706125c8565b604052919050565b5f6001600160401b03821115612690576126906125c8565b5060051b60200190565b803560ff81168114610b68575f80fd5b80151581146105a4575f80fd5b5f602082840312156126c7575f80fd5b81356001600160401b038111156126dc575f80fd5b8201601f810184136126ec575f80fd5b80356126ff6126fa82612678565b612648565b8082825260208201915060208360071b850101925086831115612720575f80fd5b6020840193505b8284101561279e576080848803121561273e575f80fd5b6127466125dc565b61274f8561269a565b8152602085013561275f816126aa565b6020820152604085013561277281612592565b6040820152606085013561278581612592565b6060820152825260809390930192602090910190612727565b9695505050505050565b5f60c082840312156127b8575f80fd5b6127c0612604565b8235815260208084013590820152905060408201356127de81612592565b604082015260608201356127f181612592565b60608201526128026080830161269a565b608082015260a08201356001600160401b0381111561281f575f80fd5b8201601f8101841361282f575f80fd5b80356001600160401b03811115612848576128486125c8565b61285b601f8201601f1916602001612648565b81815285602083850101111561286f575f80fd5b816020840160208301375f602083830101528060a085015250505092915050565b5f602082840312156128a0575f80fd5b81356001600160401b038111156128b5575f80fd5b8201601f810184136128c5575f80fd5b80356128d36126fa82612678565b8082825260208201915060208360051b8501019250868311156128f4575f80fd5b602084015b838110156129345780356001600160401b03811115612916575f80fd5b612925896020838901016127a8565b845250602092830192016128f9565b509695505050505050565b5f8060208385031215612950575f80fd5b82356001600160401b03811115612965575f80fd5b8301601f81018513612975575f80fd5b80356001600160401b0381111561298a575f80fd5b8560208260051b840101111561299e575f80fd5b6020919091019590945092505050565b5f602082840312156129be575f80fd5b6125c18261269a565b5f602082840312156129d7575f80fd5b5035919050565b5f602082840312156129ee575f80fd5b81356001600160401b03811115612a03575f80fd5b612416848285016127a8565b5f60208284031215612a1f575f80fd5b81356001600160401b03811115612a34575f80fd5b8201601f81018413612a44575f80fd5b8035612a526126fa82612678565b80828252602082019150602060a08402850101925086831115612a73575f80fd5b6020840193505b8284101561279e5760a08488031215612a91575f80fd5b612a99612626565b84358152602080860135908201526040850135612ab581612592565b6040820152606085013562ffffff81168114612acf575f80fd5b60608201526080850135612ae281612592565b6080820152825260a09390930192602090910190612a7a565b6020808252600f908201526e10dbdb9d1c9858dd081c185d5cd959608a1b604082015260600190565b5f60208284031215612b34575f80fd5b5051919050565b634e487b7160e01b5f52603260045260245ffd5b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff169083015260608084015191821690830152610100820190506080830151608083015260a083015160a083015260c083015160c083015260e0830151612bc560e08401826001600160a01b03169052565b5092915050565b5f82518060208501845e5f920191825250919050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115612c0957612c09612be2565b92915050565b8082028115828204841417612c0957612c09612be2565b5f82612c4057634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215612c55575f80fd5b81516125c1816126aa565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fea2646970667358221220eab6ea1029e0cd34be19ce4b0cdaeca385850300314870335c5c299d7657934964736f6c634300081a0033

Verified Source Code Partial Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: Yes (200 runs)
StandalonePoolAdapter.sol 1342 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;




/**
 * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
 * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
 *
 * _Available since v4.7._
 */
interface IERC4626 {
    /// @notice Triggers when an account deposits funds in the contract
    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

    event Withdraw(
        address indexed sender,
        address indexed receiver,
        address indexed owner,
        uint256 assets,
        uint256 shares
    );

    /**
     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
     *
     * - MUST be an ERC-20 token contract.
     * - MUST NOT revert.
     */
    function asset() external view returns (address assetTokenAddress);

    /**
     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
     *
     * - SHOULD include any compounding that occurs from yield.
     * - MUST be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT revert.
     */
    function totalAssets() external view returns (uint256 totalManagedAssets);

    /**
     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToShares(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToAssets(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
     * through a deposit call.
     *
     * - MUST return a limited value if receiver is subject to some deposit limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
     * - MUST NOT revert.
     */
    function maxDeposit(address receiver) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
     *   in the same transaction.
     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewDeposit(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   deposit execution, and are accounted for during deposit.
     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
     * - MUST return a limited value if receiver is subject to some mint limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
     * - MUST NOT revert.
     */
    function maxMint(address receiver) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
     *   same transaction.
     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
     *   would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by minting.
     */
    function previewMint(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
     *   execution, and are accounted for during mint.
     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function mint(uint256 shares, address receiver) external returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
     * Vault, through a withdraw call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxWithdraw(address owner) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
     *   called
     *   in the same transaction.
     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewWithdraw(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   withdraw execution, and are accounted for during withdraw.
     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function withdraw(
        uint256 assets,
        address receiver,
        address owner
    ) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
     * through a redeem call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxRedeem(address owner) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
     *   same transaction.
     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
     *   redemption would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
     */
    function previewRedeem(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   redeem execution, and are accounted for during redeem.
     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function redeem(
        uint256 shares,
        address receiver,
        address owner
    ) external returns (uint256 assets);
}




interface IUniswapV3SwapRouter {
    struct ExactInputSingleParams {
        address tokenIn;            // The contract address of the inbound token
        address tokenOut;           // The contract address of the outbound token
        uint24 fee;                 // The fee tier of the pool, used to determine the correct pool contract in which to execute the swap
        address recipient;          // The destination address of the outbound token
        uint256 deadline;           // The unix time after which a swap will fail, to protect against long-pending transactions and wild swings in prices
        uint256 amountIn;           // The input amount
        uint256 amountOutMinimum;   // The minimum amount out
        uint160 sqrtPriceLimitX96;  // The price limit
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}





// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)




// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)



/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}


// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol)



/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}


// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)



/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}


/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}







/**
 * @notice Defines the interface for whitelisting tokens.
 */
interface ITokensWhitelist {
    /**
     * @notice Whitelists the address specified.
     * @param addr The address to enable
     */
    function enableToken (address addr) external;

    /**
     * @notice Whitelists the addresses specified.
     * @param arr The addresses to enable
     */
    function enableTokens (address[] calldata arr) external;

    /**
     * @notice Disables the address specified.
     * @param addr The address to disable
     */
    function disableToken (address addr) external;

    /**
     * @notice Disables the addresses specified.
     * @param arr The addresses to disable
     */
    function disableTokens (address[] calldata arr) external;

    /**
     * @notice Indicates if the address is whitelisted or not.
     * @param addr The address to disable
     * @return Returns 1 if the address is whitelisted
     */
    function isWhitelistedToken (address addr) external view returns (bool);

    /**
     * This event is triggered when a new address is whitelisted.
     * @param addr The address that was whitelisted
     */
    event OnTokenEnabled(address addr);

    /**
     * This event is triggered when an address is disabled.
     * @param addr The address that was disabled
     */
    event OnTokenDisabled(address addr);
}







interface IOwnable {
    function transferOwnership(address newOwner) external;
    function owner() external view returns (address);
}




/**
 * @title Base reentrancy guard. This is constructor-less implementation for both proxies and standalone contracts.
 */
abstract contract BaseReentrancyGuard {
    error ReentrantCall();
    
    uint256 internal constant _REENTRANCY_NOT_ENTERED = 1;
    uint256 internal constant _REENTRANCY_ENTERED = 2;

    uint256 internal _reentrancyStatus;

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        if (_reentrancyStatus == _REENTRANCY_ENTERED) revert ReentrantCall();

        // Any calls to nonReentrant after this point will fail
        _reentrancyStatus = _REENTRANCY_ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _reentrancyStatus = _REENTRANCY_NOT_ENTERED;
    }
}




abstract contract BaseOwnable {
    error OwnerOnly();

    address internal _owner;

    /**
     * @notice Triggers when contract ownership changes.
     * @param previousOwner The previous owner of the contract.
     * @param newOwner The new owner of the contract.
     */
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        if (msg.sender != _owner) revert OwnerOnly();
        _;
    }

    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}


/**
 * @title Lightweight version of the ownership contract. This contract has a reentrancy guard.
 */
abstract contract LightweightOwnable is IOwnable, BaseReentrancyGuard, BaseOwnable {
    /**
     * @notice Transfers ownership of the contract to the account specified.
     * @param newOwner The address of the new owner.
     */
    function transferOwnership(address newOwner) external virtual nonReentrant onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @notice Gets the owner of the contract.
     * @return address The address who owns the contract.
     */
    function owner() external view virtual returns (address) {
        return _owner;
    }    
}


/**
 * @title Standalone contract for whitelisting token addresses.
 */
contract TokensWhitelist is ITokensWhitelist, LightweightOwnable {
    mapping (address => bool) internal _whitelistedTokens;

    constructor(address ownerAddr) {
        require(ownerAddr != address(0), "Owner required");
        _owner = ownerAddr;
    }

    /**
     * @notice Whitelists the address specified.
     * @param addr The address to enable
     */
    function enableToken (address addr) external override nonReentrant onlyOwner {
        require(!_whitelistedTokens[addr], "Already enabled");
        _whitelistedTokens[addr] = true;
        emit OnTokenEnabled(addr);
    }

    /**
     * @notice Whitelists the addresses specified.
     * @param arr The addresses to enable
     */
    function enableTokens (address[] calldata arr) external override nonReentrant onlyOwner {
        require(arr.length > 0, "Addresses required");

        for (uint256 i; i < arr.length; i++) {
            require(arr[i] != address(0), "Invalid address");
            require(!_whitelistedTokens[arr[i]], "Already enabled");
            _whitelistedTokens[arr[i]] = true;
            emit OnTokenEnabled(arr[i]);
        }
    }

    /**
     * @notice Disables the address specified.
     * @param addr The address to disable
     */
    function disableToken (address addr) external override nonReentrant onlyOwner {
        require(_whitelistedTokens[addr], "Already disabled");
        _whitelistedTokens[addr] = false;
        emit OnTokenDisabled(addr);
    }

    /**
     * @notice Disables the addresses specified.
     * @param arr The addresses to disable
     */
    function disableTokens (address[] calldata arr) external override nonReentrant onlyOwner {
        for (uint256 i; i < arr.length; i++) {
            require(_whitelistedTokens[arr[i]], "Already disabled");
            _whitelistedTokens[arr[i]] = false;
            emit OnTokenDisabled(arr[i]);
        }
    }

    /**
     * @notice Indicates if the address is whitelisted or not.
     * @param addr The address to evaluate.
     * @return Returns true if the address is whitelisted.
     */
    function isWhitelistedToken (address addr) external view override returns (bool) {
        return _whitelistedTokens[addr];
    }
}


/**
 * @title Primitive swapper for ERC-20 tokens.
 */
abstract contract BasePoolSwapper is TokensWhitelist {
    // ---------------------------------------------------------------
    // Structures
    // ---------------------------------------------------------------
    // Represents a bridge like Paraswap, Lifi, etc.
    struct SwapProvider {
        uint8 id;
        bool enabled;
        address routerAddress;
        address tokenTransferProxy;
    }

    // Represents the parameters of a swap
    struct SwapInfo {
        uint256 amountIn;
        uint256 minAmountOut;
        IERC20 srcToken;
        IERC20 dstToken;
        uint8 bridgeId;
        bytes quoteData;
    }

    struct SingleHopItem {
        uint256 amountIn;
        uint256 minAmountOut;
        address tokenIn;
        uint24 fee;
        uint160 sqrtPriceLimitX96;
    }

    // ---------------------------------------------------------------
    // Storage layout
    // ---------------------------------------------------------------
    /// @notice The swap providers (LiFi, Paraswap, etc)
    mapping (uint8 => SwapProvider) public swapProviders;

    // ---------------------------------------------------------------
    // Events
    // ---------------------------------------------------------------
    /// @notice Triggers when an atomic swap is processed
    event SwapProcessed(address srcToken, address dstToken, uint256 srcAmount, uint256 dstAmount);


    // ---------------------------------------------------------------
    // Functions
    // ---------------------------------------------------------------
    function _updateSwapProviders(SwapProvider[] memory newSwapProviders) internal virtual {
        for (uint256 i; i < newSwapProviders.length; i++) {
            require(newSwapProviders[i].id > 0, "Provider ID required");
            require(newSwapProviders[i].routerAddress != address(0), "Router required");
            require(newSwapProviders[i].tokenTransferProxy != address(0), "Transfer contract required");

            swapProviders[newSwapProviders[i].id] = newSwapProviders[i];
        }
    }

    function _singleSwap(SwapInfo memory item, address collectorAddr) internal virtual {
        require(swapProviders[item.bridgeId].enabled, "Invalid bridge");

        // Make sure the input token is whitelisted
        require(_whitelistedTokens[address(item.srcToken)], "Token not whitelisted");
        
        uint256 dstTokenBalanceBeforeSwap = item.dstToken.balanceOf(address(this));

        // We need this check because we do not control the off-chain payload.
        // Without this check, an attacker could trade an amount bigger than the one specified.
        uint256 srcTokenBalanceBeforeSwap = item.srcToken.balanceOf(address(this));
        if ((srcTokenBalanceBeforeSwap > 0) && (collectorAddr != address(0))) {
            SafeERC20.safeTransfer(item.srcToken, collectorAddr, srcTokenBalanceBeforeSwap);
        }

        // Transfer the funds
        SafeERC20.safeTransferFrom(item.srcToken, msg.sender, address(this), item.amountIn);

        // Determine the addresses of the bridge
        address routerAddr = swapProviders[item.bridgeId].routerAddress;
        address tokenTransferProxy = swapProviders[item.bridgeId].tokenTransferProxy;

        // Approve the bridge as a spender
        SafeERC20.safeApprove(item.srcToken, tokenTransferProxy, item.amountIn);

        // Run the swap through the router
        (bool success, ) = routerAddr.call{value: 0}(item.quoteData);
        require(success, "Swap failed");

        // Slippage check
        uint256 amountReceived = item.dstToken.balanceOf(address(this)) - dstTokenBalanceBeforeSwap;
        require(amountReceived >= item.minAmountOut, "Slippage check failed");

        // Revoke the approval
        SafeERC20.safeApprove(item.srcToken, tokenTransferProxy, 0);

        // Refund the user, if needed
        uint256 remainingInputTokens = item.srcToken.balanceOf(address(this));
        if (remainingInputTokens > 0) {
            SafeERC20.safeTransfer(item.srcToken, msg.sender, remainingInputTokens);
        }

        // Log the event
        emit SwapProcessed(address(item.srcToken), address(item.dstToken), item.amountIn, amountReceived);
    }
}


/**
 * @title Swap adapter for ERC-4626 pools. Supports deposits in multiple tokens. Tokens must be whitelisted in advance.
 * @dev This contract assumes the pool is not a proxy.
 */
contract StandalonePoolAdapter is BasePoolSwapper {
    error RouterNotSet();
    error InputTokenNotAllowed();
    error TokenNotWhitelisted();

    // ---------------------------------------------------------------
    // Storage layout
    // ---------------------------------------------------------------
    /// @notice The pool associated to this adapter.
    IERC4626 public immutable pool;

    /// @notice The underlying asset of the ERC-4626 pool.
    IERC20 public immutable poolAsset;

    /// @notice The swap fee, expressed with 2 decimal places.
    uint256 public swapFee;

    /// @notice The address of the fees collector, if any.
    address public feesCollector;

    /// @notice Indicates if the adapter is paused.
    bool public isPaused;

    /// @notice The address of the Uniswap V3 router
    address public routerAddress;

    mapping(address => bool) public isBlacklisted;

    // ---------------------------------------------------------------
    // Events
    // ---------------------------------------------------------------
    /// @notice Triggers when the contract collects swap fees
    event SwapFeeApplied(uint256 swapAmount, uint256 applicableFee, address tokenAddr);


    // ---------------------------------------------------------------
    // Constructor
    // ---------------------------------------------------------------
    constructor(
        uint256 newSwapFee,
        address ownerAddr, 
        address newFeesCollectorAddr,
        address routerAddr,
        SwapProvider[] memory newSwapProviders,
        IERC4626 newPool
    ) TokensWhitelist(ownerAddr) {
        // Checks
        require(newFeesCollectorAddr != address(0), "Fees collector required");
        require(newSwapFee < 10000, "Swap fee too high");
        require(newPool.asset() != address(0), "Invalid pool");

        // State changes
        feesCollector = newFeesCollectorAddr;
        swapFee = newSwapFee;
        routerAddress = routerAddr;
        pool = newPool;
        poolAsset = IERC20(newPool.asset());

        // Define the swap providers
        _updateSwapProviders(newSwapProviders);
    }

    // ---------------------------------------------------------------
    // Modifiers
    // ---------------------------------------------------------------
    modifier ifNotPaused() {
        require(!isPaused, "Contract paused");
        _;
    }

    // ---------------------------------------------------------------
    // Swap functions
    // ---------------------------------------------------------------
    /**
     * @notice Swaps one or more tokens via Uniswap and deposits the outcome in the pool.
     * @param items The swaps to perform.
     * @return shares The number of shares deposited in the pool.
     */
    function swapAndDeposit(
        SingleHopItem[] memory items
    ) external nonReentrant ifNotPaused returns (uint256 shares) {
        if (routerAddress == address(0)) revert RouterNotSet();
       
        // Transfer any existing underlying assets to the fee collector prior running the swap(s)
        SafeERC20.safeTransfer(poolAsset, feesCollector, poolAsset.balanceOf(address(this)));

        uint256 surplusBalance;

        for (uint256 i; i < items.length; i++) {
            // Make sure the input token is whitelisted
            if (!_whitelistedTokens[items[i].tokenIn]) revert TokenNotWhitelisted();

            if (items[i].tokenIn == address(poolAsset)) revert InputTokenNotAllowed();

            SafeERC20.safeTransferFrom(IERC20(items[i].tokenIn), msg.sender, address(this), items[i].amountIn);

            // Approve the router
            SafeERC20.safeApprove(IERC20(items[i].tokenIn), routerAddress, items[i].amountIn);

            IUniswapV3SwapRouter.ExactInputSingleParams memory swapParams = IUniswapV3SwapRouter.ExactInputSingleParams({
                tokenIn: items[i].tokenIn, 
                tokenOut: address(poolAsset),
                recipient: address(this),
                amountIn: items[i].amountIn,
                amountOutMinimum: items[i].minAmountOut,

                // The fee tier of the pool, used to determine the correct pool contract in which to execute the swap
                fee: items[i].fee,

                // The unix time after which a swap will fail, to protect against long-pending transactions and wild swings in prices
                deadline: block.timestamp,

                // The price limit
                sqrtPriceLimitX96: items[i].sqrtPriceLimitX96
            });

            // Run the swap via Uniswap V3
            IUniswapV3SwapRouter(routerAddress).exactInputSingle(swapParams);

            surplusBalance = IERC20(items[i].tokenIn).balanceOf(address(this));
            if (surplusBalance > 0) {
                SafeERC20.safeTransfer(IERC20(items[i].tokenIn), msg.sender, surplusBalance);
            }
        }

        // Apply fees
        uint256 effectiveDepositAmount = _applyFees();

        // Deposit funds in the pool and return the respective number of shares
        SafeERC20.safeApprove(poolAsset, address(pool), effectiveDepositAmount);
        shares = pool.deposit(effectiveDepositAmount, msg.sender);
        SafeERC20.safeApprove(poolAsset, address(pool), 0);
    }

    /**
     * @notice Swaps a single token and deposits the output token into the pool.
     * @param item The swap parameters.
     * @return shares The number of shares deposited in the pool.
     */
    function swapAndDeposit(SwapInfo memory item) external nonReentrant ifNotPaused returns (uint256 shares) {
        require(address(item.srcToken) != address(poolAsset), "Invalid asset");
        require(!isBlacklisted[msg.sender], "Address blacklisted");

        // Force the destination asset to match the one defined by the pool
        item.dstToken = poolAsset;

        SafeERC20.safeTransfer(poolAsset, feesCollector, poolAsset.balanceOf(address(this)));

        // Run the atomic swap through the bridge specified.
        _singleSwap(item, feesCollector);

        // Apply fees
        uint256 effectiveDepositAmount = _applyFees();

        // Deposit funds in the pool and return the respective number of shares
        SafeERC20.safeApprove(poolAsset, address(pool), effectiveDepositAmount);
        shares = pool.deposit(effectiveDepositA...

// [truncated — 54460 bytes total]

Read Contract

feesCollector 0x9cf160f6 → address
isBlacklisted 0xfe575a87 → bool
isPaused 0xb187bd26 → bool
isWhitelistedToken 0xab37f486 → bool
owner 0x8da5cb5b → address
pool 0x16f0115b → address
poolAsset 0x5ed7453e → address
routerAddress 0x3268cc56 → address
swapFee 0x54cf2aeb → uint256
swapProviders 0x8dc10776 → uint8, bool, address, address

Write Contract 15 functions

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

addToBlacklist 0x44337ea1
address addr
disableToken 0x23e27a64
address addr
disableTokens 0x53b9ed17
address[] arr
enableToken 0xc690908a
address addr
enableTokens 0x8c2de1a5
address[] arr
pause 0x8456cb59
No parameters
removeFromBlacklist 0x537df3b6
address addr
resume 0x046f7da2
No parameters
swapAndDeposit 0x292b2318
tuple[] items
returns: uint256
swapAndDeposit 0x16064f4a
tuple item
returns: uint256
swapAndDeposit 0x292b2318
tuple[] items
returns: uint256
transferOwnership 0xf2fde38b
address newOwner
updateFeesCollector 0x4487db30
address newFeesCollectorAddr
updateSwapFee 0xbf16f65a
uint256 newSwapFee
updateSwapProviders 0xa637147f
tuple[] newSwapProviders

Recent Transactions

No transactions found for this address