Request feedback on the following idea.
Goal: To create a trustless token tethered to USD so that anyone can buy and sell the token.
Alice creates, say, 10000000 tokens and stores them in a box protected by the following script:
(alice && HEIGHT > 10000) || {
val usdTokenValue = SELF.tokens(0)._2
val out = OUTPUTS(0)
val dataInput = CONTEXT.dataInputs(0) // rate oracle box
val rate = dataInput.R4[Long].get
val isValidRateToken = dataInput.tokens(0)._1 == rateTokenID
val isValidUsdToken = out.tokens(0)._1 == SELF.tokens(0)._1
val tokenDiff = out.tokens(0)._2 - SELF.tokens(0)._2
val ergsDiff = SELF.value - out.value
val isValidExchange = tokenDiff * rate == ergsDiff
val isValidBox = out.propositionBytes == SELF.propositionBytes
isValidBox && isValidExchange &&
isValidRateToken && isValidUsdToken
}
Some Questions/thoughts
- What would be the incentive for Alice to create such a box?
(After height 10000, Alice can claim whatever ergs are in the box) - In order to avoid spam/DDoS, the buy and sell rates should be slightly different
- This can be used anywhere we need to deal with USD/Erg (example, repayment of the “interest-free” loan)
- How to handle fluctuations. For instance, if Erg drops, we may end up with a box with almost 0 Ergs and less than 10000000 tokens.