pendulum-chain / pendulum-prototype

Pendulum prototype: Second Layer Network for Stellar and the DeFi ecosystem
MIT License
10 stars 6 forks source link

fix bug that withdrawal increases balance #32

Closed gonzamontiel closed 3 years ago

gonzamontiel commented 3 years ago

When executing a withdrawal, everything works on the Stellar side (funds or unlocked and moved from the escrow account) but on Pendulum's side funds are not removed but added. It is like we are minting instead of burning but that does not make sense as we call the withdrawal function of the tokens pallet, which itself is the correct function to burn tokens.

gonzamontiel commented 3 years ago

Along with @morgueye4 we discovered that there are two bugs here.

1) Is not the withdrawal what is minting the funds. Is the same offchain worker that reacts with a deposit, just right away the funds are received by the escrow account. I think this happens because we're using a hardcoded account, but need to research more about why the deposit is triggered.

2) In the other hand, the funds are not burnt by the withdrawal, so if you had 1 unit, after this operation the resulting amount would still be 1.

The combination of both makes the balance higher than before.