Hu-Fi / Mr.Market

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger
https://mr-market-one.vercel.app
GNU Affero General Public License v3.0
1 stars 6 forks source link

Test of rebalance module #104

Closed zed-wong closed 3 months ago

zed-wong commented 3 months ago

We need to test the rebalance module, what it wants to achieve is to constantly check the balance between mixin and exchange. If the balance of an asset is too low in exchange or mixin, it should trigger rebalance (which is withdrawal from the account that has more balance to the account that has less balance).

We support multiple api keys, so the rebalance() inside rebalance.service.ts would check the balance of all exchange api keys, If the balance of some asset inside the api key is lower than the minimum rebalance amount we set in the database, it would compare the balance of the asset with mixin. And if mixin has sufficient balance, it would trigger a withdrawal from mixin to exchange address. Same applies to mixin account.

The minimum rebalance amount is set by using functions inside rebalance.repository.ts.

Now the overall logic is done, we need to test and debug the code.

Related files: rebalance.service.ts rebalance.repository.ts

zed-wong commented 3 months ago

Merged at 43324ac0f7939d4f049319b27f06465004adda54 . We will skip the real environment testing for now as it's no going to be part of the demo.