@kodiak-finance/orderly-vaults 2.8.18-rc.1 → 2.8.19-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +92 -11
- package/dist/index.d.ts +92 -11
- package/dist/index.js +2924 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2920 -4
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
var orderlyHooks = require('@kodiak-finance/orderly-hooks');
|
|
5
5
|
var zustand = require('zustand');
|
|
6
6
|
var orderlyI18n = require('@kodiak-finance/orderly-i18n');
|
|
@@ -14,13 +14,2930 @@ var orderlyUiConnector = require('@kodiak-finance/orderly-ui-connector');
|
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
18
|
|
|
19
|
-
var So=Object.defineProperty;var n=(t,o)=>()=>(t&&(o=t(t=0)),o);var pt=(t,o)=>{for(var e in o)So(t,e,{get:o[e],enumerable:true});};var ee,oe,ct=n(()=>{ee={prod:"https://api-sv.orderly.org",staging:"https://testnet-api-sv.orderly.org",qa:"https://qa-api-sv-aliyun.orderly.org",dev:"https://dev-api-sv.orderly.org"},oe={prod:"https://app.orderly.network",staging:"https://staging-app.orderly.network",qa:"https://qa-app.orderly.network",dev:"https://dev-app.orderly.network"};});function X(){let t=orderlyHooks.useGetEnv();return Q.useMemo(()=>ee[t],[t])}var dt=n(()=>{ct();});function _o(t){let o=Ro(t),e=new URLSearchParams;return Object.entries(o).forEach(([r,a])=>{a!=null&&e.append(r,String(a));}),e.toString()}function Ro(t){let o={};return Object.entries(t).forEach(([e,r])=>{r!=null&&(typeof r=="string"||typeof r=="number"||typeof r=="boolean"?o[e]=r:typeof r=="object"&&r!==null&&Object.entries(r).forEach(([s,i])=>{i!=null&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&(o[s]=i);}));}),o}function Wo(t,o){if(!o||Object.keys(o).length===0)return t;let e=_o(o);if(!e)return t;let r=t.includes("?")?"&":"?";return `${t}${r}${e}`}var O,mt,Do,Z,re=n(()=>{O=class extends Error{constructor(e,r,a,s){super(e);this.code=r;this.status=a;this.response=s;this.name="VaultsApiError";}};mt=class{constructor(){this.requestInterceptors=[];this.responseInterceptors=[];this.defaultConfig={timeout:1e4,retry:3,retryDelay:1e3,validateStatus:o=>o>=200&&o<300,headers:{"Content-Type":"application/json"}};}addRequestInterceptor(o){this.requestInterceptors.push(o);}addResponseInterceptor(o){this.responseInterceptors.push(o);}createTimeoutController(o){let e=new AbortController;return setTimeout(()=>e.abort(),o),e}mergeHeaders(o={},e={}){return {...o,...e}}sleep(o){return new Promise(e=>setTimeout(e,o))}async request(o,e={}){let a={...this.defaultConfig,...e,headers:this.mergeHeaders(this.defaultConfig.headers,e.headers)};for(let S of this.requestInterceptors)a=await S(a);let s=o;typeof o=="string"&&!o.startsWith("http")&&a.baseURL&&(s=`${a.baseURL}${o.startsWith("/")?"":"/"}${o}`),a.params&&(s=typeof s=="string"?Wo(s,a.params):s);let i;a.timeout&&a.timeout>0&&(i=this.createTimeoutController(a.timeout),a.signal=i.signal);let{retry:u=0,retryDelay:m=1e3,validateStatus:h,params:l,baseURL:v,timeout:P,data:f,method:I,...C}=a,x={...C,method:I};f!==void 0&&(x.body=typeof f=="string"?f:JSON.stringify(f));let p;for(let S=0;S<=u;S++)try{let b=await fetch(s,x);if(!h(b.status)){let L=b.statusText,te;try{let lt=await b.json();L=lt.message||lt.code||L,te=lt.code;}catch{}throw new O(L,te,b.status,b)}let J;try{J=await b.json();}catch{throw new O("Invalid JSON response","PARSE_ERROR",b.status,b)}let V=J;for(let L of this.responseInterceptors)V=await L(b,V);if(typeof V=="object"&&V!==null&&"success"in V){let L=V;if(L.success)return L.data;throw new O(L.message||"API request failed",L.code,b.status,b)}return V}catch(b){if(p=b instanceof Error?b:new Error(String(b)),b instanceof O||b?.name==="AbortError"||S===u)throw p;S<u&&await this.sleep(m);}finally{i?.abort();}throw p}async get(o,e={}){return this.request(o,{...e,method:"GET"})}async post(o,e={}){return this.request(o,{...e,method:"POST"})}async put(o,e={}){return this.request(o,{...e,method:"PUT"})}async delete(o,e={}){return this.request(o,{...e,method:"DELETE"})}async patch(o,e={}){return this.request(o,{...e,method:"PATCH"})}},Do=new mt,Z=Do;});async function ae(t){return Z.get("/v1/public/strategy_vault/vault/info",{baseURL:t})}async function ie(t,o){return Z.get("/v1/public/strategy_vault/vault/performance",{params:o,baseURL:t})}async function se(t,o){return Z.get("/v1/public/strategy_vault/lp/info",{params:o,baseURL:t})}var ft=n(()=>{re();});exports.useVaultsStore = void 0;exports.useVaultInfoState = void 0;exports.useVaultLpPerformanceState = void 0;exports.useVaultLpInfoState = void 0;exports.useVaultInfoActions = void 0;exports.useVaultLpPerformanceActions = void 0;exports.useVaultLpInfoActions = void 0;exports.useVaultLpPerformanceById = void 0;exports.useVaultLpInfoById = void 0;exports.useVaultLpPerformanceIds = void 0;exports.useVaultLpInfoIds = void 0;exports.useVaultLpPerformanceArray = void 0;exports.useVaultLpInfoArray = void 0;var $=n(()=>{ft();exports.useVaultsStore=zustand.create((t,o)=>({baseUrl:"",vaultInfo:{data:[],loading:false,error:null,lastUpdated:null},vaultLpPerformance:{data:{},loading:false,error:null,lastUpdated:null,params:null},vaultLpInfo:{data:{},loading:false,error:null,lastUpdated:null,params:null},vaultsPageConfig:null,setBaseUrl:e=>{t({baseUrl:e});},fetchVaultInfo:async e=>{let r=o(),a=e||r.baseUrl;if(!a){t(s=>({vaultInfo:{...s.vaultInfo,error:"Base URL is required"}}));return}t(s=>({baseUrl:e||s.baseUrl,vaultInfo:{...s.vaultInfo,loading:true,error:null}}));try{let s=await ae(a);t(i=>({vaultInfo:{...i.vaultInfo,data:s.rows,loading:!1,error:null,lastUpdated:Date.now()}}));}catch(s){t(i=>({vaultInfo:{...i.vaultInfo,loading:false,error:s instanceof Error?s.message:"Failed to fetch vault info"}}));}},refreshVaultInfo:async()=>{let e=o();e.vaultInfo.lastUpdated&&e.baseUrl&&await e.fetchVaultInfo();},fetchVaultLpPerformance:async(e,r)=>{let a=o(),s=r||a.baseUrl;if(!s){t(i=>({vaultLpPerformance:{...i.vaultLpPerformance,error:"Base URL is required"}}));return}t(i=>({baseUrl:r||i.baseUrl,vaultLpPerformance:{...i.vaultLpPerformance,loading:true,error:null,params:e}}));try{let i=await ie(s,e);t(u=>({vaultLpPerformance:{...u.vaultLpPerformance,data:{...u.vaultLpPerformance.data,[e.vault_id]:i.rows},loading:!1,error:null,lastUpdated:Date.now()}}));}catch(i){t(u=>({vaultLpPerformance:{...u.vaultLpPerformance,loading:false,error:i instanceof Error?i.message:"Failed to fetch vault LP performance"}}));}},refreshVaultLpPerformance:async()=>{let e=o();e.vaultLpPerformance.lastUpdated&&e.vaultLpPerformance.params&&e.baseUrl&&await e.fetchVaultLpPerformance(e.vaultLpPerformance.params);},fetchVaultLpInfo:async(e,r)=>{let a=o(),s=r||a.baseUrl;if(!s){t(i=>({vaultLpInfo:{...i.vaultLpInfo,error:"Base URL is required"}}));return}t(i=>({baseUrl:r||i.baseUrl,vaultLpInfo:{...i.vaultLpInfo,loading:true,error:null,params:e}}));try{let i=await se(s,e);t(u=>({vaultLpInfo:{...u.vaultLpInfo,data:{...u.vaultLpInfo.data,[e.vault_id]:i.rows},loading:!1,error:null,lastUpdated:Date.now()}}));}catch(i){t(u=>({vaultLpInfo:{...u.vaultLpInfo,loading:false,error:i instanceof Error?i.message:"Failed to fetch vault LP info"}}));}},refreshVaultLpInfo:async()=>{let e=o();e.vaultLpInfo.lastUpdated&&e.vaultLpInfo.params&&e.baseUrl&&await e.fetchVaultLpInfo(e.vaultLpInfo.params);},setVaultsPageConfig:e=>{t({vaultsPageConfig:e});}})),exports.useVaultInfoState=()=>exports.useVaultsStore(t=>t.vaultInfo),exports.useVaultLpPerformanceState=()=>exports.useVaultsStore(t=>t.vaultLpPerformance),exports.useVaultLpInfoState=()=>exports.useVaultsStore(t=>t.vaultLpInfo),exports.useVaultInfoActions=()=>exports.useVaultsStore(t=>({fetchVaultInfo:t.fetchVaultInfo,refreshVaultInfo:t.refreshVaultInfo})),exports.useVaultLpPerformanceActions=()=>exports.useVaultsStore(t=>({fetchVaultLpPerformance:t.fetchVaultLpPerformance,refreshVaultLpPerformance:t.refreshVaultLpPerformance})),exports.useVaultLpInfoActions=()=>exports.useVaultsStore(t=>({fetchVaultLpInfo:t.fetchVaultLpInfo,refreshVaultLpInfo:t.refreshVaultLpInfo})),exports.useVaultLpPerformanceById=t=>exports.useVaultsStore(o=>o.vaultLpPerformance.data[t]),exports.useVaultLpInfoById=t=>exports.useVaultsStore(o=>o.vaultLpInfo.data[t]),exports.useVaultLpPerformanceIds=()=>exports.useVaultsStore(t=>Object.keys(t.vaultLpPerformance.data)),exports.useVaultLpInfoIds=()=>exports.useVaultsStore(t=>Object.keys(t.vaultLpInfo.data)),exports.useVaultLpPerformanceArray=()=>exports.useVaultsStore(t=>Object.values(t.vaultLpPerformance.data).flat()),exports.useVaultLpInfoArray=()=>exports.useVaultsStore(t=>Object.values(t.vaultLpInfo.data).flat());});var F=n(()=>{$();});exports.VaultsHeaderDesktop = void 0;var ht=n(()=>{exports.VaultsHeaderDesktop=t=>{let{supportVaults:o,headerImage:e,brokerName:r}=t,{t:a}=orderlyI18n.useTranslation(),s=Q.useMemo(()=>jsxRuntime.jsx("div",{className:"oui-flex oui-items-center",children:o.map((u,m)=>jsxRuntime.jsx("img",{src:`https://oss.orderly.network/static/network_logo/${u.chain_id}.png`,alt:u.chain_id,className:"oui-relative oui-size-5",style:{marginLeft:m>0?"-4px":"0",zIndex:o.length-m}},u.chain_id))}),[o]),i=Q.useMemo(()=>typeof e=="string"?jsxRuntime.jsx("img",{src:e,alt:"header",className:"oui-bg-contain oui-bg-center oui-bg-no-repeat"}):e,[e]);return jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-justify-between",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-max-w-[726px] oui-flex-col",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-gap-1 oui-text-[18px] oui-font-normal oui-text-base-contrast-54",children:[a("vaults.availableOn")," ",s]}),jsxRuntime.jsx("div",{className:"oui-mb-6 oui-mt-8 oui-text-5xl oui-font-bold oui-leading-[44px] oui-text-base-contrast",children:a("vaults.header.title")}),jsxRuntime.jsx("div",{className:"oui-text-xl oui-font-normal oui-text-base-contrast-54",children:a("vaults.header.description",{brokerName:r})})]}),jsxRuntime.jsx("div",{className:"oui-h-[238px] oui-w-[360px]",children:i})]})};});var de,me=n(()=>{de=t=>{let{supportVaults:o,headerImage:e}=t,{t:r}=orderlyI18n.useTranslation(),a=orderlyHooks.useConfig("brokerName"),s=Q.useMemo(()=>jsxRuntime.jsx("div",{className:"oui-flex oui-items-center",children:o.map((u,m)=>jsxRuntime.jsx("img",{src:`https://oss.orderly.network/static/network_logo/${u.chain_id}.png`,alt:u.chain_id,className:"oui-relative oui-size-[18px]",style:{marginLeft:m>0?"-4px":"0",zIndex:o.length-m}},u.chain_id))}),[o]),i=Q.useMemo(()=>typeof e=="string"?jsxRuntime.jsx("img",{src:e,alt:"header",className:"oui-bg-contain oui-bg-center oui-bg-no-repeat"}):e,[e]);return jsxRuntime.jsxs("div",{className:"oui-relative",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-gap-1 oui-text-2xs oui-font-semibold oui-text-base-contrast-54",children:[r("vaults.availableOn")," ",s]}),jsxRuntime.jsx("div",{className:"oui-mb-4 oui-mt-6 oui-min-h-[56px] oui-max-w-[calc(100%-187px)] oui-text-xl oui-font-bold oui-text-base-contrast",children:r("vaults.header.title")}),jsxRuntime.jsx("div",{className:"oui-max-w-[450px] oui-text-2xs oui-font-normal oui-text-base-contrast-54",children:r("vaults.header.description",{brokerName:a})})]}),jsxRuntime.jsx("div",{className:"oui-absolute -oui-right-3 -oui-top-4 oui-h-[124px] oui-w-[187px]",children:i})]})};});exports.useVaultsHeaderScript = void 0;var yt=n(()=>{F();exports.useVaultsHeaderScript=()=>{let{vaultInfo:t,vaultsPageConfig:o}=exports.useVaultsStore(),e=orderlyHooks.useConfig("brokerName");return {supportVaults:Q.useMemo(()=>{let a=[];return t.data.forEach(s=>{a.push(...s.supported_chains);}),ramda.uniqBy(s=>s.chain_id,a)},[t.data]),headerImage:o?.headerImage,brokerName:e}};});exports.VaultsHeaderWidget = void 0;var ge=n(()=>{ht();me();yt();exports.VaultsHeaderWidget=()=>{let t=exports.useVaultsHeaderScript(),{isMobile:o}=orderlyUi.useScreen();return o?jsxRuntime.jsx(de,{...t}):jsxRuntime.jsx(exports.VaultsHeaderDesktop,{...t})};});var ve={};pt(ve,{VaultsHeaderDesktop:()=>exports.VaultsHeaderDesktop,VaultsHeaderWidget:()=>exports.VaultsHeaderWidget,useVaultsHeaderScript:()=>exports.useVaultsHeaderScript});var It=n(()=>{ge();ht();yt();});var xe,Vt,ye=n(()=>{xe=t=>{let{t:o}=orderlyI18n.useTranslation(),{isMobile:e}=orderlyUi.useScreen(),{vaultsInfo:r}=t;return jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-flex oui-items-center ","oui-via-21.6% oui-via-83.23% oui-bg-gradient-to-r oui-from-[rgba(var(--oui-gradient-neutral-end)/1)] oui-to-[rgba(var(--oui-gradient-neutral-start)/1)]",e?"oui-gap-3 oui-rounded-xl oui-p-3":"oui-gap-6 oui-rounded-2xl oui-p-6"),children:[jsxRuntime.jsx(Vt,{title:o("vaults.introduction.tvl"),value:r.tvl,textProps:{currency:"$"},isMobile:e}),jsxRuntime.jsx(orderlyUi.Divider,{direction:"vertical",className:orderlyUi.cn("oui-bg-white/[0.12]",e?"oui-h-[44px]":"oui-h-[64px]")}),jsxRuntime.jsx(Vt,{title:o("common.vaults"),value:r.vaultsCount,isMobile:e}),jsxRuntime.jsx(orderlyUi.Divider,{direction:"vertical",className:orderlyUi.cn("oui-bg-white/[0.12]",e?"oui-h-[44px]":"oui-h-[64px]")}),jsxRuntime.jsx(Vt,{title:o("vaults.introduction.depositors"),value:r.lpCount,isMobile:e})]})},Vt=t=>{let{title:o,value:e,textProps:r,isMobile:a}=t;return jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-flex oui-flex-1 oui-flex-col oui-items-center ",a?"oui-gap-0.5":"oui-gap-3"),children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-font-normal oui-text-base-contrast-54",a?"oui-text-2xs":"oui-text-base"),children:o}),jsxRuntime.jsx(orderlyUi.Text.numeral,{className:orderlyUi.cn("oui-font-semibold",a?"oui-text-base":"oui-text-xl"),dp:0,...r,children:e})]})};});var Ie,Ve=n(()=>{F();Ie=()=>{let{vaultInfo:t}=exports.useVaultsStore();return {vaultsInfo:Q.useMemo(()=>{let e=t.data.reduce((a,s)=>a+s.tvl,0),r=t.data.reduce((a,s)=>a+s.lp_counts,0);return {tvl:e,lpCount:r,vaultsCount:t.data.length}},[t.data])}};});exports.VaultsIntroductionWidget = void 0;var we=n(()=>{ye();Ve();exports.VaultsIntroductionWidget=()=>{let t=Ie();return jsxRuntime.jsx(xe,{...t})};});var Pe={};pt(Pe,{VaultsIntroductionWidget:()=>exports.VaultsIntroductionWidget});var wt=n(()=>{we();});exports.RoleType = void 0;exports.OperationType = void 0;var T=n(()=>{exports.RoleType=(e=>(e.LP="lp",e.SP="sp",e))(exports.RoleType||{}),exports.OperationType=(e=>(e.DEPOSIT="deposit",e.WITHDRAWAL="withdrawal",e))(exports.OperationType||{});});var Le,Se=n(()=>{Le={prod:{vaultProtocol:"0x70Fe7d65Ac7c1a1732f64d2E6fC0E33622D0C991",vaultCrossChainManager:"0x58c9747ccAAE56182C7d9c814F5eaca395D8c93B",vaultPvLedger:"0xB7E792f0da9104A27288421583748215AefFFd78",vaultId:"0xa3426a1cef4052c056fced18099be899d93f1427d13b9a1df1806b91fad3d0c2",spAddress:"0x8bAA309D93FFFB54A64444FD98E10d92D4d9Eb22"},staging:{vaultProtocol:"0x6B6059259B4096ea6420Eb5e08a22214d2303aE9",vaultCrossChainManager:"0x510dD61a988797114A9a51b0d228E894037BD9cb",vaultPvLedger:"0x20AFe57C75D1C548A9Da265fBFC5416c43783589",vaultId:"0x95514fb145354f07bb889f711e856481b5ed52fce52200148aa834b3b29544c8",spAddress:"0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"},qa:{vaultProtocol:"0xF5b12d5F1db6DAB8C7c0561152b5e4bb8fD5eb38",vaultCrossChainManager:"0xB8a3245407571804b4db5219cBe8D9F2EA1828DE",vaultPvLedger:"0x15c9B5705CaCB4eb140dfd7a8c651E18027e5146",vaultId:"0x4812cbb88f4025372a3e2acd10d02b5f680d7d1fe78091f6cfde80122c861099",spAddress:"0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"},dev:{vaultProtocol:"0xA292E1126703F804FBD5671F034c7226538C54C7",vaultCrossChainManager:"0x7568ACC147Af12b02713143C3177D7e89C28A9A6",vaultPvLedger:"0x2a5909498d85650744dD5CF964F2136962e5AE6E",vaultId:"0x4812cbb88f4025372a3e2acd10d02b5f680d7d1fe78091f6cfde80122c861099",spAddress:"0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"}};});var Ce,Te=n(()=>{T();Ce=(t,o)=>t==="deposit"&&o==="lp"?0:t==="withdrawal"&&o==="lp"?1:t==="deposit"&&o==="sp"?2:t==="withdrawal"&&o==="sp"?3:1;});var q,tt=n(()=>{q=t=>{let{type:o,vaultId:e}=t,{data:r,mutate:a}=orderlyHooks.usePrivateQuery(`/v1/account_sv_transaction_history?type=${o}&vault_id=${e}&size=1`,{formatter:i=>i?.rows||orderlyTypes.EMPTY_LIST,revalidateOnFocus:false});return {latestOperation:Q.useMemo(()=>r?.[0],[r]),refetch:a}};});var et,Lt=n(()=>{Se();T();Te();tt();et=t=>{let{account:o,state:e}=orderlyHooks.useAccount(),r=orderlyHooks.useGetEnv(),{track:a}=orderlyHooks.useTrack(),s=Q.useMemo(()=>Le[r].vaultPvLedger,[r]),[i]=orderlyHooks.useMutation("/v1/sv_operation_request"),{refetch:u}=q({type:t.type,vaultId:t.vaultId}),m=Q.useMemo(()=>e?.accountId!==e?.mainAccountId,[e?.accountId,e?.mainAccountId]);return {handleOperation:async({amount:l,vaultId:v})=>{if(e.accountId!==e.mainAccountId){orderlyUi.toast.error("Please switch to the main account to perform this operation.");return}if(t.type==="deposit"&&new orderlyUtils.Decimal(l).lt(10)){orderlyUi.toast.error("Deposit amount is less than the minimum 10 USDC.");return}let f={payloadType:Ce(t.type,"lp"),amount:new orderlyUtils.Decimal(Number(l)).mul(10**6).toString(),vaultId:v,token:"USDC",domain:{name:"Orderly",version:"1",chainId:e.connectWallet?.chainId,verifyingContract:s}},{message:I,signatured:C}=await o.generateDexRequest(f);try{let x=await i({message:{...I,chainId:e.connectWallet?.chainId},signature:C,userAddress:e.address,verifyingContract:s});if(!x.success){t.type==="deposit"?a(orderlyTypes.TrackerEventName.vaultDepositFailed,{msg:x.message}):a(orderlyTypes.TrackerEventName.vaultWithdrawFailed,{msg:x.message}),orderlyUi.toast.error(x.message);return}await u(),t.type==="deposit"?a(orderlyTypes.TrackerEventName.vaultDepositSuccess,{quantity:l,vaultId:v}):a(orderlyTypes.TrackerEventName.vaultWithdrawSuccess,{quantity:l,vaultId:v}),orderlyUi.toast.success(`${t.type} successful`);}catch(x){let p=x instanceof Error?x.message:String(x);t.type==="deposit"?a(orderlyTypes.TrackerEventName.vaultDepositFailed,{msg:p}):a(orderlyTypes.TrackerEventName.vaultWithdrawFailed,{msg:p}),orderlyUi.toast.error(p);}},disabledOperation:m}};});var We,De=n(()=>{$();T();Lt();We=t=>{let{vaultId:o}=t,[e,r]=Q.useState(""),{vaultInfo:a}=exports.useVaultsStore(),{handleOperation:s,disabledOperation:i}=et({type:"deposit",vaultId:o}),{holding:u}=orderlyHooks.useCollateral(),{t:m}=orderlyI18n.useTranslation(),h=a.data[0]?.min_deposit_amount||0,l=orderlyHooks.useMaxWithdrawal("USDC"),v=Q.useMemo(()=>u?.find(V=>V.token==="USDC")?.holding||0,[u]),P=Q.useMemo(()=>Math.min(l,v),[l,v]),f=Q.useMemo(()=>a.data.find(L=>L.vault_id===o)?.est_main_share_price,[a.data,o]),I=Q.useMemo(()=>!f||!e?"-":new orderlyUtils.Decimal(e).div(f).toString(),[e,f]),C=async()=>{!I||I==="-"||(await s({amount:e,vaultId:o}),r(""));},x=orderlyHooks.useTokenInfo("USDC"),p=Q.useMemo(()=>({...x,display_name:x?.token,symbol:x?.token}),[x]),S=V=>{if(V&&new orderlyUtils.Decimal(V).gt(P)){r(P.toString());return}r(V);},b=Q.useMemo(()=>!e||e==="0"||i||!!e&&new orderlyUtils.Decimal(e).lt(h),[e,i]),J=Q.useMemo(()=>e&&new orderlyUtils.Decimal(e).lt(h)?{hintMessage:m("vaults.operation.error.minDeposit",{amount:h}),status:"error"}:{hintMessage:"",status:""},[e,m,l,v]);return {quantity:e,onQuantityChange:S,sourceToken:p,maxQuantity:P,sharePrice:f,shares:I,handleDeposit:C,vaultId:o,disabledDeposit:b,disabledOperation:i,inputHint:J}};});var Ne,Ae=n(()=>{T();tt();Ne=({vaultId:t})=>{let{latestOperation:o}=q({type:"deposit",vaultId:t});return {latestOperation:o}};});var rt,St=n(()=>{rt=t=>t==="completed"?"success":t==="rejected"||t==="failed"?"danger":"primary";});var Ue,Ee=n(()=>{St();Ue=t=>{let{latestOperation:o}=t,{t:e}=orderlyI18n.useTranslation();return o?jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-font-normal oui-text-base-contrast-54",children:e("vaults.deposit.latestDeposit")}),jsxRuntime.jsx("div",{className:"oui-h-[44px] oui-rounded-lg oui-border oui-border-white/[0.12] oui-p-3",children:jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-mr-1 oui-size-1 oui-rounded-full",o.status==="completed"&&"oui-bg-success",o.status==="rejected"&&"oui-bg-danger",o.status==="failed"&&"oui-bg-danger",(o.status==="pending"||o.status==="new")&&"oui-bg-primary")}),jsxRuntime.jsx(orderlyUi.Text,{color:rt(o.status),className:"oui-text-xs oui-font-normal",children:o.status.slice(0,1).toUpperCase()+o.status.slice(1)}),jsxRuntime.jsx(orderlyUi.TokenIcon,{name:"USDC",className:"oui-ml-auto oui-mr-1 oui-size-4"}),jsxRuntime.jsx(orderlyUi.Text.numeral,{className:"oui-text-sm oui-font-semibold oui-text-base-contrast-80",children:o.amount_change})]})})]}):null};});exports.LatestDepositWidget = void 0;var Ct=n(()=>{Ae();Ee();exports.LatestDepositWidget=t=>{let{vaultId:o}=t,e=Ne({vaultId:o});return jsxRuntime.jsx(Ue,{...e})};});var qe,Me=n(()=>{Ct();qe=t=>{let{quantity:o,onQuantityChange:e,sourceToken:r,maxQuantity:a,shares:s,handleDeposit:i,vaultId:u,disabledDeposit:m,disabledOperation:h,inputHint:l}=t,{t:v}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(orderlyUiTransfer.BrokerWallet,{}),jsxRuntime.jsx(orderlyUi.Box,{mt:3,mb:1,children:jsxRuntime.jsx(orderlyUiTransfer.QuantityInput,{value:o,onValueChange:e,token:{...r,precision:6},testId:"oui-testid-vault-deposit-dialog-quantity-input",hintMessage:l.hintMessage,status:l.status})}),jsxRuntime.jsx(orderlyUiTransfer.AvailableQuantity,{maxQuantity:a?.toString()||"0",onClick:()=>{e(a?.toString()||"0");}}),jsxRuntime.jsxs(orderlyUi.Box,{mt:5,mb:1,className:"oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",children:[jsxRuntime.jsx("div",{children:v("vaults.deposit.estShares")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{dp:6,padding:false,suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-54",children:v("vaults.deposit.shares")}),children:s})]}),jsxRuntime.jsxs(orderlyUi.Box,{mb:5,className:"oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",children:[jsxRuntime.jsx("div",{children:v("vaults.deposit.lockupDuration")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-54",children:"hrs"}),children:"48"})]}),h&&jsxRuntime.jsx("div",{className:"oui-mt-3 oui-text-center",children:jsxRuntime.jsx(orderlyUi.Text,{color:"warning",className:"oui-text-sm oui-font-semibold",children:v("vaults.operation.error.switchAccount")})}),jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,color:"primary",disabled:m,className:"oui-mt-3",onClick:i,children:v("common.deposit")}),jsxRuntime.jsx(exports.LatestDepositWidget,{vaultId:u})]})};});exports.VaultDepositWidget = void 0;var He=n(()=>{De();Me();exports.VaultDepositWidget=t=>{let{vaultId:o}=t,e=We({vaultId:o});return jsxRuntime.jsx(qe,{...e})};});var Wt=n(()=>{He();});var ze,Qe=n(()=>{F();T();Lt();ze=t=>{let{vaultId:o}=t,[e,r]=Q.useState(""),{handleOperation:a,disabledOperation:s}=et({type:"withdrawal",vaultId:o}),i=exports.useVaultLpInfoById(o),{vaultInfo:u}=exports.useVaultsStore(),{t:m}=orderlyI18n.useTranslation(),h=Q.useMemo(()=>u.data.find(S=>S.vault_id===o)?.est_main_share_price||0,[u.data,o]),l=i?.[0]?.available_main_shares||0,v=Q.useMemo(()=>!e||!h?"-":new orderlyUtils.Decimal(e).mul(h).toString(),[e,h]),P=async()=>{await a({amount:e,vaultId:o});},f=p=>{p&&new orderlyUtils.Decimal(p).gt(l)?r(l.toString()):r(p);},I=Q.useMemo(()=>!e||!u.data[0]?.est_main_share_price||!u.data[0]?.min_withdrawal_amount||e===l.toString()?false:new orderlyUtils.Decimal(e).mul(u.data[0]?.est_main_share_price).lt(u.data[0]?.min_withdrawal_amount),[e,u,l]),C=Q.useMemo(()=>!e||e==="0"||s||!!e&&I,[e,s]),x=Q.useMemo(()=>e&&I?{hintMessage:m("vaults.operation.error.minWithdrawal",{amount:u.data[0]?.min_withdrawal_amount}),status:"error"}:{hintMessage:"",status:""},[e,m]);return {quantity:e,onQuantityChange:f,maxQuantity:l,handleWithdraw:P,vaultId:o,sharePrice:h,receivingAmount:v,disabledWithdraw:C,disabledOperation:s,inputHint:x}};});var $e,Ge=n(()=>{T();tt();$e=({vaultId:t})=>{let{latestOperation:o}=q({type:"withdrawal",vaultId:t});return {latestOperation:o}};});var Nt,Ye,At,Ir,at,Ot=n(()=>{Nt=()=>jsxRuntime.jsx("div",{className:"oui-size-2 oui-rounded-full oui-bg-white/[0.54]"}),Ye=()=>jsxRuntime.jsx("div",{className:"oui-h-px oui-flex-1 oui-bg-white/[0.2]"}),At=({children:t,className:o})=>jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-flex-1 oui-text-2xs oui-font-normal oui-text-base-contrast-80",o),children:t}),Ir=()=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx(Nt,{}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsx(Ye,{})}),jsxRuntime.jsx(Nt,{}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsx(Ye,{})}),jsxRuntime.jsx(Nt,{})]}),jsxRuntime.jsxs("div",{className:"oui-mt-1 oui-flex oui-justify-between",children:[jsxRuntime.jsx(At,{children:t("vaults.withdraw.process.initiate")}),jsxRuntime.jsx(At,{className:"oui-text-center",children:t("vaults.withdraw.process.vaultProcess")}),jsxRuntime.jsx(At,{className:"oui-text-right",children:t("vaults.withdraw.process.transferred")})]})]})},at=()=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col oui-gap-2 oui-rounded-xl oui-border oui-border-white/[0.12] oui-p-3",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",children:[jsxRuntime.jsx("div",{children:t("vaults.withdraw.process.withdrawProcess")}),jsxRuntime.jsx(orderlyUi.Text,{color:"primary",children:t("vaults.withdraw.process.upTo")})]}),jsxRuntime.jsx(Ir,{})]})};});var Ze,je=n(()=>{St();Ot();Ze=t=>{let{latestOperation:o}=t,{t:e}=orderlyI18n.useTranslation();return o?jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-flex oui-flex-col oui-gap-2",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-font-normal oui-text-base-contrast-54",children:e("vaults.withdraw.latestWithdraw")}),jsxRuntime.jsx("div",{className:"oui-h-[44px] oui-rounded-lg oui-border oui-border-white/[0.12] oui-p-3",children:jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-mr-1 oui-size-1 oui-rounded-full",o.status==="completed"&&"oui-bg-success",o.status==="rejected"&&"oui-bg-danger",o.status==="failed"&&"oui-bg-danger",(o.status==="pending"||o.status==="new")&&"oui-bg-primary")}),jsxRuntime.jsx(orderlyUi.Text,{color:rt(o.status),className:"oui-text-xs oui-font-normal",children:o.status.slice(0,1).toUpperCase()+o.status.slice(1)}),jsxRuntime.jsx(orderlyUi.TokenIcon,{name:"USDC",className:"oui-ml-auto oui-mr-1 oui-size-4"}),jsxRuntime.jsx(orderlyUi.Text.numeral,{className:"oui-text-sm oui-font-semibold oui-text-base-contrast-80",children:o.amount_change||"-"})]})})]}):jsxRuntime.jsx(at,{})};});exports.LatestWithdrawWidget = void 0;var eo=n(()=>{Ge();je();exports.LatestWithdrawWidget=t=>{let{vaultId:o}=t,e=$e({vaultId:o});return jsxRuntime.jsx(Ze,{...e})};});var Ft=n(()=>{eo();});var ao,it,io,Or,Fr,so=n(()=>{Ft();Ot();ao=t=>{let{quantity:o,onQuantityChange:e,maxQuantity:r,handleWithdraw:a,vaultId:s,sharePrice:i,receivingAmount:u,disabledWithdraw:m,disabledOperation:h,inputHint:l}=t,{isMobile:v}=orderlyUi.useScreen(),P=()=>{orderlyUi.modal.show(v?Fr:Or,{quantity:o,receivingAmount:u,handleWithdraw:a});},{t:f}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(orderlyUiTransfer.BrokerWallet,{}),jsxRuntime.jsx(orderlyUi.Box,{mt:3,mb:1,children:jsxRuntime.jsx(orderlyUiTransfer.QuantityInput,{value:o,onValueChange:e,token:{display_name:"Shares",precision:6},testId:"oui-testid-vault-withdraw-dialog-quantity-input",hintMessage:l.hintMessage,status:l.status})}),jsxRuntime.jsx(orderlyUiTransfer.AvailableQuantity,{maxQuantity:r,onClick:()=>{e(r.toString());}}),jsxRuntime.jsx(it,{label:f("vaults.withdraw.estPricePerShare"),currency:"$",value:i||"-",className:"oui-mb-1 oui-mt-5"}),jsxRuntime.jsx(it,{label:f("vaults.withdraw.estReceivingAmount"),value:u,suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-36",children:"USDC"}),className:"oui-mb-5"}),h&&jsxRuntime.jsx("div",{className:"oui-mt-3 oui-text-center",children:jsxRuntime.jsx(orderlyUi.Text,{color:"warning",className:"oui-text-sm oui-font-semibold",children:f("vaults.operation.error.switchAccount")})}),jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,color:"primary",disabled:m,className:"oui-mt-3",onClick:P,children:f("common.withdraw")}),jsxRuntime.jsx("div",{className:"oui-mt-3",children:jsxRuntime.jsx(exports.LatestWithdrawWidget,{vaultId:s})})]})},it=({label:t,value:o,suffix:e,currency:r,className:a})=>jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",a),children:[jsxRuntime.jsx("div",{children:t}),jsxRuntime.jsx(orderlyUi.Text.numeral,{currency:r,className:"oui-text-base-contrast",suffix:e,children:o})]}),io=t=>{let{quantity:o,receivingAmount:e,handleWithdraw:r,hide:a}=t,{t:s}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col",children:[jsxRuntime.jsx(it,{label:s("vaults.withdraw.dialog.withdrawalAmount"),value:o,suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-36",children:"Shares"})}),jsxRuntime.jsx(it,{label:s("vaults.withdraw.dialog.estimatedReceiving"),value:e,suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-36",children:"USDC"}),className:"oui-mt-1"}),jsxRuntime.jsx(orderlyUi.Text,{color:"warning",className:"oui-my-5 oui-text-sm oui-font-semibold",children:s("vaults.withdraw.dialog.note")}),jsxRuntime.jsx(at,{}),jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,color:"primary",className:"oui-mt-5",onClick:async()=>{await r(),a?.();},children:s("vaults.withdraw.dialog.initiateWithdrawal")})]})},Or=orderlyUi.modal.create(({quantity:t,receivingAmount:o,handleWithdraw:e})=>{let{visible:r,hide:a,onOpenChange:s}=orderlyUi.useModal(),{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.SimpleDialog,{title:i("vaults.withdraw.dialog.title"),open:r,onOpenChange:s,children:jsxRuntime.jsx(io,{quantity:t,receivingAmount:o,handleWithdraw:e,hide:a})})}),Fr=orderlyUi.modal.create(({quantity:t,receivingAmount:o,handleWithdraw:e})=>{let{visible:r,hide:a,onOpenChange:s}=orderlyUi.useModal(),{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.SimpleSheet,{title:i("vaults.withdraw.dialog.title"),open:r,onOpenChange:s,children:jsxRuntime.jsx(io,{quantity:t,receivingAmount:o,handleWithdraw:e,hide:a})})});});exports.VaultWithdrawWidget = void 0;var uo=n(()=>{Qe();so();exports.VaultWithdrawWidget=t=>{let{vaultId:o}=t,e=ze({vaultId:o});return jsxRuntime.jsx(ao,{...e})};});var qt=n(()=>{uo();});exports.VaultDepositAndWithdrawWithDialogId = void 0;exports.VaultDepositAndWithdrawWithSheetId = void 0;exports.VaultDepositAndWithdraw = void 0;var Ht=n(()=>{Wt();qt();exports.VaultDepositAndWithdrawWithDialogId="VaultDepositAndWithdrawWithDialogId",exports.VaultDepositAndWithdrawWithSheetId="VaultDepositAndWithdrawWithSheetId",exports.VaultDepositAndWithdraw=t=>{let[o,e]=Q.useState(t.activeTab||"deposit"),{vaultId:r}=t,{t:a}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Tabs,{value:o,onValueChange:e,variant:"contained",size:"lg",classNames:{tabsList:"oui-px-0",tabsContent:"oui-pt-5"},children:[jsxRuntime.jsx(orderlyUi.TabPanel,{title:a("common.deposit"),icon:jsxRuntime.jsx(orderlyUi.ArrowDownSquareFillIcon,{}),value:"deposit",children:jsxRuntime.jsx(exports.VaultDepositWidget,{vaultId:r})}),jsxRuntime.jsx(orderlyUi.TabPanel,{title:a("common.withdraw"),icon:jsxRuntime.jsx(orderlyUi.ArrowUpSquareFillIcon,{}),value:"withdraw",children:jsxRuntime.jsx(exports.VaultWithdrawWidget,{vaultId:r})})]})};orderlyUi.registerSimpleDialog(exports.VaultDepositAndWithdrawWithDialogId,exports.VaultDepositAndWithdraw,{size:"md",classNames:{content:"oui-border oui-border-line-6"}});orderlyUi.registerSimpleSheet(exports.VaultDepositAndWithdrawWithSheetId,exports.VaultDepositAndWithdraw);});exports.ORDERLY_ICON = void 0;exports.ORDERLY_VAULT_TITLE = void 0;exports.ORDERLY_VAULT_DESCRIPTION = void 0;var zt=n(()=>{exports.ORDERLY_ICON="https://oss.orderly.network/static/symbol_logo/ORDER.png",exports.ORDERLY_VAULT_TITLE="Orderly OmniVault",exports.ORDERLY_VAULT_DESCRIPTION="Earn passive yields effortlessly, no trading expertise required. OmniVault deploys market-making strategies, taking on liquidations, and accrue platform fees.";});exports.useVaultCardScript = void 0;var Qt=n(()=>{ct();dt();$();Ht();zt();exports.useVaultCardScript=t=>{let{t:o}=orderlyI18n.useTranslation(),e=exports.useVaultLpInfoById(t.vault_id),{fetchVaultLpInfo:r}=exports.useVaultsStore(),a=orderlyHooks.useGetEnv(),{isMobile:s}=orderlyUi.useScreen(),{state:i}=orderlyHooks.useAccount(),u=X(),{holding:m}=orderlyHooks.useCollateral(),h=Q.useMemo(()=>m?.find(p=>p.token==="USDC")?.holding||0,[m]);Q.useEffect(()=>{!i.address||!u||!t.vault_id||r({vault_id:t.vault_id,wallet_address:i.address},u);},[t.vault_id,i.address,u]);let l=Q.useMemo(()=>h,[h]),v=Q.useMemo(()=>{let p=e?.[0];return p?{deposits:p.lp_tvl-p.potential_pnl,earnings:p.potential_pnl}:{deposits:"--",earnings:"--"}},[e]),P=Q.useMemo(()=>i.chainNamespace==="EVM",[i.chainNamespace]),f=Q.useMemo(()=>i.chainNamespace==="SOL",[i.chainNamespace]),I=Q.useMemo(()=>i.chainNamespace!=="EVM"&&i.chainNamespace!=="SOL"&&i.accountId!==i.mainAccountId,[i.chainNamespace,i.accountId,i.mainAccountId]),C=p=>{orderlyUi.modal.show(s?exports.VaultDepositAndWithdrawWithSheetId:exports.VaultDepositAndWithdrawWithDialogId,{activeTab:p,vaultId:t.vault_id});},x=()=>{let p=oe[a];window.open(`${p}/vaults`,"_blank");};return {title:o("vaults.card.orderly.title"),description:o("vaults.card.orderly.description"),icon:exports.ORDERLY_ICON,vaultInfo:t,lpInfo:v,isEVMConnected:P,isSOLConnected:f,openDepositAndWithdraw:C,availableBalance:l,openVaultWebsite:x,isWrongNetwork:I}};});exports.VaultCard = void 0;var fo,Gt,ra,Kt=n(()=>{exports.VaultCard=t=>{let{title:o,vaultInfo:e,lpInfo:r,description:a,isEVMConnected:s,isSOLConnected:i,openDepositAndWithdraw:u,availableBalance:m,openVaultWebsite:h}=t,{t:l}=orderlyI18n.useTranslation(),{isMobile:v}=orderlyUi.useScreen(),P=Q.useMemo(()=>jsxRuntime.jsx("div",{className:"oui-flex oui-items-center",children:e.supported_chains.map((f,I)=>jsxRuntime.jsx("img",{src:`https://oss.orderly.network/static/network_logo/${f.chain_id}.png`,alt:f.chain_id,className:orderlyUi.cn("oui-relative",v?"oui-size-[18px]":"oui-size-5"),style:{marginLeft:I>0?"-4px":"0",zIndex:e.supported_chains.length-I}},f.chain_id))}),[e.supported_chains]);return jsxRuntime.jsxs("div",{className:"oui-relative oui-h-[388px] oui-overflow-hidden oui-rounded-2xl oui-border oui-border-solid oui-border-white/[0.12] oui-bg-base-9",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:"100%",height:"180px",backdropFilter:"blur(2px)",zIndex:1,background:"linear-gradient(180deg, rgba(44, 5, 69, 0.80) 0%, rgba(19, 21, 25, 0.80) 63.46%, #131519 100%)"}}),jsxRuntime.jsx("img",{src:"/vaults/orderly_vault_card_bg.png",alt:"",style:{position:"absolute",top:0,right:0,width:"100%",height:"180px",zIndex:0}}),jsxRuntime.jsxs("div",{className:"oui-absolute oui-left-0 oui-top-0 oui-z-20 oui-flex oui-flex-col oui-gap-3 oui-p-6",children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-gap-2",children:[jsxRuntime.jsx("img",{src:"https://oss.orderly.network/static/symbol_logo/ORDER.png",alt:"",className:"oui-size-8"}),jsxRuntime.jsx("div",{className:"oui-text-[18px] oui-font-semibold oui-text-white",children:o}),P,jsxRuntime.jsx("div",{className:"oui-z-50 oui-ml-auto oui-cursor-pointer",onClick:h,children:jsxRuntime.jsx(orderlyUi.ArrowRightUpSquareFillIcon,{color:"white",width:18,height:18,viewBox:"0 0 18 18"})})]}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-font-normal oui-leading-[18px] oui-text-base-contrast-54",children:a}),jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-gap-2",children:[jsxRuntime.jsx(fo,{label:l("vaults.card.tvl"),value:e.tvl,textProps:{currency:"$",dp:0,type:"numeral"}}),jsxRuntime.jsx(fo,{label:l("vaults.card.apy"),value:(e["30d_apy"]*100).toFixed(2)+"%",textProps:{color:"brand",type:"gradient"}})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-flex oui-flex-col oui-items-center oui-gap-2 oui-rounded-lg oui-bg-white/[0.06] oui-p-3",children:[jsxRuntime.jsx(Gt,{label:l("vaults.card.myDeposits"),value:r.deposits}),jsxRuntime.jsx(Gt,{label:l("vaults.card.myEarnings"),value:r.earnings})]}),jsxRuntime.jsx(Gt,{label:l("vaults.card.accountBalance"),value:m}),jsxRuntime.jsx(ra,{isEVMConnected:s,isSOLConnected:i,openDepositAndWithdraw:u})]})]})},fo=t=>{let{label:o,value:e,textProps:r}=t;return jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-flex oui-flex-1 oui-flex-col oui-items-center oui-justify-center oui-px-3 oui-py-2","oui-rounded-lg oui-border oui-border-solid oui-border-white/[0.12]"),children:[jsxRuntime.jsx("div",{className:"oui-text-2xs oui-font-normal oui-leading-[18px] oui-text-base-contrast-54",children:o}),r.type==="gradient"?jsxRuntime.jsx(orderlyUi.Text.gradient,{className:"oui-text-base oui-font-semibold",...r,children:e}):jsxRuntime.jsx(orderlyUi.Text.numeral,{className:"oui-text-base oui-font-semibold",...r,children:e})]})},Gt=t=>{let{label:o,value:e,textProps:r}=t;return jsxRuntime.jsxs("div",{className:"oui-flex oui-w-full oui-items-center oui-justify-between oui-text-2xs oui-font-normal",children:[jsxRuntime.jsx("div",{className:"oui-text-base-contrast-54",children:o}),jsxRuntime.jsx(orderlyUi.Text.numeral,{className:"oui-text-base-contrast-80",...r,dp:2,suffix:jsxRuntime.jsx("span",{className:"oui-ml-1 oui-text-base-contrast-36",children:"USDC"}),children:e})]})},ra=t=>{let{isEVMConnected:o,isSOLConnected:e,openDepositAndWithdraw:r}=t,{t:a}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{buttonProps:{size:"md",fullWidth:true},children:o||e?jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center oui-gap-2",children:[jsxRuntime.jsx(orderlyUi.Button,{className:"oui-flex-1",size:"md",onClick:()=>r("deposit"),children:a("common.deposit")}),jsxRuntime.jsx(orderlyUi.Button,{className:"oui-flex-1",size:"md",color:"secondary",onClick:()=>r("withdraw"),children:a("common.withdraw")})]}):jsxRuntime.jsx(orderlyUi.Button,{size:"md",color:"warning",children:a("connector.wrongNetwork")})})};});exports.VaultCardWidget = void 0;var xo=n(()=>{Qt();Kt();exports.VaultCardWidget=t=>{let{vault:o}=t,e=exports.useVaultCardScript(o);return jsxRuntime.jsx(exports.VaultCard,{...e})};});var ut=n(()=>{xo();Qt();Kt();zt();});exports.AllVaultsDesktop = void 0;var Zt=n(()=>{ut();exports.AllVaultsDesktop=t=>{let{vaults:o}=t,{t:e}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col oui-gap-6",children:[jsxRuntime.jsx("div",{className:"oui-text-xl oui-font-normal oui-text-base-contrast",children:e("vaults.allVaults")}),jsxRuntime.jsx("div",{className:"oui-grid oui-grid-cols-3 oui-gap-4 min-[1024px]:oui-grid-cols-3",children:o.map(r=>jsxRuntime.jsx(exports.VaultCardWidget,{vault:r},r.vault_id))})]})};});var yo,Io=n(()=>{ut();yo=t=>{let{vaults:o}=t;return jsxRuntime.jsx("div",{className:"oui-flex oui-flex-col oui-gap-3",children:o.map(e=>jsxRuntime.jsx(exports.VaultCardWidget,{vault:e},e.vault_id))})};});exports.AllVaultsWidget = void 0;var wo=n(()=>{$();Zt();Io();exports.AllVaultsWidget=()=>{let{data:t}=exports.useVaultInfoState(),{isMobile:o}=orderlyUi.useScreen();return o?jsxRuntime.jsx(yo,{vaults:t}):jsxRuntime.jsx(exports.AllVaultsDesktop,{vaults:t})};});var Po={};pt(Po,{AllVaultsDesktop:()=>exports.AllVaultsDesktop,AllVaultsWidget:()=>exports.AllVaultsWidget});var jt=n(()=>{wo();Zt();});dt();F();var le=t=>{let o=X(),{fetchVaultInfo:e,setVaultsPageConfig:r}=exports.useVaultsStore();return Q.useEffect(()=>{t.config&&r(t.config);},[t.config]),Q.useEffect(()=>{o&&e(o);},[o]),jsxRuntime.jsx("div",{children:t.children})};var pa=Q__default.default.lazy(()=>Promise.resolve().then(()=>(It(),ve)).then(t=>({default:t.VaultsHeaderWidget}))),ca=Q__default.default.lazy(()=>Promise.resolve().then(()=>(wt(),Pe)).then(t=>({default:t.VaultsIntroductionWidget}))),da=Q__default.default.lazy(()=>Promise.resolve().then(()=>(jt(),Po)).then(t=>({default:t.AllVaultsWidget}))),hu=t=>{let{isMobile:o}=orderlyUi.useScreen();return jsxRuntime.jsx(le,{...t,children:jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-relative oui-min-h-screen ","oui-bg-base-10",o?"oui-px-3 oui-py-6":"oui-px-6 oui-py-12",t?.className),children:jsxRuntime.jsxs("div",{id:"vaults-content",className:orderlyUi.cn("oui-mx-auto oui-flex oui-max-w-[1200px] oui-flex-col",o?"oui-gap-6":"oui-gap-12"),children:[jsxRuntime.jsx(Q__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(pa,{})}),jsxRuntime.jsx(Q__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(ca,{})}),jsxRuntime.jsx(Q__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(da,{})})]})})})};T();ft();F();jt();ut();It();wt();Ht();Wt();qt();Ct();Ft();
|
|
19
|
+
var __defProp = Object.defineProperty;
|
|
20
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
21
|
+
var __esm = (fn, res) => function __init() {
|
|
22
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
23
|
+
};
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
// src/api/env.ts
|
|
30
|
+
var VAULTS_API_URLS, VAULTS_WEBSITE_URLS;
|
|
31
|
+
var init_env = __esm({
|
|
32
|
+
"src/api/env.ts"() {
|
|
33
|
+
VAULTS_API_URLS = {
|
|
34
|
+
prod: "https://api-sv.orderly.org",
|
|
35
|
+
staging: "https://testnet-api-sv.orderly.org",
|
|
36
|
+
qa: "https://qa-api-sv-aliyun.orderly.org",
|
|
37
|
+
dev: "https://dev-api-sv.orderly.org"
|
|
38
|
+
};
|
|
39
|
+
VAULTS_WEBSITE_URLS = {
|
|
40
|
+
prod: "https://app.orderly.network",
|
|
41
|
+
staging: "https://staging-app.orderly.network",
|
|
42
|
+
qa: "https://qa-app.orderly.network",
|
|
43
|
+
dev: "https://dev-app.orderly.network"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
function useSVApiUrl() {
|
|
48
|
+
const env = orderlyHooks.useGetEnv();
|
|
49
|
+
const apiUrl = React.useMemo(() => {
|
|
50
|
+
return VAULTS_API_URLS[env];
|
|
51
|
+
}, [env]);
|
|
52
|
+
return apiUrl;
|
|
53
|
+
}
|
|
54
|
+
var init_useSVAPIUrl = __esm({
|
|
55
|
+
"src/hooks/useSVAPIUrl.ts"() {
|
|
56
|
+
init_env();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// src/api/request.ts
|
|
61
|
+
function buildQueryString(params) {
|
|
62
|
+
const filteredParams = filterUndefinedParams(params);
|
|
63
|
+
const searchParams = new URLSearchParams();
|
|
64
|
+
Object.entries(filteredParams).forEach(([key, value]) => {
|
|
65
|
+
if (value !== null && value !== void 0) {
|
|
66
|
+
searchParams.append(key, String(value));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return searchParams.toString();
|
|
70
|
+
}
|
|
71
|
+
function filterUndefinedParams(params) {
|
|
72
|
+
const filtered = {};
|
|
73
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
74
|
+
if (value !== void 0 && value !== null) {
|
|
75
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
76
|
+
filtered[key] = value;
|
|
77
|
+
} else if (typeof value === "object" && value !== null) {
|
|
78
|
+
const objEntries = Object.entries(value);
|
|
79
|
+
objEntries.forEach(([objKey, objValue]) => {
|
|
80
|
+
if (objValue !== void 0 && objValue !== null && (typeof objValue === "string" || typeof objValue === "number" || typeof objValue === "boolean")) {
|
|
81
|
+
filtered[objKey] = objValue;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return filtered;
|
|
88
|
+
}
|
|
89
|
+
function appendQueryParams(url, params) {
|
|
90
|
+
if (!params || Object.keys(params).length === 0) {
|
|
91
|
+
return url;
|
|
92
|
+
}
|
|
93
|
+
const queryString = buildQueryString(params);
|
|
94
|
+
if (!queryString) {
|
|
95
|
+
return url;
|
|
96
|
+
}
|
|
97
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
98
|
+
return `${url}${separator}${queryString}`;
|
|
99
|
+
}
|
|
100
|
+
var VaultsApiError, RequestClient, defaultClient, request_default;
|
|
101
|
+
var init_request = __esm({
|
|
102
|
+
"src/api/request.ts"() {
|
|
103
|
+
VaultsApiError = class extends Error {
|
|
104
|
+
constructor(message, code, status, response) {
|
|
105
|
+
super(message);
|
|
106
|
+
this.code = code;
|
|
107
|
+
this.status = status;
|
|
108
|
+
this.response = response;
|
|
109
|
+
this.name = "VaultsApiError";
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
RequestClient = class {
|
|
113
|
+
constructor() {
|
|
114
|
+
this.requestInterceptors = [];
|
|
115
|
+
this.responseInterceptors = [];
|
|
116
|
+
this.defaultConfig = {
|
|
117
|
+
timeout: 1e4,
|
|
118
|
+
retry: 3,
|
|
119
|
+
retryDelay: 1e3,
|
|
120
|
+
validateStatus: (status) => status >= 200 && status < 300,
|
|
121
|
+
// mode: 'cors',
|
|
122
|
+
// credentials: 'include',
|
|
123
|
+
headers: {
|
|
124
|
+
"Content-Type": "application/json"
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Add request interceptor
|
|
129
|
+
addRequestInterceptor(interceptor) {
|
|
130
|
+
this.requestInterceptors.push(interceptor);
|
|
131
|
+
}
|
|
132
|
+
// Add response interceptor
|
|
133
|
+
addResponseInterceptor(interceptor) {
|
|
134
|
+
this.responseInterceptors.push(interceptor);
|
|
135
|
+
}
|
|
136
|
+
// Create timeout controller
|
|
137
|
+
createTimeoutController(timeout) {
|
|
138
|
+
const controller = new AbortController();
|
|
139
|
+
setTimeout(() => controller.abort(), timeout);
|
|
140
|
+
return controller;
|
|
141
|
+
}
|
|
142
|
+
// Merge headers
|
|
143
|
+
mergeHeaders(defaultHeaders = {}, customHeaders = {}) {
|
|
144
|
+
return {
|
|
145
|
+
...defaultHeaders,
|
|
146
|
+
...customHeaders
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Sleep utility for retry delay
|
|
150
|
+
sleep(ms) {
|
|
151
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
152
|
+
}
|
|
153
|
+
// Main request method
|
|
154
|
+
async request(url, config = {}) {
|
|
155
|
+
const finalConfig = {
|
|
156
|
+
...this.defaultConfig,
|
|
157
|
+
...config,
|
|
158
|
+
headers: this.mergeHeaders(this.defaultConfig.headers, config.headers)
|
|
159
|
+
};
|
|
160
|
+
let processedConfig = finalConfig;
|
|
161
|
+
for (const interceptor of this.requestInterceptors) {
|
|
162
|
+
processedConfig = await interceptor(processedConfig);
|
|
163
|
+
}
|
|
164
|
+
let fullUrl = url;
|
|
165
|
+
if (typeof url === "string" && !url.startsWith("http") && processedConfig.baseURL) {
|
|
166
|
+
fullUrl = `${processedConfig.baseURL}${url.startsWith("/") ? "" : "/"}${url}`;
|
|
167
|
+
}
|
|
168
|
+
if (processedConfig.params) {
|
|
169
|
+
fullUrl = typeof fullUrl === "string" ? appendQueryParams(fullUrl, processedConfig.params) : fullUrl;
|
|
170
|
+
}
|
|
171
|
+
let timeoutController;
|
|
172
|
+
if (processedConfig.timeout && processedConfig.timeout > 0) {
|
|
173
|
+
timeoutController = this.createTimeoutController(processedConfig.timeout);
|
|
174
|
+
processedConfig.signal = timeoutController.signal;
|
|
175
|
+
}
|
|
176
|
+
const {
|
|
177
|
+
retry = 0,
|
|
178
|
+
retryDelay = 1e3,
|
|
179
|
+
validateStatus,
|
|
180
|
+
params,
|
|
181
|
+
baseURL,
|
|
182
|
+
timeout,
|
|
183
|
+
data,
|
|
184
|
+
method,
|
|
185
|
+
...fetchOptions
|
|
186
|
+
} = processedConfig;
|
|
187
|
+
const finalFetchOptions = {
|
|
188
|
+
...fetchOptions,
|
|
189
|
+
method
|
|
190
|
+
};
|
|
191
|
+
if (data !== void 0) {
|
|
192
|
+
finalFetchOptions.body = typeof data === "string" ? data : JSON.stringify(data);
|
|
193
|
+
}
|
|
194
|
+
let lastError;
|
|
195
|
+
for (let attempt = 0; attempt <= retry; attempt++) {
|
|
196
|
+
try {
|
|
197
|
+
const response = await fetch(fullUrl, finalFetchOptions);
|
|
198
|
+
if (!validateStatus(response.status)) {
|
|
199
|
+
let errorMessage = response.statusText;
|
|
200
|
+
let errorCode;
|
|
201
|
+
try {
|
|
202
|
+
const errorData = await response.json();
|
|
203
|
+
errorMessage = errorData.message || errorData.code || errorMessage;
|
|
204
|
+
errorCode = errorData.code;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
throw new VaultsApiError(
|
|
208
|
+
errorMessage,
|
|
209
|
+
errorCode,
|
|
210
|
+
response.status,
|
|
211
|
+
response
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
let responseData;
|
|
215
|
+
try {
|
|
216
|
+
responseData = await response.json();
|
|
217
|
+
} catch {
|
|
218
|
+
throw new VaultsApiError(
|
|
219
|
+
"Invalid JSON response",
|
|
220
|
+
"PARSE_ERROR",
|
|
221
|
+
response.status,
|
|
222
|
+
response
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
let processedData = responseData;
|
|
226
|
+
for (const interceptor of this.responseInterceptors) {
|
|
227
|
+
processedData = await interceptor(response, processedData);
|
|
228
|
+
}
|
|
229
|
+
if (typeof processedData === "object" && processedData !== null) {
|
|
230
|
+
if ("success" in processedData) {
|
|
231
|
+
const apiResponse = processedData;
|
|
232
|
+
if (apiResponse.success) {
|
|
233
|
+
return apiResponse.data;
|
|
234
|
+
} else {
|
|
235
|
+
throw new VaultsApiError(
|
|
236
|
+
apiResponse.message || "API request failed",
|
|
237
|
+
apiResponse.code,
|
|
238
|
+
response.status,
|
|
239
|
+
response
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return processedData;
|
|
245
|
+
} catch (error) {
|
|
246
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
247
|
+
if (error instanceof VaultsApiError || error?.name === "AbortError" || attempt === retry) {
|
|
248
|
+
throw lastError;
|
|
249
|
+
}
|
|
250
|
+
if (attempt < retry) {
|
|
251
|
+
await this.sleep(retryDelay);
|
|
252
|
+
}
|
|
253
|
+
} finally {
|
|
254
|
+
timeoutController?.abort();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
throw lastError;
|
|
258
|
+
}
|
|
259
|
+
// Simplified HTTP methods - all accept a single config object
|
|
260
|
+
async get(url, config = {}) {
|
|
261
|
+
return this.request(url, { ...config, method: "GET" });
|
|
262
|
+
}
|
|
263
|
+
async post(url, config = {}) {
|
|
264
|
+
return this.request(url, { ...config, method: "POST" });
|
|
265
|
+
}
|
|
266
|
+
async put(url, config = {}) {
|
|
267
|
+
return this.request(url, { ...config, method: "PUT" });
|
|
268
|
+
}
|
|
269
|
+
async delete(url, config = {}) {
|
|
270
|
+
return this.request(url, { ...config, method: "DELETE" });
|
|
271
|
+
}
|
|
272
|
+
async patch(url, config = {}) {
|
|
273
|
+
return this.request(url, { ...config, method: "PATCH" });
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
defaultClient = new RequestClient();
|
|
277
|
+
request_default = defaultClient;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// src/api/api.ts
|
|
282
|
+
async function getVaultInfo(baseUrl, params) {
|
|
283
|
+
return request_default.get(
|
|
284
|
+
"/v1/public/strategy_vault/vault/info",
|
|
285
|
+
{
|
|
286
|
+
params,
|
|
287
|
+
baseURL: baseUrl
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
async function getVaultLpPerformance(baseUrl, params) {
|
|
292
|
+
return request_default.get(
|
|
293
|
+
"/v1/public/strategy_vault/vault/performance",
|
|
294
|
+
{
|
|
295
|
+
params,
|
|
296
|
+
baseURL: baseUrl
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
async function getVaultLpInfo(baseUrl, params) {
|
|
301
|
+
return request_default.get(
|
|
302
|
+
"/v1/public/strategy_vault/lp/info",
|
|
303
|
+
{
|
|
304
|
+
params,
|
|
305
|
+
baseURL: baseUrl
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
async function getVaultOverallInfo(baseUrl, params) {
|
|
310
|
+
return request_default.get(
|
|
311
|
+
"/v1/public/strategy_vault/vault/overall_info",
|
|
312
|
+
{
|
|
313
|
+
params,
|
|
314
|
+
baseURL: baseUrl
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
var init_api = __esm({
|
|
319
|
+
"src/api/api.ts"() {
|
|
320
|
+
init_request();
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
exports.useVaultsStore = void 0; exports.useVaultInfoState = void 0; exports.useVaultLpPerformanceState = void 0; exports.useVaultLpInfoState = void 0; exports.useVaultOverallInfoState = void 0; exports.useVaultInfoActions = void 0; exports.useVaultLpPerformanceActions = void 0; exports.useVaultLpInfoActions = void 0; exports.useVaultOverallInfoActions = void 0; exports.useVaultLpPerformanceById = void 0; exports.useVaultLpInfoById = void 0; exports.useVaultLpPerformanceIds = void 0; exports.useVaultLpInfoIds = void 0; exports.useVaultLpPerformanceArray = void 0; exports.useVaultLpInfoArray = void 0;
|
|
324
|
+
var init_vaultsStore = __esm({
|
|
325
|
+
"src/store/vaultsStore.ts"() {
|
|
326
|
+
init_api();
|
|
327
|
+
exports.useVaultsStore = zustand.create((set, get) => ({
|
|
328
|
+
// Initial state
|
|
329
|
+
baseUrl: "",
|
|
330
|
+
vaultInfo: {
|
|
331
|
+
data: [],
|
|
332
|
+
loading: false,
|
|
333
|
+
error: null,
|
|
334
|
+
lastUpdated: null,
|
|
335
|
+
params: null
|
|
336
|
+
},
|
|
337
|
+
vaultLpPerformance: {
|
|
338
|
+
data: {},
|
|
339
|
+
loading: false,
|
|
340
|
+
error: null,
|
|
341
|
+
lastUpdated: null,
|
|
342
|
+
params: null
|
|
343
|
+
},
|
|
344
|
+
vaultLpInfo: {
|
|
345
|
+
data: {},
|
|
346
|
+
loading: false,
|
|
347
|
+
error: null,
|
|
348
|
+
lastUpdated: null,
|
|
349
|
+
params: null
|
|
350
|
+
},
|
|
351
|
+
vaultOverallInfo: {
|
|
352
|
+
data: null,
|
|
353
|
+
loading: false,
|
|
354
|
+
error: null,
|
|
355
|
+
lastUpdated: null,
|
|
356
|
+
params: null
|
|
357
|
+
},
|
|
358
|
+
vaultsPageConfig: null,
|
|
359
|
+
// Set base URL
|
|
360
|
+
setBaseUrl: (baseUrl) => {
|
|
361
|
+
set({ baseUrl });
|
|
362
|
+
},
|
|
363
|
+
// Vault info actions
|
|
364
|
+
fetchVaultInfo: async (params, baseUrl) => {
|
|
365
|
+
const state = get();
|
|
366
|
+
const url = baseUrl || state.baseUrl;
|
|
367
|
+
if (!url) {
|
|
368
|
+
set((state2) => ({
|
|
369
|
+
vaultInfo: {
|
|
370
|
+
...state2.vaultInfo,
|
|
371
|
+
error: "Base URL is required"
|
|
372
|
+
}
|
|
373
|
+
}));
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
set((state2) => ({
|
|
377
|
+
baseUrl: baseUrl || state2.baseUrl,
|
|
378
|
+
vaultInfo: {
|
|
379
|
+
...state2.vaultInfo,
|
|
380
|
+
loading: true,
|
|
381
|
+
error: null,
|
|
382
|
+
params: params || null
|
|
383
|
+
}
|
|
384
|
+
}));
|
|
385
|
+
try {
|
|
386
|
+
const response = await getVaultInfo(url, params);
|
|
387
|
+
set((state2) => ({
|
|
388
|
+
vaultInfo: {
|
|
389
|
+
...state2.vaultInfo,
|
|
390
|
+
data: response.rows,
|
|
391
|
+
loading: false,
|
|
392
|
+
error: null,
|
|
393
|
+
lastUpdated: Date.now()
|
|
394
|
+
}
|
|
395
|
+
}));
|
|
396
|
+
} catch (error) {
|
|
397
|
+
set((state2) => ({
|
|
398
|
+
vaultInfo: {
|
|
399
|
+
...state2.vaultInfo,
|
|
400
|
+
loading: false,
|
|
401
|
+
error: error instanceof Error ? error.message : "Failed to fetch vault info"
|
|
402
|
+
}
|
|
403
|
+
}));
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
refreshVaultInfo: async () => {
|
|
407
|
+
const state = get();
|
|
408
|
+
if (state.vaultInfo.lastUpdated && state.baseUrl) {
|
|
409
|
+
await state.fetchVaultInfo(state.vaultInfo.params || void 0);
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
// Vault LP performance actions
|
|
413
|
+
fetchVaultLpPerformance: async (params, baseUrl) => {
|
|
414
|
+
const state = get();
|
|
415
|
+
const url = baseUrl || state.baseUrl;
|
|
416
|
+
if (!url) {
|
|
417
|
+
set((state2) => ({
|
|
418
|
+
vaultLpPerformance: {
|
|
419
|
+
...state2.vaultLpPerformance,
|
|
420
|
+
error: "Base URL is required"
|
|
421
|
+
}
|
|
422
|
+
}));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
set((state2) => ({
|
|
426
|
+
baseUrl: baseUrl || state2.baseUrl,
|
|
427
|
+
vaultLpPerformance: {
|
|
428
|
+
...state2.vaultLpPerformance,
|
|
429
|
+
loading: true,
|
|
430
|
+
error: null,
|
|
431
|
+
params
|
|
432
|
+
}
|
|
433
|
+
}));
|
|
434
|
+
try {
|
|
435
|
+
const response = await getVaultLpPerformance(
|
|
436
|
+
url,
|
|
437
|
+
params
|
|
438
|
+
);
|
|
439
|
+
set((state2) => ({
|
|
440
|
+
vaultLpPerformance: {
|
|
441
|
+
...state2.vaultLpPerformance,
|
|
442
|
+
data: {
|
|
443
|
+
...state2.vaultLpPerformance.data,
|
|
444
|
+
[params.vault_id]: response.rows
|
|
445
|
+
},
|
|
446
|
+
loading: false,
|
|
447
|
+
error: null,
|
|
448
|
+
lastUpdated: Date.now()
|
|
449
|
+
}
|
|
450
|
+
}));
|
|
451
|
+
} catch (error) {
|
|
452
|
+
set((state2) => ({
|
|
453
|
+
vaultLpPerformance: {
|
|
454
|
+
...state2.vaultLpPerformance,
|
|
455
|
+
loading: false,
|
|
456
|
+
error: error instanceof Error ? error.message : "Failed to fetch vault LP performance"
|
|
457
|
+
}
|
|
458
|
+
}));
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
refreshVaultLpPerformance: async () => {
|
|
462
|
+
const state = get();
|
|
463
|
+
if (state.vaultLpPerformance.lastUpdated && state.vaultLpPerformance.params && state.baseUrl) {
|
|
464
|
+
await state.fetchVaultLpPerformance(state.vaultLpPerformance.params);
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
// Vault LP info actions
|
|
468
|
+
fetchVaultLpInfo: async (params, baseUrl) => {
|
|
469
|
+
const state = get();
|
|
470
|
+
const url = baseUrl || state.baseUrl;
|
|
471
|
+
if (!url) {
|
|
472
|
+
set((state2) => ({
|
|
473
|
+
vaultLpInfo: {
|
|
474
|
+
...state2.vaultLpInfo,
|
|
475
|
+
error: "Base URL is required"
|
|
476
|
+
}
|
|
477
|
+
}));
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
set((state2) => ({
|
|
481
|
+
baseUrl: baseUrl || state2.baseUrl,
|
|
482
|
+
vaultLpInfo: {
|
|
483
|
+
...state2.vaultLpInfo,
|
|
484
|
+
loading: true,
|
|
485
|
+
error: null,
|
|
486
|
+
params
|
|
487
|
+
}
|
|
488
|
+
}));
|
|
489
|
+
try {
|
|
490
|
+
const response = await getVaultLpInfo(url, params);
|
|
491
|
+
set((state2) => ({
|
|
492
|
+
vaultLpInfo: {
|
|
493
|
+
...state2.vaultLpInfo,
|
|
494
|
+
data: {
|
|
495
|
+
...state2.vaultLpInfo.data,
|
|
496
|
+
[params.vault_id]: response.rows
|
|
497
|
+
},
|
|
498
|
+
loading: false,
|
|
499
|
+
error: null,
|
|
500
|
+
lastUpdated: Date.now()
|
|
501
|
+
}
|
|
502
|
+
}));
|
|
503
|
+
} catch (error) {
|
|
504
|
+
set((state2) => ({
|
|
505
|
+
vaultLpInfo: {
|
|
506
|
+
...state2.vaultLpInfo,
|
|
507
|
+
loading: false,
|
|
508
|
+
error: error instanceof Error ? error.message : "Failed to fetch vault LP info"
|
|
509
|
+
}
|
|
510
|
+
}));
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
refreshVaultLpInfo: async () => {
|
|
514
|
+
const state = get();
|
|
515
|
+
if (state.vaultLpInfo.lastUpdated && state.vaultLpInfo.params && state.baseUrl) {
|
|
516
|
+
await state.fetchVaultLpInfo(state.vaultLpInfo.params);
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
// Vault overall info actions
|
|
520
|
+
fetchVaultOverallInfo: async (params, baseUrl) => {
|
|
521
|
+
const state = get();
|
|
522
|
+
const url = baseUrl || state.baseUrl;
|
|
523
|
+
if (!url) {
|
|
524
|
+
set((state2) => ({
|
|
525
|
+
vaultOverallInfo: {
|
|
526
|
+
...state2.vaultOverallInfo,
|
|
527
|
+
error: "Base URL is required"
|
|
528
|
+
}
|
|
529
|
+
}));
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
set((state2) => ({
|
|
533
|
+
baseUrl: baseUrl || state2.baseUrl,
|
|
534
|
+
vaultOverallInfo: {
|
|
535
|
+
...state2.vaultOverallInfo,
|
|
536
|
+
loading: true,
|
|
537
|
+
error: null,
|
|
538
|
+
params: params || null
|
|
539
|
+
}
|
|
540
|
+
}));
|
|
541
|
+
try {
|
|
542
|
+
const response = await getVaultOverallInfo(
|
|
543
|
+
url,
|
|
544
|
+
params
|
|
545
|
+
);
|
|
546
|
+
set((state2) => ({
|
|
547
|
+
vaultOverallInfo: {
|
|
548
|
+
...state2.vaultOverallInfo,
|
|
549
|
+
data: response,
|
|
550
|
+
loading: false,
|
|
551
|
+
error: null,
|
|
552
|
+
lastUpdated: Date.now()
|
|
553
|
+
}
|
|
554
|
+
}));
|
|
555
|
+
} catch (error) {
|
|
556
|
+
set((state2) => ({
|
|
557
|
+
vaultOverallInfo: {
|
|
558
|
+
...state2.vaultOverallInfo,
|
|
559
|
+
loading: false,
|
|
560
|
+
error: error instanceof Error ? error.message : "Failed to fetch vault overall info"
|
|
561
|
+
}
|
|
562
|
+
}));
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
refreshVaultOverallInfo: async () => {
|
|
566
|
+
const state = get();
|
|
567
|
+
if (state.vaultOverallInfo.lastUpdated && state.baseUrl) {
|
|
568
|
+
await state.fetchVaultOverallInfo(
|
|
569
|
+
state.vaultOverallInfo.params || void 0
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
setVaultsPageConfig: (config) => {
|
|
574
|
+
set({ vaultsPageConfig: config });
|
|
575
|
+
}
|
|
576
|
+
}));
|
|
577
|
+
exports.useVaultInfoState = () => exports.useVaultsStore((state) => state.vaultInfo);
|
|
578
|
+
exports.useVaultLpPerformanceState = () => exports.useVaultsStore((state) => state.vaultLpPerformance);
|
|
579
|
+
exports.useVaultLpInfoState = () => exports.useVaultsStore((state) => state.vaultLpInfo);
|
|
580
|
+
exports.useVaultOverallInfoState = () => exports.useVaultsStore((state) => state.vaultOverallInfo);
|
|
581
|
+
exports.useVaultInfoActions = () => exports.useVaultsStore((state) => ({
|
|
582
|
+
fetchVaultInfo: state.fetchVaultInfo,
|
|
583
|
+
refreshVaultInfo: state.refreshVaultInfo
|
|
584
|
+
}));
|
|
585
|
+
exports.useVaultLpPerformanceActions = () => exports.useVaultsStore((state) => ({
|
|
586
|
+
fetchVaultLpPerformance: state.fetchVaultLpPerformance,
|
|
587
|
+
refreshVaultLpPerformance: state.refreshVaultLpPerformance
|
|
588
|
+
}));
|
|
589
|
+
exports.useVaultLpInfoActions = () => exports.useVaultsStore((state) => ({
|
|
590
|
+
fetchVaultLpInfo: state.fetchVaultLpInfo,
|
|
591
|
+
refreshVaultLpInfo: state.refreshVaultLpInfo
|
|
592
|
+
}));
|
|
593
|
+
exports.useVaultOverallInfoActions = () => exports.useVaultsStore((state) => ({
|
|
594
|
+
fetchVaultOverallInfo: state.fetchVaultOverallInfo,
|
|
595
|
+
refreshVaultOverallInfo: state.refreshVaultOverallInfo
|
|
596
|
+
}));
|
|
597
|
+
exports.useVaultLpPerformanceById = (vaultId) => exports.useVaultsStore((state) => state.vaultLpPerformance.data[vaultId]);
|
|
598
|
+
exports.useVaultLpInfoById = (vaultId) => exports.useVaultsStore((state) => state.vaultLpInfo.data[vaultId]);
|
|
599
|
+
exports.useVaultLpPerformanceIds = () => exports.useVaultsStore((state) => Object.keys(state.vaultLpPerformance.data));
|
|
600
|
+
exports.useVaultLpInfoIds = () => exports.useVaultsStore((state) => Object.keys(state.vaultLpInfo.data));
|
|
601
|
+
exports.useVaultLpPerformanceArray = () => exports.useVaultsStore(
|
|
602
|
+
(state) => Object.values(state.vaultLpPerformance.data).flat()
|
|
603
|
+
);
|
|
604
|
+
exports.useVaultLpInfoArray = () => exports.useVaultsStore((state) => Object.values(state.vaultLpInfo.data).flat());
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// src/store/index.ts
|
|
609
|
+
var init_store = __esm({
|
|
610
|
+
"src/store/index.ts"() {
|
|
611
|
+
init_vaultsStore();
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
exports.VaultsHeaderDesktop = void 0;
|
|
615
|
+
var init_vaults_header_desktop = __esm({
|
|
616
|
+
"src/components/vaults-header/vaults-header.desktop.tsx"() {
|
|
617
|
+
exports.VaultsHeaderDesktop = (props) => {
|
|
618
|
+
const { supportVaults, headerImage, brokerName } = props;
|
|
619
|
+
const { t } = orderlyI18n.useTranslation();
|
|
620
|
+
const supportVaultsList = React.useMemo(() => {
|
|
621
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-items-center", children: supportVaults.map((chain, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
622
|
+
"img",
|
|
623
|
+
{
|
|
624
|
+
src: `https://oss.orderly.network/static/network_logo/${chain.chain_id}.png`,
|
|
625
|
+
alt: chain.chain_id,
|
|
626
|
+
className: "oui-relative oui-size-5",
|
|
627
|
+
style: {
|
|
628
|
+
marginLeft: index > 0 ? "-4px" : "0",
|
|
629
|
+
zIndex: supportVaults.length - index
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
chain.chain_id
|
|
633
|
+
)) });
|
|
634
|
+
}, [supportVaults]);
|
|
635
|
+
const headerImageElement = React.useMemo(() => {
|
|
636
|
+
if (typeof headerImage === "string") {
|
|
637
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
638
|
+
"img",
|
|
639
|
+
{
|
|
640
|
+
src: headerImage,
|
|
641
|
+
alt: "header",
|
|
642
|
+
className: "oui-bg-contain oui-bg-center oui-bg-no-repeat"
|
|
643
|
+
}
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
return headerImage;
|
|
647
|
+
}, [headerImage]);
|
|
648
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-justify-between", children: [
|
|
649
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-max-w-[726px] oui-flex-col", children: [
|
|
650
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1 oui-text-[18px] oui-font-normal oui-text-base-contrast-54", children: [
|
|
651
|
+
t("vaults.availableOn"),
|
|
652
|
+
" ",
|
|
653
|
+
supportVaultsList
|
|
654
|
+
] }),
|
|
655
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mb-6 oui-mt-8 oui-text-5xl oui-font-bold oui-leading-[44px] oui-text-base-contrast", children: t("vaults.header.title") }),
|
|
656
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xl oui-font-normal oui-text-base-contrast-54", children: t("vaults.header.description", { brokerName }) })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-h-[238px] oui-w-[360px]", children: headerImageElement })
|
|
659
|
+
] });
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
var VaultsHeaderMobile;
|
|
664
|
+
var init_vaults_header_mobile = __esm({
|
|
665
|
+
"src/components/vaults-header/vaults-header.mobile.tsx"() {
|
|
666
|
+
VaultsHeaderMobile = (props) => {
|
|
667
|
+
const { supportVaults, headerImage } = props;
|
|
668
|
+
const { t } = orderlyI18n.useTranslation();
|
|
669
|
+
const brokerName = orderlyHooks.useConfig("brokerName");
|
|
670
|
+
const supportVaultsList = React.useMemo(() => {
|
|
671
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-items-center", children: supportVaults.map((chain, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
672
|
+
"img",
|
|
673
|
+
{
|
|
674
|
+
src: `https://oss.orderly.network/static/network_logo/${chain.chain_id}.png`,
|
|
675
|
+
alt: chain.chain_id,
|
|
676
|
+
className: "oui-relative oui-size-[18px]",
|
|
677
|
+
style: {
|
|
678
|
+
marginLeft: index > 0 ? "-4px" : "0",
|
|
679
|
+
zIndex: supportVaults.length - index
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
chain.chain_id
|
|
683
|
+
)) });
|
|
684
|
+
}, [supportVaults]);
|
|
685
|
+
const headerImageElement = React.useMemo(() => {
|
|
686
|
+
if (typeof headerImage === "string") {
|
|
687
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
688
|
+
"img",
|
|
689
|
+
{
|
|
690
|
+
src: headerImage,
|
|
691
|
+
alt: "header",
|
|
692
|
+
className: "oui-bg-contain oui-bg-center oui-bg-no-repeat"
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
return headerImage;
|
|
697
|
+
}, [headerImage]);
|
|
698
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-relative", children: [
|
|
699
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col", children: [
|
|
700
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1 oui-text-2xs oui-font-semibold oui-text-base-contrast-54", children: [
|
|
701
|
+
t("vaults.availableOn"),
|
|
702
|
+
" ",
|
|
703
|
+
supportVaultsList
|
|
704
|
+
] }),
|
|
705
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mb-4 oui-mt-6 oui-min-h-[56px] oui-max-w-[calc(100%-187px)] oui-text-xl oui-font-bold oui-text-base-contrast", children: t("vaults.header.title") }),
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-max-w-[450px] oui-text-2xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.header.description", { brokerName }) })
|
|
707
|
+
] }),
|
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-absolute -oui-right-3 -oui-top-4 oui-h-[124px] oui-w-[187px]", children: headerImageElement })
|
|
709
|
+
] });
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
exports.useVaultsHeaderScript = void 0;
|
|
714
|
+
var init_vaults_header_script = __esm({
|
|
715
|
+
"src/components/vaults-header/vaults-header.script.ts"() {
|
|
716
|
+
init_store();
|
|
717
|
+
exports.useVaultsHeaderScript = () => {
|
|
718
|
+
const { vaultInfo, vaultsPageConfig } = exports.useVaultsStore();
|
|
719
|
+
const brokerName = orderlyHooks.useConfig("brokerName");
|
|
720
|
+
const supportVaults = React.useMemo(() => {
|
|
721
|
+
const array = [];
|
|
722
|
+
vaultInfo.data.forEach((vault) => {
|
|
723
|
+
array.push(...vault.supported_chains);
|
|
724
|
+
});
|
|
725
|
+
return ramda.uniqBy((item) => item.chain_id, array);
|
|
726
|
+
}, [vaultInfo.data]);
|
|
727
|
+
return {
|
|
728
|
+
supportVaults,
|
|
729
|
+
headerImage: vaultsPageConfig?.headerImage,
|
|
730
|
+
brokerName
|
|
731
|
+
};
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
exports.VaultsHeaderWidget = void 0;
|
|
736
|
+
var init_vaults_header_widget = __esm({
|
|
737
|
+
"src/components/vaults-header/vaults-header.widget.tsx"() {
|
|
738
|
+
init_vaults_header_desktop();
|
|
739
|
+
init_vaults_header_mobile();
|
|
740
|
+
init_vaults_header_script();
|
|
741
|
+
exports.VaultsHeaderWidget = () => {
|
|
742
|
+
const state = exports.useVaultsHeaderScript();
|
|
743
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
744
|
+
return isMobile ? /* @__PURE__ */ jsxRuntime.jsx(VaultsHeaderMobile, { ...state }) : /* @__PURE__ */ jsxRuntime.jsx(exports.VaultsHeaderDesktop, { ...state });
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// src/components/vaults-header/index.ts
|
|
750
|
+
var vaults_header_exports = {};
|
|
751
|
+
__export(vaults_header_exports, {
|
|
752
|
+
VaultsHeaderDesktop: () => exports.VaultsHeaderDesktop,
|
|
753
|
+
VaultsHeaderWidget: () => exports.VaultsHeaderWidget,
|
|
754
|
+
useVaultsHeaderScript: () => exports.useVaultsHeaderScript
|
|
755
|
+
});
|
|
756
|
+
var init_vaults_header = __esm({
|
|
757
|
+
"src/components/vaults-header/index.ts"() {
|
|
758
|
+
init_vaults_header_widget();
|
|
759
|
+
init_vaults_header_desktop();
|
|
760
|
+
init_vaults_header_script();
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
var VaultsIntroductionDesktop, VaultsIntroductionItem;
|
|
764
|
+
var init_vaults_introduction_desktop = __esm({
|
|
765
|
+
"src/components/vaults-introduction/vaults-introduction.desktop.tsx"() {
|
|
766
|
+
VaultsIntroductionDesktop = (props) => {
|
|
767
|
+
const { t } = orderlyI18n.useTranslation();
|
|
768
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
769
|
+
const { vaultsInfo } = props;
|
|
770
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
771
|
+
"div",
|
|
772
|
+
{
|
|
773
|
+
className: orderlyUi.cn(
|
|
774
|
+
"oui-flex oui-items-center ",
|
|
775
|
+
"oui-bg-gradient-to-b oui-from-[#26292E] oui-to-[#1B1D22]",
|
|
776
|
+
isMobile ? "oui-gap-3 oui-rounded-xl oui-p-3" : "oui-gap-6 oui-rounded-2xl oui-p-6"
|
|
777
|
+
),
|
|
778
|
+
children: [
|
|
779
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
780
|
+
VaultsIntroductionItem,
|
|
781
|
+
{
|
|
782
|
+
title: t("vaults.introduction.tvl"),
|
|
783
|
+
value: vaultsInfo.tvl,
|
|
784
|
+
textProps: { currency: "$" },
|
|
785
|
+
isMobile
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
789
|
+
orderlyUi.Divider,
|
|
790
|
+
{
|
|
791
|
+
direction: "vertical",
|
|
792
|
+
className: orderlyUi.cn(
|
|
793
|
+
"oui-bg-white/[0.12]",
|
|
794
|
+
isMobile ? "oui-h-[44px]" : "oui-h-[64px]"
|
|
795
|
+
)
|
|
796
|
+
}
|
|
797
|
+
),
|
|
798
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
799
|
+
VaultsIntroductionItem,
|
|
800
|
+
{
|
|
801
|
+
title: t("common.vaults"),
|
|
802
|
+
value: vaultsInfo.vaultsCount,
|
|
803
|
+
isMobile
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
807
|
+
orderlyUi.Divider,
|
|
808
|
+
{
|
|
809
|
+
direction: "vertical",
|
|
810
|
+
className: orderlyUi.cn(
|
|
811
|
+
"oui-bg-white/[0.12]",
|
|
812
|
+
isMobile ? "oui-h-[44px]" : "oui-h-[64px]"
|
|
813
|
+
)
|
|
814
|
+
}
|
|
815
|
+
),
|
|
816
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
817
|
+
VaultsIntroductionItem,
|
|
818
|
+
{
|
|
819
|
+
title: t("vaults.introduction.depositors"),
|
|
820
|
+
value: vaultsInfo.lpCount,
|
|
821
|
+
isMobile
|
|
822
|
+
}
|
|
823
|
+
)
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
);
|
|
827
|
+
};
|
|
828
|
+
VaultsIntroductionItem = (props) => {
|
|
829
|
+
const { title, value, textProps, isMobile } = props;
|
|
830
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
831
|
+
"div",
|
|
832
|
+
{
|
|
833
|
+
className: orderlyUi.cn(
|
|
834
|
+
"oui-flex oui-flex-1 oui-flex-col oui-items-center ",
|
|
835
|
+
isMobile ? "oui-gap-0.5" : "oui-gap-3"
|
|
836
|
+
),
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
839
|
+
"div",
|
|
840
|
+
{
|
|
841
|
+
className: orderlyUi.cn(
|
|
842
|
+
"oui-font-normal oui-text-base-contrast-54",
|
|
843
|
+
isMobile ? "oui-text-2xs" : "oui-text-base"
|
|
844
|
+
),
|
|
845
|
+
children: title
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
849
|
+
orderlyUi.Text.numeral,
|
|
850
|
+
{
|
|
851
|
+
className: orderlyUi.cn(
|
|
852
|
+
"oui-font-semibold",
|
|
853
|
+
isMobile ? "oui-text-base" : "oui-text-xl"
|
|
854
|
+
),
|
|
855
|
+
dp: 0,
|
|
856
|
+
...textProps,
|
|
857
|
+
children: value
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
]
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
var useVaultsIntroductionScript;
|
|
867
|
+
var init_vaults_introduction_script = __esm({
|
|
868
|
+
"src/components/vaults-introduction/vaults-introduction.script.ts"() {
|
|
869
|
+
init_store();
|
|
870
|
+
useVaultsIntroductionScript = () => {
|
|
871
|
+
const { data: overallInfo, loading, error } = exports.useVaultOverallInfoState();
|
|
872
|
+
const vaultsInfo = React.useMemo(() => {
|
|
873
|
+
if (!overallInfo) {
|
|
874
|
+
return {
|
|
875
|
+
tvl: 0,
|
|
876
|
+
lpCount: 0,
|
|
877
|
+
vaultsCount: 0
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
tvl: overallInfo.strategy_vaults_tvl,
|
|
882
|
+
lpCount: overallInfo.strategy_vaults_lp_count,
|
|
883
|
+
vaultsCount: overallInfo.strategy_vaults_count
|
|
884
|
+
};
|
|
885
|
+
}, [overallInfo]);
|
|
886
|
+
return {
|
|
887
|
+
vaultsInfo,
|
|
888
|
+
loading,
|
|
889
|
+
error
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
exports.VaultsIntroductionWidget = void 0;
|
|
895
|
+
var init_vaults_introduction_widget = __esm({
|
|
896
|
+
"src/components/vaults-introduction/vaults-introduction.widget.tsx"() {
|
|
897
|
+
init_vaults_introduction_desktop();
|
|
898
|
+
init_vaults_introduction_script();
|
|
899
|
+
exports.VaultsIntroductionWidget = () => {
|
|
900
|
+
const state = useVaultsIntroductionScript();
|
|
901
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VaultsIntroductionDesktop, { ...state });
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
// src/components/vaults-introduction/index.ts
|
|
907
|
+
var vaults_introduction_exports = {};
|
|
908
|
+
__export(vaults_introduction_exports, {
|
|
909
|
+
VaultsIntroductionWidget: () => exports.VaultsIntroductionWidget
|
|
910
|
+
});
|
|
911
|
+
var init_vaults_introduction = __esm({
|
|
912
|
+
"src/components/vaults-introduction/index.ts"() {
|
|
913
|
+
init_vaults_introduction_widget();
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// src/types/vault.ts
|
|
918
|
+
exports.RoleType = void 0; exports.OperationType = void 0;
|
|
919
|
+
var init_vault = __esm({
|
|
920
|
+
"src/types/vault.ts"() {
|
|
921
|
+
exports.RoleType = /* @__PURE__ */ ((RoleType2) => {
|
|
922
|
+
RoleType2["LP"] = "lp";
|
|
923
|
+
RoleType2["SP"] = "sp";
|
|
924
|
+
return RoleType2;
|
|
925
|
+
})(exports.RoleType || {});
|
|
926
|
+
exports.OperationType = /* @__PURE__ */ ((OperationType2) => {
|
|
927
|
+
OperationType2["DEPOSIT"] = "deposit";
|
|
928
|
+
OperationType2["WITHDRAWAL"] = "withdrawal";
|
|
929
|
+
return OperationType2;
|
|
930
|
+
})(exports.OperationType || {});
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
// src/contract/index.ts
|
|
935
|
+
var VAULTS_CONTRACT_ADDRESSES;
|
|
936
|
+
var init_contract = __esm({
|
|
937
|
+
"src/contract/index.ts"() {
|
|
938
|
+
VAULTS_CONTRACT_ADDRESSES = {
|
|
939
|
+
prod: {
|
|
940
|
+
vaultProtocol: "0x70Fe7d65Ac7c1a1732f64d2E6fC0E33622D0C991",
|
|
941
|
+
vaultCrossChainManager: "0x58c9747ccAAE56182C7d9c814F5eaca395D8c93B",
|
|
942
|
+
vaultPvLedger: "0xB7E792f0da9104A27288421583748215AefFFd78",
|
|
943
|
+
vaultId: "0xa3426a1cef4052c056fced18099be899d93f1427d13b9a1df1806b91fad3d0c2",
|
|
944
|
+
spAddress: "0x8bAA309D93FFFB54A64444FD98E10d92D4d9Eb22"
|
|
945
|
+
},
|
|
946
|
+
staging: {
|
|
947
|
+
vaultProtocol: "0x6B6059259B4096ea6420Eb5e08a22214d2303aE9",
|
|
948
|
+
vaultCrossChainManager: "0x510dD61a988797114A9a51b0d228E894037BD9cb",
|
|
949
|
+
vaultPvLedger: "0x20AFe57C75D1C548A9Da265fBFC5416c43783589",
|
|
950
|
+
vaultId: "0x95514fb145354f07bb889f711e856481b5ed52fce52200148aa834b3b29544c8",
|
|
951
|
+
spAddress: "0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"
|
|
952
|
+
},
|
|
953
|
+
qa: {
|
|
954
|
+
vaultProtocol: "0xF5b12d5F1db6DAB8C7c0561152b5e4bb8fD5eb38",
|
|
955
|
+
vaultCrossChainManager: "0xB8a3245407571804b4db5219cBe8D9F2EA1828DE",
|
|
956
|
+
vaultPvLedger: "0x15c9B5705CaCB4eb140dfd7a8c651E18027e5146",
|
|
957
|
+
vaultId: "0x4812cbb88f4025372a3e2acd10d02b5f680d7d1fe78091f6cfde80122c861099",
|
|
958
|
+
spAddress: "0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"
|
|
959
|
+
},
|
|
960
|
+
dev: {
|
|
961
|
+
vaultProtocol: "0xA292E1126703F804FBD5671F034c7226538C54C7",
|
|
962
|
+
vaultCrossChainManager: "0x7568ACC147Af12b02713143C3177D7e89C28A9A6",
|
|
963
|
+
vaultPvLedger: "0x2a5909498d85650744dD5CF964F2136962e5AE6E",
|
|
964
|
+
vaultId: "0x4812cbb88f4025372a3e2acd10d02b5f680d7d1fe78091f6cfde80122c861099",
|
|
965
|
+
spAddress: "0xbddfd22ef902a4898147a1ca5b985d03c62a8c41"
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
// src/utils/operationPayload.ts
|
|
972
|
+
var getToAccountPayloadType;
|
|
973
|
+
var init_operationPayload = __esm({
|
|
974
|
+
"src/utils/operationPayload.ts"() {
|
|
975
|
+
init_vault();
|
|
976
|
+
getToAccountPayloadType = (type, role) => {
|
|
977
|
+
if (type === "deposit" /* DEPOSIT */ && role === "lp" /* LP */) {
|
|
978
|
+
return 0;
|
|
979
|
+
}
|
|
980
|
+
if (type === "withdrawal" /* WITHDRAWAL */ && role === "lp" /* LP */) {
|
|
981
|
+
return 1;
|
|
982
|
+
}
|
|
983
|
+
if (type === "deposit" /* DEPOSIT */ && role === "sp" /* SP */) {
|
|
984
|
+
return 2;
|
|
985
|
+
}
|
|
986
|
+
if (type === "withdrawal" /* WITHDRAWAL */ && role === "sp" /* SP */) {
|
|
987
|
+
return 3;
|
|
988
|
+
}
|
|
989
|
+
return 1;
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
var useLatestOperationScript;
|
|
994
|
+
var init_latest_script = __esm({
|
|
995
|
+
"src/components/vault-operation/depositAndWithdraw/latest.script.ts"() {
|
|
996
|
+
useLatestOperationScript = (props) => {
|
|
997
|
+
const { type, vaultId } = props;
|
|
998
|
+
const { data: operationHistory, mutate: mutateOperationHistory } = orderlyHooks.usePrivateQuery(
|
|
999
|
+
`/v1/account_sv_transaction_history?type=${type}&vault_id=${vaultId}&size=1`,
|
|
1000
|
+
{
|
|
1001
|
+
formatter: (response) => {
|
|
1002
|
+
return response?.rows || orderlyTypes.EMPTY_LIST;
|
|
1003
|
+
},
|
|
1004
|
+
revalidateOnFocus: false
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
const latestOperation = React.useMemo(() => {
|
|
1008
|
+
return operationHistory?.[0];
|
|
1009
|
+
}, [operationHistory]);
|
|
1010
|
+
return {
|
|
1011
|
+
latestOperation,
|
|
1012
|
+
refetch: mutateOperationHistory
|
|
1013
|
+
};
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
var useOperationScript;
|
|
1018
|
+
var init_operation_script = __esm({
|
|
1019
|
+
"src/components/vault-operation/depositAndWithdraw/operation.script.ts"() {
|
|
1020
|
+
init_contract();
|
|
1021
|
+
init_vault();
|
|
1022
|
+
init_operationPayload();
|
|
1023
|
+
init_latest_script();
|
|
1024
|
+
useOperationScript = (props) => {
|
|
1025
|
+
const { account, state } = orderlyHooks.useAccount();
|
|
1026
|
+
const env = orderlyHooks.useGetEnv();
|
|
1027
|
+
const { track } = orderlyHooks.useTrack();
|
|
1028
|
+
const verifyingContract = React.useMemo(() => {
|
|
1029
|
+
return VAULTS_CONTRACT_ADDRESSES[env].vaultPvLedger;
|
|
1030
|
+
}, [env]);
|
|
1031
|
+
const [postVaultOperation] = orderlyHooks.useMutation("/v1/sv_operation_request");
|
|
1032
|
+
const { refetch: refetchOperationHistory } = useLatestOperationScript({
|
|
1033
|
+
type: props.type,
|
|
1034
|
+
vaultId: props.vaultId
|
|
1035
|
+
});
|
|
1036
|
+
const disabledOperation = React.useMemo(() => {
|
|
1037
|
+
return state?.accountId !== state?.mainAccountId;
|
|
1038
|
+
}, [state?.accountId, state?.mainAccountId]);
|
|
1039
|
+
const handleOperation = async ({
|
|
1040
|
+
amount,
|
|
1041
|
+
vaultId
|
|
1042
|
+
}) => {
|
|
1043
|
+
if (state.accountId !== state.mainAccountId) {
|
|
1044
|
+
orderlyUi.toast.error(
|
|
1045
|
+
"Please switch to the main account to perform this operation."
|
|
1046
|
+
);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (props.type === "deposit" /* DEPOSIT */) {
|
|
1050
|
+
if (new orderlyUtils.Decimal(amount).lt(10)) {
|
|
1051
|
+
orderlyUi.toast.error("Deposit amount is less than the minimum 10 USDC.");
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
const payloadType = getToAccountPayloadType(props.type, "lp" /* LP */);
|
|
1056
|
+
const requestParams = {
|
|
1057
|
+
payloadType,
|
|
1058
|
+
amount: new orderlyUtils.Decimal(Number(amount)).mul(10 ** 6).toString(),
|
|
1059
|
+
vaultId,
|
|
1060
|
+
token: "USDC",
|
|
1061
|
+
domain: {
|
|
1062
|
+
name: "Orderly",
|
|
1063
|
+
version: "1",
|
|
1064
|
+
chainId: state.connectWallet?.chainId,
|
|
1065
|
+
verifyingContract
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
const { message, signatured } = await account.generateDexRequest(requestParams);
|
|
1069
|
+
try {
|
|
1070
|
+
const res = await postVaultOperation({
|
|
1071
|
+
message: {
|
|
1072
|
+
...message,
|
|
1073
|
+
chainId: state.connectWallet?.chainId
|
|
1074
|
+
},
|
|
1075
|
+
signature: signatured,
|
|
1076
|
+
userAddress: state.address,
|
|
1077
|
+
verifyingContract
|
|
1078
|
+
});
|
|
1079
|
+
if (!res.success) {
|
|
1080
|
+
if (props.type === "deposit" /* DEPOSIT */) {
|
|
1081
|
+
track(orderlyTypes.TrackerEventName.vaultDepositFailed, {
|
|
1082
|
+
msg: res.message
|
|
1083
|
+
});
|
|
1084
|
+
} else {
|
|
1085
|
+
track(orderlyTypes.TrackerEventName.vaultWithdrawFailed, {
|
|
1086
|
+
msg: res.message
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
orderlyUi.toast.error(res.message);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
await refetchOperationHistory();
|
|
1093
|
+
if (props.type === "deposit" /* DEPOSIT */) {
|
|
1094
|
+
track(orderlyTypes.TrackerEventName.vaultDepositSuccess, {
|
|
1095
|
+
quantity: amount,
|
|
1096
|
+
vaultId
|
|
1097
|
+
});
|
|
1098
|
+
} else {
|
|
1099
|
+
track(orderlyTypes.TrackerEventName.vaultWithdrawSuccess, {
|
|
1100
|
+
quantity: amount,
|
|
1101
|
+
vaultId
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
orderlyUi.toast.success(`${props.type} successful`);
|
|
1105
|
+
} catch (error) {
|
|
1106
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1107
|
+
if (props.type === "deposit" /* DEPOSIT */) {
|
|
1108
|
+
track(orderlyTypes.TrackerEventName.vaultDepositFailed, {
|
|
1109
|
+
msg: errorMessage
|
|
1110
|
+
});
|
|
1111
|
+
} else {
|
|
1112
|
+
track(orderlyTypes.TrackerEventName.vaultWithdrawFailed, {
|
|
1113
|
+
msg: errorMessage
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
orderlyUi.toast.error(errorMessage);
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
return {
|
|
1120
|
+
handleOperation,
|
|
1121
|
+
disabledOperation
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
var useVaultDepositFormScript;
|
|
1127
|
+
var init_vault_deposit_form_script = __esm({
|
|
1128
|
+
"src/components/vault-operation/deposit/vault-deposit-form.script.ts"() {
|
|
1129
|
+
init_vaultsStore();
|
|
1130
|
+
init_vault();
|
|
1131
|
+
init_operation_script();
|
|
1132
|
+
useVaultDepositFormScript = (props) => {
|
|
1133
|
+
const { vaultId } = props;
|
|
1134
|
+
const [quantity, setQuantity] = React.useState("");
|
|
1135
|
+
const { vaultInfo } = exports.useVaultsStore();
|
|
1136
|
+
const { handleOperation, disabledOperation } = useOperationScript({
|
|
1137
|
+
type: "deposit" /* DEPOSIT */,
|
|
1138
|
+
vaultId
|
|
1139
|
+
});
|
|
1140
|
+
const { holding } = orderlyHooks.useCollateral();
|
|
1141
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1142
|
+
const minDepositAmount = vaultInfo.data[0]?.min_deposit_amount || 0;
|
|
1143
|
+
const maxWithdrawalAmount = orderlyHooks.useMaxWithdrawal("USDC");
|
|
1144
|
+
const availableBalance = React.useMemo(() => {
|
|
1145
|
+
return holding?.find((h) => h.token === "USDC")?.holding || 0;
|
|
1146
|
+
}, [holding]);
|
|
1147
|
+
const maxQuantity = React.useMemo(() => {
|
|
1148
|
+
return Math.min(maxWithdrawalAmount, availableBalance);
|
|
1149
|
+
}, [maxWithdrawalAmount, availableBalance]);
|
|
1150
|
+
const sharePrice = React.useMemo(() => {
|
|
1151
|
+
const vault = vaultInfo.data.find((v) => v.vault_id === vaultId);
|
|
1152
|
+
return vault?.est_main_share_price;
|
|
1153
|
+
}, [vaultInfo.data, vaultId]);
|
|
1154
|
+
const shares = React.useMemo(() => {
|
|
1155
|
+
if (!sharePrice || !quantity) {
|
|
1156
|
+
return "-";
|
|
1157
|
+
}
|
|
1158
|
+
return new orderlyUtils.Decimal(quantity).div(sharePrice).toString();
|
|
1159
|
+
}, [quantity, sharePrice]);
|
|
1160
|
+
const handleDeposit = async () => {
|
|
1161
|
+
if (!shares || shares === "-") {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
await handleOperation({
|
|
1165
|
+
amount: quantity,
|
|
1166
|
+
vaultId
|
|
1167
|
+
});
|
|
1168
|
+
setQuantity("");
|
|
1169
|
+
};
|
|
1170
|
+
const token = orderlyHooks.useTokenInfo("USDC");
|
|
1171
|
+
const sourceToken = React.useMemo(() => {
|
|
1172
|
+
return {
|
|
1173
|
+
...token,
|
|
1174
|
+
display_name: token?.token,
|
|
1175
|
+
symbol: token?.token
|
|
1176
|
+
};
|
|
1177
|
+
}, [token]);
|
|
1178
|
+
const onQuantityChange = (value) => {
|
|
1179
|
+
if (value && new orderlyUtils.Decimal(value).gt(maxQuantity)) {
|
|
1180
|
+
setQuantity(maxQuantity.toString());
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
setQuantity(value);
|
|
1184
|
+
};
|
|
1185
|
+
const disabledDeposit = React.useMemo(() => {
|
|
1186
|
+
return !quantity || quantity === "0" || disabledOperation || !!quantity && new orderlyUtils.Decimal(quantity).lt(minDepositAmount);
|
|
1187
|
+
}, [quantity, disabledOperation]);
|
|
1188
|
+
const inputHint = React.useMemo(() => {
|
|
1189
|
+
if (quantity && new orderlyUtils.Decimal(quantity).lt(minDepositAmount)) {
|
|
1190
|
+
return {
|
|
1191
|
+
hintMessage: t("vaults.operation.error.minDeposit", {
|
|
1192
|
+
amount: minDepositAmount
|
|
1193
|
+
}),
|
|
1194
|
+
status: "error"
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
return {
|
|
1198
|
+
hintMessage: "",
|
|
1199
|
+
status: ""
|
|
1200
|
+
};
|
|
1201
|
+
}, [quantity, t, maxWithdrawalAmount, availableBalance]);
|
|
1202
|
+
return {
|
|
1203
|
+
quantity,
|
|
1204
|
+
onQuantityChange,
|
|
1205
|
+
sourceToken,
|
|
1206
|
+
maxQuantity,
|
|
1207
|
+
sharePrice,
|
|
1208
|
+
shares,
|
|
1209
|
+
handleDeposit,
|
|
1210
|
+
vaultId,
|
|
1211
|
+
disabledDeposit,
|
|
1212
|
+
disabledOperation,
|
|
1213
|
+
inputHint
|
|
1214
|
+
};
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
// src/components/vault-operation/latest-deposit/latest-deposit.script.ts
|
|
1220
|
+
var useLatestDepositScript;
|
|
1221
|
+
var init_latest_deposit_script = __esm({
|
|
1222
|
+
"src/components/vault-operation/latest-deposit/latest-deposit.script.ts"() {
|
|
1223
|
+
init_vault();
|
|
1224
|
+
init_latest_script();
|
|
1225
|
+
useLatestDepositScript = ({ vaultId }) => {
|
|
1226
|
+
const { latestOperation } = useLatestOperationScript({
|
|
1227
|
+
type: "deposit" /* DEPOSIT */,
|
|
1228
|
+
vaultId
|
|
1229
|
+
});
|
|
1230
|
+
return {
|
|
1231
|
+
latestOperation
|
|
1232
|
+
};
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// src/utils/getOperationStatusColor.ts
|
|
1238
|
+
var getOperationStatusColor;
|
|
1239
|
+
var init_getOperationStatusColor = __esm({
|
|
1240
|
+
"src/utils/getOperationStatusColor.ts"() {
|
|
1241
|
+
getOperationStatusColor = (status) => {
|
|
1242
|
+
if (status === "completed") {
|
|
1243
|
+
return "success";
|
|
1244
|
+
}
|
|
1245
|
+
if (status === "rejected" || status === "failed") {
|
|
1246
|
+
return "danger";
|
|
1247
|
+
}
|
|
1248
|
+
return "primary";
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
var LatestDepositUI;
|
|
1253
|
+
var init_latest_deposit_ui = __esm({
|
|
1254
|
+
"src/components/vault-operation/latest-deposit/latest-deposit.ui.tsx"() {
|
|
1255
|
+
init_getOperationStatusColor();
|
|
1256
|
+
LatestDepositUI = (props) => {
|
|
1257
|
+
const { latestOperation } = props;
|
|
1258
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1259
|
+
if (!latestOperation) {
|
|
1260
|
+
return null;
|
|
1261
|
+
}
|
|
1262
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-mt-3 oui-flex oui-flex-col oui-gap-2", children: [
|
|
1263
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.deposit.latestDeposit") }),
|
|
1264
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-h-[44px] oui-rounded-lg oui-border oui-border-white/[0.12] oui-p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center", children: [
|
|
1265
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1266
|
+
"div",
|
|
1267
|
+
{
|
|
1268
|
+
className: orderlyUi.cn(
|
|
1269
|
+
"oui-mr-1 oui-size-1 oui-rounded-full",
|
|
1270
|
+
latestOperation.status === "completed" && "oui-bg-success",
|
|
1271
|
+
latestOperation.status === "rejected" && "oui-bg-danger",
|
|
1272
|
+
latestOperation.status === "failed" && "oui-bg-danger",
|
|
1273
|
+
(latestOperation.status === "pending" || latestOperation.status === "new") && "oui-bg-primary"
|
|
1274
|
+
)
|
|
1275
|
+
}
|
|
1276
|
+
),
|
|
1277
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1278
|
+
orderlyUi.Text,
|
|
1279
|
+
{
|
|
1280
|
+
color: getOperationStatusColor(latestOperation.status),
|
|
1281
|
+
className: "oui-text-xs oui-font-normal",
|
|
1282
|
+
children: latestOperation.status.slice(0, 1).toUpperCase() + latestOperation.status.slice(1)
|
|
1283
|
+
}
|
|
1284
|
+
),
|
|
1285
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TokenIcon, { name: "USDC", className: "oui-ml-auto oui-mr-1 oui-size-4" }),
|
|
1286
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.numeral, { className: "oui-text-sm oui-font-semibold oui-text-base-contrast-80", children: latestOperation.amount_change })
|
|
1287
|
+
] }) })
|
|
1288
|
+
] });
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
exports.LatestDepositWidget = void 0;
|
|
1293
|
+
var init_latest_deposit_widget = __esm({
|
|
1294
|
+
"src/components/vault-operation/latest-deposit/latest-deposit.widget.tsx"() {
|
|
1295
|
+
init_latest_deposit_script();
|
|
1296
|
+
init_latest_deposit_ui();
|
|
1297
|
+
exports.LatestDepositWidget = (props) => {
|
|
1298
|
+
const { vaultId } = props;
|
|
1299
|
+
const state = useLatestDepositScript({ vaultId });
|
|
1300
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LatestDepositUI, { ...state });
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
var VaultDepositForm;
|
|
1305
|
+
var init_vault_deposit_form_ui = __esm({
|
|
1306
|
+
"src/components/vault-operation/deposit/vault-deposit-form.ui.tsx"() {
|
|
1307
|
+
init_latest_deposit_widget();
|
|
1308
|
+
VaultDepositForm = (props) => {
|
|
1309
|
+
const {
|
|
1310
|
+
quantity,
|
|
1311
|
+
onQuantityChange,
|
|
1312
|
+
sourceToken,
|
|
1313
|
+
maxQuantity,
|
|
1314
|
+
shares,
|
|
1315
|
+
handleDeposit,
|
|
1316
|
+
vaultId,
|
|
1317
|
+
disabledDeposit,
|
|
1318
|
+
disabledOperation,
|
|
1319
|
+
inputHint
|
|
1320
|
+
} = props;
|
|
1321
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1322
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1323
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUiTransfer.BrokerWallet, {}),
|
|
1324
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { mt: 3, mb: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1325
|
+
orderlyUiTransfer.QuantityInput,
|
|
1326
|
+
{
|
|
1327
|
+
value: quantity,
|
|
1328
|
+
onValueChange: onQuantityChange,
|
|
1329
|
+
token: { ...sourceToken, precision: 6 },
|
|
1330
|
+
testId: "oui-testid-vault-deposit-dialog-quantity-input",
|
|
1331
|
+
hintMessage: inputHint.hintMessage,
|
|
1332
|
+
status: inputHint.status
|
|
1333
|
+
}
|
|
1334
|
+
) }),
|
|
1335
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1336
|
+
orderlyUiTransfer.AvailableQuantity,
|
|
1337
|
+
{
|
|
1338
|
+
maxQuantity: maxQuantity?.toString() || "0",
|
|
1339
|
+
onClick: () => {
|
|
1340
|
+
onQuantityChange(maxQuantity?.toString() || "0");
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
),
|
|
1344
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1345
|
+
orderlyUi.Box,
|
|
1346
|
+
{
|
|
1347
|
+
mt: 5,
|
|
1348
|
+
mb: 1,
|
|
1349
|
+
className: "oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",
|
|
1350
|
+
children: [
|
|
1351
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: t("vaults.deposit.estShares") }),
|
|
1352
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1353
|
+
orderlyUi.Text.numeral,
|
|
1354
|
+
{
|
|
1355
|
+
dp: 6,
|
|
1356
|
+
padding: false,
|
|
1357
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-54", children: t("vaults.deposit.shares") }),
|
|
1358
|
+
children: shares
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
),
|
|
1364
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1365
|
+
orderlyUi.Box,
|
|
1366
|
+
{
|
|
1367
|
+
mb: 5,
|
|
1368
|
+
className: "oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",
|
|
1369
|
+
children: [
|
|
1370
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: t("vaults.deposit.lockupDuration") }),
|
|
1371
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1372
|
+
orderlyUi.Text.numeral,
|
|
1373
|
+
{
|
|
1374
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-54", children: "hrs" }),
|
|
1375
|
+
children: "48"
|
|
1376
|
+
}
|
|
1377
|
+
)
|
|
1378
|
+
]
|
|
1379
|
+
}
|
|
1380
|
+
),
|
|
1381
|
+
disabledOperation && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mt-3 oui-text-center", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { color: "warning", className: "oui-text-sm oui-font-semibold", children: t("vaults.operation.error.switchAccount") }) }),
|
|
1382
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1383
|
+
orderlyUi.Button,
|
|
1384
|
+
{
|
|
1385
|
+
fullWidth: true,
|
|
1386
|
+
color: "primary",
|
|
1387
|
+
disabled: disabledDeposit,
|
|
1388
|
+
className: "oui-mt-3",
|
|
1389
|
+
onClick: handleDeposit,
|
|
1390
|
+
children: t("common.deposit")
|
|
1391
|
+
}
|
|
1392
|
+
),
|
|
1393
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.LatestDepositWidget, { vaultId })
|
|
1394
|
+
] });
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
exports.VaultDepositWidget = void 0;
|
|
1399
|
+
var init_vault_deposit_form_widget = __esm({
|
|
1400
|
+
"src/components/vault-operation/deposit/vault-deposit-form.widget.tsx"() {
|
|
1401
|
+
init_vault_deposit_form_script();
|
|
1402
|
+
init_vault_deposit_form_ui();
|
|
1403
|
+
exports.VaultDepositWidget = (props) => {
|
|
1404
|
+
const { vaultId } = props;
|
|
1405
|
+
const state = useVaultDepositFormScript({ vaultId });
|
|
1406
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VaultDepositForm, { ...state });
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
// src/components/vault-operation/deposit/index.ts
|
|
1412
|
+
var init_deposit = __esm({
|
|
1413
|
+
"src/components/vault-operation/deposit/index.ts"() {
|
|
1414
|
+
init_vault_deposit_form_widget();
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
var useVaultWithdrawFormScript;
|
|
1418
|
+
var init_vault_withdraw_form_script = __esm({
|
|
1419
|
+
"src/components/vault-operation/withdraw/vault-withdraw-form.script.ts"() {
|
|
1420
|
+
init_store();
|
|
1421
|
+
init_vault();
|
|
1422
|
+
init_operation_script();
|
|
1423
|
+
useVaultWithdrawFormScript = (props) => {
|
|
1424
|
+
const { vaultId } = props;
|
|
1425
|
+
const [quantity, setQuantity] = React.useState("");
|
|
1426
|
+
const { handleOperation, disabledOperation } = useOperationScript({
|
|
1427
|
+
type: "withdrawal" /* WITHDRAWAL */,
|
|
1428
|
+
vaultId
|
|
1429
|
+
});
|
|
1430
|
+
const vaultLpInfo = exports.useVaultLpInfoById(vaultId);
|
|
1431
|
+
const { vaultInfo } = exports.useVaultsStore();
|
|
1432
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1433
|
+
const sharePrice = React.useMemo(() => {
|
|
1434
|
+
const vault = vaultInfo.data.find((v) => v.vault_id === vaultId);
|
|
1435
|
+
return vault?.est_main_share_price || 0;
|
|
1436
|
+
}, [vaultInfo.data, vaultId]);
|
|
1437
|
+
const maxQuantity = vaultLpInfo?.[0]?.available_main_shares || 0;
|
|
1438
|
+
const receivingAmount = React.useMemo(() => {
|
|
1439
|
+
if (!quantity || !sharePrice) {
|
|
1440
|
+
return "-";
|
|
1441
|
+
}
|
|
1442
|
+
return new orderlyUtils.Decimal(quantity).mul(sharePrice).toString();
|
|
1443
|
+
}, [quantity, sharePrice]);
|
|
1444
|
+
const handleWithdraw = async () => {
|
|
1445
|
+
await handleOperation({
|
|
1446
|
+
amount: quantity,
|
|
1447
|
+
vaultId
|
|
1448
|
+
});
|
|
1449
|
+
};
|
|
1450
|
+
const onQuantityChange = (value) => {
|
|
1451
|
+
if (value && new orderlyUtils.Decimal(value).gt(maxQuantity)) {
|
|
1452
|
+
setQuantity(maxQuantity.toString());
|
|
1453
|
+
} else {
|
|
1454
|
+
setQuantity(value);
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
const isMinAmount = React.useMemo(() => {
|
|
1458
|
+
if (!quantity || !vaultInfo.data[0]?.est_main_share_price || !vaultInfo.data[0]?.min_withdrawal_amount)
|
|
1459
|
+
return false;
|
|
1460
|
+
const isAll = quantity === maxQuantity.toString();
|
|
1461
|
+
if (isAll) {
|
|
1462
|
+
return false;
|
|
1463
|
+
}
|
|
1464
|
+
const receiving = new orderlyUtils.Decimal(quantity).mul(
|
|
1465
|
+
vaultInfo.data[0]?.est_main_share_price
|
|
1466
|
+
);
|
|
1467
|
+
return receiving.lt(vaultInfo.data[0]?.min_withdrawal_amount);
|
|
1468
|
+
}, [quantity, vaultInfo, maxQuantity]);
|
|
1469
|
+
const disabledWithdraw = React.useMemo(() => {
|
|
1470
|
+
return !quantity || quantity === "0" || disabledOperation || !!quantity && isMinAmount;
|
|
1471
|
+
}, [quantity, disabledOperation]);
|
|
1472
|
+
const inputHint = React.useMemo(() => {
|
|
1473
|
+
if (quantity && isMinAmount) {
|
|
1474
|
+
return {
|
|
1475
|
+
hintMessage: t("vaults.operation.error.minWithdrawal", {
|
|
1476
|
+
amount: vaultInfo.data[0]?.min_withdrawal_amount
|
|
1477
|
+
}),
|
|
1478
|
+
status: "error"
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
return {
|
|
1482
|
+
hintMessage: "",
|
|
1483
|
+
status: ""
|
|
1484
|
+
};
|
|
1485
|
+
}, [quantity, t]);
|
|
1486
|
+
return {
|
|
1487
|
+
quantity,
|
|
1488
|
+
onQuantityChange,
|
|
1489
|
+
maxQuantity,
|
|
1490
|
+
handleWithdraw,
|
|
1491
|
+
vaultId,
|
|
1492
|
+
sharePrice,
|
|
1493
|
+
receivingAmount,
|
|
1494
|
+
disabledWithdraw,
|
|
1495
|
+
disabledOperation,
|
|
1496
|
+
inputHint
|
|
1497
|
+
};
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
// src/components/vault-operation/latest-withdraw/latest-withdraw-script.ts
|
|
1503
|
+
var useLatestWithdrawScript;
|
|
1504
|
+
var init_latest_withdraw_script = __esm({
|
|
1505
|
+
"src/components/vault-operation/latest-withdraw/latest-withdraw-script.ts"() {
|
|
1506
|
+
init_vault();
|
|
1507
|
+
init_latest_script();
|
|
1508
|
+
useLatestWithdrawScript = ({ vaultId }) => {
|
|
1509
|
+
const { latestOperation } = useLatestOperationScript({
|
|
1510
|
+
type: "withdrawal" /* WITHDRAWAL */,
|
|
1511
|
+
vaultId
|
|
1512
|
+
});
|
|
1513
|
+
return {
|
|
1514
|
+
latestOperation
|
|
1515
|
+
};
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
var ProcessDot, ProcessLine, ProcessText, WithdrawProcess, WithdrawProcessWidget;
|
|
1520
|
+
var init_withdraw_process_ui = __esm({
|
|
1521
|
+
"src/components/vault-operation/withdraw/withdraw-process.ui.tsx"() {
|
|
1522
|
+
ProcessDot = () => {
|
|
1523
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-size-2 oui-rounded-full oui-bg-white/[0.54]" });
|
|
1524
|
+
};
|
|
1525
|
+
ProcessLine = () => {
|
|
1526
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-h-px oui-flex-1 oui-bg-white/[0.2]" });
|
|
1527
|
+
};
|
|
1528
|
+
ProcessText = ({
|
|
1529
|
+
children,
|
|
1530
|
+
className
|
|
1531
|
+
}) => {
|
|
1532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
"div",
|
|
1534
|
+
{
|
|
1535
|
+
className: orderlyUi.cn(
|
|
1536
|
+
"oui-flex-1 oui-text-2xs oui-font-normal oui-text-base-contrast-80",
|
|
1537
|
+
className
|
|
1538
|
+
),
|
|
1539
|
+
children
|
|
1540
|
+
}
|
|
1541
|
+
);
|
|
1542
|
+
};
|
|
1543
|
+
WithdrawProcess = () => {
|
|
1544
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1545
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1546
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center", children: [
|
|
1547
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessDot, {}),
|
|
1548
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ProcessLine, {}) }),
|
|
1549
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessDot, {}),
|
|
1550
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ProcessLine, {}) }),
|
|
1551
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessDot, {})
|
|
1552
|
+
] }),
|
|
1553
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-mt-1 oui-flex oui-justify-between", children: [
|
|
1554
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessText, { children: t("vaults.withdraw.process.initiate") }),
|
|
1555
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessText, { className: "oui-text-center", children: t("vaults.withdraw.process.vaultProcess") }),
|
|
1556
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProcessText, { className: "oui-text-right", children: t("vaults.withdraw.process.transferred") })
|
|
1557
|
+
] })
|
|
1558
|
+
] });
|
|
1559
|
+
};
|
|
1560
|
+
WithdrawProcessWidget = () => {
|
|
1561
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1562
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-2 oui-rounded-xl oui-border oui-border-white/[0.12] oui-p-3", children: [
|
|
1563
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54", children: [
|
|
1564
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: t("vaults.withdraw.process.withdrawProcess") }),
|
|
1565
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { color: "primary", children: t("vaults.withdraw.process.upTo") })
|
|
1566
|
+
] }),
|
|
1567
|
+
/* @__PURE__ */ jsxRuntime.jsx(WithdrawProcess, {})
|
|
1568
|
+
] });
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
var LatestWithdrawUI;
|
|
1573
|
+
var init_latest_withdraw_ui = __esm({
|
|
1574
|
+
"src/components/vault-operation/latest-withdraw/latest-withdraw-ui.tsx"() {
|
|
1575
|
+
init_getOperationStatusColor();
|
|
1576
|
+
init_withdraw_process_ui();
|
|
1577
|
+
LatestWithdrawUI = (props) => {
|
|
1578
|
+
const { latestOperation } = props;
|
|
1579
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1580
|
+
if (!latestOperation) {
|
|
1581
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WithdrawProcessWidget, {});
|
|
1582
|
+
}
|
|
1583
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-mt-3 oui-flex oui-flex-col oui-gap-2", children: [
|
|
1584
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.withdraw.latestWithdraw") }),
|
|
1585
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-h-[44px] oui-rounded-lg oui-border oui-border-white/[0.12] oui-p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center", children: [
|
|
1586
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1587
|
+
"div",
|
|
1588
|
+
{
|
|
1589
|
+
className: orderlyUi.cn(
|
|
1590
|
+
"oui-mr-1 oui-size-1 oui-rounded-full",
|
|
1591
|
+
latestOperation.status === "completed" && "oui-bg-success",
|
|
1592
|
+
latestOperation.status === "rejected" && "oui-bg-danger",
|
|
1593
|
+
latestOperation.status === "failed" && "oui-bg-danger",
|
|
1594
|
+
(latestOperation.status === "pending" || latestOperation.status === "new") && "oui-bg-primary"
|
|
1595
|
+
)
|
|
1596
|
+
}
|
|
1597
|
+
),
|
|
1598
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1599
|
+
orderlyUi.Text,
|
|
1600
|
+
{
|
|
1601
|
+
color: getOperationStatusColor(latestOperation.status),
|
|
1602
|
+
className: "oui-text-xs oui-font-normal",
|
|
1603
|
+
children: latestOperation.status.slice(0, 1).toUpperCase() + latestOperation.status.slice(1)
|
|
1604
|
+
}
|
|
1605
|
+
),
|
|
1606
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TokenIcon, { name: "USDC", className: "oui-ml-auto oui-mr-1 oui-size-4" }),
|
|
1607
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.numeral, { className: "oui-text-sm oui-font-semibold oui-text-base-contrast-80", children: latestOperation.amount_change || "-" })
|
|
1608
|
+
] }) })
|
|
1609
|
+
] });
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
exports.LatestWithdrawWidget = void 0;
|
|
1614
|
+
var init_latest_withdraw_widget = __esm({
|
|
1615
|
+
"src/components/vault-operation/latest-withdraw/latest-withdraw-widget.tsx"() {
|
|
1616
|
+
init_latest_withdraw_script();
|
|
1617
|
+
init_latest_withdraw_ui();
|
|
1618
|
+
exports.LatestWithdrawWidget = (props) => {
|
|
1619
|
+
const { vaultId } = props;
|
|
1620
|
+
const state = useLatestWithdrawScript({ vaultId });
|
|
1621
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LatestWithdrawUI, { ...state });
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1626
|
+
// src/components/vault-operation/latest-withdraw/index.ts
|
|
1627
|
+
var init_latest_withdraw = __esm({
|
|
1628
|
+
"src/components/vault-operation/latest-withdraw/index.ts"() {
|
|
1629
|
+
init_latest_withdraw_widget();
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1632
|
+
var VaultWithdrawForm, WithdrawKVItem, WithdrawInitialContent, WithdrawInitialDialog, WithdrawInitialSheet;
|
|
1633
|
+
var init_vault_withdraw_form_ui = __esm({
|
|
1634
|
+
"src/components/vault-operation/withdraw/vault-withdraw-form.ui.tsx"() {
|
|
1635
|
+
init_latest_withdraw();
|
|
1636
|
+
init_withdraw_process_ui();
|
|
1637
|
+
VaultWithdrawForm = (props) => {
|
|
1638
|
+
const {
|
|
1639
|
+
quantity,
|
|
1640
|
+
onQuantityChange,
|
|
1641
|
+
maxQuantity,
|
|
1642
|
+
handleWithdraw,
|
|
1643
|
+
vaultId,
|
|
1644
|
+
sharePrice,
|
|
1645
|
+
receivingAmount,
|
|
1646
|
+
disabledWithdraw,
|
|
1647
|
+
disabledOperation,
|
|
1648
|
+
inputHint
|
|
1649
|
+
} = props;
|
|
1650
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
1651
|
+
const handleInitialWithdraw = () => {
|
|
1652
|
+
orderlyUi.modal.show(isMobile ? WithdrawInitialSheet : WithdrawInitialDialog, {
|
|
1653
|
+
quantity,
|
|
1654
|
+
receivingAmount,
|
|
1655
|
+
handleWithdraw
|
|
1656
|
+
});
|
|
1657
|
+
};
|
|
1658
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1659
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1660
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUiTransfer.BrokerWallet, {}),
|
|
1661
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { mt: 3, mb: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1662
|
+
orderlyUiTransfer.QuantityInput,
|
|
1663
|
+
{
|
|
1664
|
+
value: quantity,
|
|
1665
|
+
onValueChange: onQuantityChange,
|
|
1666
|
+
token: { display_name: "Shares", precision: 6 },
|
|
1667
|
+
testId: "oui-testid-vault-withdraw-dialog-quantity-input",
|
|
1668
|
+
hintMessage: inputHint.hintMessage,
|
|
1669
|
+
status: inputHint.status
|
|
1670
|
+
}
|
|
1671
|
+
) }),
|
|
1672
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1673
|
+
orderlyUiTransfer.AvailableQuantity,
|
|
1674
|
+
{
|
|
1675
|
+
maxQuantity,
|
|
1676
|
+
onClick: () => {
|
|
1677
|
+
onQuantityChange(maxQuantity.toString());
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
),
|
|
1681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1682
|
+
WithdrawKVItem,
|
|
1683
|
+
{
|
|
1684
|
+
label: t("vaults.withdraw.estPricePerShare"),
|
|
1685
|
+
currency: "$",
|
|
1686
|
+
value: sharePrice || "-",
|
|
1687
|
+
className: "oui-mb-1 oui-mt-5"
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1691
|
+
WithdrawKVItem,
|
|
1692
|
+
{
|
|
1693
|
+
label: t("vaults.withdraw.estReceivingAmount"),
|
|
1694
|
+
value: receivingAmount,
|
|
1695
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-36", children: "USDC" }),
|
|
1696
|
+
className: "oui-mb-5"
|
|
1697
|
+
}
|
|
1698
|
+
),
|
|
1699
|
+
disabledOperation && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mt-3 oui-text-center", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { color: "warning", className: "oui-text-sm oui-font-semibold", children: t("vaults.operation.error.switchAccount") }) }),
|
|
1700
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1701
|
+
orderlyUi.Button,
|
|
1702
|
+
{
|
|
1703
|
+
fullWidth: true,
|
|
1704
|
+
color: "primary",
|
|
1705
|
+
disabled: disabledWithdraw,
|
|
1706
|
+
className: "oui-mt-3",
|
|
1707
|
+
onClick: handleInitialWithdraw,
|
|
1708
|
+
children: t("common.withdraw")
|
|
1709
|
+
}
|
|
1710
|
+
),
|
|
1711
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mt-3", children: /* @__PURE__ */ jsxRuntime.jsx(exports.LatestWithdrawWidget, { vaultId }) })
|
|
1712
|
+
] });
|
|
1713
|
+
};
|
|
1714
|
+
WithdrawKVItem = ({
|
|
1715
|
+
label,
|
|
1716
|
+
value,
|
|
1717
|
+
suffix,
|
|
1718
|
+
currency,
|
|
1719
|
+
className
|
|
1720
|
+
}) => {
|
|
1721
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1722
|
+
"div",
|
|
1723
|
+
{
|
|
1724
|
+
className: orderlyUi.cn(
|
|
1725
|
+
"oui-flex oui-items-center oui-justify-between oui-text-sm oui-font-semibold oui-text-base-contrast-54",
|
|
1726
|
+
className
|
|
1727
|
+
),
|
|
1728
|
+
children: [
|
|
1729
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: label }),
|
|
1730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1731
|
+
orderlyUi.Text.numeral,
|
|
1732
|
+
{
|
|
1733
|
+
currency,
|
|
1734
|
+
className: "oui-text-base-contrast",
|
|
1735
|
+
suffix,
|
|
1736
|
+
children: value
|
|
1737
|
+
}
|
|
1738
|
+
)
|
|
1739
|
+
]
|
|
1740
|
+
}
|
|
1741
|
+
);
|
|
1742
|
+
};
|
|
1743
|
+
WithdrawInitialContent = (props) => {
|
|
1744
|
+
const { quantity, receivingAmount, handleWithdraw, hide } = props;
|
|
1745
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1746
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col", children: [
|
|
1747
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1748
|
+
WithdrawKVItem,
|
|
1749
|
+
{
|
|
1750
|
+
label: t("vaults.withdraw.dialog.withdrawalAmount"),
|
|
1751
|
+
value: quantity,
|
|
1752
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-36", children: "Shares" })
|
|
1753
|
+
}
|
|
1754
|
+
),
|
|
1755
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1756
|
+
WithdrawKVItem,
|
|
1757
|
+
{
|
|
1758
|
+
label: t("vaults.withdraw.dialog.estimatedReceiving"),
|
|
1759
|
+
value: receivingAmount,
|
|
1760
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-36", children: "USDC" }),
|
|
1761
|
+
className: "oui-mt-1"
|
|
1762
|
+
}
|
|
1763
|
+
),
|
|
1764
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { color: "warning", className: "oui-my-5 oui-text-sm oui-font-semibold", children: t("vaults.withdraw.dialog.note") }),
|
|
1765
|
+
/* @__PURE__ */ jsxRuntime.jsx(WithdrawProcessWidget, {}),
|
|
1766
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1767
|
+
orderlyUi.Button,
|
|
1768
|
+
{
|
|
1769
|
+
fullWidth: true,
|
|
1770
|
+
color: "primary",
|
|
1771
|
+
className: "oui-mt-5",
|
|
1772
|
+
onClick: async () => {
|
|
1773
|
+
await handleWithdraw();
|
|
1774
|
+
hide?.();
|
|
1775
|
+
},
|
|
1776
|
+
children: t("vaults.withdraw.dialog.initiateWithdrawal")
|
|
1777
|
+
}
|
|
1778
|
+
)
|
|
1779
|
+
] });
|
|
1780
|
+
};
|
|
1781
|
+
WithdrawInitialDialog = orderlyUi.modal.create(
|
|
1782
|
+
({
|
|
1783
|
+
quantity,
|
|
1784
|
+
receivingAmount,
|
|
1785
|
+
handleWithdraw
|
|
1786
|
+
}) => {
|
|
1787
|
+
const { visible, hide, onOpenChange } = orderlyUi.useModal();
|
|
1788
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1789
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1790
|
+
orderlyUi.SimpleDialog,
|
|
1791
|
+
{
|
|
1792
|
+
title: t("vaults.withdraw.dialog.title"),
|
|
1793
|
+
open: visible,
|
|
1794
|
+
onOpenChange,
|
|
1795
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
WithdrawInitialContent,
|
|
1797
|
+
{
|
|
1798
|
+
quantity,
|
|
1799
|
+
receivingAmount,
|
|
1800
|
+
handleWithdraw,
|
|
1801
|
+
hide
|
|
1802
|
+
}
|
|
1803
|
+
)
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
);
|
|
1808
|
+
WithdrawInitialSheet = orderlyUi.modal.create(
|
|
1809
|
+
({
|
|
1810
|
+
quantity,
|
|
1811
|
+
receivingAmount,
|
|
1812
|
+
handleWithdraw
|
|
1813
|
+
}) => {
|
|
1814
|
+
const { visible, hide, onOpenChange } = orderlyUi.useModal();
|
|
1815
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1816
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1817
|
+
orderlyUi.SimpleSheet,
|
|
1818
|
+
{
|
|
1819
|
+
title: t("vaults.withdraw.dialog.title"),
|
|
1820
|
+
open: visible,
|
|
1821
|
+
onOpenChange,
|
|
1822
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1823
|
+
WithdrawInitialContent,
|
|
1824
|
+
{
|
|
1825
|
+
quantity,
|
|
1826
|
+
receivingAmount,
|
|
1827
|
+
handleWithdraw,
|
|
1828
|
+
hide
|
|
1829
|
+
}
|
|
1830
|
+
)
|
|
1831
|
+
}
|
|
1832
|
+
);
|
|
1833
|
+
}
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
exports.VaultWithdrawWidget = void 0;
|
|
1838
|
+
var init_vault_withdraw_form_widget = __esm({
|
|
1839
|
+
"src/components/vault-operation/withdraw/vault-withdraw-form.widget.tsx"() {
|
|
1840
|
+
init_vault_withdraw_form_script();
|
|
1841
|
+
init_vault_withdraw_form_ui();
|
|
1842
|
+
exports.VaultWithdrawWidget = (props) => {
|
|
1843
|
+
const { vaultId } = props;
|
|
1844
|
+
const state = useVaultWithdrawFormScript({ vaultId });
|
|
1845
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VaultWithdrawForm, { ...state });
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
|
|
1850
|
+
// src/components/vault-operation/withdraw/index.ts
|
|
1851
|
+
var init_withdraw = __esm({
|
|
1852
|
+
"src/components/vault-operation/withdraw/index.ts"() {
|
|
1853
|
+
init_vault_withdraw_form_widget();
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
exports.VaultDepositAndWithdrawWithDialogId = void 0; exports.VaultDepositAndWithdrawWithSheetId = void 0; exports.VaultDepositAndWithdraw = void 0;
|
|
1857
|
+
var init_depositAndWithdraw = __esm({
|
|
1858
|
+
"src/components/vault-operation/depositAndWithdraw/index.tsx"() {
|
|
1859
|
+
init_deposit();
|
|
1860
|
+
init_withdraw();
|
|
1861
|
+
exports.VaultDepositAndWithdrawWithDialogId = "VaultDepositAndWithdrawWithDialogId";
|
|
1862
|
+
exports.VaultDepositAndWithdrawWithSheetId = "VaultDepositAndWithdrawWithSheetId";
|
|
1863
|
+
exports.VaultDepositAndWithdraw = (props) => {
|
|
1864
|
+
const [activeTab, setActiveTab] = React.useState(
|
|
1865
|
+
props.activeTab || "deposit"
|
|
1866
|
+
);
|
|
1867
|
+
const { vaultId } = props;
|
|
1868
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1869
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1870
|
+
orderlyUi.Tabs,
|
|
1871
|
+
{
|
|
1872
|
+
value: activeTab,
|
|
1873
|
+
onValueChange: setActiveTab,
|
|
1874
|
+
variant: "contained",
|
|
1875
|
+
size: "lg",
|
|
1876
|
+
classNames: {
|
|
1877
|
+
tabsList: "oui-px-0",
|
|
1878
|
+
tabsContent: "oui-pt-5"
|
|
1879
|
+
},
|
|
1880
|
+
children: [
|
|
1881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1882
|
+
orderlyUi.TabPanel,
|
|
1883
|
+
{
|
|
1884
|
+
title: t("common.deposit"),
|
|
1885
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ArrowDownSquareFillIcon, {}),
|
|
1886
|
+
value: "deposit",
|
|
1887
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(exports.VaultDepositWidget, { vaultId })
|
|
1888
|
+
}
|
|
1889
|
+
),
|
|
1890
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1891
|
+
orderlyUi.TabPanel,
|
|
1892
|
+
{
|
|
1893
|
+
title: t("common.withdraw"),
|
|
1894
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ArrowUpSquareFillIcon, {}),
|
|
1895
|
+
value: "withdraw",
|
|
1896
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(exports.VaultWithdrawWidget, { vaultId })
|
|
1897
|
+
}
|
|
1898
|
+
)
|
|
1899
|
+
]
|
|
1900
|
+
}
|
|
1901
|
+
);
|
|
1902
|
+
};
|
|
1903
|
+
orderlyUi.registerSimpleDialog(
|
|
1904
|
+
exports.VaultDepositAndWithdrawWithDialogId,
|
|
1905
|
+
exports.VaultDepositAndWithdraw,
|
|
1906
|
+
{
|
|
1907
|
+
size: "md",
|
|
1908
|
+
classNames: {
|
|
1909
|
+
content: "oui-border oui-border-line-6"
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
);
|
|
1913
|
+
orderlyUi.registerSimpleSheet(
|
|
1914
|
+
exports.VaultDepositAndWithdrawWithSheetId,
|
|
1915
|
+
exports.VaultDepositAndWithdraw
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
|
|
1920
|
+
// src/components/vault-card/constants.ts
|
|
1921
|
+
exports.ORDERLY_ICON = void 0; exports.ORDERLY_VAULT_TITLE = void 0; exports.ORDERLY_VAULT_DESCRIPTION = void 0; exports.getBrokerIconUrl = void 0;
|
|
1922
|
+
var init_constants = __esm({
|
|
1923
|
+
"src/components/vault-card/constants.ts"() {
|
|
1924
|
+
exports.ORDERLY_ICON = "https://oss.orderly.network/static/symbol_logo/ORDER.png";
|
|
1925
|
+
exports.ORDERLY_VAULT_TITLE = "Orderly OmniVault";
|
|
1926
|
+
exports.ORDERLY_VAULT_DESCRIPTION = "Earn passive yields effortlessly, no trading expertise required. OmniVault deploys market-making strategies, taking on liquidations, and accrue platform fees.";
|
|
1927
|
+
exports.getBrokerIconUrl = (brokerId) => {
|
|
1928
|
+
switch (brokerId) {
|
|
1929
|
+
case "kodiak":
|
|
1930
|
+
return "https://oss.orderly.network/static/symbol_logo/kodiak.png";
|
|
1931
|
+
case "orderly":
|
|
1932
|
+
return "https://oss.orderly.network/static/symbol_logo/ORDER.png";
|
|
1933
|
+
case "woofi_pro":
|
|
1934
|
+
return "https://oss.orderly.network/static/broker_logo/woofi_pro.png";
|
|
1935
|
+
case "aden":
|
|
1936
|
+
return "/vaults/broker/aden.png";
|
|
1937
|
+
case "vooi":
|
|
1938
|
+
return "https://oss.orderly.network/static/broker_logo/vooi.png";
|
|
1939
|
+
default:
|
|
1940
|
+
return `https://oss.orderly.network/static/broker_logo/${brokerId}.png`;
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
exports.useVaultCardScript = void 0;
|
|
1946
|
+
var init_vaultCard_script = __esm({
|
|
1947
|
+
"src/components/vault-card/vaultCard.script.ts"() {
|
|
1948
|
+
init_env();
|
|
1949
|
+
init_useSVAPIUrl();
|
|
1950
|
+
init_vaultsStore();
|
|
1951
|
+
init_depositAndWithdraw();
|
|
1952
|
+
init_constants();
|
|
1953
|
+
exports.useVaultCardScript = (vault) => {
|
|
1954
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1955
|
+
const vaultLpInfo = exports.useVaultLpInfoById(vault.vault_id);
|
|
1956
|
+
const { fetchVaultLpInfo } = exports.useVaultsStore();
|
|
1957
|
+
const env = orderlyHooks.useGetEnv();
|
|
1958
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
1959
|
+
const { state } = orderlyHooks.useAccount();
|
|
1960
|
+
const svApiUrl = useSVApiUrl();
|
|
1961
|
+
const { holding } = orderlyHooks.useCollateral();
|
|
1962
|
+
const availableBalance = React.useMemo(() => {
|
|
1963
|
+
return holding?.find((h) => h.token === "USDC")?.holding || 0;
|
|
1964
|
+
}, [holding]);
|
|
1965
|
+
React.useEffect(() => {
|
|
1966
|
+
if (!state.address || !svApiUrl || !vault.vault_id) {
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
fetchVaultLpInfo(
|
|
1970
|
+
{ vault_id: vault.vault_id, wallet_address: state.address },
|
|
1971
|
+
svApiUrl
|
|
1972
|
+
);
|
|
1973
|
+
}, [vault.vault_id, state.address, svApiUrl]);
|
|
1974
|
+
const memoizedAvailableBalance = React.useMemo(() => {
|
|
1975
|
+
return availableBalance;
|
|
1976
|
+
}, [availableBalance]);
|
|
1977
|
+
const lpInfo = React.useMemo(() => {
|
|
1978
|
+
const info = vaultLpInfo?.[0];
|
|
1979
|
+
if (!info) {
|
|
1980
|
+
return {
|
|
1981
|
+
deposits: "--",
|
|
1982
|
+
earnings: "--"
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
return {
|
|
1986
|
+
deposits: info.lp_tvl - info.potential_pnl,
|
|
1987
|
+
earnings: info.potential_pnl
|
|
1988
|
+
};
|
|
1989
|
+
}, [vaultLpInfo]);
|
|
1990
|
+
const isEVMConnected = React.useMemo(() => {
|
|
1991
|
+
return state.chainNamespace === "EVM";
|
|
1992
|
+
}, [state.chainNamespace]);
|
|
1993
|
+
const isSOLConnected = React.useMemo(() => {
|
|
1994
|
+
return state.chainNamespace === "SOL";
|
|
1995
|
+
}, [state.chainNamespace]);
|
|
1996
|
+
const isWrongNetwork = React.useMemo(() => {
|
|
1997
|
+
return state.chainNamespace !== "EVM" && state.chainNamespace !== "SOL" && state.accountId !== state.mainAccountId;
|
|
1998
|
+
}, [state.chainNamespace, state.accountId, state.mainAccountId]);
|
|
1999
|
+
const isButtonsDisabled = React.useMemo(() => {
|
|
2000
|
+
return vault.status !== "live";
|
|
2001
|
+
}, [vault.status]);
|
|
2002
|
+
const openDepositAndWithdraw = (activeTab) => {
|
|
2003
|
+
orderlyUi.modal.show(
|
|
2004
|
+
isMobile ? exports.VaultDepositAndWithdrawWithSheetId : exports.VaultDepositAndWithdrawWithDialogId,
|
|
2005
|
+
{
|
|
2006
|
+
activeTab,
|
|
2007
|
+
vaultId: vault.vault_id
|
|
2008
|
+
}
|
|
2009
|
+
);
|
|
2010
|
+
};
|
|
2011
|
+
const openVaultWebsite = () => {
|
|
2012
|
+
const baseUrl = VAULTS_WEBSITE_URLS[env] || VAULTS_WEBSITE_URLS.prod;
|
|
2013
|
+
window.open(`${baseUrl}/vaults/${vault.vault_address}`, "_blank");
|
|
2014
|
+
};
|
|
2015
|
+
return {
|
|
2016
|
+
title: vault.vault_name,
|
|
2017
|
+
description: vault.description,
|
|
2018
|
+
icon: exports.getBrokerIconUrl(vault.broker_id),
|
|
2019
|
+
vaultInfo: vault,
|
|
2020
|
+
lpInfo,
|
|
2021
|
+
isEVMConnected,
|
|
2022
|
+
isSOLConnected,
|
|
2023
|
+
openDepositAndWithdraw,
|
|
2024
|
+
availableBalance: memoizedAvailableBalance,
|
|
2025
|
+
openVaultWebsite,
|
|
2026
|
+
isWrongNetwork,
|
|
2027
|
+
isButtonsDisabled
|
|
2028
|
+
};
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
});
|
|
2032
|
+
var parseMarkdownLinks;
|
|
2033
|
+
var init_parseMarkdownLinks = __esm({
|
|
2034
|
+
"src/utils/parseMarkdownLinks.tsx"() {
|
|
2035
|
+
parseMarkdownLinks = (text) => {
|
|
2036
|
+
if (!text) {
|
|
2037
|
+
return [""];
|
|
2038
|
+
}
|
|
2039
|
+
const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
2040
|
+
const parts = [];
|
|
2041
|
+
let lastIndex = 0;
|
|
2042
|
+
let match;
|
|
2043
|
+
while ((match = markdownLinkRegex.exec(text)) !== null) {
|
|
2044
|
+
const [fullMatch, linkText, url] = match;
|
|
2045
|
+
const matchIndex = match.index;
|
|
2046
|
+
if (matchIndex > lastIndex) {
|
|
2047
|
+
parts.push(text.substring(lastIndex, matchIndex));
|
|
2048
|
+
}
|
|
2049
|
+
parts.push(
|
|
2050
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2051
|
+
"a",
|
|
2052
|
+
{
|
|
2053
|
+
href: url,
|
|
2054
|
+
target: "_blank",
|
|
2055
|
+
rel: "noopener noreferrer",
|
|
2056
|
+
className: "oui-underline hover:oui-text-base-contrast-80",
|
|
2057
|
+
children: linkText
|
|
2058
|
+
},
|
|
2059
|
+
matchIndex
|
|
2060
|
+
)
|
|
2061
|
+
);
|
|
2062
|
+
lastIndex = matchIndex + fullMatch.length;
|
|
2063
|
+
}
|
|
2064
|
+
if (lastIndex < text.length) {
|
|
2065
|
+
parts.push(text.substring(lastIndex));
|
|
2066
|
+
}
|
|
2067
|
+
return parts.length > 0 ? parts : [text];
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
exports.formatAllTimeReturn = void 0; exports.VaultCard = void 0; var VaultInfoItem, LpInfoItem, VaultCardOperation;
|
|
2072
|
+
var init_vaultCard_ui = __esm({
|
|
2073
|
+
"src/components/vault-card/vaultCard.ui.tsx"() {
|
|
2074
|
+
init_parseMarkdownLinks();
|
|
2075
|
+
exports.formatAllTimeReturn = (status, vaultAge, lifetimeApy) => {
|
|
2076
|
+
if (status === "pre_launch" || vaultAge !== null && vaultAge < 7) {
|
|
2077
|
+
return "--";
|
|
2078
|
+
}
|
|
2079
|
+
if (lifetimeApy > 100) {
|
|
2080
|
+
return ">10000%";
|
|
2081
|
+
}
|
|
2082
|
+
return new orderlyUtils.Decimal(lifetimeApy).mul(100).toDecimalPlaces(2, orderlyUtils.Decimal.ROUND_UP).toFixed(2) + "%";
|
|
2083
|
+
};
|
|
2084
|
+
exports.VaultCard = (props) => {
|
|
2085
|
+
const {
|
|
2086
|
+
title,
|
|
2087
|
+
vaultInfo,
|
|
2088
|
+
lpInfo,
|
|
2089
|
+
description,
|
|
2090
|
+
isEVMConnected,
|
|
2091
|
+
isSOLConnected,
|
|
2092
|
+
openDepositAndWithdraw,
|
|
2093
|
+
availableBalance,
|
|
2094
|
+
openVaultWebsite,
|
|
2095
|
+
icon,
|
|
2096
|
+
isButtonsDisabled
|
|
2097
|
+
} = props;
|
|
2098
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2099
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
2100
|
+
const formattedAllTimeReturn = React.useMemo(
|
|
2101
|
+
() => exports.formatAllTimeReturn(
|
|
2102
|
+
vaultInfo.status,
|
|
2103
|
+
vaultInfo.vault_age,
|
|
2104
|
+
vaultInfo.lifetime_apy
|
|
2105
|
+
),
|
|
2106
|
+
[vaultInfo.status, vaultInfo.vault_age, vaultInfo.lifetime_apy]
|
|
2107
|
+
);
|
|
2108
|
+
const getStatusTag = () => {
|
|
2109
|
+
const { status } = vaultInfo;
|
|
2110
|
+
if (status === "live") {
|
|
2111
|
+
return {
|
|
2112
|
+
text: t("vaults.card.status.active"),
|
|
2113
|
+
color: "#00C076",
|
|
2114
|
+
bgColor: "rgba(0, 192, 118, 0.15)"
|
|
2115
|
+
};
|
|
2116
|
+
} else if (status === "pre_launch") {
|
|
2117
|
+
return {
|
|
2118
|
+
text: t("vaults.card.launchingSoon"),
|
|
2119
|
+
color: "#E88800",
|
|
2120
|
+
bgColor: "rgba(232, 136, 0, 0.15)"
|
|
2121
|
+
};
|
|
2122
|
+
} else if (status === "closing") {
|
|
2123
|
+
return {
|
|
2124
|
+
text: t("vaults.card.status.closing"),
|
|
2125
|
+
color: "#FF6B6B",
|
|
2126
|
+
bgColor: "rgba(255, 107, 107, 0.15)"
|
|
2127
|
+
};
|
|
2128
|
+
} else if (status === "closed") {
|
|
2129
|
+
return {
|
|
2130
|
+
text: t("vaults.card.status.closed"),
|
|
2131
|
+
color: "#999999",
|
|
2132
|
+
bgColor: "rgba(153, 153, 153, 0.15)"
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
return null;
|
|
2136
|
+
};
|
|
2137
|
+
const statusTag = getStatusTag();
|
|
2138
|
+
React.useMemo(() => {
|
|
2139
|
+
const chains = Array.isArray(vaultInfo?.supported_chains) ? vaultInfo.supported_chains : [];
|
|
2140
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-items-center", children: chains.map((chain, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2141
|
+
"img",
|
|
2142
|
+
{
|
|
2143
|
+
src: `https://oss.orderly.network/static/network_logo/${chain.chain_id}.png`,
|
|
2144
|
+
alt: chain.chain_id,
|
|
2145
|
+
className: orderlyUi.cn(
|
|
2146
|
+
"oui-relative",
|
|
2147
|
+
isMobile ? "oui-size-[18px]" : "oui-size-5"
|
|
2148
|
+
),
|
|
2149
|
+
style: {
|
|
2150
|
+
marginLeft: index > 0 ? "-4px" : "0",
|
|
2151
|
+
zIndex: chains.length - index
|
|
2152
|
+
}
|
|
2153
|
+
},
|
|
2154
|
+
chain.chain_id
|
|
2155
|
+
)) });
|
|
2156
|
+
}, [vaultInfo.supported_chains, isMobile]);
|
|
2157
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-h-[435px] oui-overflow-hidden oui-rounded-2xl oui-bg-base-9", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2158
|
+
"div",
|
|
2159
|
+
{
|
|
2160
|
+
className: orderlyUi.cn(
|
|
2161
|
+
"oui-absolute oui-left-0 oui-top-0 oui-z-20 oui-size-full oui-p-6",
|
|
2162
|
+
"oui-overflow-y-auto oui-custom-scrollbar"
|
|
2163
|
+
),
|
|
2164
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-2", children: [
|
|
2165
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
2166
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-[18px] oui-font-semibold oui-text-white oui-break-words", children: title }),
|
|
2167
|
+
statusTag && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2168
|
+
"div",
|
|
2169
|
+
{
|
|
2170
|
+
className: "oui-flex oui-w-fit oui-items-center oui-gap-[10px] oui-px-2",
|
|
2171
|
+
style: {
|
|
2172
|
+
height: "18px",
|
|
2173
|
+
borderRadius: "4px",
|
|
2174
|
+
background: statusTag.bgColor,
|
|
2175
|
+
color: statusTag.color,
|
|
2176
|
+
fontSize: "12px",
|
|
2177
|
+
fontWeight: 600,
|
|
2178
|
+
lineHeight: "18px",
|
|
2179
|
+
letterSpacing: "0.36px"
|
|
2180
|
+
},
|
|
2181
|
+
children: statusTag.text
|
|
2182
|
+
}
|
|
2183
|
+
)
|
|
2184
|
+
] }),
|
|
2185
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
2186
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-h-[54px]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-font-normal oui-leading-[18px] oui-text-base-contrast-54 oui-line-clamp-3", children: parseMarkdownLinks(description) }) }),
|
|
2187
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2188
|
+
"button",
|
|
2189
|
+
{
|
|
2190
|
+
onClick: openVaultWebsite,
|
|
2191
|
+
className: "oui-flex oui-w-fit oui-items-center oui-gap-1 oui-text-xs oui-font-medium",
|
|
2192
|
+
style: { color: "#608CFF" },
|
|
2193
|
+
children: [
|
|
2194
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("vaults.card.viewMore") }),
|
|
2195
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2196
|
+
orderlyUi.ArrowRightUpSquareFillIcon,
|
|
2197
|
+
{
|
|
2198
|
+
style: { color: "#608CFF" },
|
|
2199
|
+
width: 16,
|
|
2200
|
+
height: 16,
|
|
2201
|
+
viewBox: "0 0 18 18"
|
|
2202
|
+
}
|
|
2203
|
+
)
|
|
2204
|
+
]
|
|
2205
|
+
}
|
|
2206
|
+
)
|
|
2207
|
+
] }),
|
|
2208
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-6", children: [
|
|
2209
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-2", children: [
|
|
2210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2211
|
+
VaultInfoItem,
|
|
2212
|
+
{
|
|
2213
|
+
label: t("vaults.card.tvl"),
|
|
2214
|
+
value: vaultInfo.tvl,
|
|
2215
|
+
textProps: {
|
|
2216
|
+
currency: "$",
|
|
2217
|
+
dp: 0,
|
|
2218
|
+
type: "numeral"
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
),
|
|
2222
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2223
|
+
VaultInfoItem,
|
|
2224
|
+
{
|
|
2225
|
+
label: t("vaults.card.allTimeReturn"),
|
|
2226
|
+
value: formattedAllTimeReturn,
|
|
2227
|
+
textProps: {
|
|
2228
|
+
color: "brand",
|
|
2229
|
+
type: "gradient"
|
|
2230
|
+
},
|
|
2231
|
+
showTooltip: vaultInfo.status === "pre_launch" || vaultInfo.vault_age !== null && vaultInfo.vault_age < 7,
|
|
2232
|
+
tooltipContent: t("vaults.card.allTimeReturnTooltip")
|
|
2233
|
+
}
|
|
2234
|
+
)
|
|
2235
|
+
] }),
|
|
2236
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-items-center oui-gap-2 oui-rounded-lg oui-bg-white/[0.06] oui-p-3", children: [
|
|
2237
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2238
|
+
LpInfoItem,
|
|
2239
|
+
{
|
|
2240
|
+
label: t("vaults.card.myDeposits"),
|
|
2241
|
+
value: lpInfo.deposits
|
|
2242
|
+
}
|
|
2243
|
+
),
|
|
2244
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2245
|
+
LpInfoItem,
|
|
2246
|
+
{
|
|
2247
|
+
label: t("vaults.card.myEarnings"),
|
|
2248
|
+
value: lpInfo.earnings
|
|
2249
|
+
}
|
|
2250
|
+
)
|
|
2251
|
+
] })
|
|
2252
|
+
] }),
|
|
2253
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-4 oui-mt-2", children: [
|
|
2254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2255
|
+
LpInfoItem,
|
|
2256
|
+
{
|
|
2257
|
+
label: t("vaults.card.accountBalance"),
|
|
2258
|
+
value: availableBalance
|
|
2259
|
+
}
|
|
2260
|
+
),
|
|
2261
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2262
|
+
VaultCardOperation,
|
|
2263
|
+
{
|
|
2264
|
+
isEVMConnected,
|
|
2265
|
+
isSOLConnected,
|
|
2266
|
+
openDepositAndWithdraw,
|
|
2267
|
+
isButtonsDisabled
|
|
2268
|
+
}
|
|
2269
|
+
)
|
|
2270
|
+
] })
|
|
2271
|
+
] })
|
|
2272
|
+
}
|
|
2273
|
+
) });
|
|
2274
|
+
};
|
|
2275
|
+
VaultInfoItem = (props) => {
|
|
2276
|
+
const { label, value, textProps, showTooltip, tooltipContent } = props;
|
|
2277
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2278
|
+
"div",
|
|
2279
|
+
{
|
|
2280
|
+
className: orderlyUi.cn(
|
|
2281
|
+
"oui-flex oui-flex-1 oui-flex-col oui-items-center oui-justify-center oui-px-3 oui-py-2",
|
|
2282
|
+
"oui-rounded-lg oui-border oui-border-solid oui-border-white/[0.12]"
|
|
2283
|
+
),
|
|
2284
|
+
children: [
|
|
2285
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1 oui-text-2xs oui-font-normal oui-leading-[18px] oui-text-base-contrast-54", children: [
|
|
2286
|
+
label,
|
|
2287
|
+
showTooltip && tooltipContent && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Tooltip, { content: tooltipContent, delayDuration: 100, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2288
|
+
orderlyUi.InfoCircleIcon,
|
|
2289
|
+
{
|
|
2290
|
+
size: 12,
|
|
2291
|
+
opacity: 0.54,
|
|
2292
|
+
className: "oui-text-base-contrast"
|
|
2293
|
+
}
|
|
2294
|
+
) }) })
|
|
2295
|
+
] }),
|
|
2296
|
+
textProps.type === "gradient" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2297
|
+
orderlyUi.Text.gradient,
|
|
2298
|
+
{
|
|
2299
|
+
className: "oui-text-base oui-font-semibold",
|
|
2300
|
+
...textProps,
|
|
2301
|
+
children: value
|
|
2302
|
+
}
|
|
2303
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2304
|
+
orderlyUi.Text.numeral,
|
|
2305
|
+
{
|
|
2306
|
+
className: "oui-text-base oui-font-semibold",
|
|
2307
|
+
...textProps,
|
|
2308
|
+
children: value
|
|
2309
|
+
}
|
|
2310
|
+
)
|
|
2311
|
+
]
|
|
2312
|
+
}
|
|
2313
|
+
);
|
|
2314
|
+
};
|
|
2315
|
+
LpInfoItem = (props) => {
|
|
2316
|
+
const { label, value, textProps } = props;
|
|
2317
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-w-full oui-items-center oui-justify-between oui-text-2xs oui-font-normal", children: [
|
|
2318
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-base-contrast-54", children: label }),
|
|
2319
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2320
|
+
orderlyUi.Text.numeral,
|
|
2321
|
+
{
|
|
2322
|
+
className: "oui-text-base-contrast-80",
|
|
2323
|
+
...textProps,
|
|
2324
|
+
dp: 2,
|
|
2325
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "oui-ml-1 oui-text-base-contrast-36", children: "USDC" }),
|
|
2326
|
+
children: value
|
|
2327
|
+
}
|
|
2328
|
+
)
|
|
2329
|
+
] });
|
|
2330
|
+
};
|
|
2331
|
+
VaultCardOperation = (props) => {
|
|
2332
|
+
const {
|
|
2333
|
+
isEVMConnected,
|
|
2334
|
+
isSOLConnected,
|
|
2335
|
+
openDepositAndWithdraw,
|
|
2336
|
+
isButtonsDisabled
|
|
2337
|
+
} = props;
|
|
2338
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2339
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUiConnector.AuthGuard, { buttonProps: { size: "md", fullWidth: true }, children: isEVMConnected || isSOLConnected ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-2", children: [
|
|
2340
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2341
|
+
orderlyUi.Button,
|
|
2342
|
+
{
|
|
2343
|
+
className: "oui-flex-1",
|
|
2344
|
+
size: "md",
|
|
2345
|
+
disabled: isButtonsDisabled,
|
|
2346
|
+
onClick: () => openDepositAndWithdraw("deposit"),
|
|
2347
|
+
children: t("common.deposit")
|
|
2348
|
+
}
|
|
2349
|
+
),
|
|
2350
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2351
|
+
orderlyUi.Button,
|
|
2352
|
+
{
|
|
2353
|
+
className: "oui-flex-1",
|
|
2354
|
+
size: "md",
|
|
2355
|
+
color: "secondary",
|
|
2356
|
+
disabled: isButtonsDisabled,
|
|
2357
|
+
onClick: () => openDepositAndWithdraw("withdraw"),
|
|
2358
|
+
children: t("common.withdraw")
|
|
2359
|
+
}
|
|
2360
|
+
)
|
|
2361
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Button, { size: "md", color: "warning", children: t("connector.wrongNetwork") }) });
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
exports.VaultCardWidget = void 0;
|
|
2366
|
+
var init_vaultCard_widget = __esm({
|
|
2367
|
+
"src/components/vault-card/vaultCard.widget.tsx"() {
|
|
2368
|
+
init_vaultCard_script();
|
|
2369
|
+
init_vaultCard_ui();
|
|
2370
|
+
exports.VaultCardWidget = (props) => {
|
|
2371
|
+
const { vault } = props;
|
|
2372
|
+
const state = exports.useVaultCardScript(vault);
|
|
2373
|
+
return /* @__PURE__ */ jsxRuntime.jsx(exports.VaultCard, { ...state });
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2377
|
+
|
|
2378
|
+
// src/components/vault-card/index.ts
|
|
2379
|
+
var init_vault_card = __esm({
|
|
2380
|
+
"src/components/vault-card/index.ts"() {
|
|
2381
|
+
init_vaultCard_widget();
|
|
2382
|
+
init_vaultCard_script();
|
|
2383
|
+
init_vaultCard_ui();
|
|
2384
|
+
init_constants();
|
|
2385
|
+
}
|
|
2386
|
+
});
|
|
2387
|
+
exports.VaultsList = void 0; var VaultListRow;
|
|
2388
|
+
var init_vaults_list = __esm({
|
|
2389
|
+
"src/components/all-vaults/vaults-list.tsx"() {
|
|
2390
|
+
init_vaultCard_script();
|
|
2391
|
+
init_vaultCard_ui();
|
|
2392
|
+
exports.VaultsList = ({ vaults }) => {
|
|
2393
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2394
|
+
const [sortField, setSortField] = React.useState("apy");
|
|
2395
|
+
const [sortDirection, setSortDirection] = React.useState("desc");
|
|
2396
|
+
const shouldShowApyTooltip = React.useMemo(() => {
|
|
2397
|
+
return vaults.some(
|
|
2398
|
+
(vault) => vault.status === "pre_launch" || vault.vault_age !== null && vault.vault_age < 7
|
|
2399
|
+
);
|
|
2400
|
+
}, [vaults]);
|
|
2401
|
+
const handleSort = (field) => {
|
|
2402
|
+
if (sortField === field) {
|
|
2403
|
+
setSortDirection(sortDirection === "asc" ? "desc" : "asc");
|
|
2404
|
+
} else {
|
|
2405
|
+
setSortField(field);
|
|
2406
|
+
setSortDirection("desc");
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
const sortedVaults = React.useMemo(() => {
|
|
2410
|
+
return [...vaults].sort((a, b) => {
|
|
2411
|
+
let aValue = 0;
|
|
2412
|
+
let bValue = 0;
|
|
2413
|
+
switch (sortField) {
|
|
2414
|
+
case "tvl":
|
|
2415
|
+
aValue = a.tvl;
|
|
2416
|
+
bValue = b.tvl;
|
|
2417
|
+
break;
|
|
2418
|
+
case "apy":
|
|
2419
|
+
aValue = a.lifetime_apy;
|
|
2420
|
+
bValue = b.lifetime_apy;
|
|
2421
|
+
break;
|
|
2422
|
+
default:
|
|
2423
|
+
return 0;
|
|
2424
|
+
}
|
|
2425
|
+
return sortDirection === "asc" ? aValue - bValue : bValue - aValue;
|
|
2426
|
+
});
|
|
2427
|
+
}, [vaults, sortField, sortDirection]);
|
|
2428
|
+
const SortIcon = ({ field }) => {
|
|
2429
|
+
const isActive = sortField === field;
|
|
2430
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2431
|
+
"svg",
|
|
2432
|
+
{
|
|
2433
|
+
width: "12",
|
|
2434
|
+
height: "12",
|
|
2435
|
+
viewBox: "0 0 12 12",
|
|
2436
|
+
fill: "none",
|
|
2437
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2438
|
+
className: orderlyUi.cn(
|
|
2439
|
+
"oui-ml-1 oui-transition-colors",
|
|
2440
|
+
isActive ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
|
|
2441
|
+
),
|
|
2442
|
+
children: [
|
|
2443
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2444
|
+
"path",
|
|
2445
|
+
{
|
|
2446
|
+
d: "M6 2L8 4H4L6 2Z",
|
|
2447
|
+
fill: "currentColor",
|
|
2448
|
+
opacity: isActive && sortDirection === "asc" ? 1 : 0.3
|
|
2449
|
+
}
|
|
2450
|
+
),
|
|
2451
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2452
|
+
"path",
|
|
2453
|
+
{
|
|
2454
|
+
d: "M6 10L4 8H8L6 10Z",
|
|
2455
|
+
fill: "currentColor",
|
|
2456
|
+
opacity: isActive && sortDirection === "desc" ? 1 : 0.3
|
|
2457
|
+
}
|
|
2458
|
+
)
|
|
2459
|
+
]
|
|
2460
|
+
}
|
|
2461
|
+
);
|
|
2462
|
+
};
|
|
2463
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-3", children: [
|
|
2464
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-grid oui-grid-cols-[2fr_1fr_1fr_1fr_1fr_1fr_1.5fr] oui-gap-4 oui-px-4 oui-py-3", children: [
|
|
2465
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.list.poolName") }),
|
|
2466
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2467
|
+
"button",
|
|
2468
|
+
{
|
|
2469
|
+
onClick: () => handleSort("tvl"),
|
|
2470
|
+
className: "oui-flex oui-items-center oui-text-2xs oui-font-normal oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
2471
|
+
children: [
|
|
2472
|
+
"TVL",
|
|
2473
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortIcon, { field: "tvl" })
|
|
2474
|
+
]
|
|
2475
|
+
}
|
|
2476
|
+
),
|
|
2477
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1", children: [
|
|
2478
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2479
|
+
"button",
|
|
2480
|
+
{
|
|
2481
|
+
onClick: () => handleSort("apy"),
|
|
2482
|
+
className: "oui-flex oui-items-center oui-text-2xs oui-font-normal oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
2483
|
+
children: [
|
|
2484
|
+
t("vaults.card.allTimeReturn"),
|
|
2485
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortIcon, { field: "apy" })
|
|
2486
|
+
]
|
|
2487
|
+
}
|
|
2488
|
+
),
|
|
2489
|
+
shouldShowApyTooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2490
|
+
orderlyUi.Tooltip,
|
|
2491
|
+
{
|
|
2492
|
+
content: t("vaults.card.allTimeReturnTooltip"),
|
|
2493
|
+
delayDuration: 100,
|
|
2494
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2495
|
+
orderlyUi.InfoCircleIcon,
|
|
2496
|
+
{
|
|
2497
|
+
size: 12,
|
|
2498
|
+
opacity: 0.54,
|
|
2499
|
+
className: "oui-text-base-contrast"
|
|
2500
|
+
}
|
|
2501
|
+
) })
|
|
2502
|
+
}
|
|
2503
|
+
)
|
|
2504
|
+
] }),
|
|
2505
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2506
|
+
"button",
|
|
2507
|
+
{
|
|
2508
|
+
onClick: () => handleSort("deposits"),
|
|
2509
|
+
className: "oui-flex oui-items-center oui-text-2xs oui-font-normal oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
2510
|
+
children: [
|
|
2511
|
+
t("vaults.list.myDeposits"),
|
|
2512
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortIcon, { field: "deposits" })
|
|
2513
|
+
]
|
|
2514
|
+
}
|
|
2515
|
+
),
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2517
|
+
"button",
|
|
2518
|
+
{
|
|
2519
|
+
onClick: () => handleSort("pnl"),
|
|
2520
|
+
className: "oui-flex oui-items-center oui-text-2xs oui-font-normal oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
2521
|
+
children: [
|
|
2522
|
+
t("vaults.list.allTimePnl"),
|
|
2523
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortIcon, { field: "pnl" })
|
|
2524
|
+
]
|
|
2525
|
+
}
|
|
2526
|
+
),
|
|
2527
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.card.accountBalance") }),
|
|
2528
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-font-normal oui-text-base-contrast-54", children: t("vaults.list.operate") })
|
|
2529
|
+
] }),
|
|
2530
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-flex-col oui-gap-2", children: sortedVaults.map((vault) => /* @__PURE__ */ jsxRuntime.jsx(VaultListRow, { vault }, vault.vault_id)) })
|
|
2531
|
+
] });
|
|
2532
|
+
};
|
|
2533
|
+
VaultListRow = ({ vault }) => {
|
|
2534
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2535
|
+
const script = exports.useVaultCardScript(vault);
|
|
2536
|
+
const {
|
|
2537
|
+
title,
|
|
2538
|
+
vaultInfo,
|
|
2539
|
+
lpInfo,
|
|
2540
|
+
isEVMConnected,
|
|
2541
|
+
isSOLConnected,
|
|
2542
|
+
openDepositAndWithdraw,
|
|
2543
|
+
availableBalance,
|
|
2544
|
+
openVaultWebsite,
|
|
2545
|
+
icon,
|
|
2546
|
+
isButtonsDisabled
|
|
2547
|
+
} = script;
|
|
2548
|
+
vaultInfo.status === "pre_launch";
|
|
2549
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
2550
|
+
const getStatusTag = () => {
|
|
2551
|
+
const { status } = vaultInfo;
|
|
2552
|
+
if (status === "live") {
|
|
2553
|
+
return {
|
|
2554
|
+
text: t("vaults.card.status.active"),
|
|
2555
|
+
color: "#00C076",
|
|
2556
|
+
bgColor: "rgba(0, 192, 118, 0.15)"
|
|
2557
|
+
};
|
|
2558
|
+
} else if (status === "pre_launch") {
|
|
2559
|
+
return {
|
|
2560
|
+
text: t("vaults.card.launchingSoon"),
|
|
2561
|
+
color: "#E88800",
|
|
2562
|
+
bgColor: "rgba(232, 136, 0, 0.15)"
|
|
2563
|
+
};
|
|
2564
|
+
} else if (status === "closing") {
|
|
2565
|
+
return {
|
|
2566
|
+
text: t("vaults.card.status.closing"),
|
|
2567
|
+
color: "#FF6B6B",
|
|
2568
|
+
bgColor: "rgba(255, 107, 107, 0.15)"
|
|
2569
|
+
};
|
|
2570
|
+
} else if (status === "closed") {
|
|
2571
|
+
return {
|
|
2572
|
+
text: t("vaults.card.status.closed"),
|
|
2573
|
+
color: "#999999",
|
|
2574
|
+
bgColor: "rgba(153, 153, 153, 0.15)"
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
return null;
|
|
2578
|
+
};
|
|
2579
|
+
const statusTag = getStatusTag();
|
|
2580
|
+
const formattedAllTimeReturn = React.useMemo(
|
|
2581
|
+
() => exports.formatAllTimeReturn(
|
|
2582
|
+
vaultInfo.status,
|
|
2583
|
+
vaultInfo.vault_age,
|
|
2584
|
+
vaultInfo.lifetime_apy
|
|
2585
|
+
),
|
|
2586
|
+
[vaultInfo.status, vaultInfo.vault_age, vaultInfo.lifetime_apy]
|
|
2587
|
+
);
|
|
2588
|
+
React.useMemo(() => {
|
|
2589
|
+
const chains = Array.isArray(vaultInfo?.supported_chains) ? vaultInfo.supported_chains : [];
|
|
2590
|
+
const ICON_SIZE = isMobile ? 18 : 20;
|
|
2591
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-items-center", children: chains.map((chain, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2592
|
+
"img",
|
|
2593
|
+
{
|
|
2594
|
+
src: `https://oss.orderly.network/static/network_logo/${chain.chain_id}.png`,
|
|
2595
|
+
alt: chain.chain_id,
|
|
2596
|
+
className: orderlyUi.cn(
|
|
2597
|
+
"oui-relative",
|
|
2598
|
+
isMobile ? "oui-size-[18px]" : "oui-size-5"
|
|
2599
|
+
),
|
|
2600
|
+
style: {
|
|
2601
|
+
marginLeft: index > 0 ? "-4px" : "0",
|
|
2602
|
+
zIndex: chains.length - index,
|
|
2603
|
+
width: ICON_SIZE,
|
|
2604
|
+
height: ICON_SIZE
|
|
2605
|
+
}
|
|
2606
|
+
},
|
|
2607
|
+
chain.chain_id
|
|
2608
|
+
)) });
|
|
2609
|
+
}, [vaultInfo.supported_chains, isMobile]);
|
|
2610
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-relative oui-grid oui-grid-cols-[2fr_1fr_1fr_1fr_1fr_1fr_1.5fr] oui-gap-4 oui-rounded-2xl oui-bg-base-9 oui-px-4 oui-py-4 oui-items-center oui-overflow-hidden", children: [
|
|
2611
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10 oui-flex oui-items-center oui-gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
2612
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-sm oui-font-semibold oui-text-base-contrast", children: title }),
|
|
2613
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-wrap oui-items-center oui-gap-2", children: [
|
|
2614
|
+
statusTag && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2615
|
+
"div",
|
|
2616
|
+
{
|
|
2617
|
+
className: "oui-flex oui-items-center oui-gap-[10px] oui-px-2 oui-whitespace-nowrap oui-flex-shrink-0",
|
|
2618
|
+
style: {
|
|
2619
|
+
height: "18px",
|
|
2620
|
+
borderRadius: "4px",
|
|
2621
|
+
background: statusTag.bgColor,
|
|
2622
|
+
color: statusTag.color,
|
|
2623
|
+
fontSize: "12px",
|
|
2624
|
+
fontWeight: 600,
|
|
2625
|
+
lineHeight: "18px",
|
|
2626
|
+
letterSpacing: "0.36px"
|
|
2627
|
+
},
|
|
2628
|
+
children: statusTag.text
|
|
2629
|
+
}
|
|
2630
|
+
),
|
|
2631
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2632
|
+
"button",
|
|
2633
|
+
{
|
|
2634
|
+
onClick: openVaultWebsite,
|
|
2635
|
+
className: "oui-flex oui-items-center oui-gap-1 oui-text-xs oui-font-medium",
|
|
2636
|
+
style: { color: "#608CFF" },
|
|
2637
|
+
children: [
|
|
2638
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("vaults.card.viewMore") }),
|
|
2639
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2640
|
+
orderlyUi.ArrowRightUpSquareFillIcon,
|
|
2641
|
+
{
|
|
2642
|
+
style: { color: "#608CFF" },
|
|
2643
|
+
width: 16,
|
|
2644
|
+
height: 16,
|
|
2645
|
+
viewBox: "0 0 18 18"
|
|
2646
|
+
}
|
|
2647
|
+
)
|
|
2648
|
+
]
|
|
2649
|
+
}
|
|
2650
|
+
)
|
|
2651
|
+
] })
|
|
2652
|
+
] }) }),
|
|
2653
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2654
|
+
orderlyUi.Text.numeral,
|
|
2655
|
+
{
|
|
2656
|
+
className: "oui-text-sm oui-font-normal oui-text-base-contrast",
|
|
2657
|
+
currency: "$",
|
|
2658
|
+
dp: 0,
|
|
2659
|
+
children: vaultInfo.tvl
|
|
2660
|
+
}
|
|
2661
|
+
) }),
|
|
2662
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.gradient, { className: "oui-text-sm oui-font-semibold", color: "brand", children: formattedAllTimeReturn }) }),
|
|
2663
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2664
|
+
orderlyUi.Text.numeral,
|
|
2665
|
+
{
|
|
2666
|
+
className: "oui-text-sm oui-font-normal oui-text-base-contrast",
|
|
2667
|
+
dp: 2,
|
|
2668
|
+
children: lpInfo.deposits
|
|
2669
|
+
}
|
|
2670
|
+
) }),
|
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2672
|
+
orderlyUi.Text.numeral,
|
|
2673
|
+
{
|
|
2674
|
+
className: "oui-text-sm oui-font-normal oui-text-base-contrast",
|
|
2675
|
+
dp: 2,
|
|
2676
|
+
children: lpInfo.earnings
|
|
2677
|
+
}
|
|
2678
|
+
) }),
|
|
2679
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2680
|
+
orderlyUi.Text.numeral,
|
|
2681
|
+
{
|
|
2682
|
+
className: "oui-text-sm oui-font-normal oui-text-base-contrast",
|
|
2683
|
+
dp: 2,
|
|
2684
|
+
children: availableBalance
|
|
2685
|
+
}
|
|
2686
|
+
) }),
|
|
2687
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-relative oui-z-10 oui-flex oui-items-center oui-gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUiConnector.AuthGuard, { buttonProps: { size: "sm" }, children: isEVMConnected || isSOLConnected ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2689
|
+
orderlyUi.Button,
|
|
2690
|
+
{
|
|
2691
|
+
size: "sm",
|
|
2692
|
+
className: "oui-flex-1",
|
|
2693
|
+
disabled: isButtonsDisabled,
|
|
2694
|
+
onClick: () => openDepositAndWithdraw("deposit"),
|
|
2695
|
+
children: t("common.deposit")
|
|
2696
|
+
}
|
|
2697
|
+
),
|
|
2698
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2699
|
+
orderlyUi.Button,
|
|
2700
|
+
{
|
|
2701
|
+
size: "sm",
|
|
2702
|
+
color: "secondary",
|
|
2703
|
+
className: "oui-flex-1",
|
|
2704
|
+
disabled: isButtonsDisabled,
|
|
2705
|
+
onClick: () => openDepositAndWithdraw("withdraw"),
|
|
2706
|
+
children: t("common.withdraw")
|
|
2707
|
+
}
|
|
2708
|
+
)
|
|
2709
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Button, { size: "sm", color: "warning", fullWidth: true, children: t("connector.wrongNetwork") }) }) })
|
|
2710
|
+
] });
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
exports.ViewModeToggle = void 0;
|
|
2715
|
+
var init_view_mode_toggle = __esm({
|
|
2716
|
+
"src/components/all-vaults/view-mode-toggle.tsx"() {
|
|
2717
|
+
exports.ViewModeToggle = ({ mode, onChange }) => {
|
|
2718
|
+
const toggleMode = () => {
|
|
2719
|
+
onChange(mode === "grid" ? "list" : "grid");
|
|
2720
|
+
};
|
|
2721
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2722
|
+
"button",
|
|
2723
|
+
{
|
|
2724
|
+
onClick: toggleMode,
|
|
2725
|
+
className: "oui-flex oui-h-8 oui-w-8 oui-items-center oui-justify-center oui-rounded oui-transition-colors hover:oui-bg-base-6",
|
|
2726
|
+
"aria-label": mode === "grid" ? "Switch to list view" : "Switch to grid view",
|
|
2727
|
+
children: mode === "grid" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2728
|
+
"svg",
|
|
2729
|
+
{
|
|
2730
|
+
width: "18",
|
|
2731
|
+
height: "18",
|
|
2732
|
+
viewBox: "0 0 18 18",
|
|
2733
|
+
fill: "none",
|
|
2734
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2735
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2736
|
+
"path",
|
|
2737
|
+
{
|
|
2738
|
+
d: "M2 4h14v2H2V4zm0 4h14v2H2V8zm0 4h14v2H2v-2z",
|
|
2739
|
+
fill: "currentColor",
|
|
2740
|
+
opacity: "0.54"
|
|
2741
|
+
}
|
|
2742
|
+
)
|
|
2743
|
+
}
|
|
2744
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2745
|
+
"svg",
|
|
2746
|
+
{
|
|
2747
|
+
width: "18",
|
|
2748
|
+
height: "18",
|
|
2749
|
+
viewBox: "0 0 18 18",
|
|
2750
|
+
fill: "none",
|
|
2751
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2752
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2753
|
+
"path",
|
|
2754
|
+
{
|
|
2755
|
+
d: "M2 2h6v6H2V2zm0 8h6v6H2v-6zm8-8h6v6h-6V2zm0 8h6v6h-6v-6z",
|
|
2756
|
+
fill: "currentColor",
|
|
2757
|
+
opacity: "0.54"
|
|
2758
|
+
}
|
|
2759
|
+
)
|
|
2760
|
+
}
|
|
2761
|
+
)
|
|
2762
|
+
}
|
|
2763
|
+
);
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
exports.AllVaultsDesktop = void 0;
|
|
2768
|
+
var init_all_vaults_desktop = __esm({
|
|
2769
|
+
"src/components/all-vaults/all-vaults.desktop.tsx"() {
|
|
2770
|
+
init_vault_card();
|
|
2771
|
+
init_vaults_list();
|
|
2772
|
+
init_view_mode_toggle();
|
|
2773
|
+
exports.AllVaultsDesktop = (props) => {
|
|
2774
|
+
const { vaults } = props;
|
|
2775
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2776
|
+
const [viewMode, setViewMode] = React.useState("grid");
|
|
2777
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col oui-gap-6", children: [
|
|
2778
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-justify-between", children: [
|
|
2779
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xl oui-font-normal oui-text-base-contrast", children: t("vaults.allVaults") }),
|
|
2780
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.ViewModeToggle, { mode: viewMode, onChange: setViewMode })
|
|
2781
|
+
] }),
|
|
2782
|
+
viewMode === "grid" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-grid oui-grid-cols-3 oui-gap-4 min-[1024px]:oui-grid-cols-3", children: vaults.map((vault) => /* @__PURE__ */ jsxRuntime.jsx(exports.VaultCardWidget, { vault }, vault.vault_id)) }) : /* @__PURE__ */ jsxRuntime.jsx(exports.VaultsList, { vaults })
|
|
2783
|
+
] });
|
|
2784
|
+
};
|
|
2785
|
+
}
|
|
2786
|
+
});
|
|
2787
|
+
var AllVaultsMobile;
|
|
2788
|
+
var init_all_vaults_mobile = __esm({
|
|
2789
|
+
"src/components/all-vaults/all-vaults.mobile.tsx"() {
|
|
2790
|
+
init_vault_card();
|
|
2791
|
+
AllVaultsMobile = (props) => {
|
|
2792
|
+
const { vaults } = props;
|
|
2793
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-flex-col oui-gap-3", children: vaults.map((vault) => /* @__PURE__ */ jsxRuntime.jsx(exports.VaultCardWidget, { vault }, vault.vault_id)) });
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
});
|
|
2797
|
+
exports.AllVaultsWidget = void 0;
|
|
2798
|
+
var init_all_vaults_widget = __esm({
|
|
2799
|
+
"src/components/all-vaults/all-vaults.widget.tsx"() {
|
|
2800
|
+
init_vaultsStore();
|
|
2801
|
+
init_all_vaults_desktop();
|
|
2802
|
+
init_all_vaults_mobile();
|
|
2803
|
+
exports.AllVaultsWidget = () => {
|
|
2804
|
+
const { data } = exports.useVaultInfoState();
|
|
2805
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
2806
|
+
return isMobile ? /* @__PURE__ */ jsxRuntime.jsx(AllVaultsMobile, { vaults: data }) : /* @__PURE__ */ jsxRuntime.jsx(exports.AllVaultsDesktop, { vaults: data });
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2810
|
+
|
|
2811
|
+
// src/components/all-vaults/index.ts
|
|
2812
|
+
var all_vaults_exports = {};
|
|
2813
|
+
__export(all_vaults_exports, {
|
|
2814
|
+
AllVaultsDesktop: () => exports.AllVaultsDesktop,
|
|
2815
|
+
AllVaultsWidget: () => exports.AllVaultsWidget,
|
|
2816
|
+
VaultsList: () => exports.VaultsList,
|
|
2817
|
+
ViewModeToggle: () => exports.ViewModeToggle
|
|
2818
|
+
});
|
|
2819
|
+
var init_all_vaults = __esm({
|
|
2820
|
+
"src/components/all-vaults/index.ts"() {
|
|
2821
|
+
init_all_vaults_widget();
|
|
2822
|
+
init_all_vaults_desktop();
|
|
2823
|
+
init_view_mode_toggle();
|
|
2824
|
+
init_vaults_list();
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
|
|
2828
|
+
// src/components/provider/vaults-provider.tsx
|
|
2829
|
+
init_useSVAPIUrl();
|
|
2830
|
+
init_store();
|
|
2831
|
+
var VaultsProvider = (props) => {
|
|
2832
|
+
const svApiUrl = useSVApiUrl();
|
|
2833
|
+
const brokerId = orderlyHooks.useConfig("brokerId");
|
|
2834
|
+
const {
|
|
2835
|
+
fetchVaultInfo,
|
|
2836
|
+
fetchVaultOverallInfo,
|
|
2837
|
+
setVaultsPageConfig,
|
|
2838
|
+
vaultsPageConfig
|
|
2839
|
+
} = exports.useVaultsStore();
|
|
2840
|
+
React.useEffect(() => {
|
|
2841
|
+
if (props.config) {
|
|
2842
|
+
setVaultsPageConfig(props.config);
|
|
2843
|
+
}
|
|
2844
|
+
}, [props.config]);
|
|
2845
|
+
React.useEffect(() => {
|
|
2846
|
+
if (!svApiUrl) {
|
|
2847
|
+
return;
|
|
2848
|
+
}
|
|
2849
|
+
fetchVaultInfo(void 0, svApiUrl);
|
|
2850
|
+
}, [svApiUrl]);
|
|
2851
|
+
React.useEffect(() => {
|
|
2852
|
+
if (!svApiUrl || !brokerId) {
|
|
2853
|
+
return;
|
|
2854
|
+
}
|
|
2855
|
+
const brokerIds = vaultsPageConfig?.overallInfoBrokerIds ? vaultsPageConfig.overallInfoBrokerIds : `orderly,${brokerId}`;
|
|
2856
|
+
fetchVaultOverallInfo(
|
|
2857
|
+
brokerIds ? { broker_ids: brokerIds } : void 0,
|
|
2858
|
+
svApiUrl
|
|
2859
|
+
);
|
|
2860
|
+
}, [
|
|
2861
|
+
svApiUrl,
|
|
2862
|
+
brokerId,
|
|
2863
|
+
vaultsPageConfig?.overallInfoBrokerIds,
|
|
2864
|
+
fetchVaultOverallInfo
|
|
2865
|
+
]);
|
|
2866
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: props.children });
|
|
2867
|
+
};
|
|
2868
|
+
var LazyVaultsHeaderWidget = React__default.default.lazy(
|
|
2869
|
+
() => Promise.resolve().then(() => (init_vaults_header(), vaults_header_exports)).then((mod) => {
|
|
2870
|
+
return { default: mod.VaultsHeaderWidget };
|
|
2871
|
+
})
|
|
2872
|
+
);
|
|
2873
|
+
var LazyVaultsIntroductionWidget = React__default.default.lazy(
|
|
2874
|
+
() => Promise.resolve().then(() => (init_vaults_introduction(), vaults_introduction_exports)).then((mod) => {
|
|
2875
|
+
return { default: mod.VaultsIntroductionWidget };
|
|
2876
|
+
})
|
|
2877
|
+
);
|
|
2878
|
+
var LazyAllVaultsWidget = React__default.default.lazy(
|
|
2879
|
+
() => Promise.resolve().then(() => (init_all_vaults(), all_vaults_exports)).then((mod) => {
|
|
2880
|
+
return { default: mod.AllVaultsWidget };
|
|
2881
|
+
})
|
|
2882
|
+
);
|
|
2883
|
+
var VaultsPage = (props) => {
|
|
2884
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
2885
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VaultsProvider, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2886
|
+
"div",
|
|
2887
|
+
{
|
|
2888
|
+
className: orderlyUi.cn(
|
|
2889
|
+
"oui-relative oui-min-h-screen ",
|
|
2890
|
+
"oui-bg-base-10",
|
|
2891
|
+
isMobile ? "oui-px-3 oui-py-6" : "oui-px-6 oui-py-12",
|
|
2892
|
+
props?.className
|
|
2893
|
+
),
|
|
2894
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2895
|
+
"div",
|
|
2896
|
+
{
|
|
2897
|
+
id: "vaults-content",
|
|
2898
|
+
className: orderlyUi.cn(
|
|
2899
|
+
"oui-mx-auto oui-flex oui-max-w-[1200px] oui-flex-col",
|
|
2900
|
+
isMobile ? "oui-gap-6" : "oui-gap-12"
|
|
2901
|
+
),
|
|
2902
|
+
children: [
|
|
2903
|
+
/* @__PURE__ */ jsxRuntime.jsx(React__default.default.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(LazyVaultsHeaderWidget, {}) }),
|
|
2904
|
+
/* @__PURE__ */ jsxRuntime.jsx(React__default.default.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(LazyVaultsIntroductionWidget, {}) }),
|
|
2905
|
+
/* @__PURE__ */ jsxRuntime.jsx(React__default.default.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(LazyAllVaultsWidget, {}) })
|
|
2906
|
+
]
|
|
2907
|
+
}
|
|
2908
|
+
)
|
|
2909
|
+
}
|
|
2910
|
+
) });
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
// src/types/index.ts
|
|
2914
|
+
init_vault();
|
|
2915
|
+
|
|
2916
|
+
// src/index.ts
|
|
2917
|
+
init_api();
|
|
2918
|
+
init_store();
|
|
2919
|
+
|
|
2920
|
+
// src/components/index.ts
|
|
2921
|
+
init_all_vaults();
|
|
2922
|
+
init_vault_card();
|
|
2923
|
+
init_vaults_header();
|
|
2924
|
+
init_vaults_introduction();
|
|
2925
|
+
|
|
2926
|
+
// src/components/vault-operation/index.ts
|
|
2927
|
+
init_depositAndWithdraw();
|
|
2928
|
+
init_deposit();
|
|
2929
|
+
init_withdraw();
|
|
2930
|
+
|
|
2931
|
+
// src/components/vault-operation/latest-deposit/index.ts
|
|
2932
|
+
init_latest_deposit_widget();
|
|
2933
|
+
|
|
2934
|
+
// src/components/vault-operation/index.ts
|
|
2935
|
+
init_latest_withdraw();
|
|
2936
|
+
|
|
2937
|
+
exports.VaultsPage = VaultsPage;
|
|
2938
|
+
exports.getVaultInfo = getVaultInfo;
|
|
2939
|
+
exports.getVaultLpInfo = getVaultLpInfo;
|
|
2940
|
+
exports.getVaultLpPerformance = getVaultLpPerformance;
|
|
2941
|
+
exports.getVaultOverallInfo = getVaultOverallInfo;
|
|
25
2942
|
//# sourceMappingURL=out.js.map
|
|
26
2943
|
//# sourceMappingURL=index.js.map
|