Bonding V2 Update

by Λ L Ξ X / アレクサンダー.eth

"Ship it!"

"Ship it!"

We are having delays due to UBQ rewards having had gone off the rails.

The Discovery

Zgo & Zapaz (DeFi veterans) wrapped up the BondingV2 smart contract while Zequez (our latest engineering hire and also new to DeFi!) handled the frontend changes in parallel.

Zgo, myself, and 3commascapital (all devs) jumped in with the migration from v1 → v2 to test drive the new UI. During the initial testing we ran into several issues, including but not limited to this:

We accidentally created a scamcoin zillion percent APY farm ??

We accidentally created a scamcoin zillion percent APY farm ??

Updated claim widget with MasterChefV2 by Zequez · Pull Request #8 · pavlovcik/uad-ui-launch

At this point, we were quite certain it was the new hire who made a mistake with the calculations. After personally looking through the UI code; the horror dawned on me. The UI code was all correct. Immediately afterward, I queried the smart contract directly.

Our Solidity goose has been cooked.

Our Solidity goose has been cooked.

And thus began the wild goose chase with the uAD protocol team.

Cliff Diving

The first action taken was that we disabled the rewards emissions for BondingV2 in case anybody else figured what happened at the same time as us. Next, the team went spelunking deep into the Solidity source code and speculated an uint underflow...

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/08376ec6-e12e-459e-be0b-3ff89bfe038e/Untitled.png

The underflow hypothesis was less favored over the realization of the use of different precisions for the division.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a35e25e5-704b-489c-87b2-234f1a490062/Untitled.png

Zgo was eventually able to inspect more closely and identify what likely is causing the issue:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7ff5e669-cdf4-4bb1-8f4f-a1077615d8ee/Untitled.png

Soon after, a pull request (a proposed fix) was made.