Skip to content

Commit

Permalink
common: types for wallet balances
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliu08 committed Feb 7, 2025
1 parent 48f823e commit 1bd17ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/daimo-common/src/daimoPay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ export function getOrderDestChainId(
return order.destFinalCallTokenAmount.token.chainId;
}

export type WalletBalanceOption = {
balance: DaimoPayTokenAmount;
minimumRequired: DaimoPayTokenAmount;
fees: DaimoPayTokenAmount;
};

export type WalletPaymentOption = WalletBalanceOption & {
required: DaimoPayTokenAmount;
};

export type ExternalPaymentOptionMetadata = {
id: ExternalPaymentOptions;
cta: string;
Expand All @@ -213,6 +223,7 @@ export type ExternalPaymentOptionMetadata = {
paymentToken: DaimoPayToken;
disabled: boolean;
message?: string;
minimumUsd?: number;
};

export enum ExternalPaymentOptions {
Expand Down Expand Up @@ -352,7 +363,7 @@ export interface WebhookDelivery {
createdAt: Date;
}

export function getDisplayPrice(tokenAmount: DaimoPayTokenAmount) {
export function getDisplayPrice(tokenAmount: DaimoPayTokenAmount): string {
const { token, amount } = tokenAmount;
const amountDec = formatUnits(BigInt(amount), token.decimals);
const displayPrice = Number(amountDec).toFixed(token.displayDecimals);
Expand Down

0 comments on commit 1bd17ac

Please sign in to comment.