Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x7722891Ee45aD38AE05bDA8349bA4CF23cFd270F
Balance 0 ETH
Nonce 1
Code Size 9517 bytes
Indexed Transactions 0 (1 on-chain, 1.4% indexed)
External Etherscan · Sourcify

Contract Bytecode

9517 bytes
0x6080604052600436106101665760003560e01c8063490a8ed6116100d15780638f6f1c591161008a578063aca97d6d11610064578063aca97d6d14610625578063b99c310c14610658578063d3a2433e1461066d578063e3fb64d1146106b457610166565b80638f6f1c5914610593578063a781e7f8146105cc578063a834d32e146105ff57610166565b8063490a8ed6146104415780635714e83e146104745780635d4d3bf7146104a75780637aa7d51a146104ec57806380cb1b851461052557806381ead24c1461056057610166565b80631e45422d116101235780631e45422d1461032457806325bbe38f146103575780632754d1a1146103905780633629c8de146103ba5780633f59904f146103cf5780634708b7ac1461040857610166565b806308d0099e1461016b578063156a0f82146101e757806317ae7a5814610213578063189b55a1146102605780631a27198f146102ac5780631b441848146102d3575b600080fd5b6101976004803603604081101561018157600080fd5b506001600160a01b0381351690602001356106e7565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156101d35781810151838201526020016101bb565b505050509050019250505060405180910390f35b3480156101f357600080fd5b506102116004803603602081101561020a57600080fd5b5035610ae8565b005b34801561021f57600080fd5b50610211600480360360a081101561023657600080fd5b508035906020810135906040810135906001600160a01b0360608201358116916080013516610ba4565b34801561026c57600080fd5b506102936004803603602081101561028357600080fd5b50356001600160a01b0316610c8c565b6040805192835260208301919091528051918290030190f35b3480156102b857600080fd5b506102c1610cc6565b60408051918252519081900360200190f35b3480156102df57600080fd5b50610306600480360360208110156102f657600080fd5b50356001600160a01b0316610ccc565b60408051938452602084019290925282820152519081900360600190f35b34801561033057600080fd5b506102c16004803603602081101561034757600080fd5b50356001600160a01b0316610dbb565b34801561036357600080fd5b506102116004803603604081101561037a57600080fd5b50803590602001356001600160a01b0316610ddd565b34801561039c57600080fd5b50610211600480360360208110156103b357600080fd5b5035610eb1565b3480156103c657600080fd5b50610211610f6d565b3480156103db57600080fd5b50610211600480360360408110156103f257600080fd5b50803590602001356001600160a01b0316610fbd565b34801561041457600080fd5b506102116004803603604081101561042b57600080fd5b50803590602001356001600160a01b0316611091565b34801561044d57600080fd5b506102c16004803603602081101561046457600080fd5b50356001600160a01b0316611165565b34801561048057600080fd5b506102c16004803603602081101561049757600080fd5b50356001600160a01b0316611183565b3480156104b357600080fd5b50610211600480360360808110156104ca57600080fd5b508035906020810135906001600160a01b0360408201351690606001356111a1565b3480156104f857600080fd5b506102116004803603604081101561050f57600080fd5b50803590602001356001600160a01b031661124f565b34801561053157600080fd5b506102116004803603604081101561054857600080fd5b506001600160a01b0381351690602001351515611323565b34801561056c57600080fd5b506102936004803603602081101561058357600080fd5b50356001600160a01b0316611405565b34801561059f57600080fd5b50610293600480360360408110156105b657600080fd5b506001600160a01b038135169060200135611529565b3480156105d857600080fd5b50610211600480360360208110156105ef57600080fd5b50356001600160a01b03166115ab565b6103066004803603602081101561061557600080fd5b50356001600160a01b0316611b62565b34801561063157600080fd5b506102116004803603602081101561064857600080fd5b50356001600160a01b0316611ea1565b34801561066457600080fd5b506102c1611f01565b34801561067957600080fd5b506106a06004803603602081101561069057600080fd5b50356001600160a01b0316611f07565b604080519115158252519081900360200190f35b3480156106c057600080fd5b506106a0600480360360208110156106d757600080fd5b50356001600160a01b0316611f7f565b60606106f233611f07565b6106fb57600080fd5b6001600160a01b0383166000908152600a60205260408120600481015490919061072b908563ffffffff611f9d16565b9050816002015481101561074457506002810154610757565b8160030154811115610757575060038101545b600061076a85600363ffffffff611f9d16565b9050600080905060608260405190808252806020026020018201604052801561079d578160200160208202803883390190505b5060018601549091506000905b84841080156107b95750600081115b156108a35743811080156107da575060008181526020889052604090205415155b1561088c5760008181526020889052604090205483516001860195859181106107ff57fe5b6020026020010181815250508660000160008281526020019081526020016000206001015483858060010196508151811061083657fe5b6020026020010181815250508083858060010196508151811061085557fe5b60209081029190910101526001600160a01b03821661088c576000818152602088905260409020600301546001600160a01b031691505b6000908152602087905260409020600201546107aa565b6001600160a01b0382166108b657600080fd5b825185146108c357600080fd5b6002546040805163323442c360e11b81526001600160a01b038d8116600483015291516000939290921691636468858691602480820192602092909190829003018186803b15801561091457600080fd5b505afa158015610928573d6000803e3d6000fd5b505050506040513d602081101561093e57600080fd5b505190506001600160a01b038116610a065760045460058901546001600160a01b039091169063a10c2a789061099f9061099290600a90610986908d9063ffffffff611f9d16565b9063ffffffff611ffd16565b8a9063ffffffff61203f16565b600154604080516001600160e01b031960e086901b1681526001600160a01b03909216600483015251602480830192600092919082900301818588803b1580156109e857600080fd5b505af11580156109fc573d6000803e3d6000fd5b5050505050610a9e565b60045460058901546001600160a01b039091169063a10c2a7890610a3c9061099290600a90610986908d9063ffffffff611f9d16565b836040518363ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506000604051808303818588803b158015610a8457600080fd5b505af1158015610a98573d6000803e3d6000fd5b50505050505b610ac383610abe600a6109868c600501548c611f9d90919063ffffffff16565b612081565b610ad733610abe348a63ffffffff61203f16565b509196505050505050505b92915050565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b158015610b3357600080fd5b505afa158015610b47573d6000803e3d6000fd5b505050506040513d6020811015610b5d57600080fd5b5051610b9f576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b600855565b336000908152600d602052604090205460ff16610bf7576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b0382166000908152600a60209081526040808320868452918290529091208054610c2e908863ffffffff6120d416565b81556001810154610c45908763ffffffff6120d416565b6001828101919091556003820180546001600160a01b0319166001600160a01b0386161790558201548514610c835760018201805460028301558590555b50505050505050565b6001600160a01b0381166000908152600a602081905260408220600501548291610cbc908263ffffffff61203f16565b915091505b915091565b60085490565b60008080333214610d1d576040805162461bcd60e51b8152602060048201526016602482015275125d0818d85b89dd08189948184818dbdb9d1c9858dd60521b604482015290519081900360640190fd5b6001600160a01b0384166000908152600a6020526040902060018101545b600081118015610d6157504381101580610d615750600081815260208390526040902054155b15610d7d57600090815260208290526040902060020154610d3b565b80610d94575060009350839250829150610db49050565b600081815260209290925260409091208054600190910154909450925090505b9193909250565b6001600160a01b0381166000908152600a60205260409020600201545b919050565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b158015610e2857600080fd5b505afa158015610e3c573d6000803e3d6000fd5b505050506040513d6020811015610e5257600080fd5b5051610e94576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b03166000908152600a6020526040902060020155565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b158015610efc57600080fd5b505afa158015610f10573d6000803e3d6000fd5b505050506040513d6020811015610f2657600080fd5b5051610f68576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b600955565b600654600854600154610f97926001600160a01b039182169233929091169063ffffffff61212e16565b600954610fab90429063ffffffff6120d416565b336000908152600c6020526040902055565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b15801561100857600080fd5b505afa15801561101c573d6000803e3d6000fd5b505050506040513d602081101561103257600080fd5b5051611074576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b03166000908152600a6020526040902060040155565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b1580156110dc57600080fd5b505afa1580156110f0573d6000803e3d6000fd5b505050506040513d602081101561110657600080fd5b5051611148576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b03166000908152600a6020526040902060030155565b6001600160a01b03166000908152600a602052604090206003015490565b6001600160a01b03166000908152600a602052604090206004015490565b336000908152600d602052604090205460ff166111f4576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b0382166000908152600a6020908152604080832084845291829052909120805461122b908763ffffffff61203f16565b81556001810154611242908663ffffffff61203f16565b6001909101555050505050565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b15801561129a57600080fd5b505afa1580156112ae573d6000803e3d6000fd5b505050506040513d60208110156112c457600080fd5b5051611306576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b03166000908152600a6020526040902060050155565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b15801561136e57600080fd5b505afa158015611382573d6000803e3d6000fd5b505050506040513d602081101561139857600080fd5b50516113da576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600d6020526040812054819060ff1661145a576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b6001600160a01b0383166000908152600a6020526040902060018101545b60008111801561149e5750438110158061149e5750600081815260208390526040902054155b156114ba57600090815260208290526040902060020154611478565b806114ce575060009250829150610cc19050565b6114d661247b565b50600090815260209182526040908190208151608081018352815480825260018301549482018590526002830154938201939093526003909101546001600160a01b031660609091015292509050915091565b600080333214611579576040805162461bcd60e51b8152602060048201526016602482015275125d0818d85b89dd08189948184818dbdb9d1c9858dd60521b604482015290519081900360640190fd5b50506001600160a01b03919091166000908152600a602090815260408083209383529290522080546001909101549091565b6000546040805163a3bf06f160e01b815233600482015290516001600160a01b039092169163a3bf06f191602480820192602092909190829003018186803b1580156115f657600080fd5b505afa15801561160a573d6000803e3d6000fd5b505050506040513d602081101561162057600080fd5b5051611662576040805162461bcd60e51b815260206004820152600c60248201526b4e6f20617574686f7269747960a01b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038316908117909155604080516347f3bf4360e11b815260206004820181905260116024830152703732b9ba173b199737b33332b926b0b4b760791b60448301529151849392638fe77e869260648082019391829003018186803b1580156116de57600080fd5b505afa1580156116f2573d6000803e3d6000fd5b505050506040513d602081101561170857600080fd5b5051600380546001600160a01b0319166001600160a01b03928316179055604080516347f3bf4360e11b815260206004820181905260156024830152743732b9ba17372a37b5b2b71737b33332b926b0b4b760591b6044830152915192841692638fe77e8692606480840193919291829003018186803b15801561178b57600080fd5b505afa15801561179f573d6000803e3d6000fd5b505050506040513d60208110156117b557600080fd5b5051600580546001600160a01b0319166001600160a01b03928316179055604080516347f3bf4360e11b8152602060048201819052600e60248301526d6e6573742e76332e61626f6e757360901b6044830152915192841692638fe77e8692606480840193919291829003018186803b15801561183157600080fd5b505afa158015611845573d6000803e3d6000fd5b505050506040513d602081101561185b57600080fd5b5051600480546001600160a01b0319166001600160a01b03928316178155604080516347f3bf4360e11b8152602092810183905260136024820152723732b9ba173b19973232b9ba393ab1ba34b7b760691b6044820152905192841692638fe77e8692606480840193919291829003018186803b1580156118db57600080fd5b505afa1580156118ef573d6000803e3d6000fd5b505050506040513d602081101561190557600080fd5b5051600680546001600160a01b0319166001600160a01b03928316179055604080516347f3bf4360e11b8152602060048083018290526024830152631b995cdd60e21b6044830152915192841692638fe77e8692606480840193919291829003018186803b15801561197657600080fd5b505afa15801561198a573d6000803e3d6000fd5b505050506040513d60208110156119a057600080fd5b5051600180546001600160a01b0319166001600160a01b03928316179055604080516347f3bf4360e11b8152602060048201819052601860248301527f6e6573742e6e546f6b656e2e746f6b656e4d617070696e6700000000000000006044830152915192841692638fe77e8692606480840193919291829003018186803b158015611a2b57600080fd5b505afa158015611a3f573d6000803e3d6000fd5b505050506040513d6020811015611a5557600080fd5b5051600280546001600160a01b0319166001600160a01b03928316179055604080516347f3bf4360e11b8152602060048201819052601860248301527f6e6573742e6e546f6b656e2e746f6b656e41756374696f6e00000000000000006044830152915192841692638fe77e8692606480840193919291829003018186803b158015611ae057600080fd5b505afa158015611af4573d6000803e3d6000fd5b505050506040513d6020811015611b0a57600080fd5b5051600780546001600160a01b0319166001600160a01b0392831617905560035481166000908152600d6020526040808220805460ff1990811660019081179092556005549094168352912080549092161790555050565b6000806000611b7033611f07565b611b7957600080fd5b6001600160a01b0384166000908152600a6020526040902060018101545b600081118015611bbd57504381101580611bbd5750600081815260208390526040902054155b15611bd957600090815260208290526040902060020154611b97565b80611be357600080fd5b611beb61247b565b50600081815260208381526040808320815160808101835281548152600182015481850152600280830154828501526003909201546001600160a01b0390811660608301529154835163323442c360e11b81528c8416600482015293519195949216926364688586926024808301939192829003018186803b158015611c7057600080fd5b505afa158015611c84573d6000803e3d6000fd5b505050506040513d6020811015611c9a57600080fd5b505190506001600160a01b038116611d5d57600454600585015460028601546001600160a01b039092169163a10c2a7891611cf691611ce591600a916109869163ffffffff611f9d16565b60028801549063ffffffff61203f16565b600154604080516001600160e01b031960e086901b1681526001600160a01b03909216600483015251602480830192600092919082900301818588803b158015611d3f57600080fd5b505af1158015611d53573d6000803e3d6000fd5b5050505050611df8565b600454600585015460028601546001600160a01b039092169163a10c2a7891611d9691611ce591600a916109869163ffffffff611f9d16565b836040518363ffffffff1660e01b815260040180826001600160a01b03166001600160a01b031681526020019150506000604051808303818588803b158015611dde57600080fd5b505af1158015611df2573d6000803e3d6000fd5b50505050505b611e208260600151610abe600a61098688600501548960020154611f9d90919063ffffffff16565b611e3b33610abe86600201543461203f90919063ffffffff16565b8151602080840151604080516001600160a01b038d168152928301939093528183015290517fddfa535cacea1d1e69a1a85fabd4691a3e0102bd5c80acd82f249a88d5d509889181900360600190a1508051602090910151909790965090945092505050565b6007546001600160a01b03163314611eb857600080fd5b6001600160a01b03166000908152600a6020526040902066038d7ea4c68000600280830191909155662386f26fc100006003830155655af3107a40006004830155600590910155565b60095490565b6001600160a01b0381166000908152600b602052604081205460ff16158015611f4757506001600160a01b0382166000908152600c602052604090205442115b8015611f6a57506001600160a01b0382166000908152600c602052604090205415155b15611f7757506001610dd8565b506000610dd8565b6001600160a01b03166000908152600b602052604090205460ff1690565b600082611fac57506000610ae2565b82820282848281611fb957fe5b0414611ff65760405162461bcd60e51b81526004018080602001828103825260218152602001806124ad6021913960400191505060405180910390fd5b9392505050565b6000611ff683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612188565b6000611ff683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061222a565b6000612095836001600160a01b0316612284565b6040519091506001600160a01b0382169083156108fc029084906000818181858888f193505050501580156120ce573d6000803e3d6000fd5b50505050565b600082820183811015611ff6576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526120ce908590612287565b600081836122145760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156121d95781810151838201526020016121c1565b50505050905090810190601f1680156122065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161222057fe5b0495945050505050565b6000818484111561227c5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156121d95781810151838201526020016121c1565b505050900390565b90565b612299826001600160a01b031661243f565b6122ea576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106123285780518252601f199092019160209182019101612309565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461238a576040519150601f19603f3d011682016040523d82523d6000602084013e61238f565b606091505b5091509150816123e6576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156120ce5780806020019051602081101561240257600080fd5b50516120ce5760405162461bcd60e51b815260040180806020018281038252602a8152602001806124ce602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061247357508115155b949350505050565b604051806080016040528060008152602001600081526020016000815260200160006001600160a01b03168152509056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220cca75192aeb5e4b5aa4f6ed4aab981d1b4835f1e169f1acf93377a041364fe5a64736f6c63430006000033

Verified Source Code Partial Match

Compiler: v0.6.0+commit.26b70077 EVM: istanbul Optimization: Yes (200 runs)
Nest_3_OfferPrice.sol 483 lines
pragma solidity 0.6.0;

/**
 * @title Price contract
 * @dev Price check and call
 */
contract Nest_3_OfferPrice{
    using SafeMath for uint256;
    using address_make_payable for address;
    using SafeERC20 for ERC20;
    
    Nest_3_VoteFactory _voteFactory;                                //  Voting contract
    ERC20 _nestToken;                                               //  NestToken
    Nest_NToken_TokenMapping _tokenMapping;                         //  NToken mapping
    Nest_3_OfferMain _offerMain;                                    //  Offering main contract
    Nest_3_Abonus _abonus;                                          //  Bonus pool
    address _nTokeOfferMain;                                        //  NToken offering main contract
    address _destructionAddress;                                    //  Destruction contract address
    address _nTokenAuction;                                         //  NToken auction contract address
    struct PriceInfo {                                              //  Block price
        uint256 ethAmount;                                          //  ETH amount
        uint256 erc20Amount;                                        //  Erc20 amount
        uint256 frontBlock;                                         //  Last effective block
        address offerOwner;                                         //  Offering address
    }
    struct TokenInfo {                                              //  Token offer information
        mapping(uint256 => PriceInfo) priceInfoList;                //  Block price list, block number => block price
        uint256 latestOffer;                                        //  Latest effective block
        uint256 priceCostLeast;                                     //  Minimum ETH cost for prices
        uint256 priceCostMost;                                      //  Maximum ETH cost for prices
        uint256 priceCostSingle;                                    //  ETH cost for single data
        uint256 priceCostUser;                                      //  User ratio of cost 
    }
    uint256 destructionAmount = 10000 ether;                        //  Amount of NEST to destroy to call prices
    uint256 effectTime = 1 days;                                    //  Waiting time to start calling prices
    mapping(address => TokenInfo) _tokenInfo;                       //  Token offer information
    mapping(address => bool) _blocklist;                            //  Block list
    mapping(address => uint256) _addressEffect;                     //  Effective time of address to call prices 
    mapping(address => bool) _offerMainMapping;                     //  Offering contract mapping

    //  Real-time price  token, ETH amount, erc20 amount
    event NowTokenPrice(address a, uint256 b, uint256 c);
    
    /**
    * @dev Initialization method
    * @param voteFactory Voting contract address
    */
    constructor (address voteFactory) public {
        Nest_3_VoteFactory voteFactoryMap = Nest_3_VoteFactory(address(voteFactory));
        _voteFactory = voteFactoryMap;
        _offerMain = Nest_3_OfferMain(address(voteFactoryMap.checkAddress("nest.v3.offerMain")));
        _nTokeOfferMain = address(voteFactoryMap.checkAddress("nest.nToken.offerMain"));
        _abonus = Nest_3_Abonus(address(voteFactoryMap.checkAddress("nest.v3.abonus")));
        _destructionAddress = address(voteFactoryMap.checkAddress("nest.v3.destruction"));
        _nestToken = ERC20(address(voteFactoryMap.checkAddress("nest")));
        _tokenMapping = Nest_NToken_TokenMapping(address(voteFactoryMap.checkAddress("nest.nToken.tokenMapping")));
        _nTokenAuction = address(voteFactoryMap.checkAddress("nest.nToken.tokenAuction"));
        _offerMainMapping[address(_offerMain)] = true;
        _offerMainMapping[address(_nTokeOfferMain)] = true;
    }
    
    /**
    * @dev Modify voting contract
    * @param voteFactory Voting contract address
    */
    function changeMapping(address voteFactory) public onlyOwner {
        Nest_3_VoteFactory voteFactoryMap = Nest_3_VoteFactory(address(voteFactory));
        _voteFactory = voteFactoryMap;                                   
        _offerMain = Nest_3_OfferMain(address(voteFactoryMap.checkAddress("nest.v3.offerMain")));
        _nTokeOfferMain = address(voteFactoryMap.checkAddress("nest.nToken.offerMain"));
        _abonus = Nest_3_Abonus(address(voteFactoryMap.checkAddress("nest.v3.abonus")));
        _destructionAddress = address(voteFactoryMap.checkAddress("nest.v3.destruction"));
        _nestToken = ERC20(address(voteFactoryMap.checkAddress("nest")));
        _tokenMapping = Nest_NToken_TokenMapping(address(voteFactoryMap.checkAddress("nest.nToken.tokenMapping")));
        _nTokenAuction = address(voteFactoryMap.checkAddress("nest.nToken.tokenAuction"));
        _offerMainMapping[address(_offerMain)] = true;
        _offerMainMapping[address(_nTokeOfferMain)] = true;
    }
    
    /**
    * @dev Initialize token price charge parameters
    * @param tokenAddress Token address
    */
    function addPriceCost(address tokenAddress) public {
        require(msg.sender == _nTokenAuction);
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        tokenInfo.priceCostLeast = 0.001 ether;
        tokenInfo.priceCostMost = 0.01 ether;
        tokenInfo.priceCostSingle = 0.0001 ether;
        tokenInfo.priceCostUser = 2;
    }
    
    /**
    * @dev Add price
    * @param ethAmount ETH amount
    * @param tokenAmount Erc20 amount
    * @param endBlock Effective price block
    * @param tokenAddress Erc20 address
    * @param offerOwner Offering address
    */
    function addPrice(uint256 ethAmount, uint256 tokenAmount, uint256 endBlock, address tokenAddress, address offerOwner) public onlyOfferMain{
        // Add effective block price information
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        PriceInfo storage priceInfo = tokenInfo.priceInfoList[endBlock];
        priceInfo.ethAmount = priceInfo.ethAmount.add(ethAmount);
        priceInfo.erc20Amount = priceInfo.erc20Amount.add(tokenAmount);
        priceInfo.offerOwner = offerOwner;
        if (endBlock != tokenInfo.latestOffer) {
            // If different block offer
            priceInfo.frontBlock = tokenInfo.latestOffer;
            tokenInfo.latestOffer = endBlock;
        }
    }
    
    /**
    * @dev Price modification in taker orders
    * @param ethAmount ETH amount
    * @param tokenAmount Erc20 amount
    * @param tokenAddress Token address 
    * @param endBlock Block of effective price
    */
    function changePrice(uint256 ethAmount, uint256 tokenAmount, address tokenAddress, uint256 endBlock) public onlyOfferMain {
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        PriceInfo storage priceInfo = tokenInfo.priceInfoList[endBlock];
        priceInfo.ethAmount = priceInfo.ethAmount.sub(ethAmount);
        priceInfo.erc20Amount = priceInfo.erc20Amount.sub(tokenAmount);
    }
    
    /**
    * @dev Update and check the latest price
    * @param tokenAddress Token address
    * @return ethAmount ETH amount
    * @return erc20Amount Erc20 amount
    * @return blockNum Price block
    */
    function updateAndCheckPriceNow(address tokenAddress) public payable returns(uint256 ethAmount, uint256 erc20Amount, uint256 blockNum) {
        require(checkUseNestPrice(address(msg.sender)));
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        uint256 checkBlock = tokenInfo.latestOffer;
        while(checkBlock > 0 && (checkBlock >= block.number || tokenInfo.priceInfoList[checkBlock].ethAmount == 0)) {
            checkBlock = tokenInfo.priceInfoList[checkBlock].frontBlock;
        }
        require(checkBlock != 0);
        PriceInfo memory priceInfo = tokenInfo.priceInfoList[checkBlock];
        address nToken = _tokenMapping.checkTokenMapping(tokenAddress);
        if (nToken == address(0x0)) {
            _abonus.switchToEth.value(tokenInfo.priceCostLeast.sub(tokenInfo.priceCostLeast.mul(tokenInfo.priceCostUser).div(10)))(address(_nestToken));
        } else {
            _abonus.switchToEth.value(tokenInfo.priceCostLeast.sub(tokenInfo.priceCostLeast.mul(tokenInfo.priceCostUser).div(10)))(address(nToken));
        }
        repayEth(priceInfo.offerOwner, tokenInfo.priceCostLeast.mul(tokenInfo.priceCostUser).div(10));
        repayEth(address(msg.sender), msg.value.sub(tokenInfo.priceCostLeast));
        emit NowTokenPrice(tokenAddress,priceInfo.ethAmount, priceInfo.erc20Amount);
        return (priceInfo.ethAmount,priceInfo.erc20Amount, checkBlock);
    }
    
    /**
    * @dev Update and check the latest price-internal use
    * @param tokenAddress Token address
    * @return ethAmount ETH amount
    * @return erc20Amount Erc20 amount
    */
    function updateAndCheckPricePrivate(address tokenAddress) public view onlyOfferMain returns(uint256 ethAmount, uint256 erc20Amount) {
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        uint256 checkBlock = tokenInfo.latestOffer;
        while(checkBlock > 0 && (checkBlock >= block.number || tokenInfo.priceInfoList[checkBlock].ethAmount == 0)) {
            checkBlock = tokenInfo.priceInfoList[checkBlock].frontBlock;
        }
        if (checkBlock == 0) {
            return (0,0);
        }
        PriceInfo memory priceInfo = tokenInfo.priceInfoList[checkBlock];
        return (priceInfo.ethAmount,priceInfo.erc20Amount);
    }
    
    /**
    * @dev Update and check the effective price list
    * @param tokenAddress Token address
    * @param num Number of prices to check
    * @return uint256[] price list
    */
    function updateAndCheckPriceList(address tokenAddress, uint256 num) public payable returns (uint256[] memory) {
        require(checkUseNestPrice(address(msg.sender)));
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        // Charge
        uint256 thisPay = tokenInfo.priceCostSingle.mul(num);
        if (thisPay < tokenInfo.priceCostLeast) {
            thisPay=tokenInfo.priceCostLeast;
        } else if (thisPay > tokenInfo.priceCostMost) {
            thisPay = tokenInfo.priceCostMost;
        }
        
        // Extract data
        uint256 length = num.mul(3);
        uint256 index = 0;
        uint256[] memory data = new uint256[](length);
        address latestOfferOwner = address(0x0);
        uint256 checkBlock = tokenInfo.latestOffer;
        while(index < length && checkBlock > 0){
            if (checkBlock < block.number && tokenInfo.priceInfoList[checkBlock].ethAmount != 0) {
                // Add return data
                data[index++] = tokenInfo.priceInfoList[checkBlock].ethAmount;
                data[index++] = tokenInfo.priceInfoList[checkBlock].erc20Amount;
                data[index++] = checkBlock;
                if (latestOfferOwner == address(0x0)) {
                    latestOfferOwner = tokenInfo.priceInfoList[checkBlock].offerOwner;
                }
            }
            checkBlock = tokenInfo.priceInfoList[checkBlock].frontBlock;
        }
        require(latestOfferOwner != address(0x0));
        require(length == data.length);
        // Allocation
        address nToken = _tokenMapping.checkTokenMapping(tokenAddress);
        if (nToken == address(0x0)) {
            _abonus.switchToEth.value(thisPay.sub(thisPay.mul(tokenInfo.priceCostUser).div(10)))(address(_nestToken));
        } else {
            _abonus.switchToEth.value(thisPay.sub(thisPay.mul(tokenInfo.priceCostUser).div(10)))(address(nToken));
        }
        repayEth(latestOfferOwner, thisPay.mul(tokenInfo.priceCostUser).div(10));
        repayEth(address(msg.sender), msg.value.sub(thisPay));
        return data;
    }
    
    // Activate the price checking function
    function activation() public {
        _nestToken.safeTransferFrom(address(msg.sender), _destructionAddress, destructionAmount);
        _addressEffect[address(msg.sender)] = now.add(effectTime);
    }
    
    // Transfer ETH
    function repayEth(address accountAddress, uint256 asset) private {
        address payable addr = accountAddress.make_payable();
        addr.transfer(asset);
    }
    
    // Check block price - user account only
    function checkPriceForBlock(address tokenAddress, uint256 blockNum) public view returns (uint256 ethAmount, uint256 erc20Amount) {
        require(address(msg.sender) == address(tx.origin), "It can't be a contract");
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        return (tokenInfo.priceInfoList[blockNum].ethAmount, tokenInfo.priceInfoList[blockNum].erc20Amount);
    }    
    
    // Check real-time price - user account only
    function checkPriceNow(address tokenAddress) public view returns (uint256 ethAmount, uint256 erc20Amount, uint256 blockNum) {
        require(address(msg.sender) == address(tx.origin), "It can't be a contract");
        TokenInfo storage tokenInfo = _tokenInfo[tokenAddress];
        uint256 checkBlock = tokenInfo.latestOffer;
        while(checkBlock > 0 && (checkBlock >= block.number || tokenInfo.priceInfoList[checkBlock].ethAmount == 0)) {
            checkBlock = tokenInfo.priceInfoList[checkBlock].frontBlock;
        }
        if (checkBlock == 0) {
            return (0,0,0);
        }
        PriceInfo storage priceInfo = tokenInfo.priceInfoList[checkBlock];
        return (priceInfo.ethAmount,priceInfo.erc20Amount, checkBlock);
    }
    
    // Check the cost allocation ratio
    function checkPriceCostProportion(address tokenAddress) public view returns(uint256 user, uint256 abonus) {
        return (_tokenInfo[tokenAddress].priceCostUser, uint256(10).sub(_tokenInfo[tokenAddress].priceCostUser));
    }
    
    // Check the minimum ETH cost of obtaining the price
    function checkPriceCostLeast(address tokenAddress) public view returns(uint256) {
        return _tokenInfo[tokenAddress].priceCostLeast;
    }
    
    // Check the maximum ETH cost of obtaining the price
    function checkPriceCostMost(address tokenAddress) public view returns(uint256) {
        return _tokenInfo[tokenAddress].priceCostMost;
    }
    
    // Check the cost of a single price data
    function checkPriceCostSingle(address tokenAddress) public view returns(uint256) {
        return _tokenInfo[tokenAddress].priceCostSingle;
    }
    
    // Check whether the price-checking functions can be called
    function checkUseNestPrice(address target) public view returns (bool) {
        if (!_blocklist[target] && _addressEffect[target] < now && _addressEffect[target] != 0) {
            return true;
        } else {
            return false;
        }
    }
    
    // Check whether the address is in the blocklist
    function checkBlocklist(address add) public view returns(bool) {
        return _blocklist[add];
    }
    
    // Check the amount of NEST to destroy to call prices
    function checkDestructionAmount() public view returns(uint256) {
        return destructionAmount;
    }
    
    // Check the waiting time to start calling prices
    function checkEffectTime() public view returns (uint256) {
        return effectTime;
    }
    
    // Modify user ratio of cost 
    function changePriceCostProportion(uint256 user, address tokenAddress) public onlyOwner {
        _tokenInfo[tokenAddress].priceCostUser = user;
    }
    
    // Modify minimum ETH cost for prices
    function changePriceCostLeast(uint256 amount, address tokenAddress) public onlyOwner {
        _tokenInfo[tokenAddress].priceCostLeast = amount;
    }
    
    // Modify maximum ETH cost for prices 
    function changePriceCostMost(uint256 amount, address tokenAddress) public onlyOwner {
        _tokenInfo[tokenAddress].priceCostMost = amount;
    }
    
    // Modify ETH cost for single data
    function checkPriceCostSingle(uint256 amount, address tokenAddress) public onlyOwner {
        _tokenInfo[tokenAddress].priceCostSingle = amount;
    }
    
    // Modify the blocklist 
    function changeBlocklist(address add, bool isBlock) public onlyOwner {
        _blocklist[add] = isBlock;
    }
    
    // Amount of NEST to destroy to call price-checking functions
    function changeDestructionAmount(uint256 amount) public onlyOwner {
        destructionAmount = amount;
    }
    
    // Modify the waiting time to start calling prices
    function changeEffectTime(uint256 num) public onlyOwner {
        effectTime = num;
    }

    // Offering contract only
    modifier onlyOfferMain(){
        require(_offerMainMapping[address(msg.sender)], "No authority");
        _;
    }
    
    // Vote administrators only
    modifier onlyOwner(){
        require(_voteFactory.checkOwners(msg.sender), "No authority");
        _;
    }
}

// Voting contract
interface Nest_3_VoteFactory {
    // Check address
	function checkAddress(string calldata name) external view returns (address contractAddress);
	// Check whether administrator
	function checkOwners(address man) external view returns (bool);
}

// NToken mapping contract
interface Nest_NToken_TokenMapping {
    function checkTokenMapping(address token) external view returns (address);
}

// NEST offer main contract
interface Nest_3_OfferMain {
    function checkTokenAllow(address token) external view returns(bool);
}

// Bonus pool contract
interface Nest_3_Abonus {
    function switchToEth(address token) external payable;
}

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        return c;
    }
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

library address_make_payable {
   function make_payable(address x) internal pure returns (address payable) {
      return address(uint160(x));
   }
}

library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

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

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

    function safeApprove(ERC20 token, address spender, uint256 value) internal {
        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(ERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(ERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }
    function callOptionalReturn(ERC20 token, bytes memory data) private {
        require(address(token).isContract(), "SafeERC20: call to non-contract");
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

interface ERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

library Address {
    function isContract(address account) internal view returns (bool) {
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    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");
    }
}

Read Contract

checkBlocklist 0xe3fb64d1 → bool
checkDestructionAmount 0x1a27198f → uint256
checkEffectTime 0xb99c310c → uint256
checkPriceCostLeast 0x1e45422d → uint256
checkPriceCostMost 0x490a8ed6 → uint256
checkPriceCostProportion 0x189b55a1 → uint256, uint256
checkPriceCostSingle 0x5714e83e → uint256
checkPriceForBlock 0x8f6f1c59 → uint256, uint256
checkPriceNow 0x1b441848 → uint256, uint256, uint256
checkUseNestPrice 0xd3a2433e → bool
updateAndCheckPricePrivate 0x81ead24c → uint256, uint256

Write Contract 14 functions

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

activation 0x3629c8de
No parameters
addPrice 0x17ae7a58
uint256 ethAmount
uint256 tokenAmount
uint256 endBlock
address tokenAddress
address offerOwner
addPriceCost 0xaca97d6d
address tokenAddress
changeBlocklist 0x80cb1b85
address add
bool isBlock
changeDestructionAmount 0x156a0f82
uint256 amount
changeEffectTime 0x2754d1a1
uint256 num
changeMapping 0xa781e7f8
address voteFactory
changePrice 0x5d4d3bf7
uint256 ethAmount
uint256 tokenAmount
address tokenAddress
uint256 endBlock
changePriceCostLeast 0x25bbe38f
uint256 amount
address tokenAddress
changePriceCostMost 0x4708b7ac
uint256 amount
address tokenAddress
changePriceCostProportion 0x7aa7d51a
uint256 user
address tokenAddress
checkPriceCostSingle 0x3f59904f
uint256 amount
address tokenAddress
updateAndCheckPriceList 0x08d0099e
address tokenAddress
uint256 num
returns: uint256[]
updateAndCheckPriceNow 0xa834d32e
address tokenAddress
returns: uint256, uint256, uint256

Recent Transactions

This address has 1 on-chain transactions, but only 1.4% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →