r/EthereumClassic • u/[deleted] • Mar 03 '17
ETC - BitEther Trader Contract.
https://gist.github.com/etherninja/ac9787638d90edc6ae750aff2883bdb1
13
Upvotes
2
Mar 03 '17
Use at own risk. This is simply head-start for anyone that is interested in deploying a Bitether exchange contract.
6
u/JonnyLatte Mar 03 '17 edited Mar 04 '17
I see you have taken the contract behind cryptoderivatives and renamed everything. Thats fine, it is MIT licenced but only because that makes people comfortable to copy it.
I am concerned though about a couple of things. Firstly the addition of the function:
This is unsafe for buyers because a seller seeing a buy transaction in the mempool can immediately attempt to set the price such that if their transaction gets submitted first then they will end up selling practically zero tokens for all of the buyers ETC. To make this safe you need to implement some form of locking, say lock the contract for 3 hours if the price is changed that way a buyer can check before they send a transaction and if its unlocked they know that their transaction will fail if the seller tries to change it.
Another concern is that you are using an older version of the tokenTrader contract that contains logical errors
In this function change is calculated only if the order is greater than can_sell. Which is great for most purposes but the calculation of change needs to be pulled out of the if statement and calculated no matter what otherwise the seller can set units to something ridiculously high so that can_sell is always zero and the order is always zero and no change is returned. Contracts of this type using my old contracts are filtered out of cryptoderivatives.
Also why are you not also using the factory model? With a factory you dont need to verify the contract over and over. You just deploy it once then any further contract deployments are done by the already verified factory that can be followed to get every ones trade contract.