On February 23, 2022, Wing Flash Pool (Ontology EVM) launched. On November 28, 2022, some exceptional Wing DAO community members found that the actual Borrow APR and Supply APR in the pool were three times the theoretical value, and reported it to the Wing Finance technical team. Then the technical team shut down the Wing Flash Pool (Ontology EVM) urgently and fixed the problem.
After investigation, the Wing Finance technical team found that the reason for the unusually high interest rate is that the parameter setting of the interest rate model contract is incorrect. In the interest rate model contract, the annualized income parameter needs to be input, which will be converted into the income per second in the contract. During the conversion process, it should be divided by the number of seconds in a year. However, it was divided by the number of blocks in a year, which is 3s/block in the Wing Flash Pool (Ontology EVM). As a result, Borrow APR and Supply APR are 3 times normal.
On November 29, 2022, the pool was urgently closed for repair. Before closing the pool, due to parameter errors, Borrowers overpaid interest, while Suppliers overcharged interest. The repair has been completed, and the pool will be reopened. Before reopening the pool, we need to correct the previous errors.
The following is the calculation logic of interest refund, and the calculation is distinguished for non-USDT assets and USDT:
1.Non-USDT assets
For non-USDT assets, the interest will be calculated at 3 times from the launch to the time t, and the interest will be calculated normally after the time t.
Calculation:
Count all the records of Supply, Withdraw, Borrow and Repay of each user and user’s Supply and Borrow Position in the pool at time t: inpools, inpoolb.
Interest of supply: s1 = Withdraw + inpools - Supply
Interest of borrow: b1 = Repay + inpoolb - Borrow
User’s earnings: s1 - b1
The theoretical interest of supply: s2 = s1/3
The theoretical interest of borrow: b2 = b1/3
User’s theoretical earnings: s2 - b2 = (s1 - b1)/3
Interest difference to be returned: (s2 - b2)- (s1 - b1)= (s1 - b1)/3 - (s1 - b1) = (b1 - s1)*2/3
Special cases:
(1) User A directly transfers fToken to user B: a Withdraw record is added for user A, and a Supply record is added for user B;
(2) User A liquidates user B’s asset C and obtains collateral D: a Repay record is added for user B’s asset C, and a Withdraw record is user B’s added for asset D; a Supply record is added for user A’s asset D.
Data acquisition method:
(1) The transaction amount of Supply, Withdraw, Borrow, Repay, fToken transfer, and liquidation are obtained directly through contract events;
(2) The user’s position in pools at time t is obtained by querying the contract status through block synchronization to the specified height.
- USDT
For USDT assets, the interest will be calculated at 3 times from the launch to the time t1, interest will be calculated at 32.7 times from time t1 to t2, and interest will be calculated normally after the time t2.
Calculation:
Count all the records of Supply, Withdraw, Borrow and Repay of each user from the launch to the time t2, the user’s Supply and Borrow Position in the pool at time t2: inpools2 and inpoolb2, and the total loan interest BI of the pool from time t1 to t2.
Interest of supply: s1 = Withdraw + inpools2 - Supply
Interest of borrow: b1 =Repay + inpoolb2 - Borrow
User’s earnings: s1 - b1
Total Interest of Supply in the pool from time t1 to t2: SI = BI*90%,the amount of Supply, which is represented by S = sum(inpools2)
User’s interest of Supply from time t1 to t2: uSI = SI * inpool2/S
The theoretical interest of supply:s2 = (s1 - uSI)/3 + uSI/32.7
Total amount of Borrow in the pool from time t1 to t2, which is represented by B = sum (inpoolb2)
User’s interest of Borrow from time t1 to t2: uBI = BI * inpoolb2/B
The theoretical interest of borrow:b2 = (b1 - uBI)/3 + uBI/32.7
User’s theoretical earnings: s2 - b2
Interest difference to be returned:(s2 - b2) - (s1 - b1)
Special cases:
(1) User A directly transfers fToken to user B: a Withdraw record is added for user A, and a Supply record is added for user B;
(2) User A liquidates user B’s asset C and obtains collateral D: a Repay record is added for user B’s asset C, and a Withdraw record is user B’s added for asset D; a Supply record is added for user A’s asset D.
Data acquisition method:
(1) The transaction amount of Supply, Withdraw, Borrow, Repay, fToken transfer, and liquidation are obtained directly through contract events;
(2) The total borrow interest from time t1 to t2 is obtained directly through contract events, and the user’s position in pools at time t2 is obtained by querying the contract status through block synchronization to the specified height.
According to the above calculation logic, if the calculation result is a negative value, it means that the user needs to refund the interest to the pool, and if the calculation result is a positive value, it means that the pool needs to return the interest to the user.
Please note that if the calculation result is a negative value, it is recommended that the user does not need to refund the interest; if the calculation result is a positive value, the corresponding amount of USDT will be refunded from the Reserve to the user’s address. This correction method is referred to as “negative-zero and positive-compensation”.
The details of the final return of each address after the correction are as follows:
Address | Refund |
---|---|
0x872b…a304 | $26,991.65 |
0x5ddc…4c65 | $23,208.66 |
0xd780…1bac | $11,841.74 |
0xf551…4eef | $5,987.58 |
0x195b…fcac | $5,502.28 |
0xc9d9…8c95 | $5,320.01 |
0x474a…61e7 | $4,724.50 |
0x7b0f…ebc2 | $1,442.79 |
0xfd4b…e81b | $1,218.67 |
0x39b9…695d | $548.05 |
0x1214…cf90 | $309.67 |
0x5eac…24f3 | $264.52 |
0x4c3d…fc82 | $160.72 |
0xad0d…7590 | $134.65 |
0x6c3e…dd97 | $74.00 |
0x3e64…fe70 | $13.69 |
0xb8f4…21ee | $13.07 |
0xbb06…1ae4 | $12.61 |
0x79b5…7abd | $7.84 |
0x6c08…8ef6 | $0.43 |
The details in the current Reserve are as follows:
Asset | Value | Amount | Price |
---|---|---|---|
WING | $1,206 | 182.511 | $6.61 |
WONT | $17 | 88.7 | $0.19 |
ONG | $33 | 129.241 | $0.26 |
ETH | $20 | 0.0154 | $1280.56 |
WBTC | $11 | 0.0007 | $16948.73 |
USDT | $91,457 | 91457.1802 | $1 |
USDC | $18,369 | 18214.2711 | $1.01 |
The total amount in the Reserve is about $111,113.08, and the total amount of Reserve compensation is $87,777.13. The amount of Reserve will end up with $111,113.08-$87,777.13=$23,335.87.
If the vote is passed, the Wing team will perform the following operations step by step:
-
Extract all assets in Wing Flash Pool (Ontology EVM) Reserve.
-
Wing Flash Pool (Ontology EVM) will be opened at 8:00, Dec 12 (UTC), but liquidation will not be enabled.
-
The liquidation of Wing Flash Pool (Ontology EVM) will start at 8:00, Dec 13 (UTC).
-
According to the above details, refund to the user’s address using the USDT in the Reserve.
-
As for the remaining Reserve (approximately $23,335.87) after the refund, following the Wing buyback rules determined by WIP-4, the team will take 50% to participate in the buyback in December.
Feel free to have your say!