PageSourceSearch

https://optima.financial/assets/transactions-BMTD6-h_.js

js optima.financial collected 2026-10-04 07:39:07 UTC 11,502 bytes, 2 lines download raw bytes

1import{h as P,r as c,d as re,e as D,j as e,D as le,y as oe,g as C,l as ie,A as ce,f as k}from"./index-BfAlG-Z-.js";import{u as de}from"./use-transactions-BJK7qCY7.js";import{u as ue,a as me}from"./loading-skeleton-B7nPtDFU.js";import{r as F}from"./order-economics-BcIacgP_.js";import{B as p}from"./badge-Czn1iqFg.js";import{B as R}from"./button-5uHaljvD.js";import{S as g,a as N,b as y,c as v,d as j}from"./select-Bl8fE1-c.js";import{S as he}from"./status-badge-BuNEgyNV.js";import{E as pe}from"./external-link-ZSegfG0m.js";import{A as xe}from"./arrow-up-right-BLbZ0Uol.js";import{A as fe}from"./arrow-down-left-0JPU6h_E.js";import"./chevron-down-CQer9P9S.js";import"./check-CKjpzYlz.js";import"./index-DzFdARBX.js";const je=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]],be=P("receipt",je);const ge=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ne=P("rotate-ccw",ge);const ye=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ve=P("wand-sparkles",ye);function Te(s){return/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function ke(s,a){return[s,...a].map(o=>o.map(l=>Te(l??"")).join(",")).join(`\r
2`)}function Se(s,a){if(typeof document>"u")return;const n=new Blob(["\uFEFF",s],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=a,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}const we=[25,50,100,200],Ae=50,z=200,T="ALL",_e=[{value:"ALL",label:"All Types"},{value:"DEPOSIT",label:"Deposit"},{value:"WITHDRAWAL",label:"Withdrawal"},{value:"TRADE",label:"Trade"},{value:"ADJUSTMENT",label:"Adjustment"}],Ee=[{value:"ALL",label:"All Statuses"},{value:"PENDING",label:"Pending"},{value:"PENDING_APPROVAL",label:"Pending Approval"},{value:"COMPLETED",label:"Completed"},{value:"FAILED",label:"Failed"}];function Le(s){if(!s.tx_hash)return null;switch(s.blockchain??"arbitrum"){case"arbitrum":return`https://arbiscan.io/tx/${s.tx_hash}`;case"ethereum":return`https://etherscan.io/tx/${s.tx_hash}`;case"base":return`https://basescan.org/tx/${s.tx_hash}`;case"redbelly":return`https://explorer.redbelly.network/tx/${s.tx_hash}`;default:return null}}function De(s){switch(s.type){case"DEPOSIT":return e.jsxs(p,{variant:"outline",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:[e.jsx(fe,{className:"mr-1 size-3"}),"Deposit"]});case"WITHDRAWAL":return e.jsxs(p,{variant:"outline",className:"bg-orange-500/20 text-orange-400 border-orange-500/30",children:[e.jsx(xe,{className:"mr-1 size-3"}),"Withdrawal"]});case"TRADE":{const a=s.metadata?.order_type,n=a==="BUY"?"Buy":a==="SELL"?"Sell":"Trade";return e.jsxs(p,{variant:"outline",className:"bg-purple-500/20 text-purple-400 border-purple-500/30",children:[e.jsx(ce,{className:"mr-1 size-3"}),n]})}case"REFUND":return e.jsxs(p,{variant:"outline",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:[e.jsx(Ne,{className:"mr-1 size-3"}),"Refund"]});case"ADJUSTMENT":{const a=s.metadata?.adjustment_type,n=a==="COMPENSATION"?"Compensation":a==="CORRECTION"?"Correction":a==="BACKFILL"?"Backfill":"Adjustment";return e.jsxs(p,{variant:"outline",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[e.jsx(ve,{className:"mr-1 size-3"}),n]})}default:return e.jsx(p,{variant:"secondary",children:s.type})}}function V(s){if(s.type==="TRADE"){const n=F(s.metadata);if(n)return C(n.tokensSold)}const a=s.type==="WITHDRAWAL"&&s.metadata.original_amount?Number(s.metadata.original_amount):Number(s.token_amount);return C(a)}function H(s){if(s.usd_value===null||s.usd_value===void 0)return null;const a=Number(s.usd_value);if(!Number.isFinite(a))return null;if(s.type!=="TRADE"||s.metadata?.order_type!=="BUY")return a;const o=Number(s.metadata?.estimated_refund_usd??0);if(!Number.isFinite(o)||o<=0)return a;const l=a-o;return l>0?l:a}function W(s){if(s.type==="TRADE"){const n=F(s.metadata);if(n)return k(n.netUsd)}const a=H(s);return a===null?"—":k(a)}function B(s){if(s.type==="TRADE"){const o=F(s.metadata);if(o)return k(o.executedPrice)}const a=H(s);if(a===null)return"—";const n=s.type==="WITHDRAWAL"&&s.metadata.original_amount?Number(s.metadata.original_amount):Number(s.token_amount);return!Number.isFinite(n)||n<=0?"—":k(a/n)}function Ge(){ue("Transactions");const[s,a]=c.useState("ALL"),[n,o]=c.useState("ALL"),[l,$]=c.useState(T),[d,b]=c.useState(1),[u,G]=c.useState(Ae),[S,M]=c.useState(!1),[U,q]=c.useState(new Map),I={type:s==="ALL"?void 0:s,status:n==="ALL"?void 0:n,token_symbol
2:l===T?void 0:l},K={...I,limit:u,offset:(d-1)*u},{data:m,isLoading:w,isFetching:O}=de(K),{ref:Y,overlayElements:Z,handlers:J,style:X}=re({enableTilt:!1,spotlightSize:300,borderRadius:16});function A(t,r){t(r),b(1)}function Q(t){const r=Number(t);Number.isFinite(r)&&r>0&&(G(r),b(1))}async function ee(){if(!S){M(!0);try{const t=[];let r=0;for(let i=0;i<500;i++){const L=await ie.getTransactions({...I,limit:z,offset:r});if(t.push(...L.transactions),r+=z,r>=(L.total_count??t.length)||L.transactions.length===0)break}const f=["Date","Type","Token","Token Amount","Token Price (USD)","USD Value","Status","Tx Hash"],h=t.filter(i=>i.type!=="REFUND").map(i=>[i.created_at??"",i.type,D(i.token_symbol)??"",V(i),B(i),W(i),i.status,i.tx_hash??""]),ne=new Date().toISOString().slice(0,10);Se(ke(f,h),`optima-transactions-${ne}.csv`)}finally{M(!1)}}}c.useEffect(()=>{m&&q(t=>{let r=!1;const f=new Map(t);for(const h of m.transactions)h.token_symbol&&!f.has(h.token_symbol)&&(f.set(h.token_symbol,D(h.token_symbol)),r=!0);return r?f:t})},[m]);const te=c.useMemo(()=>[...U.entries()].sort((t,r)=>t[1].localeCompare(r[1])),[U]),_=c.useMemo(()=>(m?.transactions??[]).filter(t=>t.type!=="REFUND"),[m]),x=m?.total_count??0,E=Math.max(1,Math.ceil(x/u)),se=x===0?0:(d-1)*u+1,ae=Math.min(d*u,x);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground md:text-3xl",children:"Transactions"}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"View your deposit, withdrawal, and trade history"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(g,{value:s,onValueChange:t=>A(a,t),children:[e.jsx(N,{className:"w-[160px]",children:e.jsx(y,{})}),e.jsx(v,{children:_e.map(t=>e.jsx(j,{value:t.value,children:t.label},t.value))})]}),e.jsxs(g,{value:n,onValueChange:t=>A(o,t),children:[e.jsx(N,{className:"w-[160px]",children:e.jsx(y,{})}),e.jsx(v,{children:Ee.map(t=>e.jsx(j,{value:t.value,children:t.label},t.value))})]}),e.jsxs(g,{value:l,onValueChange:t=>A($,t),children:[e.jsx(N,{className:"w-[160px]",children:e.jsx(y,{})}),e.jsxs(v,{children:[e.jsx(j,{value:T,children:"All Tokens"}),te.map(([t,r])=>e.jsx(j,{value:t,children:r},t))]})]}),e.jsxs(g,{value:String(u),onValueChange:Q,children:[e.jsx(N,{className:"w-[140px]",children:e.jsx(y,{})}),e.jsx(v,{children:we.map(t=>e.jsxs(j,{value:String(t),children:[t," / page"]},t))})]}),e.jsxs(R,{variant:"outline",className:"ml-auto gap-2",onClick:ee,disabled:S||x===0,children:[e.jsx(le,{className:"size-4"}),S?"Exporting…":"Export CSV"]})]}),e.jsxs("div",{ref:Y,className:"glass relative overflow-hidden",style:X,...J,children:[Z,w&&e.jsx("div",{className:"p-6",children:e.jsx(me,{rows:6,columns:5})}),!w&&_.length===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-12 text-center",children:[e.jsx(be,{className:"size-10 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"No transactions yet"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:l===T?"Your transaction history will appear here.":"No transactions match the selected token filter."})]})]}),!w&&_.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-xs uppercase tracking-wider text-muted-foreground",children:[e.jsx("th",{className:"px-6 py-3 font-medium",children:"Date"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Type"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Token"}),e.jsx("th",{className:"px-6 py-3 font-medium text-right",children:"Token Amount"}),e.jsx("th",{className:"px-6 py-3 font-medium text-right",children:"Token Price"}),e.jsx("th",{className:"px-6 py-3 font-medium text-right",children:"USD Value"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Tx"})]})}),e.jsx("tbody",{children:_.map(t=>e.jsxs("tr",{className:"border-b border-border/50 transition-colors hover:bg-white/5",children:[e.jsx("td",{className:"px-6 py-4 text-sm text-muted-foreground whitespace-nowrap",children:oe(t.created_at)}),e.jsx("td",{className:"px-6 py-4",children:De(t)}),e.jsx("td",{className:"px-6 py-4 text-sm text-foreground",children:D(t.token_symbol)}),e.jsxs("td",{className:"px-6 py-4 text-right text-sm text-foreground",children:[e.jsx("span",{className:"font-mono",children:V(t)}),t.type==="WITHDRAWAL"&&t.metadata.withdrawal_fee?e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground font-mono",children:["Fee: ",C(Number(t.metadata.withdrawal_fee))]}):null]}),e.jsx("td",{className:"px-6 py-4 text-right text-sm text-muted-foreground",children:e.jsx("span",{className:"font-mono",children:B(t)})}),e.jsx("td",{className:"px-6 py-4 text-right text-sm text-foreground",children:e.jsx("span",{className:"font-mono",children:W(t)})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(he,{status:t.status})}),e.jsx("td",{className:"px-6 py-4",children:(()=>{const r=Le(t);return r?e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["View",e.jsx(pe,{className:"size-3"})]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})})()})]},t.id))})]})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-border/50 p-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",e.jsx("span",{className:"font-medium text-foreground",children:se}),"–",e.jsx("span",{className:"font-medium text-foreground",children:ae})," of"," ",e.jsx("span",{className:"font-medium text-foreground",children:x})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",e.jsx("span",{className:"font-medium text-foreground",children:d})," of"," ",e.jsx("span",{className:"font-medium text-foreground",children:E})]}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>b(t=>Math.max(1,t-1)),disabled:d<=1||O,children:"Previous"}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>b(t=>Math.min(E,t+1)),disabled:d>=E||O,children:"Next"})]})]})]})]})]})}export{Ge as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.