change: 10$ minimum transfer
This commit is contained in:
parent
8f2aee1552
commit
3a2677b334
3 changed files with 51 additions and 10 deletions
|
|
@ -30,6 +30,10 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
throw error(400, 'Transfer amount too large');
|
||||
}
|
||||
|
||||
if (type === 'CASH' && amount < 10) {
|
||||
throw error(400, 'Cash transfers require a minimum of $10.00');
|
||||
}
|
||||
|
||||
if (type === 'COIN' && !coinSymbol) {
|
||||
throw error(400, 'Coin symbol required for coin transfers');
|
||||
}
|
||||
|
|
@ -140,6 +144,13 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
throw error(404, 'Coin not found');
|
||||
}
|
||||
|
||||
const coinPrice = Number(coinData.currentPrice) || 0;
|
||||
const estimatedValue = amount * coinPrice;
|
||||
|
||||
if (estimatedValue < 10) {
|
||||
throw error(400, `Coin transfers require a minimum estimated value of $10.00. ${amount.toFixed(6)} ${coinData.symbol} is worth approximately $${estimatedValue.toFixed(2)}`);
|
||||
}
|
||||
|
||||
const [senderHolding] = await tx
|
||||
.select({
|
||||
quantity: userPortfolio.quantity
|
||||
|
|
@ -167,7 +178,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
.for('update')
|
||||
.limit(1);
|
||||
|
||||
const coinPrice = Number(coinData.currentPrice) || 0;
|
||||
const totalValue = amount * coinPrice;
|
||||
|
||||
const newSenderQuantity = Number(senderHolding.quantity) - amount;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
return;
|
||||
}
|
||||
if (userBalance <= 100_000) {
|
||||
toast.error('You need at least $100,000 in your portfolio to create a question.');
|
||||
toast.error('You need at least $100,000 in your portfolio (cash) to create a question.');
|
||||
return;
|
||||
}
|
||||
showCreateDialog = true;
|
||||
|
|
|
|||
Reference in a new issue