βThe price of a given token on a given exchange can be calculated as the exchange contract's token_balance divided by its ether_balance.β
This description means:
On-chain price: In opposed to off-chain price, which is what you may see on various exchanges, and which can of course be different on every exchange.
Spot price: This is the rate that you will get for 1 wei, but it doesn't tell you how much you will get in return for more than 1 wei.
It is important to understand the difference between rate and return here.
A rate tells you how much you will get for 1 unit.
This is a common method of interaction when you go to any exchange on any street in any country.
For example, you go to an exchange in London and ask how much is the dollar rate, and they will tell you 1 pound = 2 dollars.
In this real-world example, the terms rate and return are equivalent, because the rate is linear, which means that for 2 pounds you'll get 4 dollars, for 3 pounds you'll get 6 dollars and so on.
On UniSwap's trading system (as in many other trading systems on the blockchain), rate and return are not equivalent.
For example, if your ETH/TKN spot-price is 10 on UniSwap, then it means that for 1 wei of your TKN, you will get 10 wei of ETH.
But for 1234 wei of your TKN, you will necessarily get less than 12340 wei of ETH.
This is because your conversion is subjected to slippage (loss).
It may lead you to think that this spot-price is a charade (a hoax).
But it is nevertheless useful for some measurements of a pool.
However, you should definitely not rely on this rate in order to calculate the expected return for some given amount.
In order to do that, you may use Y * x / (X + x)
, where:
x
is your input amount of source tokens
X
is the balance of the pool in the source token
Y
is the balance of the pool in the target token
Note that as your input amount gets closer to 1, the expected return becomes closer to the rate (i.e., the spot-price, which as quoted from your question at the top of this answer, is Y / X
).
Best Answer
The idea of decentralization is that people have their token on their wallet, and you do not have control over it.
However there is some exceptions.
Even if you sell a token on a designated market place, anyone could use it elsewhere and sell the token at the prices he wishes on other market places.
Token in a sense is like real world objects. You cannot force someone to sell something for the price you want in the real life. Even a state cannot durably enforce a fixed exchange rate to its sovreign fiat.
However you could design a smart contract, check zeppelin, where your smart contract has the right to sell for the user with the function transferFrom a precise amount of token. Then you could give a fix price to those.