fix: decouple rent payouts from rate API, correct sats terminology
Rent shareholder payouts are denominated in sats and don't need a USD/sat exchange rate. Skip the getSatoshiRate() call for rent-type payments so they are never blocked by rate-API 429s or outages. Also fix a misleading log message that said "USD" instead of "sats". Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -195,12 +195,16 @@ export class PaymentService {
|
||||
type: 'watch' | 'rent' = 'watch',
|
||||
frequency: Frequency = 'automatic',
|
||||
) {
|
||||
const satoshiRate = await this.provider.getSatoshiRate();
|
||||
const column = type === 'watch' ? 'pendingRevenue' : 'rentPendingRevenue';
|
||||
|
||||
// Rental prices (and therefore rentPendingRevenue) are denominated in
|
||||
// sats, not USD. Use a 1-sat minimum threshold for rentals instead of
|
||||
// the USD-based satoshiRate.
|
||||
// sats, not USD. The satoshi rate is only needed for watch/subscription
|
||||
// payments which store revenue in USD. Skip the rate fetch entirely for
|
||||
// rent payouts so they are never blocked by rate-API outages or 429s.
|
||||
let satoshiRate = 0;
|
||||
if (type !== 'rent') {
|
||||
satoshiRate = await this.provider.getSatoshiRate();
|
||||
}
|
||||
|
||||
const column = type === 'watch' ? 'pendingRevenue' : 'rentPendingRevenue';
|
||||
const minThreshold = type === 'rent' ? 1 : satoshiRate;
|
||||
|
||||
const options: FindManyOptions<Shareholder> = {
|
||||
|
||||
@@ -236,7 +236,7 @@ export class RentsService {
|
||||
.execute();
|
||||
|
||||
Logger.log(
|
||||
`Credited ${total} USD to ${ids.length} shareholder(s) via project fallback for content ${contentId}`,
|
||||
`Credited ${total} sats to ${ids.length} shareholder(s) via project fallback for content ${contentId}`,
|
||||
'RentsService',
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user