NexusMutual / cover-router

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

Add allocationAmount value in GET products capacities endpoint (/v2/capacity) response #31

Closed mixplore closed 1 year ago

mixplore commented 1 year ago

Context

We need to sort the products on Buy Cover page by booked/used capacity (aka active cover amount, or allocationAmount). Atm we get products capacities values from the cover router api /v2/capacity GET endpoint. To support the sorting feature we need to get data for the booked capacity as well. It would be great to have that info passed on the same endpoint response.

The current response looks like:

type CapacityApiResponse = {
  capacity: Array<{
    assetId: string;
    amount: string;
  }>;
  productId: string;
};

The new response would be great to look like:

type CapacityApiResponse = {
  capacity: Array<{
    assetId: string;
    amount: string;
  }>;
  allocationAmount: string; // always denominated in NXM so no need for assetId
  productId: string;
};

Naming of the new field can be discussed if something else makes more sense in the given context.

roxdanila commented 1 year ago

To avoid confusion, let's use the following terminology:

cc @MilGard91 - pls update the PR cc @mixplore for awareness