NexusMutual / cover-router

Computes optimal capacity allocation per Nexus Mutual staking pool on cover purchase
MIT License
1 stars 1 forks source link

Feature: multi pool router #29

Closed danoctavian closed 1 year ago

danoctavian commented 1 year ago

Context

Add support for using multiple pools to allocate capacity for a cover.

Issue: https://github.com/NexusMutual/cover-router/issues/25

Changes proposed in this pull request

Add a new function that takes as input the requested cover amount and the set of staking pools that can be used.

Use a greedy allocation approach to find the best pools to allocate to, keeping in mind, price does not follow a linear function past 90% capacity, so it can't be as simple as sorting pools by base price and allocate until you fill it up etc.

Full details on this approach are in the RFC:

https://www.notion.so/nxmcommunity/RFC-Multi-pool-cover-router-e4a1637910be49268cb52c5fb9fbe21d

Test plan

Write unit tests for the computation and the parts dependant on it |(quoteEngine.js)

Checklist

Review

When reviewing a PR, please indicate intention in comments using the following emojis:

danoctavian commented 1 year ago

fixed all tests except 1.

Fairly satisfied with the coverage but i want to think of more edge cases

shark0der commented 1 year ago

Toyed around with the implementation here: https://github.com/NexusMutual/cover-router/pull/33 Feel free to borrow stuff from it or work directly on top of it. FYI it's a very much wip and probably fails to run, but should be close to its final form.