graphprotocol / mission-control-indexer

Technical indexer documentation and infrastructure templates for the Mission Control testnet
21 stars 4 forks source link

Incorrect GDAI withdrawal #239

Open koen84 opened 3 years ago

koen84 commented 3 years ago

I was using GDAI savings, as part of my strategy to maximise profits. Looks like both withdrawals resulted in incorrect values, i screenshotted the second.

Withdrawal amount image

Amount that ended up in balance image

Resulting amount in savings image

From a quick calculation, it seems it withdrew more than asked and that explains the difference.

davekaj commented 3 years ago

It looks like it might be a slight error in how we are using the front end. Or it could be a slight error in the GDAI implementation.

It is not core to the protocol and will not be on mainnet, so for now it will take a back seat. Maybe I can revisit in a few weeks

koen84 commented 3 years ago

First time i wanted to leave exactly 100k in savings and the second time 50k, neither turned out correctly.

(I get that it's not priority.)

davekaj commented 3 years ago

Ah, I think I know what is happening actually.

The savings contract is a weird implementation. I borrowed most of it from Makers savings rate contract.

I never gave the front end developer the correct way to withdraw an exact amount of GDAI. The GDAI grows in the contract. So if you deposited 1000, that means later you can only withdraw 1000. But the 1000 should have grown to a larger number, say 1005.

But if you want to withdraw exactly 1000, it means you'd have to pass 994.9...ish.

I might be mixing up the order of things but this is the gist of it.

koen84 commented 3 years ago

Both times it withdrew too much, so that matches.

I think i understand what you're saying, it withdraws the amount plus whatever interest it gathered since. Like it counts in percentages, the amount requested was X % from original deposit, so it's withdrawing X % from current amount.

That's definitely confusing / unexpected, in the way the UI presents it.