Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/app/earn/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export default function EarnPage() {
streamId: stream.id,
tokenContract: stream.token,
ftName: getTokenConfigByContractId(stream.token).ftName,
expectedAmount: stream.claimable ?? 0n,
remainingBalance:
stream.depositAmount - stream.withdrawnAmount,
})
);
if (result?.confirmed) {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/earn/streams/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export default function EarnStreamsPage() {
streamId: stream.id,
tokenContract: stream.token,
ftName: getTokenConfigByContractId(stream.token).ftName,
expectedAmount: stream.claimable ?? 0n,
remainingBalance:
stream.depositAmount - stream.withdrawnAmount,
})
);
if (result?.confirmed) {
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/lib/stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,15 @@ export function buildClaimAllTx(params: {
streamId: number;
tokenContract: string;
ftName: string;
/** Expected claimable amount fetched pre-build (upper bound). */
expectedAmount: bigint;
/**
* Stable upper bound for the payout: deposit − withdrawn (the stream's
* remaining escrow). NEVER bound this by the claimable amount — claimable
* grows every block, so a bound sampled at build time is already stale
* when the tx mines and claim-all aborts by post-condition on any active
* stream. Remaining only shrinks (on claims), so it always covers the
* payout while still capping outflow at what the stream actually holds.
*/
remainingBalance: bigint;
}) {
const [mgrAddr, mgrName] = splitContract(STREAM_MANAGER_CONTRACT);

Expand All @@ -311,7 +318,7 @@ export function buildClaimAllTx(params: {
postConditionMode: PostConditionMode.Deny,
postConditions: [
Pc.principal(`${mgrAddr}.${mgrName}`)
.willSendLte(params.expectedAmount)
.willSendLte(params.remainingBalance)
.ft(params.tokenContract as `${string}.${string}`, params.ftName),
],
network: getNetwork(),
Expand Down
Loading