Ton-Dynasty / ticton-v0

Innovative price oracle for TON
https://ticton.xyz
7 stars 1 forks source link

tick and wind basic test-suite #7

Closed ipromise2324 closed 9 months ago

ipromise2324 commented 10 months ago

Code I changed:

  1. In the receive(msg: JettonTransferNotification), I added a sendBackAmount variable to record how much money needs to be returned to the user after building alarm successfully. Also, I changed the mode to SendIgnoreErrors and set the value to sendBackAmount in the receive(msg: JettonTransferNotification).
  2. In the receive(msg: JettonTransferNotification), needBaseAssetAmount = msg.amount.float() / baseAssetPrice; After calculation, it needs to be multiplied by 10**9 to represent the amount of ton to be transferred (e.g., 10/2.5 = 4, which means 4 tons, therefore 4 should be multiplied by Decimal)
  3. In the Alarm contract, I modified requireNotInitialized to self.watchmaker == newAddress(0, 0). This means that if watchmaker.address == 0x00, it indicates that the alarm has not been initialized yet (originally it was judged by self.oracleAddress == newAddress(0, 0)).
  4. In the receive(msg: Reset) function, I changed the require(self.remainScale > msg.buyNum, "Not enough scale to buy"); to >=, to allow the Timekeeper to buy all of the remainScale.
  5. In the receive(msg: JettonTransferNotification) function, within if(opCode == 1), the Reset message's sender is msg.sender (timekeeper), not ctx.sender (oracle jetton wallet).
  6. In the receive(msg: Chime) function, when deploying a new alarm, a basic value is required to build the contract. I have currently hardcoded it as 0.05 ton.
  7. In the receive(msg: Chime) function, after building the alarm, totalAlarms is not incremented by 1.

Code need to be revised:

  1. In the receive(msg: JettonTransferNotification) function of the Oracle contract, code for returning Jettons to the user was not written.
  2. When the timekeeper sends the wind message, it does not specify the new price to be offered, therefore there is no check to see if the jettons and tons sent are sufficient for this quotation.
  3. In the receive(msg: Reset) function, baseAssetPrice is not overwritten with a new value. It should be changed to the new price as perceived by the timekeeper. Currently, it is 0, so the baseAssetPrice for the new alarm built by the timekeeper is also 0.
  4. In the receive(msg: Chime) function, in addition to checking if msg.remainScale > 0, should there also be a check to see if the verification stage has passed? Only if it has passed, the price can be changed.
  5. In receive(msg: Reset), if require(self.remainScale >= msg.buyNum, "Not enough scale to buy") is not met, the jettons are not returned to the timekeeper.
alan890104 commented 10 months ago

Link to #2

alan890104 commented 10 months ago

Thanks to @ipromise2324 for finding the bug of forgetting to raise new prices when the Wind message is sent. This bug is fixed in a7c63a3. PTAL.

alan890104 commented 9 months ago

Currently there are 6 tests related to Wind failed, but i cannot figure out the reason. @ipromise2324 PTAL.

ipromise2324 commented 9 months ago

Currently there are 6 tests related to Wind failed, but i cannot figure out the reason. @ipromise2324 PTAL.

I've seen the issue and will promptly investigate the 6 failed tests to identify the cause. I'll update on progress ASAP.

ipromise2324 commented 9 months ago

Currently there are 6 tests related to Wind failed, but i cannot figure out the reason. @ipromise2324 PTAL.

I've seen the issue and will promptly investigate the 6 failed tests to identify the cause. I'll update on progress ASAP.

I've identified two issues.

After addressing the two issues mentioned above, all testcases can now be passed successfully.