@zkp2p/sdk 0.6.2 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -198,6 +198,17 @@ function formatCapFromBaseUnits(baseUnits) {
198
198
  const value = Number(viem.formatUnits(BigInt(baseUnits), 6));
199
199
  return `$${value.toLocaleString()}`;
200
200
  }
201
+ function getCapForDisplay(tier) {
202
+ const platformLimits = tier.platformLimits ?? [];
203
+ if (platformLimits.length === 0) {
204
+ return tier.perIntentCapBaseUnits ?? tier.maxOrderSize;
205
+ }
206
+ const bestCap = platformLimits.filter((limit) => !limit.isLocked && limit.effectiveCap && limit.effectiveCap !== "0").reduce((current, limit) => {
207
+ if (!current) return limit.effectiveCap;
208
+ return BigInt(limit.effectiveCap) > BigInt(current) ? limit.effectiveCap : current;
209
+ }, void 0);
210
+ return bestCap ?? "0";
211
+ }
201
212
  function getTierDisplayInfo(tier) {
202
213
  if (!tier) {
203
214
  return {
@@ -216,7 +227,7 @@ function getTierDisplayInfo(tier) {
216
227
  PRO: "Peer Pro",
217
228
  PLATINUM: "Peer Platinum"
218
229
  };
219
- const capDisplay = formatCapFromBaseUnits(tier.perIntentCapBaseUnits);
230
+ const capDisplay = formatCapFromBaseUnits(getCapForDisplay(tier));
220
231
  return {
221
232
  tierLabel: tierLabels[tier.tier] || tier.tier,
222
233
  capDisplay,