Address Contract Partially Verified
Address
0xFe7cbf216d6bbE781d78fC8AB02b91250D52D956
Balance
0.000100000 ETH
Nonce
1
Code Size
23559 bytes
Creator
0x96C33074...5B68 at tx 0xb3cab305...a724ac
Indexed Transactions
0
Contract Bytecode
23559 bytes
0x608060405260043610610195575f3560e01c80636fecdf24116100e7578063cbc70d4111610087578063e357b1d311610062578063e357b1d3146104f2578063f0f4426014610511578063f2fde38b14610530578063f851a4401461054f575f5ffd5b8063cbc70d4114610494578063d01dd6d2146104b4578063d06cd738146104d3575f5ffd5b80638da5cb5b116100c25780638da5cb5b14610404578063b5f522f714610420578063bd94b00514610456578063c927bdf514610475575f5ffd5b80636fecdf24146103a1578063715018a6146103d1578063866993a9146103e5575f5ffd5b8063409e6d461161015257806360abb53a1161012d57806360abb53a1461032357806361d027b3146103385780636885b03c146103575780636ef19c9d14610376575f5ffd5b8063409e6d461461029e5780635c8b5f44146102d25780636096cf0a14610310575f5ffd5b80630331b0a01461019957806309867ab1146101ae578063104789c7146101e45780631e6c598e1461021b57806324b8ce671461024e5780632e0135ad1461027b575b5f5ffd5b6101ac6101a7366004614fcc565b61056e565b005b3480156101b9575f5ffd5b506101cd6101c8366004615075565b610ee6565b6040516101db929190615156565b60405180910390f35b3480156101ef575f5ffd5b50600854610203906001600160a01b031681565b6040516001600160a01b0390911681526020016101db565b348015610226575f5ffd5b5061023a61023536600461523d565b611b43565b6040516101db989796959493929190615254565b348015610259575f5ffd5b5061026d6102683660046152b6565b611e63565b6040516101db92919061536a565b348015610286575f5ffd5b5061029060055481565b6040519081526020016101db565b3480156102a9575f5ffd5b506102bd6102b836600461523d565b612b7e565b604080519283526020830191909152016101db565b3480156102dd575f5ffd5b506103006102ec36600461547f565b600b6020525f908152604090205460ff1681565b60405190151581526020016101db565b6101ac61031e3660046154fe565b612cd8565b34801561032e575f5ffd5b5061029060045481565b348015610343575f5ffd5b50600654610203906001600160a01b031681565b348015610362575f5ffd5b506101ac6103713660046155ad565b613a6e565b348015610381575f5ffd5b5061029061039036600461547f565b60096020525f908152604090205481565b3480156103ac575f5ffd5b506103c06103bb36600461547f565b613a94565b6040516101db9594939291906155c6565b3480156103dc575f5ffd5b506101ac613bdf565b3480156103f0575f5ffd5b506101ac6103ff36600461547f565b613bf2565b34801561040f575f5ffd5b505f546001600160a01b0316610203565b34801561042b575f5ffd5b5061043f61043a36600461523d565b613c1c565b6040516101db9b9a99989796959493929190615616565b348015610461575f5ffd5b506101ac61047036600461523d565b613f55565b348015610480575f5ffd5b506101ac61048f36600461523d565b614146565b34801561049f575f5ffd5b5060075461030090600160a01b900460ff1681565b3480156104bf575f5ffd5b506101ac6104ce3660046156a0565b61419c565b3480156104de575f5ffd5b506101ac6104ed36600461523d565b6141ce565b3480156104fd575f5ffd5b506101ac61050c3660046156d1565b6141db565b34801561051c575f5ffd5b506101ac61052b36600461547f565b614331565b34801561053b575f5ffd5b506101ac61054a36600461547f565b61435b565b34801561055a575f5ffd5b50600754610203906001600160a01b031681565b610576614395565b846001600160a01b0316866001600160a01b0316036105e85760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f742073656c6c20616e642070617920776974682073616d6520746f60448201526235b2b760e91b60648201526084015b60405180910390fd5b6001600160a01b0386166106345760405162461bcd60e51b8152602060048201526013602482015272043616e6e6f742062652061646472657373203606c1b60448201526064016105df565b6001600160a01b0385166106805760405162461bcd60e51b8152602060048201526013602482015272043616e6e6f742062652061646472657373203606c1b60448201526064016105df565b5f84116106bd5760405162461bcd60e51b815260206004820152600b60248201526a16995c9bc8185b5bdd5b9d60aa1b60448201526064016105df565b5f83116106f95760405162461bcd60e51b815260206004820152600a6024820152695a65726f20707269636560b01b60448201526064016105df565b6001600160a01b0386165f908152600b602052604090205460ff1615801561073957506001600160a01b0385165f908152600b602052604090205460ff16155b61077c5760405162461bcd60e51b8152602060048201526014602482015273151bdad95b881a5cc8189b1858dadb1a5cdd195960621b60448201526064016105df565b5f5f196001600160a01b038816016107dd578434146107d65760405162461bcd60e51b815260206004820152601660248201527526bab9ba1039b2b732103730ba34bb32903a37b5b2b760511b60448201526064016105df565b50346108d5565b6040516370a0823160e01b81523060048201525f906001600160a01b038916906370a0823190602401602060405180830381865afa158015610821573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061084591906156f1565b905061085c6001600160a01b0389163330896143ee565b6040516370a0823160e01b81523060048201525f906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156108a0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108c491906156f1565b90506108d0828261571c565b925050505b6001600160a01b0387165f908152600a6020526040902060020154600160a81b900460ff166109075761090787614455565b6001600160a01b0386165f908152600a6020526040902060020154600160a81b900460ff166109395761093986614455565b60408051610160810182526002805482526001600160a01b038a165f908152600a602090815290849020845160a081019095528054929491840192829082906109819061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546109ad9061572f565b80156109f85780601f106109cf576101008083540402835291602001916109f8565b820191905f5260205f20905b8154815290600101906020018083116109db57829003601f168201915b50505050508152602001600182018054610a119061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3d9061572f565b8015610a885780601f10610a5f57610100808354040283529160200191610a88565b820191905f5260205f20905b815481529060010190602001808311610a6b57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b9094049092161515606090940193909352928452918b165f908152600a8252829020825160a081019093528054939091019282908290610b019061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2d9061572f565b8015610b785780601f10610b4f57610100808354040283529160200191610b78565b820191905f5260205f20905b815481529060010190602001808311610b5b57829003601f168201915b50505050508152602001600182018054610b919061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbd9061572f565b8015610c085780601f10610bdf57610100808354040283529160200191610c08565b820191905f5260205f20905b815481529060010190602001808311610beb57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b909404909216151560609485015293855233938501939093529188169183019190915281018490525f6080820181905260a0820188905285151560c083015260e0909101908152426020918201528254600181810185555f948552938290208351600e909202019081559082015180519293919290918301908190610cc790826157b2565b5060208201516001820190610cdc90826157b2565b506040828101516002909201805460608501516080909501511515600160a81b0260ff60a81b196001600160a01b03909616610100026001600160a81b031990921660ff90951694909417179390931691909117909155820151805160048301908190610d4990826157b2565b5060208201516001820190610d5e90826157b2565b506040820151600290910180546060808501516080958601511515600160a81b0260ff60a81b196001600160a01b039283166101009081026001600160a81b031990961660ff90981697909717949094179390931692909217909255908501516007850180549183166001600160a01b0319928316179055928501516008850180549190921693169290921790915560a0830151600983015560c0830151600a83015560e0830151600b83015582810151600c8301805491151560ff1983168117825561012086015193919261ff001990911661ffff199091161790836003811115610e4c57610e4c615336565b02179055506101409190910151600d909101556002546001600160a01b038816903390610e7b9060019061571c565b604080516001600160a01b038b81168252602082018790528183018a905288166060820152861515608082015290517fd63fcbe7ff237e54d5ed9b35176b7b4d573226747ce8a6f0da6a814831b51cec9181900360a00190a450610ede60018055565b505050505050565b60605f80805b6003548110156112795761125e60038281548110610f0c57610f0c61586c565b905f5260205f2090600c0201604051806101000160405290815f82016040518060a00160405290815f82018054610f429061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6e9061572f565b8015610fb95780601f10610f9057610100808354040283529160200191610fb9565b820191905f5260205f20905b815481529060010190602001808311610f9c57829003601f168201915b50505050508152602001600182018054610fd29061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ffe9061572f565b80156110495780601f1061102057610100808354040283529160200191611049565b820191905f5260205f20905b81548152906001019060200180831161102c57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526003840180549390910192829082906110b79061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546110e39061572f565b801561112e5780601f106111055761010080835404028352916020019161112e565b820191905f5260205f20905b81548152906001019060200180831161111157829003601f168201915b505050505081526020016001820180546111479061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546111739061572f565b80156111be5780601f10611195576101008083540402835291602001916111be565b820191905f5260205f20905b8154815290600101906020018083116111a157829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b9094049092161515606094850152938552600686015481169385019390935260078501549092169183019190915260088301549082015260098201546080820152600a82015460a0820152600b9091015460c09091015261125987896158a6565b61474c565b15611271578161126d81615953565b9250505b600101610eec565b50856001611287828461596b565b611291919061571c565b61129b9190615992565b91505f6112a887896159a5565b9050818110806112b6575081155b6112f65760405162461bcd60e51b815260206004820152601160248201527050616765206f7574206f662072616e676560781b60448201526064016105df565b5f818311611304575f61130e565b61130e828461571c565b90505f88821061131e5788611320565b815b9050806001600160401b0381111561133a5761133a615498565b60405190808252806020026020018201604052801561140c57816020015b6113f9604080516101a0810182526060610100820181815261012083018290525f610140840181905261016084018190526101808401819052908352835160a08101855282815260208181018490529481018290529182018190526080820152909182019081526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f81526020015f81526020015f81526020015f81525090565b8152602001906001900390816113585790505b5095505f80805b6003548110801561142357508382105b15611b335761178b6003828154811061143e5761143e61586c565b905f5260205f2090600c0201604051806101000160405290815f82016040518060a00160405290815f820180546114749061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546114a09061572f565b80156114eb5780601f106114c2576101008083540402835291602001916114eb565b820191905f5260205f20905b8154815290600101906020018083116114ce57829003601f168201915b505050505081526020016001820180546115049061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546115309061572f565b801561157b5780601f106115525761010080835404028352916020019161157b565b820191905f5260205f20905b81548152906001019060200180831161155e57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526003840180549390910192829082906115e99061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546116159061572f565b80156116605780601f1061163757610100808354040283529160200191611660565b820191905f5260205f20905b81548152906001019060200180831161164357829003601f168201915b505050505081526020016001820180546116799061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546116a59061572f565b80156116f05780601f106116c7576101008083540402835291602001916116f0565b820191905f5260205f20905b8154815290600101906020018083116116d357829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b9094049092161515606094850152938552600686015481169385019390935260078501549092169183019190915260088301549082015260098201546080820152600a82015460a0820152600b9091015460c0909101526112598c8e6158a6565b15611b2157858361179b81615953565b945010611b2157600381815481106117b5576117b561586c565b905f5260205f2090600c0201604051806101000160405290815f82016040518060a00160405290815f820180546117eb9061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546118179061572f565b80156118625780601f1061183957610100808354040283529160200191611862565b820191905f5260205f20905b81548152906001019060200180831161184557829003601f168201915b5050505050815260200160018201805461187b9061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546118a79061572f565b80156118f25780601f106118c9576101008083540402835291602001916118f2565b820191905f5260205f20905b8154815290600101906020018083116118d557829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526003840180549390910192829082906119609061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461198c9061572f565b80156119d75780601f106119ae576101008083540402835291602001916119d7565b820191905f5260205f20905b8154815290600101906020018083116119ba57829003601f168201915b505050505081526020016001820180546119f09061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611a1c9061572f565b8015611a675780601f10611a3e57610100808354040283529160200191611a67565b820191905f5260205f20905b815481529060010190602001808311611a4a57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b9094049092161515606094850152938552600686015481169385019390935260078501549092169183019190915260088301549082015260098201546080820152600a82015460a0820152600b9091015460c0909101528983611b0381615953565b945081518110611b1557611b1561586c565b60200260200101819052505b80611b2b81615953565b915050611413565b5050505050505094509492505050565b60038181548110611b52575f80fd5b905f5260205f2090600c02015f91509050805f016040518060a00160405290815f82018054611b809061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611bac9061572f565b8015611bf75780601f10611bce57610100808354040283529160200191611bf7565b820191905f5260205f20905b815481529060010190602001808311611bda57829003601f168201915b50505050508152602001600182018054611c109061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611c3c9061572f565b8015611c875780601f10611c5e57610100808354040283529160200191611c87565b820191905f5260205f20905b815481529060010190602001808311611c6a57829003601f168201915b50505091835250506002919091015460ff80821660208401526001600160a01b03610100830416604080850191909152600160a81b909204161515606090920191909152805160a0810190915260038301805492939282908290611cea9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611d169061572f565b8015611d615780601f10611d3857610100808354040283529160200191611d61565b820191905f5260205f20905b815481529060010190602001808311611d4457829003601f168201915b50505050508152602001600182018054611d7a9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611da69061572f565b8015611df15780601f10611dc857610100808354040283529160200191611df1565b820191905f5260205f20905b815481529060010190602001808311611dd457829003601f168201915b50505091835250506002919091015460ff80821660208401526001600160a01b03610100830481166040850152600160a81b9092041615156060909201919091526006830154600784015460088501546009860154600a870154600b9097015495969385169592909416939092909188565b60605f80805b6002548110156122745761225960028281548110611e8957611e8961586c565b905f5260205f2090600e0201604051806101600160405290815f8201548152602001600182016040518060a00160405290815f82018054611ec99061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611ef59061572f565b8015611f405780601f10611f1757610100808354040283529160200191611f40565b820191905f5260205f20905b815481529060010190602001808311611f2357829003601f168201915b50505050508152602001600182018054611f599061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054611f859061572f565b8015611fd05780601f10611fa757610100808354040283529160200191611fd0565b820191905f5260205f20905b815481529060010190602001808311611fb357829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a0810190925260048401805493909101928290829061203e9061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461206a9061572f565b80156120b55780601f1061208c576101008083540402835291602001916120b5565b820191905f5260205f20905b81548152906001019060200180831161209857829003601f168201915b505050505081526020016001820180546120ce9061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546120fa9061572f565b80156121455780601f1061211c57610100808354040283529160200191612145565b820191905f5260205f20905b81548152906001019060200180831161212857829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b036101008085048216604080880191909152600160a81b90950484161515606096870152958752600788015481169187019190915260088701541691850191909152600985015491840191909152600a8401546080840152600b84015460a0840152600c840154808216151560c085015260e090930192919091041660038111156121f6576121f6615336565b600381111561220757612207615336565b8152602001600d820154815250508989808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525061225492508a91508b90506158a6565b61486f565b1561226c578161226881615953565b9250505b600101611e69565b50876001612282828461596b565b61228c919061571c565b6122969190615992565b91505f6122a3898b6159a5565b9050818110806122b1575081155b6122f15760405162461bcd60e51b815260206004820152601160248201527050616765206f7574206f662072616e676560781b60448201526064016105df565b5f8183116122ff575f612309565b612309828461571c565b90505f8a8210612319578a61231b565b815b9050806001600160401b0381111561233557612335615498565b60405190808252806020026020018201604052801561236e57816020015b61235b614ef2565b8152602001906001900390816123535790505b5095505f80805b6002548110801561238557508382105b15612b6c5761277a600282815481106123a0576123a061586c565b905f5260205f2090600e0201604051806101600160405290815f8201548152602001600182016040518060a00160405290815f820180546123e09061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461240c9061572f565b80156124575780601f1061242e57610100808354040283529160200191612457565b820191905f5260205f20905b81548152906001019060200180831161243a57829003601f168201915b505050505081526020016001820180546124709061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461249c9061572f565b80156124e75780601f106124be576101008083540402835291602001916124e7565b820191905f5260205f20905b8154815290600101906020018083116124ca57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526004840180549390910192829082906125559061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546125819061572f565b80156125cc5780601f106125a3576101008083540402835291602001916125cc565b820191905f5260205f20905b8154815290600101906020018083116125af57829003601f168201915b505050505081526020016001820180546125e59061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546126119061572f565b801561265c5780601f106126335761010080835404028352916020019161265c565b820191905f5260205f20905b81548152906001019060200180831161263f57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b036101008085048216604080880191909152600160a81b90950484161515606096870152958752600788015481169187019190915260088701541691850191909152600985015491840191909152600a8401546080840152600b84015460a0840152600c840154808216151560c085015260e0909301929190910416600381111561270d5761270d615336565b600381111561271e5761271e615336565b8152602001600d820154815250508e8e808060200260200160405190810160405280939291908181526020018383602002808284375f81840152601f19601f820116905080830192505050505050508d8d9061225491906158a6565b15612b5a57858361278a81615953565b945010612b5a57600281815481106127a4576127a461586c565b905f5260205f2090600e0201604051806101600160405290815f8201548152602001600182016040518060a00160405290815f820180546127e49061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546128109061572f565b801561285b5780601f106128325761010080835404028352916020019161285b565b820191905f5260205f20905b81548152906001019060200180831161283e57829003601f168201915b505050505081526020016001820180546128749061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546128a09061572f565b80156128eb5780601f106128c2576101008083540402835291602001916128eb565b820191905f5260205f20905b8154815290600101906020018083116128ce57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526004840180549390910192829082906129599061572f565b80601f01602080910402602001604051908101604052809291908181526020018280546129859061572f565b80156129d05780601f106129a7576101008083540402835291602001916129d0565b820191905f5260205f20905b8154815290600101906020018083116129b357829003601f168201915b505050505081526020016001820180546129e99061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054612a159061572f565b8015612a605780601f10612a3757610100808354040283529160200191612a60565b820191905f5260205f20905b815481529060010190602001808311612a4357829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b036101008085048216604080880191909152600160a81b90950484161515606096870152958752600788015481169187019190915260088701541691850191909152600985015491840191909152600a8401546080840152600b84015460a0840152600c840154808216151560c085015260e09093019291909104166003811115612b1157612b11615336565b6003811115612b2257612b22615336565b8152602001600d82015481525050898380612b3c90615953565b945081518110612b4e57612b4e61586c565b60200260200101819052505b80612b6481615953565b915050612375565b50505050505050965096945050505050565b6002545f9081908310612b9557505f928392509050565b5f60028481548110612ba957612ba961586c565b5f91825260209091206007600e9092020181015490546001600160a01b03909116915060ff600160a01b909104168015612bed57506008546001600160a01b031615155b15612cd2573315612c645760085460405163cf7f968d60e01b81523360048201526001600160a01b039091169063cf7f968d90602401602060405180830381865afa925050508015612c5c575060408051601f3d908101601f19168201909252612c59918101906156f1565b60015b15612c645792505b600854604051633541cf3360e11b81526001600160a01b03838116600483015290911690636a839e6690602401602060405180830381865afa925050508015612cca575060408051601f3d908101601f19168201909252612cc7918101906156f1565b60015b15612cd25791505b50915091565b612ce0614395565b5f60028581548110612cf457612cf461586c565b5f91825260208220600e909102019150600c820154610100900460ff166003811115612d2257612d22615336565b1480612d4b57506002600c820154610100900460ff166003811115612d4957612d49615336565b145b612d865760405162461bcd60e51b815260206004820152600c60248201526b4e6f7420666f722073616c6560a01b60448201526064016105df565b60088101546001600160a01b03161580612dac575060088101546001600160a01b031633145b612de95760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016105df565b8381600a01548260090154612dfe919061571c565b1015612e3e5760405162461bcd60e51b815260206004820152600f60248201526e139bdd08195b9bdd59da081b19599d608a1b60448201526064016105df565b5f8411612e7d5760405162461bcd60e51b815260206004820152600d60248201526c5a65726f207175616e7469747960981b60448201526064016105df565b825f81518110612e8f57612e8f61586c565b60200260200101516004541115612ede5760405162461bcd60e51b81526020600482015260136024820152720a6cad8d8cae440cccaca40e8dede40d0d2ced606b1b60448201526064016105df565b82600181518110612ef157612ef161586c565b60200260200101516005541115612f3f5760405162461bcd60e51b8152602060048201526012602482015271084eaf2cae440cccaca40e8dede40d0d2ced60731b60448201526064016105df565b80600b0154821015612f845760405162461bcd60e51b815260206004820152600e60248201526d0a0e4d2c6ca40e8dede40d0d2ced60931b60448201526064016105df565b600c81015460ff1615612ff35780600a01548160090154612fa5919061571c565b8414612ff35760405162461bcd60e51b815260206004820181905260248201527f4d7573742062757920656e746972652072656d61696e696e6720616d6f756e7460448201526064016105df565b60068101545f906130089060ff16600a615a9f565b600b83015461301790876159a5565b6130219190615992565b90505f6127106004548361303591906159a5565b61303f9190615992565b60055460075491925090600160a01b900460ff16801561306957506008546001600160a01b031615155b156131be576008546007850154604051633541cf3360e11b81526001600160a01b039182166004820152911690636a839e6690602401602060405180830381865afa9250505080156130d8575060408051601f3d908101601f191682019092526130d5918101906156f1565b60015b15613119575f811180156130ee57506127108111155b1561311757612710613100828261571c565b61310a90856159a5565b6131149190615992565b92505b505b60085460405163cf7f968d60e01b81523360048201526001600160a01b039091169063cf7f968d90602401602060405180830381865afa92505050801561317d575060408051601f3d908101601f1916820190925261317a918101906156f1565b60015b156131be575f8111801561319357506127108111155b156131bc576127106131a5828261571c565b6131af90846159a5565b6131b99190615992565b91505b505b8684600a015f8282546131d1919061596b565b9091555050600384015461010090046001600160a01b03165f908152600960205260408120805489929061320690849061596b565b9091555050600684015461010090046001600160a01b03165f908152600960205260408120805485929061323b90849061596b565b925050819055506003604051806101000160405280866001016040518060a00160405290815f8201805461326e9061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461329a9061572f565b80156132e55780601f106132bc576101008083540402835291602001916132e5565b820191905f5260205f20905b8154815290600101906020018083116132c857829003601f168201915b505050505081526020016001820180546132fe9061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461332a9061572f565b80156133755780601f1061334c57610100808354040283529160200191613375565b820191905f5260205f20905b81548152906001019060200180831161335857829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b03610100840416604080860191909152600160a81b9093049091161515606090930192909252918352815160a081019092526004890180549390910192829082906133e39061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461340f9061572f565b801561345a5780601f106134315761010080835404028352916020019161345a565b820191905f5260205f20905b81548152906001019060200180831161343d57829003601f168201915b505050505081526020016001820180546134739061572f565b80601f016020809104026020016040519081016040528092919081815260200182805461349f9061572f565b80156134ea5780601f106134c1576101008083540402835291602001916134ea565b820191905f5260205f20905b8154815290600101906020018083116134cd57829003601f168201915b50505091835250506002919091015460ff8082166020808501919091526001600160a01b0361010084048116604080870191909152600160a81b9094049092161515606094850152938552338585015260078b0154169084015282018b905260808201879052600b88015460a08301524260c09092019190915282546001810184555f9384529220815180519293600c02909101918290819061358d90826157b2565b50602082015160018201906135a290826157b2565b5060408201516002909101805460608401516080909401511515600160a81b0260ff60a81b196001600160a01b03909516610100026001600160a81b031990921660ff909416939093171792909216179055602082015180516003830190819061360c90826157b2565b506020820151600182019061362190826157b2565b50604082810151600290920180546060808601516080968701511515600160a81b0260ff60a81b196001600160a01b03928316610100026001600160a81b031990951660ff90981697909717939093179590951691909117909155908501516006850180549184166001600160a01b031992831617905590850151600785018054919093169116179055820151600882015560a082015160098083019190915560c0830151600a8084019190915560e090930151600b9092019190915585015490850154036136fc57600c8401805461ff0019166101001790555b60068401545f196101009091046001600160a01b0316016137c2575f613722828561596b565b90508034101561376b5760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b60448201526064016105df565b60065461378a906001600160a01b0316613785848661596b565b614a09565b60078501546137a6906001600160a01b0316613785858761571c565b803411156137bc576137bc33613785833461571c565b506138ab565b803410156138125760405162461bcd60e51b815260206004820152601a60248201527f4d697373696e6720666c61742066656520696e206e617469766500000000000060448201526064016105df565b600684015461010090046001600160a01b0316821561384757600654613847906001600160a01b0383811691339116866143ee565b60078501546138779033906001600160a01b0316613865868861571c565b6001600160a01b0385169291906143ee565b811561389357600654613893906001600160a01b031683614a09565b813411156138a9576138a933613785843461571c565b505b60038401545f196101009091046001600160a01b031601613919578647101561390a5760405162461bcd60e51b81526020600482015260116024820152704e6f7420656e6f756768204e617469766560781b60448201526064016105df565b6139143388614a09565b6139f0565b60038401546040516370a0823160e01b81523060048201525f9161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015613966573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061398a91906156f1565b9050878110156139d05760405162461bcd60e51b81526020600482015260116024820152704e6f7420656e6f75676820546f6b656e7360781b60448201526064016105df565b60038501546139ee9061010090046001600160a01b0316338a614ad3565b505b60038401546006850154604080518a8152602081018790526001600160a01b036101009485900481169282019290925292909104166060820152339089907f13443749e3e76602a68067eb25e3a1c288e700533f34725577b63664e370fd6e9060800160405180910390a350505050613a6860018055565b50505050565b613a76614b04565b60078054911515600160a01b0260ff60a01b19909216919091179055565b600a6020525f9081526040902080548190613aae9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613ada9061572f565b8015613b255780601f10613afc57610100808354040283529160200191613b25565b820191905f5260205f20905b815481529060010190602001808311613b0857829003601f168201915b505050505090806001018054613b3a9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613b669061572f565b8015613bb15780601f10613b8857610100808354040283529160200191613bb1565b820191905f5260205f20905b815481529060010190602001808311613b9457829003601f168201915b5050506002909301549192505060ff808216916001600160a01b0361010082041691600160a81b9091041685565b613be7614b04565b613bf05f614b30565b565b613bfa614b04565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b60028181548110613c2b575f80fd5b905f5260205f2090600e02015f91509050805f015490806001016040518060a00160405290815f82018054613c5f9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613c8b9061572f565b8015613cd65780601f10613cad57610100808354040283529160200191613cd6565b820191905f5260205f20905b815481529060010190602001808311613cb957829003601f168201915b50505050508152602001600182018054613cef9061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613d1b9061572f565b8015613d665780601f10613d3d57610100808354040283529160200191613d66565b820191905f5260205f20905b815481529060010190602001808311613d4957829003601f168201915b50505091835250506002919091015460ff80821660208401526001600160a01b03610100830416604080850191909152600160a81b909204161515606090920191909152805160a0810190915260048301805492939282908290613dc99061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613df59061572f565b8015613e405780601f10613e1757610100808354040283529160200191613e40565b820191905f5260205f20905b815481529060010190602001808311613e2357829003601f168201915b50505050508152602001600182018054613e599061572f565b80601f0160208091040260200160405190810160405280929190818152602001828054613e859061572f565b8015613ed05780601f10613ea757610100808354040283529160200191613ed0565b820191905f5260205f20905b815481529060010190602001808311613eb357829003601f168201915b50505091835250506002919091015460ff80821660208401526101008083046001600160a01b039081166040860152600160a81b90930482161515606090940193909352600785015460088601546009870154600a880154600b890154600c8a0154600d909a015498999487169893909616969195909490938082169392900416908b565b613f5d614395565b5f60028281548110613f7157613f7161586c565b5f9182526020909120600e9091020160078101549091506001600160a01b0316331480613fa857506007546001600160a01b031633145b613fe25760405162461bcd60e51b815260206004820152600b60248201526a139bdd08185b1b1bddd95960aa1b60448201526064016105df565b5f600c820154610100900460ff16600381111561400157614001615336565b148061402a57506002600c820154610100900460ff16600381111561402857614028615336565b145b6140675760405162461bcd60e51b815260206004820152600e60248201526d4e6f742063616e63656c61626c6560901b60448201526064016105df565b600c8101805461ff00191661030017905560038101545f196101009091046001600160a01b0316016140be576007810154600a82015460098301546140b9926001600160a01b0316916137859161571c565b6140fe565b6007810154600a82015460098301546140fe926001600160a01b0316916140e49161571c565b600384015461010090046001600160a01b03169190614ad3565b60078101546040516001600160a01b039091169083907fd9e530acb8429c8e5337d9d3230e4cc7d742e32c2fc8d76608c19f2e1701ed04905f90a35061414360018055565b50565b61414e614b04565b61012c8111156141975760405162461bcd60e51b81526020600482015260146024820152734665652063616e6e6f742065786365656420332560601b60448201526064016105df565b600455565b6141a4614b04565b6001600160a01b03919091165f908152600b60205260409020805460ff1916911515919091179055565b6141d6614b04565b600555565b6141e3614395565b5f600283815481106141f7576141f761586c565b5f9182526020909120600e9091020160078101549091506001600160a01b031633146142525760405162461bcd60e51b815260206004820152600a6024820152692737ba1039b2b63632b960b11b60448201526064016105df565b5f600c820154610100900460ff16600381111561427157614271615336565b148061429a57506002600c820154610100900460ff16600381111561429857614298615336565b145b6142d65760405162461bcd60e51b815260206004820152600d60248201526c10d85b9b9bdd0818591a9d5cdd609a1b60448201526064016105df565b600b8101829055600c8101805461ff00191661020017905560405182815283907fb323bb56b09949cc3cffc0e9386b6629bb4e260b312eb7887b24152486d865029060200160405180910390a25061432d60018055565b5050565b614339614b04565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b614363614b04565b6001600160a01b03811661438c57604051631e4fbdf760e01b81525f60048201526024016105df565b61414381614b30565b6002600154036143e75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105df565b6002600155565b6040516001600160a01b038481166024830152838116604483015260648201839052613a689186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614b7f565b6060805f836001600160a01b03166306fdde036040518163ffffffff1660e01b81526004015f60405180830381865afa9250505080156144b657506040513d5f823e601f3d908101601f191682016040526144b39190810190615aad565b60015b6144f95760405162461bcd60e51b81526020600482015260146024820152734661696c656420746f206665746368206e616d6560601b60448201526064016105df565b9250836001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa92505050801561455857506040513d5f823e601f3d908101601f191682016040526145559190810190615aad565b60015b61459d5760405162461bcd60e51b815260206004820152601660248201527511985a5b1959081d1bc819995d18da081cde5b589bdb60521b60448201526064016105df565b9150836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156145f9575060408051601f3d908101601f191682019092526145f691810190615b21565b60015b6146455760405162461bcd60e51b815260206004820152601860248201527f4661696c656420746f20666574636820646563696d616c73000000000000000060448201526064016105df565b60128160ff16111561468d5760405162461bcd60e51b8152602060048201526011602482015270088cac6d2dac2d8e640e8dede40d0d2ced607b1b60448201526064016105df565b90506040805160a081018252848152602080820185905260ff8416828401526001600160a01b03871660608301819052600160808401525f908152600a90915291909120815181906146df90826157b2565b50602082015160018201906146f490826157b2565b5060408201516002909101805460608401516080909401511515600160a81b0260ff60a81b196001600160a01b03909516610100026001600160a81b031990921660ff90941693909317179290921617905550505050565b5f81515f0361475d57506001614869565b5f5b8251811015614863575f83828151811061477b5761477b61586c565b602002602001015190505f5f905061479a865f01516020015183614beb565b806147b257506147b286602001516020015183614beb565b806147c557508551516147c59083614beb565b806147db57506020860151516147db9083614beb565b806147fa57506147fa6147f4875f015160600151614cd4565b83614beb565b8061481457506148146147f4876020015160600151614cd4565b8061482a575061482a6147f48760400151614cd4565b8061484057506148406147f48760600151614cd4565b15614849575060015b80614859575f9350505050614869565b505060010161475f565b50600190505b92915050565b5f80805b84518110156148d45784818151811061488e5761488e61586c565b602002602001015160038111156148a7576148a7615336565b86610120015160038111156148be576148be615336565b036148cc57600191506148d4565b600101614873565b50806148e3575f915050614a02565b82515f036148f5576001915050614a02565b5f5b83518110156149fb575f8482815181106149135761491361586c565b602002602001015190505f5f905061493388602001516020015183614beb565b8061494b575061494b88604001516020015183614beb565b8061496157506020880151516149619083614beb565b8061497757506040880151516149779083614beb565b8061499157506149916147f4896020015160600151614cd4565b806149ab57506149ab6147f4896040015160600151614cd4565b806149c157506149c16147f48960600151614cd4565b806149d757506149d76147f48960800151614cd4565b156149e0575060015b806149f1575f945050505050614a02565b50506001016148f7565b5060019150505b9392505050565b604080515f808252602082019092526001600160a01b038416908390604051614a329190615b41565b5f6040518083038185875af1925050503d805f8114614a6c576040519150601f19603f3d011682016040523d82523d5f602084013e614a71565b606091505b5050905080614ace5760405162461bcd60e51b815260206004820152602360248201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960448201526213115160ea1b60648201526084016105df565b505050565b6040516001600160a01b03838116602483015260448201839052614ace91859182169063a9059cbb90606401614423565b5f546001600160a01b03163314613bf05760405163118cdaa760e01b81523360048201526024016105df565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f5f60205f8451602086015f885af180614b9e576040513d5f823e3d81fd5b50505f513d91508115614bb5578060011415614bc2565b6001600160a01b0384163b155b15613a6857604051635274afe760e01b81526001600160a01b03851660048201526024016105df565b80515f90839083901580614c00575080518251105b15614c0f575f92505050614869565b5f5b81518351614c1f919061571c565b8111614cc95760015f5b8351811015614ca257614c5b848281518110614c4757614c4761586c565b01602001516001600160f81b031916614e73565b6001600160f81b031916614c8386614c73848761596b565b81518110614c4757614c4761586c565b6001600160f81b03191614614c9a575f9150614ca2565b600101614c29565b508015614cb6576001945050505050614869565b5080614cc181615953565b915050614c11565b505f95945050505050565b60408051602a80825260608281019093525f9190602082018180368337019050509050600360fc1b815f81518110614d0e57614d0e61586c565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110614d3c57614d3c61586c565b60200101906001600160f81b03191690815f1a9053505f5b6014811015614e6c575f614d6982601361571c565b614d749060086159a5565b614d7f906002615b57565b614d92906001600160a01b038716615992565b60f81b90505f60108260f81c614da89190615b62565b60f81b90505f8160f81c6010614dbe9190615b83565b8360f81c614dcc9190615b9f565b60f81b9050614dda82614ec1565b85614de68660026159a5565b614df190600261596b565b81518110614e0157614e0161586c565b60200101906001600160f81b03191690815f1a905350614e2081614ec1565b85614e2c8660026159a5565b614e3790600361596b565b81518110614e4757614e4761586c565b60200101906001600160f81b03191690815f1a9053505060019092019150614d549050565b5092915050565b5f604160f81b6001600160f81b0319831610801590614ea05750602d60f91b6001600160f81b0319831611155b15614ebd57614eb460f883901c6020615bb8565b60f81b92915050565b5090565b5f600a60f883901c1015614ede57614eb460f883901c6030615bb8565b614eb460f883901c6057615bb8565b919050565b6040518061016001604052805f8152602001614f346040805160a0810182526060808252602082018190525f9282018390528101829052608081019190915290565b8152602001614f696040805160a0810182526060808252602082018190525f9282018390528101829052608081019190915290565b81525f6020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e082018190526101009091015290565b80356001600160a01b0381168114614eed575f5ffd5b80358015158114614eed575f5ffd5b5f5f5f5f5f5f60c08789031215614fe1575f5ffd5b614fea87614fa7565b9550614ff860208801614fa7565b9450604087013593506060870135925061501460808801614fa7565b915061502260a08801614fbd565b90509295509295509295565b5f5f83601f84011261503e575f5ffd5b5081356001600160401b03811115615054575f5ffd5b6020830191508360208260051b850101111561506e575f5ffd5b9250929050565b5f5f5f5f60608587031215615088575f5ffd5b843593506020850135925060408501356001600160401b038111156150ab575f5ffd5b6150b78782880161502e565b95989497509550505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b5f815160a0845261510560a08501826150c3565b90506020830151848203602086015261511e82826150c3565b60408581015160ff16908701526060808601516001600160a01b03169087015260809485015115159490950193909352509192915050565b5f604082016040835280855180835260608501915060608160051b8601019250602087015f5b8281101561522957605f198786030184528151805161010087526151a46101008801826150f1565b9050602082015187820360208901526151bd82826150f1565b91505060018060a01b03604083015116604088015260608201516151ec60608901826001600160a01b03169052565b506080828101519088015260a0808301519088015260c0808301519088015260e0918201519190960152602093840193919091019060010161517c565b505050506020929092019290925292915050565b5f6020828403121561524d575f5ffd5b5035919050565b61010081525f61526861010083018b6150f1565b828103602084015261527a818b6150f1565b6001600160a01b03998a16604085015297909816606083015250608081019490945260a084019290925260c083015260e0909101529392505050565b5f5f5f5f5f5f608087890312156152cb575f5ffd5b863595506020870135945060408701356001600160401b038111156152ee575f5ffd5b6152fa89828a0161502e565b90955093505060608701356001600160401b03811115615318575f5ffd5b61532489828a0161502e565b979a9699509497509295939492505050565b634e487b7160e01b5f52602160045260245ffd5b6004811061536657634e487b7160e01b5f52602160045260245ffd5b9052565b5f604082016040835280855180835260608501915060608160051b8601019250602087015f5b8281101561522957605f19878603018452815180518652602081015161016060208801526153c26101608801826150f1565b9050604082015187820360408901526153db82826150f1565b91505060608201516153f860608901826001600160a01b03169052565b50608082015161541360808901826001600160a01b03169052565b5060a082015160a088015260c082015160c088015260e082015160e088015261010082015161544761010089018215159052565b5061012082015161545c61012089018261534a565b506101409182015196909101959095526020938401939190910190600101615390565b5f6020828403121561548f575f5ffd5b614a0282614fa7565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b03811182821017156154d4576154d4615498565b604052919050565b5f6001600160401b038211156154f4576154f4615498565b5060051b60200190565b5f5f5f5f60808587031215615511575f5ffd5b843593506020850135925060408501356001600160401b03811115615534575f5ffd5b8501601f81018713615544575f5ffd5b8035615557615552826154dc565b6154ac565b8082825260208201915060208360051b850101925089831115615578575f5ffd5b6020840193505b8284101561559a57833582526020938401939091019061557f565b9699959850959660600135955050505050565b5f602082840312156155bd575f5ffd5b614a0282614fbd565b60a081525f6155d860a08301886150c3565b82810360208401526155ea81886150c3565b60ff96909616604084015250506001600160a01b03929092166060830152151560809091015292915050565b8b815261016060208201525f61563061016083018d6150f1565b8281036040840152615642818d6150f1565b6001600160a01b038c811660608601528b16608085015260a084018a905260c0840189905260e084018890528615156101008501529150615689905061012083018561534a565b826101408301529c9b505050505050505050505050565b5f5f604083850312156156b1575f5ffd5b6156ba83614fa7565b91506156c860208401614fbd565b90509250929050565b5f5f604083850312156156e2575f5ffd5b50508035926020909101359150565b5f60208284031215615701575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561486957614869615708565b600181811c9082168061574357607f821691505b60208210810361576157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115614ace57805f5260205f20601f840160051c8101602085101561578c5750805b601f840160051c820191505b818110156157ab575f8155600101615798565b5050505050565b81516001600160401b038111156157cb576157cb615498565b6157df816157d9845461572f565b84615767565b6020601f821160018114615811575f83156157fa5750848201515b5f19600385901b1c1916600184901b1784556157ab565b5f84815260208120601f198516915b828110156158405787850151825560209485019460019092019101615820565b508482101561585d57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b634e487b7160e01b5f52603260045260245ffd5b5f6001600160401b0382111561589857615898615498565b50601f01601f191660200190565b5f6158b3615552846154dc565b8381526020810190600585901b8401368111156158ce575f5ffd5b845b818110156159485780356001600160401b038111156158ed575f5ffd5b860136601f8201126158fd575f5ffd5b803561590b61555282615880565b81815236602083850101111561591f575f5ffd5b816020840160208301375f602083830101528087525050506020840193506020810190506158d0565b509095945050505050565b5f6001820161596457615964615708565b5060010190565b8082018082111561486957614869615708565b634e487b7160e01b5f52601260045260245ffd5b5f826159a0576159a061597e565b500490565b808202811582820484141761486957614869615708565b6001815b60018411156159f7578085048111156159db576159db615708565b60018416156159e957908102905b60019390931c9280026159c0565b935093915050565b5f82615a0d57506001614869565b81615a1957505f614869565b8160018114615a2f5760028114615a3957615a55565b6001915050614869565b60ff841115615a4a57615a4a615708565b50506001821b614869565b5060208310610133831016604e8410600b8410161715615a78575081810a614869565b615a845f1984846159bc565b805f1904821115615a9757615a97615708565b029392505050565b5f614a0260ff8416836159ff565b5f60208284031215615abd575f5ffd5b81516001600160401b03811115615ad2575f5ffd5b8201601f81018413615ae2575f5ffd5b8051615af061555282615880565b818152856020838501011115615b04575f5ffd5b8160208401602083015e5f91810160200191909152949350505050565b5f60208284031215615b31575f5ffd5b815160ff81168114614a02575f5ffd5b5f82518060208501845e5f920191825250919050565b5f614a0283836159ff565b5f60ff831680615b7457615b7461597e565b8060ff84160491505092915050565b60ff8181168382160290811690818114614e6c57614e6c615708565b60ff828116828216039081111561486957614869615708565b60ff81811683821601908111156148695761486961570856fea26469706673582212208a708a6f799d053895e49e6d3b8b3831ab6958c93146d0d582374d9115a5e9a264736f6c634300081e0033
Verified Source Code Partial Match
Compiler: v0.8.30+commit.73712a01
EVM: prague
Optimization: Yes (200 runs)
OTCTrade.sol 1246 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
// File: @openzeppelin/contracts/interfaces/IERC20.sol
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/interfaces/IERC165.sol
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
// File: @openzeppelin/contracts/interfaces/IERC1363.sol
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
// File: OTCSALES4.sol
pragma solidity ^0.8.30;
interface IDiscountChecker {
function getSellerDiscount(address seller) external view returns (uint256 discountBps);
function getBuyerDiscount(address buyer) external view returns (uint256 discountBps);
}
contract OTCTrade is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
enum SaleStatus { ForSale, SoldOut, Adjusted, Cancelled }
struct Sale {
uint256 id;
TokenInfo token;
TokenInfo acceptedPayment;
address seller;
address buyer;
uint256 amount;
uint256 sold;
uint256 pricePerToken;
bool wholePurchase;
SaleStatus status;
uint256 dateAdded;
}
struct Trade {
TokenInfo token;
TokenInfo acceptedPayment;
address buyer;
address seller;
uint256 tokenAmount;
uint256 nativeAmount;
uint256 pricePerToken;
uint256 timestamp;
}
struct TokenInfo {
string name;
string symbol;
uint8 decimals;
address tokenAddress;
bool exists;
}
event SaleCreated(
uint256 indexed saleId,
address indexed seller,
address indexed token,
address acceptedPayment,
uint256 amount,
uint256 pricePerToken,
address buyer,
bool wholePurchase
);
event SaleBought(
uint256 indexed saleId,
address indexed buyer,
uint256 quantity,
uint256 cost,
address token,
address acceptedPayment
);
event SaleCancelled(uint256 indexed saleId, address indexed seller);
event SalePriceAdjusted(uint256 indexed saleId, uint256 newPrice);
Sale[] public sales;
Trade[] public trades;
uint256 public sellerFeeBps = 50; // 0.5%
uint256 public buyerFlatFee = 0;
address public treasury;
address public admin;
bool public discountActive = false;
address public discountContract;
mapping(address => uint256) public volumeByToken;
mapping(address => TokenInfo) public tokenMetadata;
mapping(address => bool) public blacklistedTokens;
constructor(
address _treasury,
address _admin,
string memory _nativeName,
string memory _nativeSymbol,
uint8 _nativeDecimals,
uint256 _buyerFlatFee
) Ownable(msg.sender) {
treasury = _treasury;
admin = _admin;
buyerFlatFee = _buyerFlatFee;
tokenMetadata[address(1)] = TokenInfo({
name: _nativeName,
symbol: _nativeSymbol,
decimals: _nativeDecimals,
tokenAddress: address(1),
exists: true
});
}
function setDiscountActive(bool active) external onlyOwner {
discountActive = active;
}
function setDiscountContract(address _contract) external onlyOwner {
discountContract = _contract;
}
function setSellerFeeBps(uint256 _sellerFeeBps) external onlyOwner {
require(_sellerFeeBps <= 300, "Fee cannot exceed 3%");
sellerFeeBps = _sellerFeeBps;
}
function setBuyerFlatFee(uint256 _buyerFlatFee) external onlyOwner {
buyerFlatFee = _buyerFlatFee;
}
function setTreasury(address _treasury) external onlyOwner {
treasury = _treasury;
}
function setBlacklisted(address _token, bool value) external onlyOwner {
blacklistedTokens[_token] = value;
}
function addSale(
address token,
address acceptedPayment,
uint256 amount,
uint256 pricePerToken,
address buyer,
bool wholePurchase
) external payable nonReentrant {
require(token != acceptedPayment, "Cannot sell and pay with same token");
require(token != address(0), "Cannot be address 0");
require(acceptedPayment != address(0), "Cannot be address 0");
require(amount > 0, "Zero amount");
require(pricePerToken > 0, "Zero price");
require(!blacklistedTokens[token] && !blacklistedTokens[acceptedPayment], "Token is blacklisted");
uint256 actualAmount = 0;
if (token == address(1)) {
require(msg.value == amount, "Must send native token");
actualAmount = msg.value;
} else {
uint256 preBalance = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
uint256 postBalance = IERC20(token).balanceOf(address(this));
actualAmount = postBalance - preBalance;
}
// Fetch and store token metadata if new
if (!tokenMetadata[token].exists) {
setTokenInfo(token);
}
// Fetch and store token metadata if new
if (!tokenMetadata[acceptedPayment].exists) {
setTokenInfo(acceptedPayment);
}
sales.push(Sale({
id: sales.length,
token: tokenMetadata[token],
acceptedPayment: tokenMetadata[acceptedPayment],
seller: msg.sender,
buyer: buyer,
amount: actualAmount,
sold: 0,
pricePerToken: pricePerToken,
wholePurchase: wholePurchase,
status: SaleStatus.ForSale,
dateAdded: block.timestamp
}));
emit SaleCreated(
sales.length - 1,
msg.sender,
token,
acceptedPayment,
actualAmount,
pricePerToken,
buyer,
wholePurchase
);
}
function buy(uint256 saleId, uint256 quantity, uint256[] memory maxFees, uint256 maxPricePerToken) external payable nonReentrant {
Sale storage s = sales[saleId];
require(s.status == SaleStatus.ForSale || s.status == SaleStatus.Adjusted, "Not for sale");
require(s.buyer == address(0) || s.buyer == msg.sender, "Not authorized");
require(s.amount - s.sold >= quantity, "Not enough left");
require(quantity > 0, "Zero quantity");
require(sellerFeeBps <= maxFees[0], "Seller fee too high");
require(buyerFlatFee <= maxFees[1], "Buyer fee too high");
require(maxPricePerToken >= s.pricePerToken, "Price too high");
if (s.wholePurchase) {
require(quantity == s.amount - s.sold, "Must buy entire remaining amount");
}
// cost for tokens
uint256 cost = (quantity * s.pricePerToken) / (10 ** s.acceptedPayment.decimals);
// seller fee
uint256 fee = (cost * sellerFeeBps) / 10000;
// buyer fee
uint256 flatFee = buyerFlatFee;
if (discountActive && discountContract != address(0)) {
try IDiscountChecker(discountContract).getSellerDiscount(s.seller) returns (uint256 discountBps) {
if (discountBps > 0 && discountBps <= 10000) {
fee = (fee * (10000 - discountBps)) / 10000;
}
} catch {}
try IDiscountChecker(discountContract).getBuyerDiscount(msg.sender) returns (uint256 discountBps) {
if (discountBps > 0 && discountBps <= 10000) {
flatFee = (flatFee * (10000 - discountBps)) / 10000;
}
} catch {}
}
// Update state first
s.sold += quantity;
volumeByToken[s.token.tokenAddress] += quantity;
volumeByToken[s.acceptedPayment.tokenAddress] += cost;
trades.push(Trade({
token: s.token,
acceptedPayment: s.acceptedPayment,
buyer: msg.sender,
seller: s.seller,
tokenAmount: quantity,
nativeAmount: cost,
pricePerToken: s.pricePerToken,
timestamp: block.timestamp
}));
if (s.sold == s.amount) s.status = SaleStatus.SoldOut;
if (s.acceptedPayment.tokenAddress == address(1)) {
// Native coin
uint256 totalRequired = cost + flatFee;
require(msg.value >= totalRequired, "Insufficient payment");
// send fees to treasury
safeTransferETH(treasury, fee + flatFee);
// send funds to seller
safeTransferETH(s.seller, cost - fee);
// Refund any extra native accidentally sent
if (msg.value > totalRequired) {
safeTransferETH(msg.sender, msg.value - totalRequired);
}
} else {
require(msg.value >= flatFee, "Missing flat fee in native");
// ERC20 payment + flat fee in native
IERC20 payToken = IERC20(s.acceptedPayment.tokenAddress);
if (fee > 0) {
payToken.safeTransferFrom(msg.sender, treasury, fee);
}
payToken.safeTransferFrom(msg.sender, s.seller, cost - fee);
// Send native flat fee separately
if (flatFee > 0) {
safeTransferETH(treasury, flatFee);
}
// Refund any extra native accidentally sent
if (msg.value > flatFee) {
safeTransferETH(msg.sender, msg.value - flatFee);
}
}
if (s.token.tokenAddress == address(1)) {
// send native to purchaser
require(address(this).balance >= quantity, "Not enough Native");
safeTransferETH(msg.sender, quantity);
} else {
// send tokens to purchaser
uint256 balance = IERC20(s.token.tokenAddress).balanceOf(address(this));
require(balance >= quantity, "Not enough Tokens");
IERC20(s.token.tokenAddress).safeTransfer(msg.sender, quantity);
}
emit SaleBought(
saleId,
msg.sender,
quantity,
cost,
s.token.tokenAddress,
s.acceptedPayment.tokenAddress
);
}
function adjustPrice(uint256 saleId, uint256 newPrice) external nonReentrant {
Sale storage s = sales[saleId];
require(msg.sender == s.seller, "Not seller");
require(s.status == SaleStatus.ForSale || s.status == SaleStatus.Adjusted, "Cannot adjust");
s.pricePerToken = newPrice;
s.status = SaleStatus.Adjusted;
emit SalePriceAdjusted(saleId, newPrice);
}
function cancelSale(uint256 saleId) external nonReentrant {
Sale storage s = sales[saleId];
require(msg.sender == s.seller || msg.sender == admin, "Not allowed");
require(s.status == SaleStatus.ForSale || s.status == SaleStatus.Adjusted, "Not cancelable");
s.status = SaleStatus.Cancelled;
if (s.token.tokenAddress == address(1)) {
safeTransferETH(s.seller, s.amount - s.sold);
} else {
IERC20(s.token.tokenAddress).safeTransfer(s.seller, s.amount - s.sold);
}
emit SaleCancelled(saleId, s.seller);
}
function getDiscountsForSale(uint256 saleId) external view returns (uint256 buyerDiscountBps, uint256 sellerDiscountBps) {
if (saleId >= sales.length) return (0, 0); // invalid sale
address seller = sales[saleId].seller;
if (discountActive && discountContract != address(0)) {
// Buyer: only check if msg.sender is non-zero
if (msg.sender != address(0)) {
try IDiscountChecker(discountContract).getBuyerDiscount(msg.sender) returns (uint256 bDisc) {
buyerDiscountBps = bDisc;
} catch {}
}
// Seller
try IDiscountChecker(discountContract).getSellerDiscount(seller) returns (uint256 sDisc) {
sellerDiscountBps = sDisc;
} catch {}
}
}
function getFilteredSales(
uint256 page,
uint256 perPage,
SaleStatus[] calldata statuses,
string[] calldata filters
) external view returns (Sale[] memory pageSales, uint256 totalPages) {
uint256 matchCount = 0;
for (uint i = 0; i < sales.length; i++) {
if (_matches(sales[i], statuses, filters)) {
matchCount++;
}
}
totalPages = (matchCount + perPage - 1) / perPage;
uint256 start = page * perPage;
require(start < matchCount || matchCount == 0, "Page out of range");
uint256 remaining = matchCount > start ? matchCount - start : 0;
uint256 size = remaining < perPage ? remaining : perPage;
pageSales = new Sale[](size);
uint256 idx = 0;
uint256 written = 0;
for (uint i = 0; i < sales.length && written < size; i++) {
if (_matches(sales[i], statuses, filters)) {
if (idx++ >= start) {
pageSales[written++] = sales[i];
}
}
}
}
function _matches(
Sale memory s,
SaleStatus[] memory statuses,
string[] memory filters
) internal pure returns (bool) {
// Check if the sale matches one of the statuses
bool statusMatch = false;
for (uint i = 0; i < statuses.length; i++) {
if (s.status == statuses[i]) {
statusMatch = true;
break;
}
}
if (!statusMatch) return false;
// If no filters, allow all
if (filters.length == 0) return true;
// Each filter must match somewhere
for (uint f = 0; f < filters.length; f++) {
string memory filter = filters[f];
bool matched = false;
if (
_includesIgnoreCase(s.token.symbol, filter) ||
_includesIgnoreCase(s.acceptedPayment.symbol, filter) ||
_includesIgnoreCase(s.token.name, filter) ||
_includesIgnoreCase(s.acceptedPayment.name, filter) ||
_includesIgnoreCase(_toAsciiString(s.token.tokenAddress), filter) ||
_includesIgnoreCase(_toAsciiString(s.acceptedPayment.tokenAddress), filter) ||
_includesIgnoreCase(_toAsciiString(s.seller), filter) ||
_includesIgnoreCase(_toAsciiString(s.buyer), filter)
) {
matched = true;
}
if (!matched) return false; // must match ALL filters
}
return true;
}
function getFilteredTrades(
uint256 page,
uint256 perPage,
string[] calldata filters
) external view returns (Trade[] memory pageTrades, uint256 totalPages) {
uint256 matchCount = 0;
for (uint i = 0; i < trades.length; i++) {
if (_tradeMatches(trades[i], filters)) {
matchCount++;
}
}
totalPages = (matchCount + perPage - 1) / perPage;
uint256 start = page * perPage;
require(start < matchCount || matchCount == 0, "Page out of range");
uint256 remaining = matchCount > start ? matchCount - start : 0;
uint256 size = remaining < perPage ? remaining : perPage;
pageTrades = new Trade[](size);
uint256 idx = 0;
uint256 written = 0;
for (uint i = 0; i < trades.length && written < size; i++) {
if (_tradeMatches(trades[i], filters)) {
if (idx++ >= start) {
pageTrades[written++] = trades[i];
}
}
}
}
function _tradeMatches(Trade memory t, string[] memory filters) internal pure returns (bool) {
if (filters.length == 0) return true;
for (uint f = 0; f < filters.length; f++) {
string memory filter = filters[f];
bool matched = false;
if (
_includesIgnoreCase(t.token.symbol, filter) ||
_includesIgnoreCase(t.acceptedPayment.symbol, filter) ||
_includesIgnoreCase(t.token.name, filter) ||
_includesIgnoreCase(t.acceptedPayment.name, filter) ||
_includesIgnoreCase(_toAsciiString(t.token.tokenAddress), filter) ||
_includesIgnoreCase(_toAsciiString(t.acceptedPayment.tokenAddress), filter) ||
_includesIgnoreCase(_toAsciiString(t.buyer), filter) ||
_includesIgnoreCase(_toAsciiString(t.seller), filter)
) {
matched = true;
}
if (!matched) return false; // must match ALL filters
}
return true;
}
function _includesIgnoreCase(string memory haystack, string memory needle) internal pure returns (bool) {
bytes memory h = bytes(haystack);
bytes memory n = bytes(needle);
if (n.length == 0 || h.length < n.length) return false;
for (uint i = 0; i <= h.length - n.length; i++) {
bool matchFound = true;
for (uint j = 0; j < n.length; j++) {
if (_lower(h[i + j]) != _lower(n[j])) {
matchFound = false;
break;
}
}
if (matchFound) return true;
}
return false;
}
function _lower(bytes1 char) internal pure returns (bytes1) {
if (char >= 0x41 && char <= 0x5A) {
return bytes1(uint8(char) + 32); // A-Z → a-z
}
return char;
}
function _toAsciiString(address x) internal pure returns (string memory) {
bytes memory s = new bytes(42);
s[0] = '0';
s[1] = 'x';
for (uint i = 0; i < 20; i++) {
bytes1 b = bytes1(uint8(uint(uint160(x)) / (2 ** (8 * (19 - i)))));
bytes1 hi = bytes1(uint8(b) / 16);
bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));
s[2 + 2 * i] = _char(hi);
s[3 + 2 * i] = _char(lo);
}
return string(s);
}
function _char(bytes1 b) internal pure returns (bytes1 c) {
if (uint8(b) < 10) return bytes1(uint8(b) + 0x30); // 0-9
else return bytes1(uint8(b) + 0x57); // a-f
}
function setTokenInfo(address tokenAddress) internal {
string memory name;
string memory symbol;
uint8 decimals;
// name
try IERC20Metadata(tokenAddress).name() returns (string memory n) {
name = n;
} catch {
revert("Failed to fetch name");
}
// symbol
try IERC20Metadata(tokenAddress).symbol() returns (string memory s) {
symbol = s;
} catch {
revert("Failed to fetch symbol");
}
// decimals
try IERC20Metadata(tokenAddress).decimals() returns (uint8 d) {
require(d <= 18, "Decimals too high");
decimals = d;
} catch {
revert("Failed to fetch decimals");
}
tokenMetadata[tokenAddress] = TokenInfo({
name: name,
symbol: symbol,
decimals: decimals,
tokenAddress: tokenAddress,
exists: true
});
}
function safeTransferETH(address to, uint value) internal {
(bool success,) = to.call{value:value}(new bytes(0));
require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
}
}
Read Contract
admin 0xf851a440 → address
blacklistedTokens 0x5c8b5f44 → bool
buyerFlatFee 0x2e0135ad → uint256
discountActive 0xcbc70d41 → bool
discountContract 0x104789c7 → address
getDiscountsForSale 0x409e6d46 → uint256, uint256
getFilteredSales 0x24b8ce67 → tuple[], uint256
getFilteredTrades 0x09867ab1 → tuple[], uint256
owner 0x8da5cb5b → address
sales 0xb5f522f7 → uint256, tuple, tuple, address, address, uint256, uint256, uint256, bool, uint8, uint256
sellerFeeBps 0x60abb53a → uint256
tokenMetadata 0x6fecdf24 → string, string, uint8, address, bool
trades 0x1e6c598e → tuple, tuple, address, address, uint256, uint256, uint256, uint256
treasury 0x61d027b3 → address
volumeByToken 0x6ef19c9d → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
addSale 0x0331b0a0
address token
address acceptedPayment
uint256 amount
uint256 pricePerToken
address buyer
bool wholePurchase
adjustPrice 0xe357b1d3
uint256 saleId
uint256 newPrice
buy 0x6096cf0a
uint256 saleId
uint256 quantity
uint256[] maxFees
uint256 maxPricePerToken
cancelSale 0xbd94b005
uint256 saleId
renounceOwnership 0x715018a6
No parameters
setBlacklisted 0xd01dd6d2
address _token
bool value
setBuyerFlatFee 0xd06cd738
uint256 _buyerFlatFee
setDiscountActive 0x6885b03c
bool active
setDiscountContract 0x866993a9
address _contract
setSellerFeeBps 0xc927bdf5
uint256 _sellerFeeBps
setTreasury 0xf0f44260
address _treasury
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address