|
@@ -11,9 +11,11 @@
|
|
|
|
|
|
|
|
const orders = writable([]);
|
|
const orders = writable([]);
|
|
|
|
|
|
|
|
- let currentPrice = 125;
|
|
|
|
|
|
|
+ let currentPrice = 100;
|
|
|
|
|
|
|
|
onMount(() => {
|
|
onMount(() => {
|
|
|
|
|
+
|
|
|
|
|
+ //remover a parte que ele salva no localstorage porque vai ser conectado o endpoint
|
|
|
if (browser) {
|
|
if (browser) {
|
|
|
try {
|
|
try {
|
|
|
const saved = localStorage.getItem('tradingOrders');
|
|
const saved = localStorage.getItem('tradingOrders');
|
|
@@ -33,7 +35,7 @@
|
|
|
function formatBRL(n) {
|
|
function formatBRL(n) {
|
|
|
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number(n || 0));
|
|
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number(n || 0));
|
|
|
}
|
|
}
|
|
|
- function formatEasyCoin(n) {
|
|
|
|
|
|
|
+ function formatEasyToken(n) {
|
|
|
return new Intl.NumberFormat('pt-BR', { minimumFractionDigits: 6, maximumFractionDigits: 6 }).format(Number(n || 0));
|
|
return new Intl.NumberFormat('pt-BR', { minimumFractionDigits: 6, maximumFractionDigits: 6 }).format(Number(n || 0));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -42,17 +44,17 @@
|
|
|
|
|
|
|
|
let buyAmountFiat = '';
|
|
let buyAmountFiat = '';
|
|
|
let buyLimitPrice = '';
|
|
let buyLimitPrice = '';
|
|
|
- let sellAmountEasyCoin = '';
|
|
|
|
|
|
|
+ let sellAmountEasyToken = '';
|
|
|
let sellLimitPrice = '';
|
|
let sellLimitPrice = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
- $: buyComputedEasyCoin = buyTab === 'market'
|
|
|
|
|
|
|
+ $: buyComputedEasyToken = buyTab === 'market'
|
|
|
? (Number(buyAmountFiat) && currentPrice ? Number(buyAmountFiat) / currentPrice : 0)
|
|
? (Number(buyAmountFiat) && currentPrice ? Number(buyAmountFiat) / currentPrice : 0)
|
|
|
: (Number(buyAmountFiat) && Number(buyLimitPrice) ? Number(buyAmountFiat) / Number(buyLimitPrice) : 0);
|
|
: (Number(buyAmountFiat) && Number(buyLimitPrice) ? Number(buyAmountFiat) / Number(buyLimitPrice) : 0);
|
|
|
|
|
|
|
|
$: sellComputedFiat = sellTab === 'market'
|
|
$: sellComputedFiat = sellTab === 'market'
|
|
|
- ? (Number(sellAmountEasyCoin) && currentPrice ? Number(sellAmountEasyCoin) * currentPrice : 0)
|
|
|
|
|
- : (Number(sellAmountEasyCoin) && Number(sellLimitPrice) ? Number(sellAmountEasyCoin) * Number(sellLimitPrice) : 0);
|
|
|
|
|
|
|
+ ? (Number(sellAmountEasyToken) && currentPrice ? Number(sellAmountEasyToken) * currentPrice : 0)
|
|
|
|
|
+ : (Number(sellAmountEasyToken) && Number(sellLimitPrice) ? Number(sellAmountEasyToken) * Number(sellLimitPrice) : 0);
|
|
|
|
|
|
|
|
function confirmBuy() {
|
|
function confirmBuy() {
|
|
|
const price = buyTab === 'limit' ? Number(buyLimitPrice) : currentPrice;
|
|
const price = buyTab === 'limit' ? Number(buyLimitPrice) : currentPrice;
|
|
@@ -66,19 +68,19 @@
|
|
|
|
|
|
|
|
function confirmSell() {
|
|
function confirmSell() {
|
|
|
const price = sellTab === 'limit' ? Number(sellLimitPrice) : currentPrice;
|
|
const price = sellTab === 'limit' ? Number(sellLimitPrice) : currentPrice;
|
|
|
- const amount = Number(sellAmountEasyCoin);
|
|
|
|
|
|
|
+ const amount = Number(sellAmountEasyToken);
|
|
|
if (!price || !amount) return;
|
|
if (!price || !amount) return;
|
|
|
const total = amount * price;
|
|
const total = amount * price;
|
|
|
addOrder({ side: 'Venda', price, amount, total, status: 'Aberta', type: sellTab });
|
|
addOrder({ side: 'Venda', price, amount, total, status: 'Aberta', type: sellTab });
|
|
|
- sellAmountEasyCoin = '';
|
|
|
|
|
|
|
+ sellAmountEasyToken = '';
|
|
|
sellLimitPrice = '';
|
|
sellLimitPrice = '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const orderColumns = [
|
|
const orderColumns = [
|
|
|
{ key: 'side', label: 'Tipo' },
|
|
{ key: 'side', label: 'Tipo' },
|
|
|
- { key: 'price', label: 'Preço (R$)' },
|
|
|
|
|
- { key: 'amount', label: 'Quantidade (EasyCoin)' },
|
|
|
|
|
- { key: 'total', label: 'Total (R$)' },
|
|
|
|
|
|
|
+ { key: 'price', label: 'EasyCoin' },
|
|
|
|
|
+ { key: 'amount', label: 'EasyToken' },
|
|
|
|
|
+ { key: 'total', label: 'Total EasyCoin' },
|
|
|
{ key: 'status', label: 'Status' }
|
|
{ key: 'status', label: 'Status' }
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -87,16 +89,16 @@ $: pendingSells = $orders.filter((o) => o.side === 'Venda' && o.type === 'limit'
|
|
|
|
|
|
|
|
$: displayPendingBuys = pendingBuys.map((o) => ({
|
|
$: displayPendingBuys = pendingBuys.map((o) => ({
|
|
|
side: o.side,
|
|
side: o.side,
|
|
|
- price: formatBRL(o.price),
|
|
|
|
|
- amount: formatEasyCoin(o.amount),
|
|
|
|
|
- total: formatBRL(o.total),
|
|
|
|
|
|
|
+ price: formatEasyToken(o.price),
|
|
|
|
|
+ amount: formatEasyToken(o.amount),
|
|
|
|
|
+ total: formatEasyToken(o.total),
|
|
|
status: o.status
|
|
status: o.status
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
$: displayPendingSells = pendingSells.map((o) => ({
|
|
$: displayPendingSells = pendingSells.map((o) => ({
|
|
|
side: o.side,
|
|
side: o.side,
|
|
|
price: formatBRL(o.price),
|
|
price: formatBRL(o.price),
|
|
|
- amount: formatEasyCoin(o.amount),
|
|
|
|
|
|
|
+ amount: formatEasyToken(o.amount),
|
|
|
total: formatBRL(o.total),
|
|
total: formatBRL(o.total),
|
|
|
status: o.status
|
|
status: o.status
|
|
|
}));
|
|
}));
|