init commit
This commit is contained in:
commit
6664599bc2
|
@ -0,0 +1,6 @@
|
|||
**/node_modules/*
|
||||
**/out/*
|
||||
**/.next/*
|
||||
**/public/charting_library/*
|
||||
**/public/datafeeds/*
|
||||
**/components/charting_library/*
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"next",
|
||||
"prettier",
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:tailwindcss/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"react/react-in-jsx-scope": 0,
|
||||
"@next/next/no-img-element": 0,
|
||||
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
|
||||
"react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"argsIgnorePattern": "^_"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
name: Code Review
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ['main']
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'yarn'
|
||||
|
||||
- name: Check dep dupes
|
||||
run: yarn ci-dupe-check
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn ci
|
||||
|
||||
- name: Build
|
||||
run: yarn build
|
||||
|
||||
semgrep:
|
||||
name: Code Scan
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: returntocorp/semgrep
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- run: semgrep ci --exclude 'public/charting_library'
|
||||
env:
|
||||
SEMGREP_RULES: p/typescript
|
||||
|
||||
sca:
|
||||
name: Dependency Scan
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Report all vulnerabilities in CI output
|
||||
- name: Report on all vulnerabilities
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
scan-type: 'fs'
|
||||
ignore-unfixed: true
|
||||
hide-progress: true
|
||||
format: 'table'
|
||||
|
||||
# Fail the job on critical vulnerabiliies with fix available
|
||||
- name: Fail on critical vulnerabilities
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
scan-type: 'fs'
|
||||
ignore-unfixed: true
|
||||
hide-progress: true
|
||||
security-checks: 'vuln' # disable secrets scanning until public
|
||||
format: 'table'
|
||||
severity: 'CRITICAL'
|
||||
exit-code: '1'
|
|
@ -0,0 +1,44 @@
|
|||
.serverless/
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
.env
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# TradingView
|
||||
public/charting_library
|
||||
public/datafeeds
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
# Sentry Auth Token
|
||||
.sentryclirc
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
yarn typecheck && yarn lint --quiet && yarn format
|
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
.next
|
||||
.vercel
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
public
|
||||
components/charting_library
|
|
@ -0,0 +1 @@
|
|||
enableScripts: false
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,61 @@
|
|||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
## Dependency Management
|
||||
|
||||
When updating dependencies, there are various files that must be kept up-to-date. Newly added, or updated dependencies can introduce unwanted/malicious scripts that can introduce risks for users and/or developers. The `lavamoat allow-scripts` feature allows us to deny by default, but adds some additional steps to the usual workflow.
|
||||
|
||||
`yarn.lock`:
|
||||
|
||||
- Instead of running `yarn` or `yarn install`, run `yarn setup` to ensure the `yarn.lock` file is in sync and that dependency scripts are run according to the `allowScripts` policy (set in `packages.json`)
|
||||
- If `lavamoat` detects new scripts that are not explicitely allowed/denied, it'll throw and error with details (see below)
|
||||
- Running `yarn setup` will also dedupe the `yarn.lock` file to reduce the dependency tree. Note CI will fail if there are dupes in `yarn.lock`!
|
||||
|
||||
The `allowScripts` configuration in `package.json`:
|
||||
|
||||
- There are two ways to configure script policies:
|
||||
1. Update the allow-scripts section manually by adding the missing package in the `allowScripts` section in `package.json`
|
||||
2. Run `yarn allow-scripts auto` to update the `allowScripts` configuration automatically
|
||||
- Review each new package to determine whether the install script needs to run or not, testing if necessary.
|
||||
- Use `npx can-i-ignore-scripts` to help assessing whether scripts are needed
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
|
||||
|
||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
|
||||
## Creating Color Themes
|
||||
|
||||
1. Copy one of the other color themes in [tailwind.config.js](https://github.com/blockworks-foundation/mango-v4-ui/blob/main/tailwind.config.js) (starting line 25)
|
||||
2. Modify the colors. For the variables bkg-\* and fgd-\* pick a base color for bkg-1 and fgd-1 then adjust the lightness for 2-4. Use this same process to create dark/hover variations for the colors that have these properties. The base color can be anything that works for your theme.
|
||||
3. Add your corresponding theme values [here](https://github.com/blockworks-foundation/mango-v4-ui/blob/main/styles/colors.ts). The format needs to be converted to HEX, you can paste the HSL values into [Coolors](https://coolors.co/fff05a-ffd25a-ffaa5a-ff785a-191919) to do this.
|
||||
4. Copy one of the other themes in [global.css](https://github.com/blockworks-foundation/mango-v4-ui/blob/main/styles/globals.css) and modify to match your theme name in tailwind.config.js
|
||||
5. Add a translation variable for your theme name in [locales](https://github.com/blockworks-foundation/mango-v4-ui/tree/main/public/locales). Theme names are to be added to settings.json and make sure to add this to each locale (they can all be in English to start with). Make sure the value matches data-theme from your css vars in global.css
|
||||
6. Add your theme to the THEMES array in [display settings](https://github.com/blockworks-foundation/mango-v4-ui/blob/main/components/settings/DisplaySettings.tsx). It should go after mango-classic then in alphabetical order. You need to use the translation key you added to the locales.
|
|
@ -0,0 +1,49 @@
|
|||
import useMangoGroup from 'hooks/useMangoGroup'
|
||||
import { useMemo } from 'react'
|
||||
import FormatNumericValue from './shared/FormatNumericValue'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
|
||||
const AccountStats = ({ token }: { token: string }) => {
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
const { group } = useMangoGroup()
|
||||
|
||||
const bank = useMemo(() => {
|
||||
if (!group) return undefined
|
||||
return group.banksMapByName.get(token)?.[0]
|
||||
}, [group, token])
|
||||
|
||||
const position = bank ? mangoAccount?.getTokenBalanceUi(bank) || 0.0 : 0.0
|
||||
|
||||
return (
|
||||
<div className="my-8 ml-4 mr-8">
|
||||
<div className="grid grid-cols-2 gap-8">
|
||||
<div>
|
||||
<div>Est. {token} APR</div>
|
||||
<div className="text-2xl font-bold">14.89%</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Max Leverage</div>
|
||||
<div className="text-2xl font-bold">3x</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Available to borrow</div>
|
||||
<div className="text-2xl font-bold">100,000</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Your position</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{bank ? <FormatNumericValue value={position} decimals={6} /> : 0.0}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Title Here</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Title Here</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AccountStats
|
|
@ -0,0 +1,42 @@
|
|||
import React, { Component, ErrorInfo, ReactNode } from 'react'
|
||||
|
||||
interface Props {
|
||||
children?: ReactNode
|
||||
}
|
||||
|
||||
interface State {
|
||||
error: Error | null | undefined
|
||||
hasError: boolean
|
||||
}
|
||||
|
||||
class ErrorBoundary extends Component<Props, State> {
|
||||
public state: State = {
|
||||
error: null,
|
||||
hasError: false,
|
||||
}
|
||||
|
||||
public static getDerivedStateFromError(e: Error): State {
|
||||
// Update state so the next render will show the fallback UI.
|
||||
return { hasError: true, error: e }
|
||||
}
|
||||
|
||||
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
console.error('Uncaught error:', error, errorInfo)
|
||||
}
|
||||
|
||||
public render() {
|
||||
const error = this.state.error
|
||||
if (this.state.hasError) {
|
||||
return (
|
||||
<div>
|
||||
<p>Error. Please refresh</p>
|
||||
<div>{`${error}`}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return this.props.children
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorBoundary
|
|
@ -0,0 +1,18 @@
|
|||
import { PhotoIcon } from '@heroicons/react/20/solid'
|
||||
import { useState } from 'react'
|
||||
|
||||
export const ImgWithLoader = (props: {
|
||||
className: string
|
||||
src: string
|
||||
alt: string
|
||||
}) => {
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
return (
|
||||
<div className="relative">
|
||||
{isLoading && (
|
||||
<PhotoIcon className="absolute left-1/2 top-1/2 z-10 h-1/4 w-1/4 -translate-x-1/2 -translate-y-1/2 animate-pulse text-th-fgd-4" />
|
||||
)}
|
||||
<img {...props} onLoad={() => setIsLoading(false)} alt={props.alt} />
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
import { Fragment, ReactNode, useEffect, useMemo, useState } from 'react'
|
||||
import { ArrowPathIcon } from '@heroicons/react/20/solid'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import BottomBar from './mobile/BottomBar'
|
||||
import TopBar from './TopBar'
|
||||
import useLocalStorageState from '../hooks/useLocalStorageState'
|
||||
import { ACCEPT_TERMS_KEY, SECONDS } from '../utils/constants'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import useInterval from './shared/useInterval'
|
||||
import { Transition } from '@headlessui/react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import TermsOfUseModal from './modals/TermsOfUseModal'
|
||||
|
||||
export const sideBarAnimationDuration = 300
|
||||
const termsLastUpdated = 1679441610978
|
||||
|
||||
const Layout = ({ children }: { children: ReactNode }) => {
|
||||
const themeData = mangoStore((s) => s.themeData)
|
||||
|
||||
const [mounted, setMounted] = useState(false)
|
||||
useEffect(() => setMounted(true), [])
|
||||
if (!mounted) return null
|
||||
|
||||
return (
|
||||
<main
|
||||
className={`${themeData.fonts.body.variable} ${themeData.fonts.display.variable} ${themeData.fonts.mono.variable} font-sans`}
|
||||
>
|
||||
<div className={`min-h-screen grow text-th-fgd-2 transition-all`}>
|
||||
<div className="fixed bottom-0 left-0 z-20 w-full md:hidden">
|
||||
<BottomBar />
|
||||
</div>
|
||||
{/* note: overflow-x-hidden below prevents position sticky from working in activity feed */}
|
||||
<div
|
||||
className={`w-full transition-all duration-${sideBarAnimationDuration} ease-in-out`}
|
||||
>
|
||||
<TopBar />
|
||||
{children}
|
||||
</div>
|
||||
<DeployRefreshManager />
|
||||
<TermsOfUse />
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export default Layout
|
||||
|
||||
const TermsOfUse = () => {
|
||||
const { connected } = useWallet()
|
||||
const [acceptTerms, setAcceptTerms] = useLocalStorageState(
|
||||
ACCEPT_TERMS_KEY,
|
||||
'',
|
||||
)
|
||||
|
||||
const showTermsOfUse = useMemo(() => {
|
||||
return (!acceptTerms || acceptTerms < termsLastUpdated) && connected
|
||||
}, [acceptTerms, connected])
|
||||
|
||||
return (
|
||||
<>
|
||||
{showTermsOfUse ? (
|
||||
<TermsOfUseModal
|
||||
isOpen={showTermsOfUse}
|
||||
onClose={() => setAcceptTerms(Date.now())}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function DeployRefreshManager(): JSX.Element | null {
|
||||
const { t } = useTranslation('common')
|
||||
const [newBuildAvailable, setNewBuildAvailable] = useState(false)
|
||||
|
||||
useInterval(async () => {
|
||||
const response = await fetch('/api/build-id')
|
||||
const { buildId } = await response.json()
|
||||
|
||||
if (buildId && process.env.BUILD_ID && buildId !== process.env.BUILD_ID) {
|
||||
// There's a new version deployed that we need to load
|
||||
setNewBuildAvailable(true)
|
||||
}
|
||||
}, 300 * SECONDS)
|
||||
|
||||
return (
|
||||
<Transition
|
||||
appear={true}
|
||||
show={newBuildAvailable}
|
||||
as={Fragment}
|
||||
enter="transition ease-in duration-300"
|
||||
enterFrom="translate-y-0"
|
||||
enterTo="-translate-y-[130px] md:-translate-y-20"
|
||||
leave="transition ease-out"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<button
|
||||
className="fixed -bottom-[46px] left-1/2 z-50 flex -translate-x-1/2 items-center rounded-full border border-th-bkg-4 bg-th-bkg-3 px-4 py-3 shadow-md focus:outline-none md:hover:bg-th-bkg-4 md:hover:shadow-none"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
<p className="mr-2 whitespace-nowrap text-th-fgd-1">
|
||||
{t('new-version')}
|
||||
</p>
|
||||
<ArrowPathIcon className="h-5 w-5" />
|
||||
</button>
|
||||
</Transition>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
import { useCallback, useEffect } from 'react'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { Keypair, PublicKey } from '@solana/web3.js'
|
||||
import { useRouter } from 'next/router'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
import useInterval from './shared/useInterval'
|
||||
import { LAST_WALLET_NAME, PRIORITY_FEE_KEY, SECONDS } from 'utils/constants'
|
||||
import useNetworkSpeed from 'hooks/useNetworkSpeed'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { DEFAULT_PRIORITY_FEE_LEVEL } from './settings/RpcSettings'
|
||||
import { useHiddenMangoAccounts } from 'hooks/useHiddenMangoAccounts'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
const actions = mangoStore.getState().actions
|
||||
|
||||
const HydrateStore = () => {
|
||||
const router = useRouter()
|
||||
const { name: marketName } = router.query
|
||||
const { mangoAccountPk, mangoAccountAddress } = useMangoAccount()
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const slowNetwork = useNetworkSpeed()
|
||||
const { wallet } = useWallet()
|
||||
|
||||
const [, setLastWalletName] = useLocalStorageState(LAST_WALLET_NAME, '')
|
||||
|
||||
const handleWindowResize = useCallback(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
set((s) => {
|
||||
s.window.width = window.innerWidth
|
||||
s.window.height = window.innerHeight
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
// store the window width and height on resize
|
||||
useEffect(() => {
|
||||
handleWindowResize()
|
||||
window.addEventListener('resize', handleWindowResize)
|
||||
return () => window.removeEventListener('resize', handleWindowResize)
|
||||
}, [handleWindowResize])
|
||||
|
||||
useEffect(() => {
|
||||
if (wallet?.adapter) {
|
||||
setLastWalletName(wallet?.adapter.name)
|
||||
}
|
||||
}, [wallet, setLastWalletName])
|
||||
|
||||
useEffect(() => {
|
||||
if (marketName && typeof marketName === 'string') {
|
||||
set((s) => {
|
||||
s.selectedMarket.name = marketName
|
||||
})
|
||||
}
|
||||
actions.fetchGroup()
|
||||
}, [marketName])
|
||||
|
||||
useInterval(
|
||||
() => {
|
||||
actions.fetchGroup()
|
||||
},
|
||||
(slowNetwork ? 60 : 30) * SECONDS,
|
||||
)
|
||||
|
||||
// refetches open orders every 30 seconds
|
||||
// only the selected market's open orders are updated via websocket
|
||||
useInterval(
|
||||
() => {
|
||||
if (mangoAccountAddress) {
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
},
|
||||
(slowNetwork ? 60 : 30) * SECONDS,
|
||||
)
|
||||
|
||||
// refetch trade history and activity feed when switching accounts
|
||||
useEffect(() => {
|
||||
const actions = mangoStore.getState().actions
|
||||
if (mangoAccountAddress) {
|
||||
actions.fetchActivityFeed(mangoAccountAddress)
|
||||
}
|
||||
}, [mangoAccountAddress])
|
||||
|
||||
// reload and parse market fills from the event queue
|
||||
useInterval(
|
||||
async () => {
|
||||
const actions = mangoStore.getState().actions
|
||||
actions.loadMarketFills()
|
||||
},
|
||||
(slowNetwork ? 60 : 20) * SECONDS,
|
||||
)
|
||||
|
||||
// estimate the priority fee every 30 seconds
|
||||
useInterval(
|
||||
async () => {
|
||||
if (mangoAccountAddress) {
|
||||
const priorityFeeMultiplier = Number(
|
||||
localStorage.getItem(PRIORITY_FEE_KEY) ??
|
||||
DEFAULT_PRIORITY_FEE_LEVEL.value,
|
||||
)
|
||||
actions.estimatePriorityFee(priorityFeeMultiplier)
|
||||
}
|
||||
},
|
||||
(slowNetwork ? 60 : 10) * SECONDS,
|
||||
)
|
||||
|
||||
// The websocket library solana/web3.js uses closes its websocket connection when the subscription list
|
||||
// is empty after opening its first time, preventing subsequent subscriptions from receiving responses.
|
||||
// This is a hack to prevent the list from every getting empty
|
||||
useEffect(() => {
|
||||
const id = connection.onAccountChange(new Keypair().publicKey, () => {
|
||||
return
|
||||
})
|
||||
return () => {
|
||||
connection.removeAccountChangeListener(id)
|
||||
}
|
||||
}, [connection])
|
||||
|
||||
// watch selected Mango Account for changes
|
||||
useEffect(() => {
|
||||
const client = mangoStore.getState().client
|
||||
if (!mangoAccountPk) return
|
||||
const subscriptionId = connection.onAccountChange(
|
||||
mangoAccountPk,
|
||||
async (info, context) => {
|
||||
if (info?.lamports === 0) return
|
||||
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
if (!mangoAccount) return
|
||||
const newMangoAccount = client.getMangoAccountFromAi(
|
||||
mangoAccount.publicKey,
|
||||
info,
|
||||
)
|
||||
// don't fetch serum3OpenOrders if the slot is old
|
||||
if (context.slot > mangoStore.getState().mangoAccount.lastSlot) {
|
||||
if (newMangoAccount.serum3Active().length > 0) {
|
||||
await newMangoAccount.reloadSerum3OpenOrders(client)
|
||||
// check again that the slot is still the most recent after the reloading open orders
|
||||
if (context.slot > mangoStore.getState().mangoAccount.lastSlot) {
|
||||
set((s) => {
|
||||
s.mangoAccount.current = newMangoAccount
|
||||
s.mangoAccount.lastSlot = context.slot
|
||||
})
|
||||
}
|
||||
}
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return () => {
|
||||
connection.removeAccountChangeListener(subscriptionId)
|
||||
}
|
||||
}, [connection, mangoAccountPk])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const ReadOnlyMangoAccount = () => {
|
||||
const router = useRouter()
|
||||
const groupLoaded = mangoStore((s) => s.groupLoaded)
|
||||
const ma = router.query?.address
|
||||
const { hiddenAccounts } = useHiddenMangoAccounts()
|
||||
|
||||
useEffect(() => {
|
||||
if (!groupLoaded) return
|
||||
const set = mangoStore.getState().set
|
||||
const group = mangoStore.getState().group
|
||||
|
||||
async function loadUnownedMangoAccount() {
|
||||
try {
|
||||
if (!ma || !group || hiddenAccounts?.includes(ma as string)) return
|
||||
|
||||
const client = mangoStore.getState().client
|
||||
const pk = new PublicKey(ma)
|
||||
const readOnlyMangoAccount = await client.getMangoAccount(pk)
|
||||
await readOnlyMangoAccount.reloadSerum3OpenOrders(client)
|
||||
set((state) => {
|
||||
state.mangoAccount.current = readOnlyMangoAccount
|
||||
state.mangoAccount.initialLoad = false
|
||||
})
|
||||
await actions.fetchOpenOrders()
|
||||
} catch (error) {
|
||||
console.error('error', error)
|
||||
}
|
||||
}
|
||||
|
||||
if (ma) {
|
||||
set((state) => {
|
||||
state.mangoAccount.initialLoad = true
|
||||
})
|
||||
loadUnownedMangoAccount()
|
||||
}
|
||||
}, [ma, groupLoaded, router])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const MangoProvider = () => {
|
||||
return (
|
||||
<>
|
||||
<HydrateStore />
|
||||
<ReadOnlyMangoAccount />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default MangoProvider
|
|
@ -0,0 +1,62 @@
|
|||
import { Connection } from '@solana/web3.js'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { useEffect, useState } from 'react'
|
||||
import useInterval from './shared/useInterval'
|
||||
import { formatNumericValue } from 'utils/numbers'
|
||||
import Tooltip from './shared/Tooltip'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { StatusDot } from './Tps'
|
||||
|
||||
const rpcAlertThreshold = 250
|
||||
const rpcWarningThreshold = 500
|
||||
|
||||
const getPingTime = async (
|
||||
connection: Connection,
|
||||
setRpcPing: (x: number) => void,
|
||||
) => {
|
||||
const startTime = Date.now()
|
||||
try {
|
||||
await connection.getSlot()
|
||||
|
||||
const endTime = Date.now()
|
||||
const pingTime = endTime - startTime
|
||||
setRpcPing(pingTime)
|
||||
} catch (error) {
|
||||
console.error('Error pinging the RPC:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const RpcPing = () => {
|
||||
const { t } = useTranslation('common')
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const [rpcPing, setRpcPing] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
getPingTime(connection, setRpcPing)
|
||||
}, [])
|
||||
|
||||
useInterval(() => {
|
||||
getPingTime(connection, setRpcPing)
|
||||
}, 30 * 1000)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center">
|
||||
<StatusDot
|
||||
status={rpcPing}
|
||||
alert={rpcAlertThreshold}
|
||||
warning={rpcWarningThreshold}
|
||||
/>
|
||||
<Tooltip content={t('rpc-ping')}>
|
||||
<span className="font-mono text-xs text-th-fgd-2">
|
||||
<span className="mr-1">{formatNumericValue(rpcPing, 0)}</span>
|
||||
<span className="font-normal text-th-fgd-4">MS</span>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RpcPing
|
|
@ -0,0 +1,79 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import sumBy from 'lodash/sumBy'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { Connection } from '@solana/web3.js'
|
||||
import mangoStore, { CLUSTER } from '@store/mangoStore'
|
||||
import useInterval from './shared/useInterval'
|
||||
|
||||
const tpsAlertThreshold = 1000
|
||||
const tpsWarningThreshold = 1300
|
||||
|
||||
const getRecentPerformance = async (
|
||||
connection: Connection,
|
||||
setTps: (x: number) => void,
|
||||
) => {
|
||||
try {
|
||||
const samples = 2
|
||||
const response = await connection.getRecentPerformanceSamples(samples)
|
||||
const totalSecs = sumBy(response, 'samplePeriodSecs')
|
||||
const totalTransactions = sumBy(response, 'numTransactions')
|
||||
const tps = totalTransactions / totalSecs
|
||||
|
||||
setTps(tps)
|
||||
} catch {
|
||||
console.warn('Unable to fetch TPS')
|
||||
}
|
||||
}
|
||||
|
||||
const SolanaTps = () => {
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const [tps, setTps] = useState(0)
|
||||
const { t } = useTranslation('common')
|
||||
|
||||
useEffect(() => {
|
||||
getRecentPerformance(connection, setTps)
|
||||
}, [])
|
||||
|
||||
useInterval(() => {
|
||||
getRecentPerformance(connection, setTps)
|
||||
}, 60 * 1000)
|
||||
|
||||
if (CLUSTER == 'mainnet-beta') {
|
||||
return (
|
||||
<div>
|
||||
<p className="text-xs text-th-fgd-4">{t('solana-tps')}</p>
|
||||
<div className="flex items-center">
|
||||
<div className="relative mr-1 h-3 w-3">
|
||||
<div
|
||||
className={`absolute left-0.5 top-0.5 h-2 w-2 rounded-full ${
|
||||
tps < tpsWarningThreshold
|
||||
? 'bg-th-warning'
|
||||
: tps < tpsAlertThreshold
|
||||
? 'bg-th-error'
|
||||
: 'bg-th-success'
|
||||
}`}
|
||||
/>
|
||||
<div
|
||||
className={`absolute h-3 w-3 rounded-full opacity-40 ${
|
||||
tps < tpsWarningThreshold
|
||||
? 'bg-th-warning'
|
||||
: tps < tpsAlertThreshold
|
||||
? 'bg-th-error'
|
||||
: 'bg-th-success'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
<span className="font-mono text-th-fgd-2">
|
||||
{tps?.toLocaleString(undefined, {
|
||||
maximumFractionDigits: 0,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export default SolanaTps
|
|
@ -0,0 +1,403 @@
|
|||
import { ArrowPathIcon, ExclamationCircleIcon } from '@heroicons/react/20/solid'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import NumberFormat, { NumberFormatValues } from 'react-number-format'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import {
|
||||
ACCOUNT_ACTION_MODAL_INNER_HEIGHT,
|
||||
// INPUT_TOKEN_DEFAULT,
|
||||
} from '../utils/constants'
|
||||
import { notify } from '../utils/notifications'
|
||||
import { TokenAccount } from '../utils/tokens'
|
||||
// import ActionTokenList from './account/ActionTokenList'
|
||||
import Label from './forms/Label'
|
||||
import Button, { IconButton } from './shared/Button'
|
||||
import Loading from './shared/Loading'
|
||||
import { EnterBottomExitBottom, FadeInFadeOut } from './shared/Transitions'
|
||||
import MaxAmountButton from '@components/shared/MaxAmountButton'
|
||||
import Tooltip from '@components/shared/Tooltip'
|
||||
import SolBalanceWarnings from '@components/shared/SolBalanceWarnings'
|
||||
import useSolBalance from 'hooks/useSolBalance'
|
||||
import { floorToDecimal, withValueLimit } from 'utils/numbers'
|
||||
import BankAmountWithValue from './shared/BankAmountWithValue'
|
||||
// import useBanksWithBalances from 'hooks/useBanksWithBalances'
|
||||
import { isMangoError } from 'types'
|
||||
import TokenListButton from './shared/TokenListButton'
|
||||
import TokenLogo from './shared/TokenLogo'
|
||||
import SecondaryConnectButton from './shared/SecondaryConnectButton'
|
||||
import useMangoAccountAccounts from 'hooks/useMangoAccountAccounts'
|
||||
import InlineNotification from './shared/InlineNotification'
|
||||
import Link from 'next/link'
|
||||
import BackButton from './swap/BackButton'
|
||||
import LeverageSlider from './shared/LeverageSlider'
|
||||
import useMangoGroup from 'hooks/useMangoGroup'
|
||||
import FormatNumericValue from './shared/FormatNumericValue'
|
||||
import { stakeAndCreate } from 'utils/transactions'
|
||||
import { MangoAccount } from '@blockworks-foundation/mango-v4'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
interface DepositFormProps {
|
||||
onSuccess: () => void
|
||||
token: string
|
||||
}
|
||||
|
||||
export const walletBalanceForToken = (
|
||||
walletTokens: TokenAccount[],
|
||||
token: string,
|
||||
): { maxAmount: number; maxDecimals: number } => {
|
||||
const group = mangoStore.getState().group
|
||||
const bank = group?.banksMapByName.get(token)?.[0]
|
||||
|
||||
let walletToken
|
||||
if (bank) {
|
||||
const tokenMint = bank?.mint
|
||||
walletToken = tokenMint
|
||||
? walletTokens.find((t) => t.mint.toString() === tokenMint.toString())
|
||||
: null
|
||||
}
|
||||
|
||||
return {
|
||||
maxAmount: walletToken ? walletToken.uiAmount : 0,
|
||||
maxDecimals: bank?.mintDecimals || 6,
|
||||
}
|
||||
}
|
||||
|
||||
const getNextAccountNumber = (accounts: MangoAccount[]): number => {
|
||||
if (accounts.length > 1) {
|
||||
return (
|
||||
accounts
|
||||
.map((a) => a.accountNum)
|
||||
.reduce((a, b) => Math.max(a, b), -Infinity) + 1
|
||||
)
|
||||
} else if (accounts.length === 1) {
|
||||
return accounts[0].accountNum + 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function DepositForm({ onSuccess, token: selectedToken }: DepositFormProps) {
|
||||
const { t } = useTranslation(['common', 'account'])
|
||||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
// const [selectedToken, setSelectedToken] = useState(
|
||||
// token || INPUT_TOKEN_DEFAULT,
|
||||
// )
|
||||
const [leverage, setLeverage] = useState(1)
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [refreshingWalletTokens, setRefreshingWalletTokens] = useState(false)
|
||||
const { maxSolDeposit } = useSolBalance()
|
||||
// const banks = useBanksWithBalances('walletBalance')
|
||||
const { usedTokens, totalTokens } = useMangoAccountAccounts()
|
||||
const { group } = useMangoGroup()
|
||||
|
||||
const stakeBank = useMemo(() => {
|
||||
return group?.banksMapByName.get(selectedToken)?.[0]
|
||||
}, [selectedToken, group])
|
||||
|
||||
const solBank = useMemo(() => {
|
||||
return group?.banksMapByName.get('SOL')?.[0]
|
||||
}, [group])
|
||||
|
||||
const tokenPositionsFull = useMemo(() => {
|
||||
if (!stakeBank || !usedTokens.length || !totalTokens.length) return false
|
||||
const hasTokenPosition = usedTokens.find(
|
||||
(token) => token.tokenIndex === stakeBank.tokenIndex,
|
||||
)
|
||||
return hasTokenPosition ? false : usedTokens.length >= totalTokens.length
|
||||
}, [stakeBank, usedTokens, totalTokens])
|
||||
|
||||
const { connected, publicKey } = useWallet()
|
||||
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
||||
|
||||
const tokenMax = useMemo(() => {
|
||||
return walletBalanceForToken(walletTokens, selectedToken)
|
||||
}, [walletTokens, selectedToken])
|
||||
|
||||
const setMax = useCallback(() => {
|
||||
const max = floorToDecimal(tokenMax.maxAmount, 6)
|
||||
setInputAmount(max.toFixed())
|
||||
}, [tokenMax])
|
||||
|
||||
// const handleSelectToken = (token: string) => {
|
||||
// setSelectedToken(token)
|
||||
// setShowTokenList(false)
|
||||
// }
|
||||
|
||||
const solAmountToBorrow = useMemo(() => {
|
||||
const solPrice = solBank?.uiPrice
|
||||
const stakePrice = stakeBank?.uiPrice
|
||||
if (!solPrice || !stakePrice || !Number(inputAmount)) return 0
|
||||
const priceDifference = (stakePrice - solPrice) / solPrice
|
||||
const borrowAmount =
|
||||
(1 + priceDifference) * Number(inputAmount) * (leverage - 1)
|
||||
|
||||
return borrowAmount
|
||||
}, [leverage, solBank, stakeBank, inputAmount])
|
||||
|
||||
const handleRefreshWalletBalances = useCallback(async () => {
|
||||
if (!publicKey) return
|
||||
const actions = mangoStore.getState().actions
|
||||
setRefreshingWalletTokens(true)
|
||||
await actions.fetchWalletTokens(publicKey)
|
||||
setRefreshingWalletTokens(false)
|
||||
}, [publicKey])
|
||||
|
||||
const handleDeposit = useCallback(async () => {
|
||||
const client = mangoStore.getState().client
|
||||
const group = mangoStore.getState().group
|
||||
const actions = mangoStore.getState().actions
|
||||
const mangoAccounts = mangoStore.getState().mangoAccounts
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
|
||||
if (!group || !stakeBank || !publicKey) return
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
console.log('starting deposit')
|
||||
console.log('solAmountToBorrow', solAmountToBorrow)
|
||||
|
||||
const newAccountNum = getNextAccountNumber(mangoAccounts)
|
||||
const { signature: tx, slot } = await stakeAndCreate(
|
||||
client,
|
||||
group,
|
||||
mangoAccount,
|
||||
solAmountToBorrow,
|
||||
stakeBank.mint,
|
||||
parseFloat(inputAmount),
|
||||
newAccountNum,
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
type: 'success',
|
||||
txid: tx,
|
||||
})
|
||||
|
||||
await actions.reloadMangoAccount(slot)
|
||||
actions.fetchWalletTokens(publicKey)
|
||||
setSubmitting(false)
|
||||
onSuccess()
|
||||
} catch (e) {
|
||||
console.error('Error depositing:', e)
|
||||
setSubmitting(false)
|
||||
if (!isMangoError(e)) return
|
||||
notify({
|
||||
title: 'Transaction failed',
|
||||
description: e.message,
|
||||
txid: e?.txid,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}, [stakeBank, publicKey, inputAmount, solAmountToBorrow, onSuccess])
|
||||
|
||||
const showInsufficientBalance =
|
||||
tokenMax.maxAmount < Number(inputAmount) ||
|
||||
(selectedToken === 'SOL' && maxSolDeposit <= 0)
|
||||
|
||||
const changeLeverage = useCallback((v: string) => {
|
||||
setLeverage(Number(v) * 1)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const group = mangoStore.getState().group
|
||||
set((state) => {
|
||||
state.swap.outputBank = group?.banksMapByName.get(selectedToken)?.[0]
|
||||
})
|
||||
}, [selectedToken])
|
||||
|
||||
return (
|
||||
<>
|
||||
<EnterBottomExitBottom
|
||||
className={`absolute bottom-0 left-0 z-20 h-[${ACCOUNT_ACTION_MODAL_INNER_HEIGHT}] w-full overflow-auto rounded-lg bg-th-bkg-1 p-6`}
|
||||
show={showTokenList}
|
||||
>
|
||||
<BackButton onClick={() => setShowTokenList(false)} />
|
||||
<h2 className="mb-4 text-center text-lg">Select token to stake</h2>
|
||||
<div className="flex items-center px-4 pb-2">
|
||||
<div className="w-1/2 text-left">
|
||||
<p className="text-xs">{t('token')}</p>
|
||||
</div>
|
||||
<div className="w-1/2 text-right">
|
||||
<p className="whitespace-nowrap text-xs">{t('wallet-balance')}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/* <ActionTokenList
|
||||
banks={banks}
|
||||
onSelect={handleSelectToken}
|
||||
showDepositRates
|
||||
valueKey="walletBalance"
|
||||
/> */}
|
||||
</EnterBottomExitBottom>
|
||||
<FadeInFadeOut show={!showTokenList}>
|
||||
<div className="m-6 flex flex-col justify-between">
|
||||
<div>
|
||||
<SolBalanceWarnings
|
||||
amount={inputAmount}
|
||||
className="mb-4"
|
||||
setAmount={setInputAmount}
|
||||
selectedToken={selectedToken}
|
||||
/>
|
||||
<div className="grid grid-cols-2">
|
||||
<div className="col-span-2 flex justify-between">
|
||||
<Label text={`Stake Token`} />
|
||||
<div className="mb-2 flex items-center space-x-2">
|
||||
<MaxAmountButton
|
||||
decimals={tokenMax.maxDecimals}
|
||||
label={t('wallet-balance')}
|
||||
onClick={setMax}
|
||||
value={tokenMax.maxAmount}
|
||||
/>
|
||||
<Tooltip content={t('account:refresh-balance')}>
|
||||
<IconButton
|
||||
className={refreshingWalletTokens ? 'animate-spin' : ''}
|
||||
onClick={handleRefreshWalletBalances}
|
||||
hideBg
|
||||
>
|
||||
<ArrowPathIcon className="h-4 w-4" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-1">
|
||||
<TokenListButton
|
||||
token={selectedToken}
|
||||
logo={<TokenLogo bank={stakeBank} />}
|
||||
setShowList={setShowTokenList}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-1">
|
||||
<NumberFormat
|
||||
name="amountIn"
|
||||
id="amountIn"
|
||||
inputMode="decimal"
|
||||
thousandSeparator=","
|
||||
allowNegative={false}
|
||||
isNumericString={true}
|
||||
decimalScale={6}
|
||||
className={
|
||||
'w-full rounded-lg rounded-l-none border border-th-input-border bg-th-input-bkg p-3 text-right font-mono text-xl text-th-fgd-1 focus:outline-none focus-visible:border-th-fgd-4 md:hover:border-th-input-border-hover md:hover:focus-visible:border-th-fgd-4'
|
||||
}
|
||||
placeholder="0.00"
|
||||
value={inputAmount}
|
||||
onValueChange={(e: NumberFormatValues) => {
|
||||
setInputAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}}
|
||||
isAllowed={withValueLimit}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3">
|
||||
<div>Leverage: {leverage}x</div>
|
||||
<LeverageSlider
|
||||
amount={leverage}
|
||||
leverageMax={3}
|
||||
onChange={changeLeverage}
|
||||
step={0.1}
|
||||
/>
|
||||
</div>
|
||||
{stakeBank && solBank ? (
|
||||
<>
|
||||
<div className="mt-2 space-y-1.5 px-2 py-4 text-sm">
|
||||
<div className="flex justify-between">
|
||||
<p>{t('deposit-amount')}</p>
|
||||
<BankAmountWithValue
|
||||
amount={inputAmount}
|
||||
bank={stakeBank}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p>SOL borrowed</p>
|
||||
{solBank ? (
|
||||
<FormatNumericValue
|
||||
value={solAmountToBorrow}
|
||||
decimals={3}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5 border-t border-th-bkg-3 px-2 py-4 text-sm ">
|
||||
<div className="flex justify-between">
|
||||
<p>{selectedToken} Leveraged APR</p>
|
||||
<span>
|
||||
<FormatNumericValue
|
||||
value={7.28 * leverage}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p>{selectedToken} Deposit Rate</p>
|
||||
<span>
|
||||
<FormatNumericValue
|
||||
value={stakeBank.getDepositRateUi()}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p>SOL Borrow Rate</p>
|
||||
<span>
|
||||
<FormatNumericValue
|
||||
value={solBank.getDepositRateUi()}
|
||||
decimals={2}
|
||||
/>
|
||||
%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
{connected ? (
|
||||
<Button
|
||||
onClick={handleDeposit}
|
||||
className="flex w-full items-center justify-center"
|
||||
disabled={connected && (!inputAmount || showInsufficientBalance)}
|
||||
size="large"
|
||||
>
|
||||
{submitting ? (
|
||||
<Loading className="mr-2 h-5 w-5" />
|
||||
) : showInsufficientBalance ? (
|
||||
<div className="flex items-center">
|
||||
<ExclamationCircleIcon className="mr-2 h-5 w-5 flex-shrink-0" />
|
||||
{t('swap:insufficient-balance', {
|
||||
symbol: selectedToken,
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center">
|
||||
Leverage Stake {inputAmount} {selectedToken}
|
||||
</div>
|
||||
)}
|
||||
</Button>
|
||||
) : (
|
||||
<SecondaryConnectButton
|
||||
className="flex w-full items-center justify-center"
|
||||
isLarge
|
||||
/>
|
||||
)}
|
||||
{tokenPositionsFull ? (
|
||||
<InlineNotification
|
||||
type="error"
|
||||
desc={
|
||||
<>
|
||||
{t('error-token-positions-full')}{' '}
|
||||
<Link href="/settings" onClick={() => onSuccess()} shallow>
|
||||
{t('manage')}
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</FadeInFadeOut>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default DepositForm
|
|
@ -0,0 +1,30 @@
|
|||
import Image from 'next/image'
|
||||
|
||||
const TokenButton = ({
|
||||
handleTokenSelect,
|
||||
selectedToken,
|
||||
tokenName,
|
||||
}: {
|
||||
tokenName: string
|
||||
selectedToken: string
|
||||
handleTokenSelect: (v: string) => void
|
||||
}) => {
|
||||
return (
|
||||
<button onClick={() => handleTokenSelect(tokenName)}>
|
||||
<div
|
||||
className={`h-16 w-16 rounded-full border bg-th-bkg-1 p-4 hover:cursor-pointer hover:border-2 hover:border-orange-400 ${
|
||||
selectedToken === tokenName ? 'border-black' : ''
|
||||
}`}
|
||||
>
|
||||
<Image
|
||||
src={`/icons/${tokenName.toLowerCase()}.svg`}
|
||||
width={100}
|
||||
height={100}
|
||||
alt="Select a token"
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default TokenButton
|
|
@ -0,0 +1,81 @@
|
|||
import { useCallback, useEffect, useState } from 'react'
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
ExclamationTriangleIcon,
|
||||
} from '@heroicons/react/20/solid'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import ConnectedMenu from './wallet/ConnectedMenu'
|
||||
import ConnectWalletButton from './wallet/ConnectWalletButton'
|
||||
import { useRouter } from 'next/router'
|
||||
// import SolanaTps from './SolanaTps'
|
||||
import useOnlineStatus from 'hooks/useOnlineStatus'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
const TopBar = () => {
|
||||
const { connected } = useWallet()
|
||||
const themeData = mangoStore((s) => s.themeData)
|
||||
|
||||
const [copied, setCopied] = useState('')
|
||||
const isOnline = useOnlineStatus()
|
||||
|
||||
const router = useRouter()
|
||||
const { query } = router
|
||||
|
||||
const handleShowSetup = useCallback(() => {
|
||||
set((s) => {
|
||||
s.showUserSetup = true
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => setCopied(''), 2000)
|
||||
}, [copied])
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex h-16 items-center justify-between`}
|
||||
style={{ backgroundImage: `url(${themeData.topTilePath})` }}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between md:space-x-4">
|
||||
<span className="mb-0 flex items-center">
|
||||
{query.token || query.market ? (
|
||||
<button
|
||||
className="mr-4 flex h-16 w-16 items-center justify-center border-r border-th-bkg-3 focus-visible:bg-th-bkg-3 md:hover:bg-th-bkg-2"
|
||||
onClick={() => router.back()}
|
||||
>
|
||||
<ArrowLeftIcon className="h-5 w-5" />
|
||||
</button>
|
||||
) : null}
|
||||
<div className="flex h-[63px] w-16 items-center justify-center bg-th-bkg-1 md:hidden">
|
||||
<img
|
||||
className="h-9 w-9 flex-shrink-0"
|
||||
src={themeData.logoPath}
|
||||
alt="logo"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
{!isOnline ? (
|
||||
<div className="absolute left-1/2 top-3 z-10 flex h-10 w-max -translate-x-1/2 items-center rounded-full bg-th-down px-4 py-2 md:top-8">
|
||||
<ExclamationTriangleIcon className="h-5 w-5 flex-shrink-0 text-th-fgd-1" />
|
||||
<p className="ml-2 text-th-fgd-1">
|
||||
Your connection appears to be offline
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex items-center">
|
||||
{connected ? (
|
||||
<div className="flex h-[63px] items-center rounded-full bg-th-bkg-1">
|
||||
<ConnectedMenu />
|
||||
</div>
|
||||
) : (
|
||||
<ConnectWalletButton handleShowSetup={handleShowSetup} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TopBar
|
|
@ -0,0 +1,106 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import sumBy from 'lodash/sumBy'
|
||||
import { Connection } from '@solana/web3.js'
|
||||
import mangoStore, { CLUSTER } from '@store/mangoStore'
|
||||
import useInterval from './shared/useInterval'
|
||||
import { formatNumericValue } from 'utils/numbers'
|
||||
import Tooltip from './shared/Tooltip'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const tpsAlertThreshold = 1000
|
||||
const tpsWarningThreshold = 1300
|
||||
|
||||
const getRecentPerformance = async (
|
||||
connection: Connection,
|
||||
setTps: (x: number) => void,
|
||||
) => {
|
||||
try {
|
||||
const samples = 2
|
||||
const response = await connection.getRecentPerformanceSamples(samples)
|
||||
const totalSecs = sumBy(response, 'samplePeriodSecs')
|
||||
const totalTransactions = sumBy(response, 'numTransactions')
|
||||
const tps = totalTransactions / totalSecs
|
||||
|
||||
setTps(tps)
|
||||
} catch {
|
||||
console.warn('Unable to fetch TPS')
|
||||
}
|
||||
}
|
||||
|
||||
const Tps = () => {
|
||||
const { t } = useTranslation('common')
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const [tps, setTps] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
getRecentPerformance(connection, setTps)
|
||||
}, [])
|
||||
|
||||
useInterval(() => {
|
||||
getRecentPerformance(connection, setTps)
|
||||
}, 60 * 1000)
|
||||
|
||||
if (CLUSTER == 'mainnet-beta') {
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center">
|
||||
<StatusDot
|
||||
status={tps}
|
||||
alert={tpsAlertThreshold}
|
||||
warning={tpsWarningThreshold}
|
||||
isLessThan
|
||||
/>
|
||||
<Tooltip content={t('solana-tps-desc')}>
|
||||
<span className="font-mono text-xs text-th-fgd-2">
|
||||
<span className="mr-1">{formatNumericValue(tps, 0)}</span>
|
||||
<span className="font-normal text-th-fgd-4">TPS</span>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export default Tps
|
||||
|
||||
export const StatusDot = ({
|
||||
status,
|
||||
alert,
|
||||
warning,
|
||||
isLessThan,
|
||||
}: {
|
||||
status: number
|
||||
alert: number
|
||||
warning: number
|
||||
isLessThan?: boolean
|
||||
}) => {
|
||||
const greaterOrLessThan = (status: number, threshold: number) => {
|
||||
if (isLessThan) {
|
||||
return status < threshold
|
||||
} else return status > threshold
|
||||
}
|
||||
|
||||
const dotColor = isLessThan
|
||||
? greaterOrLessThan(status, alert)
|
||||
? 'bg-th-warning'
|
||||
: greaterOrLessThan(status, warning)
|
||||
? 'bg-th-error'
|
||||
: 'bg-th-success'
|
||||
: greaterOrLessThan(status, warning)
|
||||
? 'bg-th-error'
|
||||
: greaterOrLessThan(status, alert)
|
||||
? 'bg-th-warning'
|
||||
: 'bg-th-success'
|
||||
|
||||
return (
|
||||
<div className="relative mr-1 h-3 w-3">
|
||||
<div
|
||||
className={`absolute left-0.5 top-0.5 h-2 w-2 rounded-full ${dotColor}`}
|
||||
/>
|
||||
<div className={`absolute h-3 w-3 rounded-full opacity-40 ${dotColor}`} />
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
import { ArrowPathIcon, ExclamationCircleIcon } from '@heroicons/react/20/solid'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import NumberFormat, { NumberFormatValues } from 'react-number-format'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import {
|
||||
ACCOUNT_ACTION_MODAL_INNER_HEIGHT,
|
||||
// INPUT_TOKEN_DEFAULT,
|
||||
} from '../utils/constants'
|
||||
import { notify } from '../utils/notifications'
|
||||
import { TokenAccount } from '../utils/tokens'
|
||||
// import ActionTokenList from './account/ActionTokenList'
|
||||
import Label from './forms/Label'
|
||||
import Button, { IconButton } from './shared/Button'
|
||||
import Loading from './shared/Loading'
|
||||
import { EnterBottomExitBottom, FadeInFadeOut } from './shared/Transitions'
|
||||
import MaxAmountButton from '@components/shared/MaxAmountButton'
|
||||
import Tooltip from '@components/shared/Tooltip'
|
||||
import SolBalanceWarnings from '@components/shared/SolBalanceWarnings'
|
||||
import useSolBalance from 'hooks/useSolBalance'
|
||||
import { floorToDecimal, withValueLimit } from 'utils/numbers'
|
||||
import BankAmountWithValue from './shared/BankAmountWithValue'
|
||||
// import useBanksWithBalances from 'hooks/useBanksWithBalances'
|
||||
import { isMangoError } from 'types'
|
||||
import TokenListButton from './shared/TokenListButton'
|
||||
import TokenLogo from './shared/TokenLogo'
|
||||
import SecondaryConnectButton from './shared/SecondaryConnectButton'
|
||||
import useMangoAccountAccounts from 'hooks/useMangoAccountAccounts'
|
||||
import InlineNotification from './shared/InlineNotification'
|
||||
import Link from 'next/link'
|
||||
import BackButton from './swap/BackButton'
|
||||
import useMangoGroup from 'hooks/useMangoGroup'
|
||||
import FormatNumericValue from './shared/FormatNumericValue'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
import { unstakeAndClose } from 'utils/transactions'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
interface UnstakeFormProps {
|
||||
onSuccess: () => void
|
||||
token: string
|
||||
}
|
||||
|
||||
export const walletBalanceForToken = (
|
||||
walletTokens: TokenAccount[],
|
||||
token: string,
|
||||
): { maxAmount: number; maxDecimals: number } => {
|
||||
const group = mangoStore.getState().group
|
||||
const bank = group?.banksMapByName.get(token)?.[0]
|
||||
|
||||
let walletToken
|
||||
if (bank) {
|
||||
const tokenMint = bank?.mint
|
||||
walletToken = tokenMint
|
||||
? walletTokens.find((t) => t.mint.toString() === tokenMint.toString())
|
||||
: null
|
||||
}
|
||||
|
||||
return {
|
||||
maxAmount: walletToken ? walletToken.uiAmount : 0,
|
||||
maxDecimals: bank?.mintDecimals || 6,
|
||||
}
|
||||
}
|
||||
|
||||
function UnstakeForm({ onSuccess, token: selectedToken }: UnstakeFormProps) {
|
||||
const { t } = useTranslation(['common', 'account'])
|
||||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
// const [selectedToken, setSelectedToken] = useState(
|
||||
// token || INPUT_TOKEN_DEFAULT,
|
||||
// )
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [refreshingWalletTokens, setRefreshingWalletTokens] = useState(false)
|
||||
const { maxSolDeposit } = useSolBalance()
|
||||
// const banks = useBanksWithBalances('walletBalance')
|
||||
const { usedTokens, totalTokens } = useMangoAccountAccounts()
|
||||
const { group } = useMangoGroup()
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
|
||||
const stakeBank = useMemo(() => {
|
||||
return group?.banksMapByName.get(selectedToken)?.[0]
|
||||
}, [selectedToken, group])
|
||||
|
||||
const solBank = useMemo(() => {
|
||||
return group?.banksMapByName.get('SOL')?.[0]
|
||||
}, [group])
|
||||
|
||||
const tokenPositionsFull = useMemo(() => {
|
||||
if (!stakeBank || !usedTokens.length || !totalTokens.length) return false
|
||||
const hasTokenPosition = usedTokens.find(
|
||||
(token) => token.tokenIndex === stakeBank.tokenIndex,
|
||||
)
|
||||
return hasTokenPosition ? false : usedTokens.length >= totalTokens.length
|
||||
}, [stakeBank, usedTokens, totalTokens])
|
||||
|
||||
const { connected, publicKey } = useWallet()
|
||||
|
||||
const tokenMax = useMemo(() => {
|
||||
if (!stakeBank || !mangoAccount) return { maxAmount: 0.0, maxDecimals: 6 }
|
||||
return {
|
||||
maxAmount: mangoAccount.getTokenBalanceUi(stakeBank),
|
||||
maxDecimals: stakeBank.mintDecimals,
|
||||
}
|
||||
}, [stakeBank, mangoAccount])
|
||||
|
||||
const setMax = useCallback(() => {
|
||||
const max = floorToDecimal(tokenMax.maxAmount, tokenMax.maxDecimals)
|
||||
setInputAmount(max.toFixed())
|
||||
}, [tokenMax])
|
||||
|
||||
// const handleSelectToken = (token: string) => {
|
||||
// setSelectedToken(token)
|
||||
// setShowTokenList(false)
|
||||
// }
|
||||
|
||||
const handleRefreshWalletBalances = useCallback(async () => {
|
||||
if (!publicKey) return
|
||||
const actions = mangoStore.getState().actions
|
||||
setRefreshingWalletTokens(true)
|
||||
await actions.fetchMangoAccounts(publicKey)
|
||||
setRefreshingWalletTokens(false)
|
||||
}, [publicKey])
|
||||
|
||||
const solBorrowed = useMemo(() => {
|
||||
if (!solBank || !mangoAccount) return 0.0
|
||||
return mangoAccount.getTokenBalanceUi(solBank)
|
||||
}, [solBank, mangoAccount])
|
||||
|
||||
const handleWithdraw = useCallback(async () => {
|
||||
const client = mangoStore.getState().client
|
||||
const group = mangoStore.getState().group
|
||||
const actions = mangoStore.getState().actions
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
|
||||
if (!group || !stakeBank || !publicKey || !mangoAccount) return
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
console.log('starting deposit')
|
||||
const { signature: tx } = await unstakeAndClose(
|
||||
client,
|
||||
group,
|
||||
mangoAccount,
|
||||
stakeBank.mint,
|
||||
Number(inputAmount),
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
type: 'success',
|
||||
txid: tx,
|
||||
})
|
||||
|
||||
await actions.fetchMangoAccounts(mangoAccount.owner)
|
||||
await actions.fetchWalletTokens(publicKey)
|
||||
setSubmitting(false)
|
||||
onSuccess()
|
||||
} catch (e) {
|
||||
console.error('Error depositing:', e)
|
||||
setSubmitting(false)
|
||||
if (!isMangoError(e)) return
|
||||
notify({
|
||||
title: 'Transaction failed',
|
||||
description: e.message,
|
||||
txid: e?.txid,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}, [stakeBank, publicKey, inputAmount, onSuccess])
|
||||
|
||||
const showInsufficientBalance =
|
||||
tokenMax.maxAmount < Number(inputAmount) ||
|
||||
(selectedToken === 'SOL' && maxSolDeposit <= 0)
|
||||
|
||||
useEffect(() => {
|
||||
const group = mangoStore.getState().group
|
||||
set((state) => {
|
||||
state.swap.outputBank = group?.banksMapByName.get(selectedToken)?.[0]
|
||||
})
|
||||
}, [selectedToken])
|
||||
|
||||
return (
|
||||
<>
|
||||
<EnterBottomExitBottom
|
||||
className={`absolute bottom-0 left-0 z-20 h-[${ACCOUNT_ACTION_MODAL_INNER_HEIGHT}] w-full overflow-auto rounded-lg bg-th-bkg-1 p-6`}
|
||||
show={showTokenList}
|
||||
>
|
||||
<BackButton onClick={() => setShowTokenList(false)} />
|
||||
<h2 className="mb-4 text-center text-lg">Select token to unstake</h2>
|
||||
<div className="flex items-center px-4 pb-2">
|
||||
<div className="w-1/2 text-left">
|
||||
<p className="text-xs">{t('token')}</p>
|
||||
</div>
|
||||
<div className="w-1/2 text-right">
|
||||
<p className="whitespace-nowrap text-xs">{t('wallet-balance')}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/* <ActionTokenList
|
||||
banks={banks}
|
||||
onSelect={handleSelectToken}
|
||||
showDepositRates
|
||||
valueKey="walletBalance"
|
||||
/> */}
|
||||
</EnterBottomExitBottom>
|
||||
<FadeInFadeOut show={!showTokenList}>
|
||||
<div className="m-6 flex flex-col justify-between">
|
||||
<div>
|
||||
<SolBalanceWarnings
|
||||
amount={inputAmount}
|
||||
className="mb-4"
|
||||
setAmount={setInputAmount}
|
||||
selectedToken={selectedToken}
|
||||
/>
|
||||
<div className="grid grid-cols-2">
|
||||
<div className="col-span-2 flex justify-between">
|
||||
<Label text={`Stake Token`} />
|
||||
<div className="mb-2 flex items-center space-x-2">
|
||||
<MaxAmountButton
|
||||
decimals={tokenMax.maxDecimals}
|
||||
label={t('balance')}
|
||||
onClick={setMax}
|
||||
value={tokenMax.maxAmount}
|
||||
/>
|
||||
<Tooltip content={t('account:refresh-balance')}>
|
||||
<IconButton
|
||||
className={refreshingWalletTokens ? 'animate-spin' : ''}
|
||||
onClick={handleRefreshWalletBalances}
|
||||
hideBg
|
||||
>
|
||||
<ArrowPathIcon className="h-4 w-4" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-1">
|
||||
<TokenListButton
|
||||
token={selectedToken}
|
||||
logo={<TokenLogo bank={stakeBank} />}
|
||||
setShowList={setShowTokenList}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-1">
|
||||
<NumberFormat
|
||||
name="amountIn"
|
||||
id="amountIn"
|
||||
inputMode="decimal"
|
||||
thousandSeparator=","
|
||||
allowNegative={false}
|
||||
isNumericString={true}
|
||||
decimalScale={stakeBank?.mintDecimals || 6}
|
||||
className={
|
||||
'w-full rounded-lg rounded-l-none border border-th-input-border bg-th-input-bkg p-3 text-right font-mono text-xl text-th-fgd-1 focus:outline-none focus-visible:border-th-fgd-4 md:hover:border-th-input-border-hover md:hover:focus-visible:border-th-fgd-4'
|
||||
}
|
||||
placeholder="0.00"
|
||||
value={inputAmount}
|
||||
onValueChange={(e: NumberFormatValues) => {
|
||||
setInputAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}}
|
||||
isAllowed={withValueLimit}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{stakeBank && solBank ? (
|
||||
<>
|
||||
<div className="mt-2 space-y-1.5 px-2 py-4 text-sm">
|
||||
<div className="flex justify-between">
|
||||
<p>Staked amount</p>
|
||||
<BankAmountWithValue
|
||||
amount={tokenMax.maxAmount}
|
||||
bank={stakeBank}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<p>SOL borrowed</p>
|
||||
{solBank ? (
|
||||
<FormatNumericValue value={solBorrowed} decimals={3} />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
{connected ? (
|
||||
<Button
|
||||
onClick={handleWithdraw}
|
||||
className="flex w-full items-center justify-center"
|
||||
disabled={connected && (!inputAmount || showInsufficientBalance)}
|
||||
size="large"
|
||||
>
|
||||
{submitting ? (
|
||||
<Loading className="mr-2 h-5 w-5" />
|
||||
) : showInsufficientBalance ? (
|
||||
<div className="flex items-center">
|
||||
<ExclamationCircleIcon className="mr-2 h-5 w-5 flex-shrink-0" />
|
||||
{t('swap:insufficient-balance', {
|
||||
symbol: selectedToken,
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center">
|
||||
Unstake {inputAmount} {selectedToken}
|
||||
</div>
|
||||
)}
|
||||
</Button>
|
||||
) : (
|
||||
<SecondaryConnectButton
|
||||
className="flex w-full items-center justify-center"
|
||||
isLarge
|
||||
/>
|
||||
)}
|
||||
{tokenPositionsFull ? (
|
||||
<InlineNotification
|
||||
type="error"
|
||||
desc={
|
||||
<>
|
||||
{t('error-token-positions-full')}{' '}
|
||||
<Link href="/settings" onClick={() => onSuccess()} shallow>
|
||||
{t('manage')}
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</FadeInFadeOut>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default UnstakeForm
|
|
@ -0,0 +1,65 @@
|
|||
import { Bank } from '@blockworks-foundation/mango-v4'
|
||||
import FormatNumericValue from '@components/shared/FormatNumericValue'
|
||||
import TokenLogo from '@components/shared/TokenLogo'
|
||||
|
||||
const ActionTokenItem = ({
|
||||
bank,
|
||||
customValue,
|
||||
onSelect,
|
||||
roundUp,
|
||||
showBorrowRates,
|
||||
showDepositRates,
|
||||
}: {
|
||||
bank: Bank
|
||||
customValue: number
|
||||
onSelect: (x: string) => void
|
||||
roundUp?: boolean
|
||||
showBorrowRates?: boolean
|
||||
showDepositRates?: boolean
|
||||
}) => {
|
||||
const { name } = bank
|
||||
|
||||
return (
|
||||
<button
|
||||
className="flex w-full items-center rounded-md border border-th-bkg-4 bg-th-bkg-1 px-4 py-3 focus-visible:border-th-fgd-4 disabled:cursor-not-allowed disabled:opacity-30 md:hover:border-th-fgd-4 md:disabled:hover:border-th-bkg-4"
|
||||
onClick={() => onSelect(name)}
|
||||
disabled={customValue <= 0}
|
||||
>
|
||||
<div
|
||||
className={`flex ${
|
||||
!showBorrowRates && !showDepositRates ? 'w-1/2' : 'w-1/4'
|
||||
} items-center`}
|
||||
>
|
||||
<div className="mr-2.5 flex flex-shrink-0 items-center">
|
||||
<TokenLogo bank={bank} />
|
||||
</div>
|
||||
<p className="text-left text-th-fgd-1">{name}</p>
|
||||
</div>
|
||||
{showDepositRates ? (
|
||||
<div className="w-1/4 text-right font-mono">
|
||||
<p className="text-th-up">
|
||||
<FormatNumericValue value={bank.getDepositRateUi()} decimals={2} />%
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
{showBorrowRates ? (
|
||||
<div className="w-1/4 text-right font-mono">
|
||||
<p className="text-th-down">
|
||||
<FormatNumericValue value={bank.getBorrowRateUi()} decimals={2} />%
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="w-1/2 pl-3 text-right">
|
||||
<p className="truncate font-mono text-th-fgd-1">
|
||||
<FormatNumericValue
|
||||
value={customValue}
|
||||
decimals={bank.mintDecimals}
|
||||
roundUp={roundUp}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActionTokenItem
|
|
@ -0,0 +1,61 @@
|
|||
import { Bank } from '@blockworks-foundation/mango-v4'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
import ActionTokenItem from './ActionTokenItem'
|
||||
|
||||
type BankParams = {
|
||||
bank: Bank
|
||||
balance: number
|
||||
borrowedAmount: number
|
||||
walletBalance: number
|
||||
maxBorrow: number
|
||||
maxWithdraw: number
|
||||
}
|
||||
|
||||
const ActionTokenList = ({
|
||||
banks,
|
||||
onSelect,
|
||||
valueKey,
|
||||
}: {
|
||||
banks: BankParams[]
|
||||
onSelect: (x: string) => void
|
||||
showBorrowRates?: boolean
|
||||
showDepositRates?: boolean
|
||||
valueKey:
|
||||
| 'balance'
|
||||
| 'borrowedAmount'
|
||||
| 'maxBorrow'
|
||||
| 'maxWithdraw'
|
||||
| 'walletBalance'
|
||||
}) => {
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
|
||||
return mangoAccount ? (
|
||||
<>
|
||||
<div className="space-y-2">
|
||||
{banks?.length ? (
|
||||
banks
|
||||
.filter((b: BankParams) => !!b)
|
||||
.map((b) => {
|
||||
return (
|
||||
<ActionTokenItem
|
||||
bank={b.bank}
|
||||
customValue={b[valueKey]}
|
||||
key={b.bank.name}
|
||||
onSelect={onSelect}
|
||||
roundUp={valueKey === 'borrowedAmount'}
|
||||
showBorrowRates={false}
|
||||
showDepositRates={false}
|
||||
/>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<div className="mt-4 rounded border border-th-bkg-2 py-3 text-center text-th-fgd-4">
|
||||
Nothing to select
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
|
||||
export default ActionTokenList
|
|
@ -0,0 +1,65 @@
|
|||
type Values = string | number
|
||||
|
||||
interface ButtonGroupProps<T extends Values> {
|
||||
activeValue: T
|
||||
className?: string
|
||||
disabled?: boolean
|
||||
onChange: (x: T) => void
|
||||
unit?: string
|
||||
values: T[]
|
||||
names?: Array<string>
|
||||
large?: boolean
|
||||
}
|
||||
|
||||
const ButtonGroup = <T extends Values>({
|
||||
activeValue,
|
||||
className,
|
||||
disabled,
|
||||
unit,
|
||||
values,
|
||||
onChange,
|
||||
names,
|
||||
large,
|
||||
}: ButtonGroupProps<T>) => {
|
||||
return (
|
||||
<div className={`rounded-md bg-th-bkg-3 ${disabled ? 'opacity-50' : ''}`}>
|
||||
<div className="relative flex">
|
||||
{activeValue && values.includes(activeValue) ? (
|
||||
<div
|
||||
className={`absolute left-0 top-0 h-full transform rounded-md bg-th-bkg-4`}
|
||||
style={{
|
||||
transform: `translateX(${
|
||||
values.findIndex((v) => v === activeValue) * 100
|
||||
}%)`,
|
||||
width: `${100 / values.length}%`,
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{values.map((v, i) => (
|
||||
<button
|
||||
className={`${className} relative w-1/2 cursor-pointer rounded-md px-3 text-center focus-visible:bg-th-bkg-4 focus-visible:text-th-fgd-2 disabled:cursor-not-allowed ${
|
||||
large ? 'h-12 text-sm' : 'h-10 text-xs'
|
||||
} font-normal
|
||||
${
|
||||
v === activeValue
|
||||
? `text-th-active`
|
||||
: `text-th-fgd-2 md:hover:text-th-fgd-1`
|
||||
}
|
||||
`}
|
||||
disabled={disabled}
|
||||
key={`${v}${i}`}
|
||||
onClick={() => onChange(v)}
|
||||
style={{
|
||||
width: `${100 / values.length}%`,
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{names ? (unit ? names[i] + unit : names[i]) : unit ? v + unit : v}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ButtonGroup
|
|
@ -0,0 +1,65 @@
|
|||
import React, { ChangeEvent, ReactNode } from 'react'
|
||||
import { CheckIcon } from '@heroicons/react/20/solid'
|
||||
|
||||
interface CheckboxProps {
|
||||
checked: boolean
|
||||
children: ReactNode
|
||||
onChange: (x: ChangeEvent<HTMLInputElement>) => void
|
||||
disabled?: boolean
|
||||
halfState?: boolean
|
||||
labelClass?: string
|
||||
}
|
||||
|
||||
const Checkbox = ({
|
||||
checked,
|
||||
children,
|
||||
disabled = false,
|
||||
halfState = false,
|
||||
labelClass,
|
||||
...props
|
||||
}: CheckboxProps) => (
|
||||
<label className="flex cursor-pointer items-center text-th-fgd-3 hover:text-th-fgd-2">
|
||||
<input
|
||||
checked={checked}
|
||||
{...props}
|
||||
disabled={disabled}
|
||||
type="checkbox"
|
||||
style={{
|
||||
border: '0',
|
||||
clip: 'rect(0 0 0 0)',
|
||||
clipPath: 'inset(50%)',
|
||||
height: '1px',
|
||||
margin: '-1px',
|
||||
overflow: 'hidden',
|
||||
padding: '0',
|
||||
position: 'absolute',
|
||||
whiteSpace: 'nowrap',
|
||||
width: '1px',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
className={`${
|
||||
checked && !disabled && !halfState ? 'bg-th-active' : 'bg-th-bkg-4'
|
||||
} flex h-4 w-4 flex-shrink-0 cursor-pointer items-center justify-center rounded`}
|
||||
>
|
||||
{halfState ? (
|
||||
<div className="mb-0.5 font-bold text-th-bkg-1">–</div>
|
||||
) : (
|
||||
<CheckIcon
|
||||
className={`${checked ? 'block' : 'hidden'} h-4 w-4 ${
|
||||
disabled ? 'text-th-fgd-4' : 'text-th-bkg-1'
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<span
|
||||
className={`ml-2 whitespace-nowrap text-xs ${labelClass} ${
|
||||
checked && !disabled ? 'text-th-fgd-2' : ''
|
||||
}`}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
</label>
|
||||
)
|
||||
|
||||
export default Checkbox
|
|
@ -0,0 +1,82 @@
|
|||
import { ChangeEvent, forwardRef, InputHTMLAttributes } from 'react'
|
||||
|
||||
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
value: string
|
||||
onChange: (e: ChangeEvent<HTMLInputElement>) => void
|
||||
type?: string
|
||||
maxLength?: number
|
||||
className?: string
|
||||
disabled?: boolean
|
||||
prefixClassname?: string
|
||||
wrapperClassName?: string
|
||||
hasError?: boolean
|
||||
prefix?: string
|
||||
prefixClassName?: string
|
||||
suffix?: string
|
||||
}
|
||||
|
||||
const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
|
||||
const {
|
||||
type,
|
||||
value,
|
||||
onChange,
|
||||
maxLength,
|
||||
className,
|
||||
hasError,
|
||||
wrapperClassName = 'w-full',
|
||||
disabled,
|
||||
prefix,
|
||||
prefixClassName,
|
||||
suffix,
|
||||
} = props
|
||||
return (
|
||||
<>
|
||||
<div className={`relative flex ${wrapperClassName}`}>
|
||||
{prefix ? (
|
||||
<div
|
||||
className={`absolute left-2 top-1/2 -translate-y-1/2 ${prefixClassName}`}
|
||||
>
|
||||
{prefix}
|
||||
</div>
|
||||
) : null}
|
||||
<input
|
||||
className={`${className} h-12 w-full flex-1 rounded-md border bg-th-input-bkg px-3 text-base
|
||||
text-th-fgd-1 ${
|
||||
hasError ? 'border-th-down' : 'border-th-input-border'
|
||||
} focus:outline-none
|
||||
md:hover:border-th-input-border-hover
|
||||
${
|
||||
disabled
|
||||
? 'cursor-not-allowed bg-th-bkg-3 text-th-fgd-3 hover:border-th-fgd-4'
|
||||
: ''
|
||||
}
|
||||
${prefix ? 'pl-8' : ''}
|
||||
${suffix ? 'pr-11' : ''}`}
|
||||
disabled={disabled}
|
||||
ref={ref}
|
||||
type={type}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
maxLength={maxLength ? maxLength : undefined}
|
||||
/>
|
||||
{suffix ? (
|
||||
<span className="absolute right-0 flex h-full items-center bg-transparent pr-2 text-xs text-th-fgd-4">
|
||||
{suffix}
|
||||
</span>
|
||||
) : null}
|
||||
{maxLength ? (
|
||||
<p
|
||||
className={`absolute -top-7 right-0 mt-1 flex justify-end text-xs ${
|
||||
value.length === maxLength ? 'text-th-down' : 'text-th-fgd-4'
|
||||
}`}
|
||||
>
|
||||
{`${value.length}/${maxLength}`}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
Input.displayName = 'Input'
|
||||
export default Input
|
|
@ -0,0 +1,18 @@
|
|||
const Label = ({
|
||||
text,
|
||||
optional,
|
||||
className,
|
||||
}: {
|
||||
text: string
|
||||
optional?: boolean
|
||||
className?: string
|
||||
}) => (
|
||||
<p className={`mb-2 text-left text-sm text-th-fgd-3 ${className}`}>
|
||||
{text}{' '}
|
||||
{optional ? (
|
||||
<span className="ml-1 text-xs text-th-fgd-4">(Optional)</span>
|
||||
) : null}
|
||||
</p>
|
||||
)
|
||||
|
||||
export default Label
|
|
@ -0,0 +1,82 @@
|
|||
import { Fragment } from 'react'
|
||||
import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { Popover, Transition } from '@headlessui/react'
|
||||
import Checkbox from './Checkbox'
|
||||
|
||||
const MultiSelectDropdown = ({
|
||||
options,
|
||||
selected,
|
||||
toggleOption,
|
||||
placeholder,
|
||||
}: {
|
||||
options: string[]
|
||||
selected: string[]
|
||||
toggleOption: (x: string) => void
|
||||
placeholder?: string
|
||||
}) => {
|
||||
const { t } = useTranslation(['activity', 'common'])
|
||||
return (
|
||||
<Popover className="relative w-full min-w-[120px]">
|
||||
{({ open }) => (
|
||||
<div className="flex flex-col">
|
||||
<Popover.Button
|
||||
className={`h-12 rounded-md bg-th-input-bkg px-3 text-th-fgd-1 ring-1 ring-inset ring-th-input-border focus-visible:ring-th-fgd-4 md:hover:ring-th-input-border-hover ${
|
||||
open ? 'ring-th-input-border-hover' : 'ring-th-input-border'
|
||||
}`}
|
||||
>
|
||||
<div className={`flex items-center justify-between`}>
|
||||
{selected.length ? (
|
||||
<span className="text-left">
|
||||
{selected
|
||||
.map((v) => t(v))
|
||||
.toString()
|
||||
.replace(/,/g, ', ')}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-th-fgd-4">
|
||||
{placeholder || t('common:select')}
|
||||
</span>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className={`ml-0.5 h-6 w-6 ${
|
||||
open ? 'rotate-180 transform' : 'rotate-360 transform'
|
||||
}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</Popover.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition-all ease-in duration-200"
|
||||
enterFrom="opacity-0 transform scale-75"
|
||||
enterTo="opacity-100 transform scale-100"
|
||||
leave="transition ease-out duration-200"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<Popover.Panel className="absolute top-14 z-10 h-72 max-h-60 w-full overflow-y-auto rounded-md">
|
||||
<div className="relative space-y-2.5 bg-th-bkg-3 p-3">
|
||||
{options.map((option: string) => {
|
||||
const isSelected = selected.includes(option)
|
||||
return (
|
||||
<Checkbox
|
||||
labelClass="text-sm"
|
||||
checked={isSelected}
|
||||
key={option}
|
||||
onChange={() => toggleOption(option)}
|
||||
>
|
||||
{t(option)}
|
||||
</Checkbox>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</Popover.Panel>
|
||||
</Transition>
|
||||
</div>
|
||||
)}
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
export default MultiSelectDropdown
|
|
@ -0,0 +1,93 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Listbox } from '@headlessui/react'
|
||||
import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
||||
import { ReactNode } from 'react'
|
||||
import { TradeForm } from 'types'
|
||||
|
||||
type Values = TradeForm['tradeType'] | ReactNode
|
||||
|
||||
interface SelectProps<T extends Values> {
|
||||
value: T | string
|
||||
onChange: (x: T) => void
|
||||
children: ReactNode
|
||||
className?: string
|
||||
buttonClassName?: string
|
||||
dropdownPanelClassName?: string
|
||||
icon?: ReactNode
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const Select = <T extends Values>({
|
||||
value,
|
||||
onChange,
|
||||
children,
|
||||
className,
|
||||
buttonClassName,
|
||||
dropdownPanelClassName,
|
||||
icon,
|
||||
placeholder = 'Select',
|
||||
disabled = false,
|
||||
}: SelectProps<T>) => {
|
||||
return (
|
||||
<div className={`relative ${className}`}>
|
||||
<Listbox value={value} onChange={onChange} disabled={disabled}>
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Listbox.Button
|
||||
className={`h-full w-full rounded-md bg-th-input-bkg py-2.5 font-normal ring-1 ring-inset ring-th-input-border focus:outline-none focus-visible:ring-th-fgd-4 md:hover:ring-th-input-border-hover ${buttonClassName}`}
|
||||
>
|
||||
<div
|
||||
className={`flex items-center justify-between space-x-2 px-3 text-th-fgd-1`}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
{icon ? icon : null}
|
||||
{value ? (
|
||||
value
|
||||
) : (
|
||||
<span className="text-th-fgd-3">{placeholder}</span>
|
||||
)}
|
||||
</div>
|
||||
<ChevronDownIcon
|
||||
className={`ml-1 h-5 w-5 flex-shrink-0 text-th-fgd-3 ${
|
||||
open ? 'rotate-180' : 'rotate-360'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
</Listbox.Button>
|
||||
<Listbox.Options
|
||||
className={`thin-scroll absolute left-0 z-20 mt-1 max-h-60 w-full origin-top-left overflow-auto rounded-md bg-th-bkg-2 p-2 outline-none ${dropdownPanelClassName}`}
|
||||
>
|
||||
{children}
|
||||
</Listbox.Options>
|
||||
</>
|
||||
)}
|
||||
</Listbox>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface OptionProps {
|
||||
value: string
|
||||
children: string | ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
const Option = ({ value, children, className }: OptionProps) => {
|
||||
return (
|
||||
<Listbox.Option
|
||||
className="default-transition mb-0 rounded-md p-2 text-th-fgd-2 hover:cursor-pointer focus-visible:text-th-active md:hover:bg-th-bkg-3 md:hover:text-th-fgd-1"
|
||||
value={value}
|
||||
>
|
||||
{({ selected }) => (
|
||||
<div className={` ${selected ? 'text-th-active' : ''} ${className}`}>
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</Listbox.Option>
|
||||
)
|
||||
}
|
||||
|
||||
Select.Option = Option
|
||||
|
||||
export default Select
|
|
@ -0,0 +1,70 @@
|
|||
import { ChangeEvent, useEffect, useRef, useState } from 'react'
|
||||
|
||||
const Slider = ({
|
||||
amount,
|
||||
max,
|
||||
min,
|
||||
onChange,
|
||||
step,
|
||||
}: {
|
||||
amount: number
|
||||
max?: string
|
||||
min?: string
|
||||
onChange: (x: string) => void
|
||||
step: number
|
||||
}) => {
|
||||
const [value, setValue] = useState(0)
|
||||
const inputEl = useRef<HTMLInputElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (inputEl.current) {
|
||||
const target = inputEl.current
|
||||
const min = parseFloat(target.min)
|
||||
const max = parseFloat(target.max)
|
||||
|
||||
target.style.backgroundSize =
|
||||
max - min === 0
|
||||
? '0% 100%'
|
||||
: ((value - min) * 100) / (max - min) + '% 100%'
|
||||
}
|
||||
}, [value])
|
||||
|
||||
useEffect(() => {
|
||||
if (amount) {
|
||||
setValue(amount)
|
||||
} else {
|
||||
setValue(0)
|
||||
}
|
||||
}, [amount])
|
||||
|
||||
const handleSliderChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const target = e.target
|
||||
const min = parseFloat(target.min)
|
||||
const max = parseFloat(target.max)
|
||||
const val = parseFloat(target.value)
|
||||
|
||||
target.style.backgroundSize = ((val - min) * 100) / (max - min) + '% 100%'
|
||||
|
||||
onChange(e.target.value)
|
||||
setValue(parseFloat(e.target.value))
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<label htmlFor="default-range" className="block text-sm"></label>
|
||||
<input
|
||||
ref={inputEl}
|
||||
id="default-range"
|
||||
type="range"
|
||||
min={min || '0'}
|
||||
max={max || '100'}
|
||||
step={step}
|
||||
className="w-full focus:outline-none"
|
||||
onChange={handleSliderChange}
|
||||
value={value}
|
||||
></input>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Slider
|
|
@ -0,0 +1,61 @@
|
|||
import { FunctionComponent, ReactNode, memo } from 'react'
|
||||
|
||||
interface SwitchProps {
|
||||
checked: boolean
|
||||
className?: string
|
||||
onChange: (x: boolean) => void
|
||||
children?: ReactNode
|
||||
disabled?: boolean
|
||||
small?: boolean
|
||||
}
|
||||
|
||||
const Switch: FunctionComponent<SwitchProps> = ({
|
||||
checked = false,
|
||||
className = '',
|
||||
children,
|
||||
onChange,
|
||||
disabled,
|
||||
small,
|
||||
}) => {
|
||||
const handleClick = () => {
|
||||
onChange(!checked)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`flex items-center ${className}`}>
|
||||
<span className="mr-2 text-xs text-th-fgd-2">{children}</span>
|
||||
<button
|
||||
type="button"
|
||||
className={`${
|
||||
checked ? 'bg-th-success' : 'bg-th-bkg-4'
|
||||
} relative inline-flex ${
|
||||
small ? 'h-4 w-8' : 'h-5 w-10'
|
||||
} flex-shrink-0 cursor-pointer rounded-full
|
||||
border-2 border-transparent transition-colors duration-200 ease-in-out focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-th-fgd-4 ${
|
||||
disabled ? 'opacity-60' : ''
|
||||
}`}
|
||||
role="switch"
|
||||
aria-checked={checked}
|
||||
onClick={handleClick}
|
||||
disabled={disabled}
|
||||
>
|
||||
<span className="sr-only">{children}</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`${
|
||||
checked
|
||||
? small
|
||||
? 'translate-x-4'
|
||||
: 'translate-x-5'
|
||||
: 'translate-x-0'
|
||||
} pointer-events-none inline-block ${
|
||||
small ? 'h-3 w-3' : 'h-4 w-4'
|
||||
} rounded-full
|
||||
bg-white shadow ring-0 transition duration-200 ease-in-out`}
|
||||
></span>
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(Switch)
|
|
@ -0,0 +1,14 @@
|
|||
const AcornIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 40 40"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M31.9764 20.7091L31.47 16.9109C31.2226 15.0512 30.4484 13.36 29.3079 11.9846L31.6864 9.60615C32.034 9.2594 32.034 8.69894 31.6864 8.35219C31.3397 8.00544 30.7801 8.00544 30.4324 8.35219L28.0584 10.7262C26.674 9.56713 24.9686 8.7823 23.0903 8.53044L19.292 8.02407C18.6145 7.93273 17.9192 8.10122 17.3445 8.53221L16.5934 9.09623C16.1624 9.41814 16.1154 10.0496 16.4985 10.4327L29.5695 23.5035C29.9722 23.9061 30.5983 23.8183 30.906 23.4095L31.4691 22.6574C31.8886 22.0961 32.0686 21.4035 31.9764 20.7091ZM15.2427 11.6857L15.2108 11.6529L12.161 13.7875C9.21582 15.8493 7.64701 19.3478 8.06737 22.919L8.77062 28.8989C8.91518 30.1271 9.87385 31.0857 11.1021 31.2303L17.082 31.9335C20.6515 32.3503 24.1519 30.7851 26.2138 27.84L28.3484 24.7902L28.3156 24.7583L15.2427 11.6857Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default AcornIcon
|
|
@ -0,0 +1,14 @@
|
|||
const BtcMonoIcon = ({ className }: { className: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 32 32"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M28.1127 12.8648C28.6164 9.50263 26.0546 7.69482 22.5545 6.48855L23.6902 1.93293L20.9183 1.24317L19.8115 5.67848C19.0833 5.49561 18.3358 5.32558 17.5899 5.15555L18.7047 0.691363L15.9328 0L14.7971 4.55401C14.194 4.41606 13.6005 4.28132 13.0262 4.13695L13.0294 4.12251L9.20528 3.16808L8.46739 6.12923C8.46739 6.12923 10.5254 6.60083 10.4821 6.62971C11.605 6.91042 11.8071 7.65312 11.7734 8.24342L10.4805 13.4327C10.5575 13.4519 10.657 13.4808 10.7693 13.5241L10.4757 13.4519L8.66309 20.7216C8.52514 21.0617 8.17705 21.5734 7.39105 21.3793C7.41992 21.4194 5.37631 20.8772 5.37631 20.8772L4 24.0501L7.6092 24.95C8.27971 25.1185 8.93739 25.2949 9.58384 25.4601L8.43692 30.0671L11.2072 30.7568L12.3429 26.2012C13.1 26.4049 13.8347 26.5942 14.5533 26.7739L13.4208 31.3102L16.1927 32L17.3396 27.4027C22.0685 28.2978 25.6231 27.9368 27.1198 23.6603C28.326 20.218 27.0604 18.2305 24.5725 16.936C26.3851 16.5189 27.7486 15.3271 28.1127 12.8648ZM21.7765 21.7483C20.9216 25.1922 15.1228 23.3299 13.2428 22.8631L14.7667 16.7595C16.6467 17.2295 22.6732 18.1583 21.7765 21.7483ZM22.6347 12.8151C21.8535 15.9479 17.0284 14.355 15.4644 13.9652L16.844 8.4311C18.4079 8.82089 23.4496 9.54755 22.6347 12.8151Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default BtcMonoIcon
|
|
@ -0,0 +1,233 @@
|
|||
const ChartMiddleOBLeft = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 106 60"
|
||||
fill="none"
|
||||
>
|
||||
<rect width="106" height="60" rx="4" fill="var(--bkg-1)" />
|
||||
<rect x="2" y="2" width="102" height="4" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="2" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="14"
|
||||
y="10"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 14 10)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="14"
|
||||
y="54"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 14 54)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="12"
|
||||
y="14"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 12 14)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="12"
|
||||
y="50"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 12 50)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="10"
|
||||
y="18"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 10 18)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="10"
|
||||
y="46"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 10 46)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="8"
|
||||
y="22"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 8 22)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="8"
|
||||
y="42"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 8 42)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="6"
|
||||
y="26"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 6 26)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="6"
|
||||
y="38"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 6 38)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="4"
|
||||
y="30"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 4 30)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="4"
|
||||
y="34"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 4 34)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect x="86" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="94"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 94 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="14"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 102 14)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="26"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 102 26)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="18"
|
||||
width="4"
|
||||
height="14"
|
||||
transform="rotate(90 102 18)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 102 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="22" y="44" width="62" height="14" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="38"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 38 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="38"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 38 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="52"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 52 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="52"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 52 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="66"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 66 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="66"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 66 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="80"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 80 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="80"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 80 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="22" y="8" width="62" height="34" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="26" y="29" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="30" y="25" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="38" y="23" width="2" height="7" fill="var(--down)" />
|
||||
<rect x="50" y="21" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="58" y="16" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="70" y="17" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="34" y="25" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="42" y="28" width="2" height="3" fill="var(--up)" />
|
||||
<rect x="46" y="27" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="54" y="21" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="62" y="18" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="66" y="20" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="74" y="16" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="78" y="17" width="2" height="3" fill="var(--down)" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ChartMiddleOBLeft
|
|
@ -0,0 +1,233 @@
|
|||
const ChartMiddleOBRight = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 106 60"
|
||||
fill="none"
|
||||
>
|
||||
<rect width="106" height="60" rx="4" fill="var(---bkg-1)" />
|
||||
<rect x="2" y="2" width="102" height="4" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="86" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="98"
|
||||
y="10"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 98 10)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="98"
|
||||
y="54"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 98 54)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="96"
|
||||
y="14"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 96 14)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="96"
|
||||
y="50"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 96 50)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="94"
|
||||
y="18"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 94 18)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="94"
|
||||
y="46"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 94 46)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="92"
|
||||
y="22"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 92 22)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="92"
|
||||
y="42"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 92 42)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="90"
|
||||
y="26"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 90 26)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="90"
|
||||
y="38"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 90 38)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="88"
|
||||
y="30"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 88 30)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="88"
|
||||
y="34"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 88 34)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect x="2" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="10"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 10 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="14"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 18 14)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="26"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 18 26)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="18"
|
||||
width="4"
|
||||
height="14"
|
||||
transform="rotate(90 18 18)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 18 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="22" y="44" width="62" height="14" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="38"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 38 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="38"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 38 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="52"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 52 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="52"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 52 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="66"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 66 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="66"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 66 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="80"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 80 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="80"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 80 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="22" y="8" width="62" height="34" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="26" y="29" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="30" y="25" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="38" y="23" width="2" height="7" fill="var(--down)" />
|
||||
<rect x="50" y="21" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="58" y="16" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="70" y="17" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="34" y="25" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="42" y="28" width="2" height="3" fill="var(--up)" />
|
||||
<rect x="46" y="27" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="54" y="21" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="62" y="18" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="66" y="20" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="74" y="16" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="78" y="17" width="2" height="3" fill="var(--down)" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ChartMiddleOBRight
|
|
@ -0,0 +1,239 @@
|
|||
const ChartOnLeft = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 106 60"
|
||||
fill="none"
|
||||
>
|
||||
<rect
|
||||
width="106"
|
||||
height="60"
|
||||
rx="4"
|
||||
fill="var(--bkg-1)"
|
||||
// stroke="var(--bkg-4)"
|
||||
/>
|
||||
<rect x="2" y="2" width="102" height="4" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="66" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="78"
|
||||
y="10"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 78 10)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="78"
|
||||
y="54"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 78 54)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="76"
|
||||
y="14"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 76 14)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="76"
|
||||
y="50"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 76 50)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="74"
|
||||
y="18"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 74 18)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="74"
|
||||
y="46"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 74 46)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="72"
|
||||
y="22"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 72 22)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="72"
|
||||
y="42"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 72 42)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="70"
|
||||
y="26"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 70 26)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="70"
|
||||
y="38"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 70 38)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="68"
|
||||
y="30"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 68 30)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="68"
|
||||
y="34"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 68 34)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect x="86" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="94"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 94 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="14"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 102 14)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="26"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 102 26)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="18"
|
||||
width="4"
|
||||
height="14"
|
||||
transform="rotate(90 102 18)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="102"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 102 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="2" y="44" width="62" height="14" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="18"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 18 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 18 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="32"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 32 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="32"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 32 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="46"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 46 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="46"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 46 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="60"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 60 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="60"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 60 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="2" y="8" width="62" height="34" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="6" y="29" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="10" y="25" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="18" y="23" width="2" height="7" fill="var(--down)" />
|
||||
<rect x="30" y="21" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="38" y="16" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="50" y="17" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="14" y="25" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="22" y="28" width="2" height="3" fill="var(--up)" />
|
||||
<rect x="26" y="27" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="34" y="21" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="42" y="18" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="46" y="20" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="54" y="16" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="58" y="17" width="2" height="3" fill="var(--down)" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ChartOnLeft
|
|
@ -0,0 +1,233 @@
|
|||
const ChartOnRight = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 106 60"
|
||||
fill="none"
|
||||
>
|
||||
<rect width="106" height="60" rx="4" fill="var(--bkg-1)" />
|
||||
<rect x="2" y="2" width="102" height="4" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="22" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="34"
|
||||
y="10"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 34 10)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="34"
|
||||
y="54"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 34 54)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="32"
|
||||
y="14"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 32 14)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="32"
|
||||
y="50"
|
||||
width="2"
|
||||
height="10"
|
||||
transform="rotate(90 32 50)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="30"
|
||||
y="18"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 30 18)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="30"
|
||||
y="46"
|
||||
width="2"
|
||||
height="8"
|
||||
transform="rotate(90 30 46)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="28"
|
||||
y="22"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 28 22)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="28"
|
||||
y="42"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 28 42)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="26"
|
||||
y="26"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 26 26)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="26"
|
||||
y="38"
|
||||
width="2"
|
||||
height="4"
|
||||
transform="rotate(90 26 38)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect
|
||||
x="24"
|
||||
y="30"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 24 30)"
|
||||
fill="var(--down)"
|
||||
/>
|
||||
<rect
|
||||
x="24"
|
||||
y="34"
|
||||
width="2"
|
||||
height="2"
|
||||
transform="rotate(90 24 34)"
|
||||
fill="var(--up)"
|
||||
/>
|
||||
<rect x="2" y="8" width="18" height="50" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="10"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 10 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="14"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 18 14)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="26"
|
||||
width="2"
|
||||
height="14"
|
||||
transform="rotate(90 18 26)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="18"
|
||||
width="4"
|
||||
height="14"
|
||||
transform="rotate(90 18 18)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="18"
|
||||
y="10"
|
||||
width="2"
|
||||
height="6"
|
||||
transform="rotate(90 18 10)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="42" y="44" width="62" height="14" rx="2" fill="var(--bkg-2)" />
|
||||
<rect
|
||||
x="58"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 58 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="58"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 58 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="72"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 72 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="72"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 72 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="86"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 86 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="86"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 86 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="100"
|
||||
y="48"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 100 48)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect
|
||||
x="100"
|
||||
y="52"
|
||||
width="2"
|
||||
height="12"
|
||||
transform="rotate(90 100 52)"
|
||||
fill="var(--fgd-4)"
|
||||
/>
|
||||
<rect x="42" y="8" width="62" height="34" rx="2" fill="var(--bkg-2)" />
|
||||
<rect x="46" y="29" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="50" y="25" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="58" y="23" width="2" height="7" fill="var(--down)" />
|
||||
<rect x="70" y="21" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="78" y="16" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="90" y="17" width="2" height="7" fill="var(--up)" />
|
||||
<rect x="54" y="25" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="62" y="28" width="2" height="3" fill="var(--up)" />
|
||||
<rect x="66" y="27" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="74" y="21" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="82" y="18" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="86" y="20" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="94" y="16" width="2" height="3" fill="var(--down)" />
|
||||
<rect x="98" y="17" width="2" height="3" fill="var(--down)" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ChartOnRight
|
|
@ -0,0 +1,14 @@
|
|||
const DiscordIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 28 20"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M23.7187 1.67497C21.9061 0.89249 19.9681 0.323786 17.9421 0C17.6932 0.41511 17.4025 0.973432 17.2021 1.4176C15.0482 1.11872 12.9142 1.11872 10.8 1.4176C10.5996 0.973432 10.3023 0.41511 10.0513 0C8.02293 0.323786 6.08271 0.894565 4.27023 1.67912C0.614418 6.77668 -0.376613 11.7477 0.118903 16.648C2.54363 18.3188 4.89347 19.3337 7.20367 19.9979C7.77407 19.2736 8.2828 18.5036 8.72106 17.692C7.88639 17.3993 7.08696 17.0382 6.33156 16.6189C6.53197 16.482 6.72798 16.3387 6.91738 16.1914C11.5246 18.1797 16.5304 18.1797 21.0826 16.1914C21.2741 16.3387 21.4701 16.482 21.6683 16.6189C20.9107 17.0402 20.1091 17.4014 19.2744 17.6941C19.7127 18.5036 20.2192 19.2757 20.7918 20C23.1042 19.3358 25.4563 18.3209 27.881 16.648C28.4624 10.9672 26.8878 6.04193 23.7187 1.67497ZM9.34871 13.6343C7.96567 13.6343 6.83149 12.4429 6.83149 10.9922C6.83149 9.54132 7.94144 8.34791 9.34871 8.34791C10.756 8.34791 11.8901 9.53924 11.8659 10.9922C11.8682 12.4429 10.756 13.6343 9.34871 13.6343ZM18.6512 13.6343C17.2682 13.6343 16.1339 12.4429 16.1339 10.9922C16.1339 9.54132 17.2439 8.34791 18.6512 8.34791C20.0584 8.34791 21.1926 9.53924 21.1684 10.9922C21.1684 12.4429 20.0584 13.6343 18.6512 13.6343Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default DiscordIcon
|
|
@ -0,0 +1,14 @@
|
|||
const LeaderboardIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M6.55423 13.2164L7.61683 13.5408C7.80664 13.8247 7.99644 14.0679 8.18597 14.2704C8.86894 15 9.66603 15.4867 10.6148 15.7703V16.4595C10.6148 17.7162 9.66603 18.7705 8.48964 18.7705H8.26198C8.07218 18.7705 7.92049 18.9325 7.92049 19.1353V20.6352C7.92049 20.838 8.07218 21 8.26198 21H15.7761C15.9659 21 16.1176 20.838 16.1176 20.6352V19.1353C16.1176 18.9325 15.9659 18.7705 15.7761 18.7705H15.5484C14.3721 18.7705 13.4233 17.7569 13.4233 16.5002V15.8111C14.3721 15.5679 15.1692 15.0815 15.8521 14.3111C16.0419 14.1084 16.1936 13.8652 16.4213 13.5815L17.4839 13.2976C20.1403 12.5273 22 9.93272 22 7.0137V5.7974C22 5.39187 21.6964 5.02705 21.2789 5.02705H18.1668L18.1671 3.77035C18.1671 3.36482 17.8635 3 17.446 3H6.55429C6.17468 3 5.83317 3.32436 5.83317 3.77035V5.0678H2.72112C2.34151 5.0678 2 5.39217 2 5.83815V6.9733C2.03812 9.89196 3.85963 12.4865 6.55423 13.2164ZM18.0911 7.05412H20.0645C20.0267 8.838 19.0019 10.419 17.4841 11.1082C17.9772 9.44596 18.0911 7.78371 18.0911 7.05412ZM5.87112 7.05412C5.90898 7.82447 5.98495 9.44596 6.47839 11.1082C4.96052 10.4191 3.93573 8.838 3.89791 7.05412H5.87112Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default LeaderboardIcon
|
|
@ -0,0 +1,20 @@
|
|||
const LineChartIcon = ({ className }: { className: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M2.766 24.073a1.5 1.5 0 0 1 .098-2.12l9.875-8.999a1.5 1.5 0 0 1 1.99-.028l3.493 3.008 8.892-8.105a1.5 1.5 0 1 1 2.021 2.217l-9.875 9a1.5 1.5 0 0 1-1.989.028l-3.493-3.007-8.893 8.104a1.5 1.5 0 0 1-2.119-.098Z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default LineChartIcon
|
|
@ -0,0 +1,14 @@
|
|||
const MangoIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 40 40"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M30.9524 16.6647C29.6789 12.8631 26.0028 10.0966 22.9101 9.51321C23.0607 7.74416 23.7758 6.92237 24.3655 6.55225C24.7544 6.30132 24.8799 5.79319 24.6352 5.39798C24.3906 5.00904 23.8699 4.8773 23.4872 5.12823C22.4835 5.79319 22.0883 6.9851 21.9566 8.13938C20.2628 8.08919 16.2668 8.30875 13.7575 11.3764C10.7087 15.1027 11.5367 16.2318 9.11528 19.2869C8.83298 19.6445 9.10273 20.1777 9.56068 20.1463C11.4426 20.0271 15.1564 19.4814 17.9982 17.1101C19.9805 15.4665 21.1724 13.2458 21.8625 11.4328L22.7595 12.562C21.9817 14.3812 20.7396 16.4639 18.8011 18.0762C17.1387 19.4625 15.2317 20.2781 13.494 20.7548C13.8076 21.7836 14.228 23.1073 14.3095 23.4272C14.9494 25.9491 15.5391 28.5775 14.9682 31.0555C14.4914 33.1068 16.6431 34.5747 18.5314 34.8884C21.0407 35.3087 23.6754 34.512 25.7268 33.0002C27.7844 31.4695 29.2711 29.3366 30.2686 26.9653C31.6361 23.7283 32.0627 20.002 30.9524 16.6647ZM27.9601 25.9867C26.649 29.1045 24.3844 31.4256 21.9064 32.2035C21.8437 32.2223 21.781 32.2348 21.7182 32.2348C21.4485 32.2348 21.2038 32.0592 21.1223 31.7957C21.0156 31.4632 21.1976 31.1119 21.53 31.0053C23.6629 30.3403 25.6327 28.2827 26.7996 25.5037C26.9376 25.1837 27.3014 25.0332 27.6213 25.1649C27.9412 25.3029 28.0918 25.6667 27.9601 25.9867Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default MangoIcon
|
|
@ -0,0 +1,23 @@
|
|||
const MedalIcon = ({
|
||||
className,
|
||||
rank,
|
||||
}: {
|
||||
className?: string
|
||||
rank: number
|
||||
}) => {
|
||||
const medalColors = ['#FFCF40', '#C7C7C7', '#DBA36B']
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 41 40"
|
||||
>
|
||||
<path
|
||||
d="M39.4976 22.5643H39.5039C39.3431 22.2203 39.2124 21.8366 39.1199 21.4217C38.804 20.0252 38.9791 18.5701 39.5054 17.4376H39.4976C40.1013 16.3684 40.2648 15.0721 39.8425 13.8221C39.4202 12.5721 38.4959 11.6151 37.3534 11.0914L37.3586 11.0878C37.0175 10.8997 36.6804 10.6629 36.3506 10.3811C35.2425 9.42877 34.4956 8.15084 34.2293 6.93991L34.2229 6.94354C34.0693 5.82411 33.4911 4.76075 32.5273 3.99682C32.4511 3.93711 32.374 3.87852 32.2929 3.82216C31.1883 3.04816 29.8559 2.7993 28.612 3.02137L28.6135 3.01523C28.2228 3.0543 27.8057 3.05541 27.3669 3.01272C25.8884 2.86875 24.5039 2.25965 23.5478 1.42815L23.5454 1.43541C22.6745 0.552905 21.4433 0.000976562 20.0779 0.000976562C18.7122 0.000976562 17.4825 0.552877 16.6112 1.43541L16.6089 1.42676C16.3159 1.68066 15.9788 1.92006 15.5983 2.13239C14.3149 2.85139 12.8228 3.14296 11.5409 3.01132L11.5446 3.02109C10.3006 2.79899 8.96688 3.04787 7.8638 3.82187C7.0966 4.35647 6.54272 5.07301 6.22189 5.86509C6.07987 6.21163 5.98336 6.57435 5.93264 6.94294L5.92627 6.93792C5.84656 7.3079 5.71701 7.69099 5.53963 8.07935C4.94113 9.38792 3.91168 10.4669 2.79435 11.0846L2.80188 11.0908C1.66081 11.6145 0.735125 12.5715 0.31428 13.8215C-0.109162 15.0715 0.0554584 16.3678 0.659177 17.437H0.650193C0.811341 17.7838 0.940607 18.1658 1.03451 18.5796C1.35014 19.9771 1.17508 21.4333 0.650193 22.5639H0.659177C0.0554584 23.6356 -0.109133 24.9319 0.31428 26.1819C0.735407 27.4319 1.66081 28.3887 2.80188 28.9113L2.79551 28.9163C3.13664 29.1041 3.47517 29.3412 3.80206 29.6245C4.91153 30.5767 5.65847 31.8532 5.92447 33.0667L5.932 33.0594C5.96127 33.262 6.00301 33.462 6.05894 33.6601C6.33284 34.6392 6.94412 35.5401 7.86312 36.1819C8.54654 36.6579 9.31753 36.9386 10.1012 37.0265C10.5843 37.0829 11.0701 37.0681 11.544 36.9824L11.5413 36.9897C11.932 36.9506 12.3502 36.9481 12.7879 36.9922C14.2652 37.1361 15.6497 37.7441 16.6071 38.5767L16.6108 38.567C17.4821 39.4509 18.7118 40 20.0775 40C21.4429 40 22.6741 39.4509 23.5454 38.567L23.5465 38.572C23.8395 38.3181 24.1769 38.0812 24.5586 37.8689C25.8417 37.1487 27.3329 36.858 28.6145 36.9899L28.6119 36.9827C28.7667 37.0095 28.92 37.0315 29.0771 37.0438C30.1817 37.1339 31.3254 36.8582 32.2928 36.1822C33.1473 35.584 33.7371 34.7662 34.035 33.8655C34.1236 33.6018 34.1845 33.3331 34.2228 33.0597L34.228 33.0647C34.308 32.6937 34.4361 32.3105 34.6146 31.9222C35.2146 30.6136 36.2441 29.5343 37.3611 28.9169L37.3533 28.9119C38.4957 28.3893 39.4203 27.43 39.8423 26.1825C40.2646 24.9322 40.101 23.6334 39.4976 22.5643Z"
|
||||
fill={medalColors[rank - 1]}
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default MedalIcon
|
|
@ -0,0 +1,25 @@
|
|||
const NukeIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 32 32"
|
||||
fill="currentColor"
|
||||
>
|
||||
<g clipPath="url(#a)">
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M16 32c8.8366 0 16-7.1634 16-16 0-8.83656-7.1634-16-16-16C7.16344 0 0 7.16344 0 16c0 8.8366 7.16344 16 16 16Zm.026-20.9524c.7047 0 1.3722.1482 1.9656.4077.2967.1482.6675 0 .8159-.2595l3.3748-5.85549c.1854-.33355.0742-.74121-.2596-.88945-3.5973-1.85302-8.0105-2.00126-11.8675-.03706-.33375.1853-.445.59296-.25957.92651l3.44897 5.81849c.1484.2965.5192.4076.8159.2594.5934-.2224 1.2609-.3706 1.9655-.3706Zm-5.5628 4.9661H3.67652c-.37086 0-.66755.2965-.66755.6671.11126 1.9642.66755 3.9654 1.70595 5.7814 1.07549 1.853 2.52184 3.3354 4.22779 4.4472.29668.1853.74171.0741.89006-.2224l3.44893-5.8925c.1484-.2965.1113-.6301-.1483-.8524-1.0755-.7783-1.8172-2.0013-2.0026-3.3725-.0371-.2965-.3338-.5559-.6676-.5559Zm10.4953.5559c-.1855 1.3712-.9272 2.5942-2.0027 3.3725-.2596.1853-.3338.5559-.1483.8524l3.3748 5.8555c.1854.3335.5934.4447.9271.2224 3.5603-2.2978 5.6371-6.152 5.8967-10.1546.0371-.3706-.2967-.667-.6676-.667h-6.7496c-.3338-.0371-.5934.2223-.6304.5188ZM16.026 19.312c1.8434 0 3.3377-1.4933 3.3377-3.3354 0-1.8421-1.4943-3.3354-3.3377-3.3354s-3.3377 1.4933-3.3377 3.3354c0 1.8421 1.4943 3.3354 3.3377 3.3354Z"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="a">
|
||||
<path d="M0 0h32v32H0z" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default NukeIcon
|
|
@ -0,0 +1,22 @@
|
|||
const ProfileIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 45.532 45.532"
|
||||
fill="currentColor"
|
||||
>
|
||||
<g>
|
||||
<path
|
||||
d="M22.766,0.001C10.194,0.001,0,10.193,0,22.766s10.193,22.765,22.766,22.765c12.574,0,22.766-10.192,22.766-22.765
|
||||
S35.34,0.001,22.766,0.001z M22.766,6.808c4.16,0,7.531,3.372,7.531,7.53c0,4.159-3.371,7.53-7.531,7.53
|
||||
c-4.158,0-7.529-3.371-7.529-7.53C15.237,10.18,18.608,6.808,22.766,6.808z M22.761,39.579c-4.149,0-7.949-1.511-10.88-4.012
|
||||
c-0.714-0.609-1.126-1.502-1.126-2.439c0-4.217,3.413-7.592,7.631-7.592h8.762c4.219,0,7.619,3.375,7.619,7.592
|
||||
c0,0.938-0.41,1.829-1.125,2.438C30.712,38.068,26.911,39.579,22.761,39.579z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProfileIcon
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,21 @@
|
|||
const RobotIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 40 40"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M15.102 17.2186C14.3807 17.2186 13.7959 17.8104 13.7959 18.5404C13.7959 19.2705 14.3807 19.8623 15.102 19.8623C15.8233 19.8623 16.4082 19.2705 16.4082 18.5404C16.4082 17.8104 15.8233 17.2186 15.102 17.2186Z" />
|
||||
<path d="M23.5918 18.5404C23.5918 17.8104 24.1767 17.2186 24.898 17.2186C25.6193 17.2186 26.2041 17.8104 26.2041 18.5404C26.2041 19.2705 25.6193 19.8623 24.898 19.8623C24.1767 19.8623 23.5918 19.2705 23.5918 18.5404Z" />
|
||||
<path d="M24.2449 25.8107H15.7551V27.1325H24.2449V25.8107Z" />
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M16.4082 7.30465C16.4082 5.47955 17.8701 4 19.6735 4C21.4769 4 22.9388 5.47955 22.9388 7.30465C22.9388 8.78436 21.9778 10.0369 20.6531 10.458V11.6007H30.449C31.5309 11.6007 32.4082 12.4884 32.4082 13.5835V16.5577H34.3673C35.269 16.5577 36 17.2974 36 18.21V24.8193C36 25.7318 35.269 26.4716 34.3673 26.4716H32.4082V29.4458C32.4082 30.5409 31.5309 31.4286 30.449 31.4286H9.55102C8.46907 31.4286 7.59184 30.5409 7.59184 29.4458V26.4716H5.63265C4.73103 26.4716 4 25.7318 4 24.8193V18.21C4 17.2974 4.73103 16.5577 5.63265 16.5577H7.59184V13.5835C7.59184 12.4884 8.46907 11.6007 9.55102 11.6007H18.6939V10.458C17.3691 10.0369 16.4082 8.78436 16.4082 7.30465ZM19.6735 5.98279C18.9522 5.98279 18.3673 6.57462 18.3673 7.30465C18.3673 8.03468 18.9522 8.62651 19.6735 8.62651C20.3948 8.62651 20.9796 8.03468 20.9796 7.30465C20.9796 6.57462 20.3948 5.98279 19.6735 5.98279ZM7.59184 18.5404H5.95918V24.4888H7.59184V18.5404ZM32.4082 24.4888H34.0408V18.5404H32.4082V24.4888ZM11.8367 18.5404C11.8367 16.7153 13.2986 15.2358 15.102 15.2358C16.9055 15.2358 18.3673 16.7153 18.3673 18.5404C18.3673 20.3655 16.9055 21.8451 15.102 21.8451C13.2986 21.8451 11.8367 20.3655 11.8367 18.5404ZM24.898 15.2358C23.0945 15.2358 21.6327 16.7153 21.6327 18.5404C21.6327 20.3655 23.0945 21.8451 24.898 21.8451C26.7014 21.8451 28.1633 20.3655 28.1633 18.5404C28.1633 16.7153 26.7014 15.2358 24.898 15.2358ZM13.7959 25.4802C13.7959 24.5676 14.5269 23.8279 15.4286 23.8279H24.5714C25.4731 23.8279 26.2041 24.5676 26.2041 25.4802V27.463C26.2041 28.3756 25.4731 29.1153 24.5714 29.1153H15.4286C14.5269 29.1153 13.7959 28.3756 13.7959 27.463V25.4802Z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default RobotIcon
|
|
@ -0,0 +1,45 @@
|
|||
const ThemesIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 32 32"
|
||||
fill="none"
|
||||
>
|
||||
<path
|
||||
d="M6.15479 12.2139H6.18078C6.17324 12.2168 6.16359 12.2168 6.15479 12.2139Z"
|
||||
fill="#308D8A"
|
||||
/>
|
||||
<path
|
||||
d="M20.6969 3C18.8692 3 17.1697 3.56287 15.7612 4.5228C18.1064 6.12314 19.6446 8.83184 19.6446 11.903C19.6446 12.1185 19.6345 12.3295 19.6196 12.5412C22.3771 13.898 24.3264 16.6644 24.5553 19.9088C27.4928 18.4634 29.5223 15.4219 29.5223 11.903C29.5223 6.98617 25.5709 3 20.6969 3Z"
|
||||
fill="#00FF00"
|
||||
/>
|
||||
<path
|
||||
d="M15.7546 19.2832C14.3461 20.2431 12.6466 20.806 10.8189 20.806C9.43314 20.806 8.12123 20.483 6.95425 19.9088C6.93962 20.1184 6.9292 20.3272 6.9292 20.5406C6.9292 25.4575 10.8806 29.4436 15.7546 29.4436C20.6285 29.4436 24.5799 25.4575 24.5799 20.5406C24.5799 20.3272 24.5695 20.1184 24.5549 19.9088C23.3879 20.483 22.076 20.806 20.6903 20.806C18.8625 20.806 17.1631 20.2431 15.7546 19.2832Z"
|
||||
fill="#0000FF"
|
||||
/>
|
||||
<path
|
||||
d="M10.8254 3C5.95141 3 2 6.98617 2 11.903C2 15.4219 4.02327 18.4634 6.96075 19.9088C7.18964 16.6645 9.13922 13.8981 11.8964 12.5412C11.8817 12.3308 11.8714 12.1172 11.8714 11.903C11.8714 8.82998 13.4135 6.12277 15.7611 4.5228C14.3526 3.56287 12.6531 3 10.8254 3Z"
|
||||
fill="#FF0000"
|
||||
/>
|
||||
<path
|
||||
d="M15.7548 11.644C14.369 11.644 13.0571 11.9671 11.8901 12.5413C12.0881 15.3479 13.5719 17.7956 15.7548 19.2833C17.9377 17.7956 19.4215 15.348 19.6194 12.5413C18.4523 11.967 17.1407 11.644 15.7548 11.644Z"
|
||||
fill="white"
|
||||
/>
|
||||
<path
|
||||
d="M15.755 19.2767C13.5738 17.7902 12.0901 15.345 11.8904 12.541C9.13715 13.8992 7.18961 16.661 6.96094 19.9023C8.12662 20.4749 9.43558 20.7995 10.8193 20.7995C12.647 20.7995 14.3465 20.2366 15.755 19.2767Z"
|
||||
fill="#FF00FF"
|
||||
/>
|
||||
<path
|
||||
d="M15.7549 4.52275C13.4073 6.12272 11.8652 8.82993 11.8652 11.903C11.8652 12.1171 11.8755 12.3307 11.8903 12.5411C13.0559 11.9685 14.3649 11.6439 15.7487 11.6439C17.1346 11.6439 18.4462 11.9668 19.6133 12.5411C19.6283 12.3294 19.6383 12.1185 19.6383 11.903C19.6383 8.83362 18.104 6.12346 15.7612 4.52275C15.7592 4.52174 15.7564 4.52376 15.755 4.52275H15.7549Z"
|
||||
fill="#FFFF00"
|
||||
/>
|
||||
<path
|
||||
d="M19.6131 12.541C19.4153 15.3477 17.9314 17.7953 15.7485 19.283C17.157 20.243 18.8565 20.8058 20.6842 20.8058C22.07 20.8058 23.3819 20.4828 24.5488 19.9086C24.32 16.6642 22.3706 13.8978 19.6131 12.541ZM24.5551 19.9086C24.5531 19.9094 24.5505 19.9078 24.5489 19.9086V19.9086"
|
||||
fill="#00FFFF"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default ThemesIcon
|
|
@ -0,0 +1,17 @@
|
|||
const TradeIcon = ({ className }: { className: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M7 4C5.34315 4 4 5.34315 4 7V21.9199L15.3027 11.3572C15.8558 10.8403 16.7073 10.8166 17.2884 11.3018L20.0552 13.6124L27.8668 6.1133C27.4886 4.8893 26.3482 4 25 4H7Z" />
|
||||
<path d="M28 10.1441L21.1637 16.707C20.612 17.2365 19.7503 17.2664 19.1634 16.7762L16.3827 14.454L4.13677 25.8982C4.5185 27.1163 5.65604 28 7 28H25C26.6569 28 28 26.6569 28 25V10.1441Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default TradeIcon
|
|
@ -0,0 +1,17 @@
|
|||
export const TwitterIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
// stroke="currentColor"
|
||||
// strokeWidth="2"
|
||||
// strokeLinecap="round"
|
||||
>
|
||||
<path d="M23 3a10.9 10.9 0 0 1-3.14 1.53 4.48 4.48 0 0 0-7.86 3v1A10.66 10.66 0 0 1 3 4s-4 9 5 13a11.64 11.64 0 0 1-7 2c9 5 20 0 20-11.5a4.5 4.5 0 0 0-.08-.83A7.72 7.72 0 0 0 23 3z"></path>
|
||||
</svg>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
const WalletIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M17.999 3c1.103 0 2 .897 2 2v2c1.103 0 2 .897 2 2v10c0 1.103-.897 2-2 2h-15c-1.206 0-3-.799-3-3V6c0-1.654 1.346-3 3-3h13Zm0 2h-13a1.001 1.001 0 0 0 0 2h13V5Zm-1.001 7a1 1 0 0 0-1 1v2a1 1 0 0 0 2 0v-2a1 1 0 0 0-1-1Z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default WalletIcon
|
|
@ -0,0 +1,20 @@
|
|||
const WhaleIcon = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 40 40"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M37.4952 15.4842C34.6812 14.5986 31.5602 14.4129 27.1108 16.8341C24.0041 18.5267 20.1331 19.6908 16.605 18.8552C13.084 18.0196 10.3772 14.97 9.30594 11.1776C11.27 10.1778 12.1127 5.98546 10.3987 4C7.98469 4.78561 6.21349 6.20686 6.00637 8.18518C3.56383 6.82821 1.06415 7.57811 0 8.6994C2.24257 13.4059 6.3349 12.4132 6.3349 12.4132C6.3349 12.4132 5.98494 16.5127 6.73485 21.7834C6.7577 21.9605 6.79884 22.1376 6.83997 22.3148C6.85026 22.359 6.86054 22.4033 6.87054 22.4476C6.9991 22.4119 7.1348 22.3905 7.27049 22.3905C7.65616 22.3905 8.03468 22.5476 8.31322 22.8404C8.82029 23.3832 11.6199 26.1614 16.6621 27.6541C17.5335 27.9112 18.3762 28.1112 19.2047 28.2754C18.4405 31.6393 19.4046 35.8673 19.4046 35.8673C22.0043 35.3674 25.0325 32.9248 25.8467 29.3539C25.8661 29.2513 25.8844 29.1508 25.9025 29.0517C25.931 28.8955 25.9589 28.7426 25.9895 28.5897C28.0535 28.2754 29.8676 27.547 31.4888 26.3685C31.8745 26.09 32.2244 25.8258 32.5529 25.5758C34.4527 24.1403 35.9597 23.0047 38.7164 23.0047C38.8521 23.0047 38.995 23.0047 39.1378 23.0118C39.2664 23.0118 39.3878 23.0404 39.5092 23.0761C40.4019 19.7623 40.2662 16.277 37.4952 15.4771V15.4842ZM31.878 20.2015C31.0924 20.2015 30.4497 19.5587 30.4497 18.7731C30.4497 17.9875 31.0924 17.3447 31.878 17.3447C32.6637 17.3447 33.3064 17.9875 33.3064 18.7731C33.3064 19.5587 32.6637 20.2015 31.878 20.2015Z"
|
||||
/>
|
||||
<path d="M16.2621 29.0254C10.7628 27.397 7.72034 24.2903 7.27754 23.8189C8.7345 27.5827 12.6483 31.2679 17.5476 32.7892C17.4762 31.7464 17.4619 30.5609 17.5905 29.3825L17.4391 29.3428C17.0525 29.2416 16.6608 29.1391 16.2692 29.0254H16.2621Z" />
|
||||
<path d="M27.2036 29.8109C29.0319 29.411 30.7531 28.6754 32.3315 27.5255C32.7224 27.2405 33.0802 26.9702 33.4156 26.7169C35.3661 25.2436 36.5588 24.3427 39.0878 24.4402C38.5236 26.0257 37.7594 27.4755 36.9952 28.4397C34.167 31.9964 30.4889 33.439 25.3538 33.5962C26.1894 32.5249 26.8465 31.2536 27.2036 29.8109Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default WhaleIcon
|
|
@ -0,0 +1,228 @@
|
|||
import { ReactNode, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { IconButton } from '../shared/Button'
|
||||
import {
|
||||
ChartBarIcon,
|
||||
Bars3Icon,
|
||||
XMarkIcon,
|
||||
ChevronRightIcon,
|
||||
ArrowsRightLeftIcon,
|
||||
CurrencyDollarIcon,
|
||||
Cog8ToothIcon,
|
||||
BuildingLibraryIcon,
|
||||
ArrowTrendingUpIcon,
|
||||
MagnifyingGlassIcon,
|
||||
BanknotesIcon,
|
||||
PlusCircleIcon,
|
||||
ArchiveBoxArrowDownIcon,
|
||||
// ClipboardDocumentIcon,
|
||||
NewspaperIcon,
|
||||
ExclamationTriangleIcon,
|
||||
DocumentTextIcon,
|
||||
} from '@heroicons/react/20/solid'
|
||||
import SolanaTps from '@components/SolanaTps'
|
||||
import LeaderboardIcon from '@components/icons/LeaderboardIcon'
|
||||
|
||||
const StyledBarItemLabel = ({
|
||||
children,
|
||||
...props
|
||||
}: {
|
||||
children: ReactNode
|
||||
}) => (
|
||||
<div style={{ fontSize: '0.6rem', lineHeight: 1 }} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
||||
const BottomBarLink = ({
|
||||
children,
|
||||
isActive,
|
||||
pathName,
|
||||
}: {
|
||||
children: ReactNode
|
||||
isActive: boolean
|
||||
pathName: string
|
||||
}) => {
|
||||
return (
|
||||
<Link
|
||||
href={{
|
||||
pathname: pathName,
|
||||
}}
|
||||
className={`${
|
||||
isActive ? 'text-th-active' : 'text-th-fgd-2'
|
||||
} col-span-1 flex flex-col items-center justify-center`}
|
||||
shallow={true}
|
||||
>
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
const BottomBar = () => {
|
||||
const { t } = useTranslation('common')
|
||||
const { asPath } = useRouter()
|
||||
const [showPanel, setShowPanel] = useState(false)
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid h-12 grid-cols-5 grid-rows-1 bg-th-bkg-3 shadow-bottomBar">
|
||||
<BottomBarLink isActive={asPath === '/'} pathName="/">
|
||||
<CurrencyDollarIcon className="mb-1 h-4 w-4" />
|
||||
<StyledBarItemLabel>{t('account')}</StyledBarItemLabel>
|
||||
</BottomBarLink>
|
||||
<BottomBarLink isActive={asPath === '/swap'} pathName="/swap">
|
||||
<ArrowsRightLeftIcon className="mb-1 h-4 w-4" />
|
||||
<StyledBarItemLabel>{t('swap')}</StyledBarItemLabel>
|
||||
</BottomBarLink>
|
||||
<BottomBarLink isActive={asPath === '/trade'} pathName="/trade">
|
||||
<ArrowTrendingUpIcon className="mb-1 h-4 w-4" />
|
||||
<StyledBarItemLabel>{t('trade')}</StyledBarItemLabel>
|
||||
</BottomBarLink>
|
||||
<BottomBarLink isActive={asPath === '/borrow'} pathName="/borrow">
|
||||
<BanknotesIcon className="mb-1 h-4 w-4" />
|
||||
<StyledBarItemLabel>{t('borrow')}</StyledBarItemLabel>
|
||||
</BottomBarLink>
|
||||
<button
|
||||
className={`${
|
||||
showPanel ? 'text-th-active' : 'text-th-fgd-2'
|
||||
} col-span-1 flex cursor-pointer flex-col items-center justify-center`}
|
||||
onClick={() => setShowPanel(!showPanel)}
|
||||
>
|
||||
<Bars3Icon className="mb-1 h-4 w-4" />
|
||||
<StyledBarItemLabel>{t('more')}</StyledBarItemLabel>
|
||||
</button>
|
||||
</div>
|
||||
<MoreMenuPanel showPanel={showPanel} setShowPanel={setShowPanel} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default BottomBar
|
||||
|
||||
const MoreMenuPanel = ({
|
||||
showPanel,
|
||||
setShowPanel,
|
||||
}: {
|
||||
showPanel: boolean
|
||||
setShowPanel: (showPanel: boolean) => void
|
||||
}) => {
|
||||
const { t } = useTranslation(['common', 'search'])
|
||||
return (
|
||||
<div
|
||||
className={`fixed bottom-0 z-30 h-full w-full overflow-hidden bg-th-bkg-2 px-4 transition duration-300 ease-in-out ${
|
||||
showPanel ? 'translate-y-0' : 'translate-y-full'
|
||||
}`}
|
||||
>
|
||||
<div className="flex justify-between py-4">
|
||||
<SolanaTps />
|
||||
<IconButton onClick={() => setShowPanel(false)} hideBg>
|
||||
<XMarkIcon className="h-6 w-6 text-th-fgd-3" />
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="border-b border-th-bkg-4"
|
||||
onClick={() => setShowPanel(false)}
|
||||
>
|
||||
<MoreMenuItem
|
||||
title={t('settings')}
|
||||
path="/settings"
|
||||
icon={<Cog8ToothIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('stats')}
|
||||
path="/stats"
|
||||
icon={<ChartBarIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('leaderboard')}
|
||||
path="/leaderboard"
|
||||
icon={<LeaderboardIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('search:search-accounts')}
|
||||
path="/search"
|
||||
icon={<MagnifyingGlassIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('common:list-market-token')}
|
||||
path="/governance/list"
|
||||
icon={<PlusCircleIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('common:vote')}
|
||||
path="/governance/vote"
|
||||
icon={<ArchiveBoxArrowDownIcon className="h-5 w-5" />}
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('learn')}
|
||||
path="https://docs.mango.markets/"
|
||||
icon={<DocumentTextIcon className="h-5 w-5" />}
|
||||
isExternal
|
||||
/>
|
||||
<MoreMenuItem
|
||||
title={t('governance')}
|
||||
path="https://dao.mango.markets/"
|
||||
icon={<BuildingLibraryIcon className="h-5 w-5" />}
|
||||
isExternal
|
||||
/>
|
||||
{/* <MoreMenuItem
|
||||
title={t('feedback-survey')}
|
||||
path="https://forms.gle/JgV4w7SJ2kPH89mq7"
|
||||
icon={<ClipboardDocumentIcon className="h-5 w-5" />}
|
||||
isExternal
|
||||
/> */}
|
||||
<MoreMenuItem
|
||||
title={t('terms-of-use')}
|
||||
path="https://docs.mango.markets/legal"
|
||||
icon={<NewspaperIcon className="h-5 w-5" />}
|
||||
isExternal
|
||||
/>
|
||||
<MoreMenuItem
|
||||
icon={<ExclamationTriangleIcon className="h-5 w-5" />}
|
||||
title={t('risks')}
|
||||
path="https://docs.mango.markets/mango-markets/risks"
|
||||
isExternal
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const MoreMenuItem = ({
|
||||
title,
|
||||
path,
|
||||
icon,
|
||||
isExternal,
|
||||
}: {
|
||||
title: string
|
||||
path: string
|
||||
icon: ReactNode
|
||||
isExternal?: boolean
|
||||
}) => {
|
||||
const classNames =
|
||||
'flex w-full items-center justify-between border-t border-th-bkg-4 px-2 py-4 text-th-fgd-2 hover:text-th-fgd-1'
|
||||
return isExternal ? (
|
||||
<a
|
||||
className={classNames}
|
||||
href={path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<div className="flex items-center space-x-3">
|
||||
{icon}
|
||||
<span>{title}</span>
|
||||
</div>
|
||||
<ChevronRightIcon className="h-5 w-5" />
|
||||
</a>
|
||||
) : (
|
||||
<Link href={path} shallow={true} className={classNames}>
|
||||
<div className="flex items-center space-x-3">
|
||||
{icon}
|
||||
<span>{title}</span>
|
||||
</div>
|
||||
<ChevronRightIcon className="h-5 w-5" />
|
||||
</Link>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
import { ModalProps } from '../../types/modal'
|
||||
import Modal from '../shared/Modal'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import Button from '@components/shared/Button'
|
||||
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid'
|
||||
|
||||
const TermsOfUseModal = ({ isOpen, onClose }: ModalProps) => {
|
||||
const { t } = useTranslation('common')
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose} disableOutsideClose hideClose>
|
||||
<>
|
||||
<h2 className="mb-2 text-center">{t('accept-terms')}</h2>
|
||||
<p className="mb-6 flex flex-wrap justify-center">
|
||||
<span className="mr-1">{t('accept-terms-desc')}</span>
|
||||
<a
|
||||
className="flex items-center"
|
||||
href="https://docs.mango.markets/legal/terms-of-use"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{t('terms-of-use')}
|
||||
<ArrowTopRightOnSquareIcon className="ml-1 h-4 w-4 flex-shrink-0" />
|
||||
</a>
|
||||
<span className="mx-1">and</span>
|
||||
<a
|
||||
className="flex items-center"
|
||||
href="https://docs.mango.markets/mango-markets/risks"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{t('risks')}
|
||||
<ArrowTopRightOnSquareIcon className="ml-1 h-4 w-4 flex-shrink-0" />
|
||||
</a>
|
||||
</p>
|
||||
<Button className="w-full" onClick={onClose} size="large">
|
||||
{t('agree-and-continue')}
|
||||
</Button>
|
||||
</>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default TermsOfUseModal
|
|
@ -0,0 +1,316 @@
|
|||
import { useCallback, useEffect, useState } from 'react'
|
||||
import {
|
||||
CheckCircleIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
InformationCircleIcon,
|
||||
XCircleIcon,
|
||||
XMarkIcon,
|
||||
} from '@heroicons/react/20/solid'
|
||||
import mangoStore, { CLUSTER } from '@store/mangoStore'
|
||||
import { TransactionNotification, notify } from '../../utils/notifications'
|
||||
import Loading from '@components/shared/Loading'
|
||||
import { Transition } from '@headlessui/react'
|
||||
import {
|
||||
CLIENT_TX_TIMEOUT,
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
} from '../../utils/constants'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import useSolBalance from 'hooks/useSolBalance'
|
||||
import { EXPLORERS } from '@components/settings/PreferredExplorerSettings'
|
||||
|
||||
const setMangoStore = mangoStore.getState().set
|
||||
|
||||
function parseDescription(description: string | null | undefined) {
|
||||
if (
|
||||
description?.includes('{"err":{"InstructionError":[2,{"Custom":6001}]}}')
|
||||
) {
|
||||
return 'Your max slippage tolerance was exceeded'
|
||||
}
|
||||
|
||||
return description
|
||||
}
|
||||
|
||||
const TransactionNotificationList = () => {
|
||||
const { t } = useTranslation()
|
||||
const transactionNotifications = mangoStore((s) => s.transactionNotifications)
|
||||
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
||||
const notEnoughSoLMessage = t('deposit-more-sol')
|
||||
const [notificationPosition] = useLocalStorageState(
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
'bottom-left',
|
||||
)
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { maxSolDeposit } = useSolBalance()
|
||||
|
||||
// if a notification is shown with {"InstructionError":[0,{"Custom":1}]} then
|
||||
// add a notification letting the user know they may not have enough SOL
|
||||
useEffect(() => {
|
||||
if (transactionNotifications.length) {
|
||||
const customErrorNotification = transactionNotifications.find(
|
||||
(n) => n.description && n.description.includes('"Custom":1'),
|
||||
)
|
||||
const notEnoughSolNotification = transactionNotifications.find(
|
||||
(n) => n.title && n.title.includes(notEnoughSoLMessage),
|
||||
)
|
||||
|
||||
if (
|
||||
!notEnoughSolNotification &&
|
||||
customErrorNotification &&
|
||||
maxSolDeposit <= 0
|
||||
) {
|
||||
notify({
|
||||
title: notEnoughSoLMessage,
|
||||
type: 'info',
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [transactionNotifications, walletTokens, maxSolDeposit])
|
||||
|
||||
const clearAll = useCallback(() => {
|
||||
setMangoStore((s) => {
|
||||
const newNotifications = s.transactionNotifications.map((n) => ({
|
||||
...n,
|
||||
show: false,
|
||||
}))
|
||||
s.transactionNotifications = newNotifications
|
||||
})
|
||||
}, [transactionNotifications])
|
||||
|
||||
const reversedNotifications = [...transactionNotifications].reverse()
|
||||
|
||||
const getPosition = (position: string) => {
|
||||
const sharedClasses =
|
||||
'pointer-events-none fixed z-50 flex items-end p-4 text-th-fgd-1 md:p-6'
|
||||
switch (position) {
|
||||
case 'Bottom-Left':
|
||||
return 'flex-col bottom-0 left-0 ' + sharedClasses
|
||||
case 'Bottom-Right':
|
||||
return 'flex-col w-full bottom-0 right-0 ' + sharedClasses
|
||||
case 'Top-Left':
|
||||
return 'flex-col-reverse top-0 left-0 ' + sharedClasses
|
||||
case 'Top-Right':
|
||||
return 'flex-col-reverse w-full top-0 right-0 ' + sharedClasses
|
||||
default:
|
||||
return 'flex-col bottom-0 left-0 ' + sharedClasses
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => setMounted(true), [])
|
||||
if (!mounted) return null
|
||||
|
||||
return (
|
||||
<div className={`${getPosition(notificationPosition)} w-full sm:w-auto`}>
|
||||
{transactionNotifications.filter((n) => n.show).length > 1 ? (
|
||||
<button
|
||||
className="pointer-events-auto my-1 flex items-center rounded bg-th-bkg-3 px-2 py-1 text-xs text-th-fgd-3 md:hover:bg-th-bkg-4"
|
||||
onClick={clearAll}
|
||||
>
|
||||
<XMarkIcon className="mr-1 h-3.5 w-3.5" />
|
||||
{t('clear-all')}
|
||||
</button>
|
||||
) : null}
|
||||
{reversedNotifications.map((n) => (
|
||||
<TransactionNotification key={n.id} notification={n} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const TransactionNotification = ({
|
||||
notification,
|
||||
}: {
|
||||
notification: TransactionNotification
|
||||
}) => {
|
||||
const [notificationPosition] = useLocalStorageState(
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
'Bottom-Left',
|
||||
)
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0],
|
||||
)
|
||||
const { type, title, description, txid, show, id } = notification
|
||||
|
||||
// overwrite the title if of the error message if it is a time out error
|
||||
let parsedTitle: string | undefined
|
||||
if (description) {
|
||||
if (
|
||||
description.includes('Timed out awaiting') ||
|
||||
description.includes('was not confirmed')
|
||||
) {
|
||||
parsedTitle = 'Transaction status unknown'
|
||||
}
|
||||
}
|
||||
|
||||
const parsedDescription = parseDescription(description)
|
||||
|
||||
// if the notification is a success, then hide the confirming tx notification with the same txid
|
||||
useEffect(() => {
|
||||
if ((type === 'error' || type === 'success') && txid) {
|
||||
setMangoStore((s) => {
|
||||
const newNotifications = s.transactionNotifications.map((n) =>
|
||||
n.txid === txid && n.type === 'confirm' ? { ...n, show: false } : n,
|
||||
)
|
||||
s.transactionNotifications = newNotifications
|
||||
})
|
||||
}
|
||||
}, [type, txid])
|
||||
|
||||
const hideNotification = useCallback(() => {
|
||||
setMangoStore((s) => {
|
||||
const newNotifications = s.transactionNotifications.map((n) =>
|
||||
n.id === id ? { ...n, show: false } : n,
|
||||
)
|
||||
s.transactionNotifications = newNotifications
|
||||
})
|
||||
}, [id])
|
||||
|
||||
// auto hide a notification
|
||||
// if no status is provided for a tx notification after 90s, hide it
|
||||
useEffect(() => {
|
||||
const timeoutInterval =
|
||||
parsedTitle || type === 'confirm'
|
||||
? CLIENT_TX_TIMEOUT
|
||||
: type === 'error'
|
||||
? 30000
|
||||
: type === 'info'
|
||||
? 4000
|
||||
: 10000
|
||||
|
||||
const id = setTimeout(() => {
|
||||
if (show) {
|
||||
hideNotification()
|
||||
}
|
||||
}, timeoutInterval)
|
||||
|
||||
return () => {
|
||||
clearInterval(id)
|
||||
}
|
||||
}, [hideNotification, parsedTitle, show, type])
|
||||
|
||||
const getTransformClasses = (position: string) => {
|
||||
const fromLeft = {
|
||||
enterFromClass: 'md:-translate-x-48',
|
||||
enterToClass: 'md:translate-x-100',
|
||||
leaveFromClass: 'md:translate-x-0',
|
||||
leaveToClass: 'md:-translate-x-48',
|
||||
}
|
||||
const fromRight = {
|
||||
enterFromClass: 'md:translate-x-48',
|
||||
enterToClass: 'md:-translate-x-100',
|
||||
leaveFromClass: 'md:translate-x-0',
|
||||
leaveToClass: 'md:translate-x-48',
|
||||
}
|
||||
switch (position) {
|
||||
case 'Bottom-Left':
|
||||
return fromLeft
|
||||
case 'Bottom-Right':
|
||||
return fromRight
|
||||
case 'Top-Left':
|
||||
return fromLeft
|
||||
case 'Top-Right':
|
||||
return fromRight
|
||||
default:
|
||||
return fromLeft
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Transition
|
||||
className="my-1 w-full sm:w-auto"
|
||||
show={show}
|
||||
appear={true}
|
||||
enter="ease-out duration-500 transition"
|
||||
enterFrom={`-translate-y-2 opacity-0 md:translate-y-0 ${
|
||||
getTransformClasses(notificationPosition).enterFromClass
|
||||
}`}
|
||||
enterTo={`translate-y-0 opacity-100 ${
|
||||
getTransformClasses(notificationPosition).enterToClass
|
||||
}`}
|
||||
leave="ease-in duration-200 transition"
|
||||
leaveFrom={`translate-y-0 ${
|
||||
getTransformClasses(notificationPosition).leaveFromClass
|
||||
}`}
|
||||
leaveTo={`-translate-y-2 md:translate-y-0 ${
|
||||
getTransformClasses(notificationPosition).leaveToClass
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`pointer-events-auto w-full rounded-md border bg-th-bkg-2 shadow-lg sm:w-auto ${
|
||||
type === 'success'
|
||||
? 'border-th-success'
|
||||
: type === 'error'
|
||||
? 'border-th-error'
|
||||
: 'border-th-bkg-4'
|
||||
}`}
|
||||
>
|
||||
<div className={`relative flex w-full items-center p-3.5 sm:w-96`}>
|
||||
<div className={`mr-1 flex-shrink-0`}>
|
||||
{type === 'success' ? (
|
||||
<CheckCircleIcon className={`h-6 w-6 text-th-success`} />
|
||||
) : null}
|
||||
{type === 'info' && (
|
||||
<InformationCircleIcon className={`h-6 w-6 text-th-fgd-3`} />
|
||||
)}
|
||||
{type === 'error' && (
|
||||
<XCircleIcon className={`h-6 w-6 text-th-error`} />
|
||||
)}
|
||||
{type === 'confirm' && (
|
||||
<Loading className="mr-0.5 h-5 w-5 text-th-active" />
|
||||
)}
|
||||
</div>
|
||||
<div className={`ml-2 flex-1`}>
|
||||
<p className={`text-th-fgd-1`}>{parsedTitle || title}</p>
|
||||
{parsedDescription ? (
|
||||
<p
|
||||
className={`mb-0 mt-0.5 break-all text-sm leading-tight text-th-fgd-4`}
|
||||
>
|
||||
{parsedDescription}
|
||||
</p>
|
||||
) : null}
|
||||
{txid ? (
|
||||
<a
|
||||
href={preferredExplorer.url + txid + '?cluster=' + CLUSTER}
|
||||
className="mt-1 flex items-center text-xs text-th-active underline hover:text-th-fgd-2"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<div className="break-all">
|
||||
{type === 'error'
|
||||
? txid
|
||||
: `${txid.slice(0, 14)}...${txid.slice(txid.length - 14)}`}
|
||||
</div>
|
||||
<ArrowTopRightOnSquareIcon className="mb-0.5 ml-1 h-5 w-5 flex-shrink-0" />
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={`absolute right-2 top-2 flex-shrink-0`}>
|
||||
<button
|
||||
onClick={hideNotification}
|
||||
className={`text-th-fgd-4 focus:outline-none md:hover:text-th-fgd-3`}
|
||||
>
|
||||
<span className={`sr-only`}>Close</span>
|
||||
<svg
|
||||
className={`h-5 w-5`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
)
|
||||
}
|
||||
|
||||
export default TransactionNotificationList
|
|
@ -0,0 +1,41 @@
|
|||
import mangoStore from '../../store/mangoStore'
|
||||
import ProfileIcon from '../icons/ProfileIcon'
|
||||
|
||||
const ProfileImage = ({
|
||||
imageSize,
|
||||
placeholderSize,
|
||||
imageUrl,
|
||||
isOwnerProfile,
|
||||
}: {
|
||||
imageSize: string
|
||||
placeholderSize: string
|
||||
imageUrl?: string | null
|
||||
isOwnerProfile?: boolean
|
||||
}) => {
|
||||
const profile = mangoStore((s) => s.profile.details)
|
||||
|
||||
return imageUrl || (isOwnerProfile && profile?.profile_image_url) ? (
|
||||
<img
|
||||
alt=""
|
||||
src={imageUrl ? imageUrl : profile?.profile_image_url}
|
||||
className={`rounded-full`}
|
||||
style={{ width: `${imageSize}px`, height: `${imageSize}px` }}
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className={`flex flex-shrink-0 items-center justify-center rounded-full bg-th-bkg-3`}
|
||||
style={{ width: `${imageSize}px`, height: `${imageSize}px` }}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: `${placeholderSize}px`,
|
||||
height: `${placeholderSize}px`,
|
||||
}}
|
||||
>
|
||||
<ProfileIcon className={`h-full w-full text-th-fgd-3`} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProfileImage
|
|
@ -0,0 +1,49 @@
|
|||
import { CheckCircleIcon } from '@heroicons/react/20/solid'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import Image from 'next/image'
|
||||
import { PREFERRED_EXPLORER_KEY } from 'utils/constants'
|
||||
|
||||
export const EXPLORERS = [
|
||||
{ name: 'solana-explorer', url: 'https://explorer.solana.com/tx/' },
|
||||
{ name: 'solscan', url: 'https://solscan.io/tx/' },
|
||||
{ name: 'solana-beach', url: 'https://solanabeach.io/transaction/' },
|
||||
{ name: 'solanafm', url: 'https://solana.fm/tx/' },
|
||||
]
|
||||
|
||||
const PreferredExplorerSettings = () => {
|
||||
const { t } = useTranslation('settings')
|
||||
const [preferredExplorer, setPreferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0],
|
||||
)
|
||||
return (
|
||||
<>
|
||||
<h2 className="mb-4 text-base">{t('settings:preferred-explorer')}</h2>
|
||||
<div className="space-y-2">
|
||||
{EXPLORERS.map((ex) => (
|
||||
<button
|
||||
className="flex w-full items-center justify-between rounded-md border border-th-bkg-4 p-4 hover:border-th-fgd-4"
|
||||
onClick={() => setPreferredExplorer(ex)}
|
||||
key={ex.name}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Image
|
||||
alt=""
|
||||
width="24"
|
||||
height="24"
|
||||
src={`/explorer-logos/${ex.name}.png`}
|
||||
/>
|
||||
<p>{t(`settings:${ex.name}`)}</p>
|
||||
</div>
|
||||
{preferredExplorer.url === ex.url ? (
|
||||
<CheckCircleIcon className="h-5 w-5 text-th-success" />
|
||||
) : null}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default PreferredExplorerSettings
|
|
@ -0,0 +1,205 @@
|
|||
import ButtonGroup from '@components/forms/ButtonGroup'
|
||||
import Input from '@components/forms/Input'
|
||||
import Button from '@components/shared/Button'
|
||||
import Switch from '@components/forms/Switch'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import {
|
||||
PRIORITY_FEE_KEY,
|
||||
RPC_PROVIDER_KEY,
|
||||
USE_ORDERBOOK_FEED_KEY,
|
||||
} from 'utils/constants'
|
||||
import Tooltip from '@components/shared/Tooltip'
|
||||
|
||||
export const TRITON_DEDICATED_URL = process.env.NEXT_PUBLIC_TRITON_TOKEN
|
||||
? `https://mango.rpcpool.com/${process.env.NEXT_PUBLIC_TRITON_TOKEN}`
|
||||
: 'https://mango.rpcpool.com/946ef7337da3f5b8d3e4a34e7f88'
|
||||
|
||||
const RPC_URLS = [
|
||||
{
|
||||
label: 'Triton Shared',
|
||||
value: process.env.NEXT_PUBLIC_ENDPOINT || TRITON_DEDICATED_URL,
|
||||
},
|
||||
{
|
||||
label: 'Triton Dedicated',
|
||||
value: TRITON_DEDICATED_URL,
|
||||
},
|
||||
// {
|
||||
// label: 'Genesys Go',
|
||||
// value: 'https://mango.genesysgo.net',
|
||||
// },
|
||||
{ label: 'Custom', value: '' },
|
||||
]
|
||||
|
||||
export const PRIORITY_FEE_LEVELS = [
|
||||
{ label: 'None', value: 0 },
|
||||
{ label: 'Low', value: 1.2 }, // +20%
|
||||
{ label: 'High', value: 2 }, // +100%
|
||||
]
|
||||
|
||||
export const DEFAULT_PRIORITY_FEE = 1
|
||||
export const DEFAULT_PRIORITY_FEE_LEVEL = PRIORITY_FEE_LEVELS[1]
|
||||
|
||||
const RpcSettings = () => {
|
||||
const { t } = useTranslation('settings')
|
||||
const actions = mangoStore.getState().actions
|
||||
const { wallet } = useWallet()
|
||||
const [customUrl, setCustomUrl] = useState('')
|
||||
const [showCustomForm, setShowCustomForm] = useState(false)
|
||||
const [rpcEndpointProvider, setRpcEndpointProvider] = useLocalStorageState(
|
||||
RPC_PROVIDER_KEY,
|
||||
RPC_URLS[0].value,
|
||||
)
|
||||
const [storedPriorityFeeLevel, setStoredPriorityFeeLevel] =
|
||||
useLocalStorageState(PRIORITY_FEE_KEY, DEFAULT_PRIORITY_FEE_LEVEL)
|
||||
const [storedUseOrderbookFeed, setStoredUseOrderbookFeed] =
|
||||
useLocalStorageState(USE_ORDERBOOK_FEED_KEY, true)
|
||||
|
||||
const rpcEndpoint = useMemo(() => {
|
||||
return (
|
||||
RPC_URLS.find((node) => node.value === rpcEndpointProvider) || {
|
||||
label: 'Custom',
|
||||
value: rpcEndpointProvider,
|
||||
}
|
||||
)
|
||||
}, [rpcEndpointProvider])
|
||||
|
||||
const priorityFee = useMemo(() => {
|
||||
return (
|
||||
PRIORITY_FEE_LEVELS.find(
|
||||
(node) => node.value === storedPriorityFeeLevel,
|
||||
) || DEFAULT_PRIORITY_FEE_LEVEL
|
||||
)
|
||||
}, [storedPriorityFeeLevel])
|
||||
|
||||
const handleSetEndpointProvider = (provider: string) => {
|
||||
const endpointProvider = RPC_URLS.find(
|
||||
(node) => node.label === provider,
|
||||
) || { label: 'Custom', value: rpcEndpointProvider }
|
||||
setRpcEndpointProvider(endpointProvider.value)
|
||||
if (provider !== 'Custom') {
|
||||
setShowCustomForm(false)
|
||||
actions.updateConnection(endpointProvider.value)
|
||||
}
|
||||
}
|
||||
|
||||
const handlePriorityFee = useCallback(
|
||||
(label: string) => {
|
||||
const fee = PRIORITY_FEE_LEVELS.find((fee) => fee.label === label)
|
||||
if (fee) {
|
||||
setStoredPriorityFeeLevel(fee?.value)
|
||||
if (wallet) {
|
||||
actions.connectMangoClientWithWallet(wallet)
|
||||
}
|
||||
}
|
||||
},
|
||||
[setStoredPriorityFeeLevel, actions, wallet],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (rpcEndpoint.label === 'Custom') {
|
||||
setShowCustomForm(true)
|
||||
setCustomUrl(rpcEndpoint.value)
|
||||
}
|
||||
}, [rpcEndpoint])
|
||||
|
||||
const handleSaveCustomEndpoint = () => {
|
||||
if (!customUrl) return
|
||||
setRpcEndpointProvider(customUrl)
|
||||
actions.updateConnection(customUrl)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="mb-4 text-base">{t('rpc')}</h2>
|
||||
<div className="flex flex-col border-t border-th-bkg-3 py-4 md:flex-row md:items-center md:justify-between md:px-4">
|
||||
<p className="mb-2 md:mb-0">{t('rpc-provider')}</p>
|
||||
<div className="w-full min-w-[400px] md:w-auto">
|
||||
<ButtonGroup
|
||||
activeValue={rpcEndpoint.label}
|
||||
onChange={(v) => handleSetEndpointProvider(v)}
|
||||
values={RPC_URLS.map((val) => val.label)}
|
||||
/>
|
||||
{showCustomForm ? (
|
||||
<div className="mt-2">
|
||||
<div className="flex space-x-2">
|
||||
<Input
|
||||
type="text"
|
||||
name="url"
|
||||
id="url"
|
||||
className="!h-10"
|
||||
placeholder={t('rpc-url')}
|
||||
value={customUrl}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
setCustomUrl(e.target.value)
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
disabled={!customUrl}
|
||||
onClick={handleSaveCustomEndpoint}
|
||||
>
|
||||
{t('save')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col border-t border-th-bkg-3 py-4 md:flex-row md:items-center md:justify-between md:px-4">
|
||||
<p className="mb-2 md:mb-0">Priority Fee</p>
|
||||
<div className="w-full min-w-[220px] md:w-auto md:pl-4">
|
||||
<ButtonGroup
|
||||
activeValue={priorityFee.label}
|
||||
onChange={(v) => handlePriorityFee(v)}
|
||||
values={PRIORITY_FEE_LEVELS.map((val) => val.label)}
|
||||
/>
|
||||
{/* {showCustomForm ? (
|
||||
<div className="mt-2">
|
||||
<div className="flex space-x-2">
|
||||
<Input
|
||||
type="text"
|
||||
name="url"
|
||||
id="url"
|
||||
className="!h-10"
|
||||
placeholder={t('rpc-url')}
|
||||
value={customUrl}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
setCustomUrl(e.target.value)
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
className="h-12"
|
||||
disabled={!customUrl}
|
||||
onClick={handleSaveCustomEndpoint}
|
||||
>
|
||||
{t('save')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null} */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between border-t border-th-bkg-3 p-4">
|
||||
<Tooltip
|
||||
content={t('settings:tooltip-orderbook-bandwidth-saving')}
|
||||
maxWidth="25rem"
|
||||
placement="top-start"
|
||||
delay={100}
|
||||
>
|
||||
<p className="tooltip-underline">
|
||||
{t('settings:orderbook-bandwidth-saving')}
|
||||
</p>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
checked={storedUseOrderbookFeed}
|
||||
onChange={() => setStoredUseOrderbookFeed(!storedUseOrderbookFeed)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default RpcSettings
|
|
@ -0,0 +1,37 @@
|
|||
import { Bank } from '@blockworks-foundation/mango-v4'
|
||||
import Decimal from 'decimal.js'
|
||||
import FormatNumericValue from './FormatNumericValue'
|
||||
|
||||
const BankAmountWithValue = ({
|
||||
amount = 0,
|
||||
bank,
|
||||
fixDecimals = true,
|
||||
stacked,
|
||||
value,
|
||||
}: {
|
||||
amount: Decimal | number | string
|
||||
bank: Bank
|
||||
fixDecimals?: boolean
|
||||
stacked?: boolean
|
||||
value?: number
|
||||
}) => {
|
||||
return (
|
||||
<p className={`font-mono text-th-fgd-2 ${stacked ? 'text-right' : ''}`}>
|
||||
<>
|
||||
<FormatNumericValue
|
||||
value={amount}
|
||||
decimals={amount && fixDecimals ? bank.mintDecimals : undefined}
|
||||
/>{' '}
|
||||
<span className={`text-th-fgd-4 ${stacked ? 'block' : ''}`}>
|
||||
<FormatNumericValue
|
||||
value={value ? value : Number(amount) * bank.uiPrice}
|
||||
decimals={fixDecimals ? 2 : undefined}
|
||||
isUsd={true}
|
||||
/>
|
||||
</span>
|
||||
</>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export default BankAmountWithValue
|
|
@ -0,0 +1,130 @@
|
|||
import mangoStore from '@store/mangoStore'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { forwardRef, FunctionComponent, ReactNode, Ref } from 'react'
|
||||
|
||||
interface AllButtonProps {
|
||||
onClick?: (e?: React.MouseEvent) => void
|
||||
disabled?: boolean
|
||||
className?: string
|
||||
secondary?: boolean
|
||||
children?: ReactNode
|
||||
}
|
||||
|
||||
interface ButtonProps {
|
||||
size?: 'large' | 'medium' | 'small'
|
||||
type?: 'button' | 'submit'
|
||||
}
|
||||
|
||||
type ButtonCombinedProps = AllButtonProps & ButtonProps
|
||||
|
||||
const Button: FunctionComponent<ButtonCombinedProps> = ({
|
||||
children,
|
||||
onClick,
|
||||
disabled = false,
|
||||
className,
|
||||
secondary,
|
||||
size = 'medium',
|
||||
type = 'button',
|
||||
...props
|
||||
}) => {
|
||||
const { theme } = useTheme()
|
||||
const themeData = mangoStore((s) => s.themeData)
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
className={`rounded-md ${
|
||||
themeData.buttonStyle === 'raised'
|
||||
? 'raised-button'
|
||||
: secondary
|
||||
? 'border border-th-button focus-visible:border-th-fgd-4 md:hover:border-th-button-hover'
|
||||
: 'bg-th-button focus-visible:border focus-visible:border-th-fgd-4 md:hover:bg-th-button-hover'
|
||||
} ${
|
||||
size === 'medium'
|
||||
? 'h-10 px-4'
|
||||
: size === 'large'
|
||||
? 'h-12 px-6'
|
||||
: 'h-8 px-3'
|
||||
} font-display ${
|
||||
theme === 'High Contrast' && !secondary
|
||||
? 'text-th-bkg-1'
|
||||
: 'text-th-fgd-1'
|
||||
} disabled:cursor-not-allowed disabled:opacity-60 ${className}`}
|
||||
type={type}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
interface IconButtonProps {
|
||||
hideBg?: boolean
|
||||
size?: 'small' | 'medium' | 'large'
|
||||
ref?: Ref<HTMLButtonElement>
|
||||
}
|
||||
|
||||
type IconButtonCombinedProps = AllButtonProps & IconButtonProps
|
||||
|
||||
export const IconButton = forwardRef<
|
||||
HTMLButtonElement,
|
||||
IconButtonCombinedProps
|
||||
>((props, ref) => {
|
||||
const { children, onClick, disabled = false, className, hideBg, size } = props
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
className={`flex flex-shrink-0 ${
|
||||
size === 'large'
|
||||
? 'h-12 w-12'
|
||||
: size === 'small'
|
||||
? 'h-8 w-8'
|
||||
: size === 'medium'
|
||||
? 'h-10 w-10'
|
||||
: ''
|
||||
} items-center justify-center rounded-full ${
|
||||
hideBg
|
||||
? 'md:hover:text-th-active'
|
||||
: 'border border-th-button focus-visible:border-th-fgd-3 md:hover:border-th-button-hover'
|
||||
} text-th-fgd-1 focus:outline-none disabled:cursor-not-allowed disabled:bg-th-bkg-4
|
||||
disabled:text-th-fgd-4 md:disabled:hover:text-th-fgd-4 ${className} focus-visible:text-th-active`}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
})
|
||||
|
||||
IconButton.displayName = 'IconButton'
|
||||
|
||||
interface LinkButtonProps {
|
||||
icon?: ReactNode
|
||||
}
|
||||
|
||||
type LinkButtonCombinedProps = AllButtonProps & LinkButtonProps
|
||||
|
||||
export const LinkButton: FunctionComponent<LinkButtonCombinedProps> = ({
|
||||
children,
|
||||
onClick,
|
||||
disabled = false,
|
||||
className,
|
||||
secondary,
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
className={`flex items-center border-0 font-bold ${
|
||||
secondary ? 'text-th-active' : 'text-th-fgd-2'
|
||||
} rounded-sm focus-visible:text-th-active focus-visible:underline disabled:cursor-not-allowed disabled:opacity-50 ${className} md:hover:text-th-fgd-3`}
|
||||
{...props}
|
||||
type="button"
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default Button
|
|
@ -0,0 +1,31 @@
|
|||
import Decimal from 'decimal.js'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { PRIVACY_MODE } from 'utils/constants'
|
||||
import { formatCurrencyValue, formatNumericValue } from 'utils/numbers'
|
||||
|
||||
const FormatNumericValue = ({
|
||||
classNames,
|
||||
value,
|
||||
decimals,
|
||||
isUsd,
|
||||
roundUp,
|
||||
}: {
|
||||
classNames?: string
|
||||
value: Decimal | number | string
|
||||
decimals?: number
|
||||
isUsd?: boolean
|
||||
roundUp?: boolean
|
||||
}) => {
|
||||
const [privacyMode] = useLocalStorageState(PRIVACY_MODE)
|
||||
return (
|
||||
<span className={classNames}>
|
||||
{isUsd
|
||||
? privacyMode
|
||||
? '****'
|
||||
: formatCurrencyValue(value, decimals)
|
||||
: formatNumericValue(value, decimals, roundUp)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export default FormatNumericValue
|
|
@ -0,0 +1,73 @@
|
|||
import { FunctionComponent, ReactElement } from 'react'
|
||||
import {
|
||||
CheckCircleIcon,
|
||||
ExclamationCircleIcon,
|
||||
ExclamationTriangleIcon,
|
||||
InformationCircleIcon,
|
||||
} from '@heroicons/react/20/solid'
|
||||
|
||||
interface InlineNotificationProps {
|
||||
desc?: string | ReactElement
|
||||
title?: string | ReactElement
|
||||
type: 'error' | 'info' | 'success' | 'warning'
|
||||
hideBorder?: boolean
|
||||
hidePadding?: boolean
|
||||
}
|
||||
|
||||
const InlineNotification: FunctionComponent<InlineNotificationProps> = ({
|
||||
desc,
|
||||
title,
|
||||
type,
|
||||
hideBorder,
|
||||
hidePadding,
|
||||
}) => {
|
||||
const iconClasses = `mr-1.5 ${
|
||||
hidePadding ? 'h-4 w-4' : 'h-5 w-5'
|
||||
} flex-shrink-0`
|
||||
return (
|
||||
<div
|
||||
className={`${
|
||||
!hideBorder
|
||||
? `border text-th-fgd-3 ${
|
||||
type === 'error'
|
||||
? 'border-th-error'
|
||||
: type === 'success'
|
||||
? 'border-th-success'
|
||||
: type === 'info'
|
||||
? 'border-th-bkg-4'
|
||||
: 'border-th-warning'
|
||||
}`
|
||||
: type === 'error'
|
||||
? 'text-th-error'
|
||||
: type === 'success'
|
||||
? 'text-th-success'
|
||||
: type === 'info'
|
||||
? 'text-th-bkg-4'
|
||||
: 'text-th-warning'
|
||||
} flex items-center rounded-md ${!hidePadding ? 'p-2' : ''}`}
|
||||
>
|
||||
{type === 'error' ? (
|
||||
<ExclamationCircleIcon className={`${iconClasses} text-th-error`} />
|
||||
) : null}
|
||||
{type === 'success' ? (
|
||||
<CheckCircleIcon className={`${iconClasses} text-th-success`} />
|
||||
) : null}
|
||||
{type === 'warning' ? (
|
||||
<ExclamationTriangleIcon className={`${iconClasses} text-th-warning`} />
|
||||
) : null}
|
||||
{type === 'info' ? (
|
||||
<InformationCircleIcon className={`${iconClasses} text-th-fgd-4`} />
|
||||
) : null}
|
||||
<div>
|
||||
<div className="text-th-fgd-2">{title}</div>
|
||||
<div
|
||||
className={`${title && desc && 'pt-1'} text-left text-xs font-normal`}
|
||||
>
|
||||
{desc}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default InlineNotification
|
|
@ -0,0 +1,68 @@
|
|||
import { ChangeEvent, useEffect, useRef, useState } from 'react'
|
||||
|
||||
const LeverageSlider = ({
|
||||
amount,
|
||||
leverageMax,
|
||||
onChange,
|
||||
step,
|
||||
}: {
|
||||
amount: number
|
||||
leverageMax: number
|
||||
onChange: (x: string) => void
|
||||
step: number
|
||||
}) => {
|
||||
const [value, setValue] = useState(0)
|
||||
const inputEl = useRef<HTMLInputElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (inputEl.current) {
|
||||
const target = inputEl.current
|
||||
const min = parseFloat(target.min)
|
||||
const max = leverageMax
|
||||
|
||||
target.style.backgroundSize =
|
||||
max - min === 0
|
||||
? '0% 100%'
|
||||
: ((value - min) * 100) / (max - min) + '% 100%'
|
||||
}
|
||||
}, [leverageMax, value])
|
||||
|
||||
useEffect(() => {
|
||||
if (amount) {
|
||||
setValue(amount)
|
||||
} else {
|
||||
setValue(0)
|
||||
}
|
||||
}, [amount])
|
||||
|
||||
const handleSliderChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const target = e.target
|
||||
const min = parseFloat(target.min)
|
||||
const max = parseFloat(target.max)
|
||||
const val = parseFloat(target.value)
|
||||
|
||||
target.style.backgroundSize = ((val - min) * 100) / (max - min) + '% 100%'
|
||||
|
||||
onChange(e.target.value)
|
||||
setValue(parseFloat(e.target.value))
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<label htmlFor="default-range" className="block text-sm"></label>
|
||||
<input
|
||||
ref={inputEl}
|
||||
id="default-range"
|
||||
type="range"
|
||||
min="1"
|
||||
max={leverageMax}
|
||||
step={step}
|
||||
className="w-full focus:outline-none"
|
||||
onChange={handleSliderChange}
|
||||
value={value}
|
||||
></input>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default LeverageSlider
|
|
@ -0,0 +1,26 @@
|
|||
const Loading = ({ className = '' }: { className?: string }) => {
|
||||
return (
|
||||
<svg
|
||||
className={`${className} h-5 w-5 animate-spin`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<circle
|
||||
className={`opacity-25`}
|
||||
cx="12"
|
||||
cy="12"
|
||||
r="10"
|
||||
stroke="currentColor"
|
||||
strokeWidth="4"
|
||||
></circle>
|
||||
<path
|
||||
className={`opacity-75`}
|
||||
fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||
></path>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default Loading
|
|
@ -0,0 +1,34 @@
|
|||
import Decimal from 'decimal.js'
|
||||
import { LinkButton } from './Button'
|
||||
import FormatNumericValue from './FormatNumericValue'
|
||||
|
||||
const MaxAmountButton = ({
|
||||
className,
|
||||
decimals,
|
||||
disabled,
|
||||
label,
|
||||
onClick,
|
||||
value,
|
||||
}: {
|
||||
className?: string
|
||||
decimals: number
|
||||
disabled?: boolean
|
||||
label: string
|
||||
onClick: () => void
|
||||
value: number | string | Decimal
|
||||
}) => {
|
||||
return (
|
||||
<LinkButton
|
||||
className={`font-normal ${className}`}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
>
|
||||
<p className="mr-1 text-th-fgd-4">{label}:</p>
|
||||
<span className="font-mono">
|
||||
<FormatNumericValue value={value} decimals={decimals} />
|
||||
</span>
|
||||
</LinkButton>
|
||||
)
|
||||
}
|
||||
|
||||
export default MaxAmountButton
|
|
@ -0,0 +1,74 @@
|
|||
import { Dialog } from '@headlessui/react'
|
||||
import { XMarkIcon } from '@heroicons/react/20/solid'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
|
||||
type ModalProps = {
|
||||
children: React.ReactNode
|
||||
disableOutsideClose?: boolean
|
||||
fullScreen?: boolean
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
panelClassNames?: string
|
||||
hideClose?: boolean
|
||||
}
|
||||
|
||||
function Modal({
|
||||
children,
|
||||
disableOutsideClose = false,
|
||||
fullScreen = false,
|
||||
isOpen,
|
||||
onClose,
|
||||
panelClassNames,
|
||||
hideClose,
|
||||
}: ModalProps) {
|
||||
const themeData = mangoStore((s) => s.themeData)
|
||||
|
||||
const handleClose = () => {
|
||||
if (disableOutsideClose) return
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onClose={handleClose}
|
||||
className="relative z-40 overflow-y-auto"
|
||||
>
|
||||
<div
|
||||
className={`fixed inset-0 backdrop-brightness-[0.5] ${
|
||||
disableOutsideClose ? 'pointer-events-none' : ''
|
||||
}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div
|
||||
className={`fixed inset-0 flex items-center sm:justify-center ${
|
||||
fullScreen ? '' : 'sm:px-4'
|
||||
}`}
|
||||
>
|
||||
<Dialog.Panel
|
||||
className={`${themeData.fonts.body.variable} ${
|
||||
themeData.fonts.display.variable
|
||||
} ${
|
||||
themeData.fonts.mono.variable
|
||||
} font-sans h-full w-full bg-th-bkg-1 font-body ${
|
||||
fullScreen
|
||||
? ''
|
||||
: 'p-4 pt-6 sm:h-auto sm:max-w-md sm:rounded-lg sm:border sm:border-th-bkg-3 sm:p-6'
|
||||
} relative ${panelClassNames}`}
|
||||
>
|
||||
<div>{children}</div>
|
||||
{!hideClose ? (
|
||||
<button
|
||||
onClick={onClose}
|
||||
className={`absolute right-4 top-4 z-40 text-th-fgd-4 focus:outline-none focus-visible:text-th-active sm:right-2 sm:top-2 md:hover:text-th-active`}
|
||||
>
|
||||
<XMarkIcon className={`h-6 w-6`} />
|
||||
</button>
|
||||
) : null}
|
||||
</Dialog.Panel>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default Modal
|
|
@ -0,0 +1,67 @@
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import Button from './Button'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { WalletName, WalletReadyState } from '@solana/wallet-adapter-base'
|
||||
import { AUTO_CONNECT_WALLET, LAST_WALLET_NAME } from 'utils/constants'
|
||||
import { notify } from 'utils/notifications'
|
||||
import { LinkIcon } from '@heroicons/react/20/solid'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { useCallback } from 'react'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
const SecondaryConnectButton = ({
|
||||
className,
|
||||
isLarge,
|
||||
}: {
|
||||
className?: string
|
||||
isLarge?: boolean
|
||||
}) => {
|
||||
const { t } = useTranslation('common')
|
||||
const { wallets, select } = useWallet()
|
||||
const [lastWalletName] = useLocalStorageState<WalletName | null>(
|
||||
LAST_WALLET_NAME,
|
||||
'',
|
||||
)
|
||||
const [autoConnect] = useLocalStorageState(AUTO_CONNECT_WALLET, true)
|
||||
|
||||
const handleConnect = useCallback(() => {
|
||||
if (!autoConnect) {
|
||||
set((s) => {
|
||||
s.showUserSetup = true
|
||||
})
|
||||
} else if (lastWalletName) {
|
||||
select(lastWalletName)
|
||||
} else {
|
||||
const walletToConnect = wallets.find(
|
||||
(w) =>
|
||||
w.readyState === WalletReadyState.Installed ||
|
||||
w.readyState === WalletReadyState.Loadable,
|
||||
)
|
||||
if (walletToConnect) {
|
||||
select(walletToConnect.adapter.name)
|
||||
} else {
|
||||
notify({
|
||||
title: 'No wallet found. Install a Solana wallet and try again',
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [autoConnect, lastWalletName, select, wallets])
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={className}
|
||||
onClick={handleConnect}
|
||||
size={isLarge ? 'large' : 'medium'}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<LinkIcon className="mr-2 h-5 w-5" />
|
||||
{t('connect')}
|
||||
</div>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export default SecondaryConnectButton
|
|
@ -0,0 +1,72 @@
|
|||
import useSolBalance from 'hooks/useSolBalance'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { MIN_SOL_BALANCE } from 'utils/constants'
|
||||
import InlineNotification from './InlineNotification'
|
||||
|
||||
const SolBalanceWarnings = ({
|
||||
amount,
|
||||
className,
|
||||
setAmount,
|
||||
selectedToken,
|
||||
}: {
|
||||
amount?: string
|
||||
className?: string
|
||||
setAmount?: (a: string) => void
|
||||
selectedToken?: string
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const [showMaxSolWarning, setShowMaxSolWarning] = useState(false)
|
||||
const [showLowSolWarning, setShowLowSolWarning] = useState(false)
|
||||
const { maxSolDeposit } = useSolBalance()
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
selectedToken === 'SOL' &&
|
||||
maxSolDeposit > 0 &&
|
||||
maxSolDeposit <= Number(amount)
|
||||
) {
|
||||
setShowMaxSolWarning(true)
|
||||
if (setAmount) {
|
||||
setAmount(maxSolDeposit.toString())
|
||||
}
|
||||
}
|
||||
}, [maxSolDeposit, amount, selectedToken])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedToken !== 'SOL') {
|
||||
if (showMaxSolWarning) {
|
||||
setShowMaxSolWarning(false)
|
||||
}
|
||||
} else {
|
||||
if (showMaxSolWarning && maxSolDeposit > Number(amount)) {
|
||||
setShowMaxSolWarning(false)
|
||||
}
|
||||
}
|
||||
}, [amount, selectedToken, showMaxSolWarning])
|
||||
|
||||
useEffect(() => {
|
||||
if (maxSolDeposit <= 0) {
|
||||
setShowLowSolWarning(true)
|
||||
} else {
|
||||
if (showLowSolWarning) {
|
||||
setShowLowSolWarning(false)
|
||||
}
|
||||
}
|
||||
}, [maxSolDeposit])
|
||||
|
||||
return showLowSolWarning ? (
|
||||
<div className={className}>
|
||||
<InlineNotification type="warning" desc={t('deposit-more-sol')} />
|
||||
</div>
|
||||
) : showMaxSolWarning ? (
|
||||
<div className={className}>
|
||||
<InlineNotification
|
||||
type="info"
|
||||
desc={`Max SOL deposits are reduced to leave ${MIN_SOL_BALANCE} SOL in your wallet for sending transactions`}
|
||||
/>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
|
||||
export default SolBalanceWarnings
|
|
@ -0,0 +1,81 @@
|
|||
type Values = string | number
|
||||
|
||||
interface TabUnderlineProps<T extends Values> {
|
||||
activeValue: string
|
||||
onChange: (x: T) => void
|
||||
values: T[]
|
||||
names?: Array<string>
|
||||
small?: boolean
|
||||
fillWidth?: boolean
|
||||
}
|
||||
|
||||
const TabUnderline = <T extends Values>({
|
||||
activeValue,
|
||||
values,
|
||||
names,
|
||||
onChange,
|
||||
small,
|
||||
fillWidth = true,
|
||||
}: TabUnderlineProps<T>) => {
|
||||
return (
|
||||
<div
|
||||
className={`relative mb-3 border-b border-th-bkg-3 ${
|
||||
values.includes('buy' as T) || values.includes('sell' as T)
|
||||
? 'pb-1 font-display md:pb-2.5'
|
||||
: 'pb-1 font-bold'
|
||||
} md:-mt-2.5`}
|
||||
>
|
||||
<div
|
||||
className={`absolute bottom-[-1px] left-0 h-0.5 ${
|
||||
activeValue === 'buy'
|
||||
? 'bg-th-up'
|
||||
: activeValue === 'sell'
|
||||
? 'bg-th-down'
|
||||
: 'bg-th-active'
|
||||
}`}
|
||||
style={{
|
||||
maxWidth: !fillWidth ? '176px' : '',
|
||||
transform: `translateX(${
|
||||
values.findIndex((v) => v === activeValue) * 100
|
||||
}%)`,
|
||||
width: `${100 / values.length}%`,
|
||||
}}
|
||||
/>
|
||||
<nav className="-mb-px flex" aria-label="Tabs">
|
||||
{values.map((value, i) => (
|
||||
<button
|
||||
onClick={() => onChange(value)}
|
||||
className={`relative flex h-10 w-1/2 ${
|
||||
fillWidth ? '' : 'max-w-[176px]'
|
||||
}
|
||||
cursor-pointer items-center justify-center whitespace-nowrap rounded py-1 focus-visible:text-th-fgd-2 md:h-auto md:rounded-none md:hover:opacity-100 ${
|
||||
small ? 'text-sm' : 'text-sm lg:text-base'
|
||||
}
|
||||
${
|
||||
activeValue === value
|
||||
? activeValue === 'buy'
|
||||
? 'text-th-up'
|
||||
: activeValue === 'sell'
|
||||
? 'text-th-down'
|
||||
: 'text-th-active'
|
||||
: 'text-th-fgd-4 md:hover:text-th-fgd-3'
|
||||
}
|
||||
`}
|
||||
key={`${value}` + i}
|
||||
>
|
||||
<span className="relative">
|
||||
{names ? names[i] : value}
|
||||
{value === 'trade:trigger-order' ? (
|
||||
<span className="absolute -right-5 -top-3 ml-2 rounded bg-th-active px-1 py-0.5 text-xxs font-bold uppercase leading-none text-th-bkg-1">
|
||||
beta
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TabUnderline
|
|
@ -0,0 +1,29 @@
|
|||
// import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
||||
import { ReactNode } from 'react'
|
||||
import { formatTokenSymbol } from 'utils/tokens'
|
||||
|
||||
const TokenListButton = ({
|
||||
logo,
|
||||
token,
|
||||
setShowList,
|
||||
}: {
|
||||
logo: ReactNode
|
||||
token: string
|
||||
setShowList: (x: boolean) => void
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
// onClick={() => setShowList(true)}
|
||||
onClick={() => setShowList(false)}
|
||||
className="flex h-full w-full items-center rounded-lg rounded-r-none border border-r-0 border-th-input-border bg-th-input-bkg px-3 py-2 text-th-fgd-2 focus-visible:bg-th-bkg-2 md:hover:cursor-pointer md:hover:bg-th-bkg-2 md:hover:text-th-fgd-1"
|
||||
>
|
||||
<div className="mr-2.5 flex min-w-[24px] items-center">{logo}</div>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<div className="text-xl font-bold">{formatTokenSymbol(token)}</div>
|
||||
{/* <ChevronDownIcon className="h-6 w-6" /> */}
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default TokenListButton
|
|
@ -0,0 +1,46 @@
|
|||
import { Bank } from '@blockworks-foundation/mango-v4'
|
||||
import { QuestionMarkCircleIcon } from '@heroicons/react/20/solid'
|
||||
import useJupiterMints from 'hooks/useJupiterMints'
|
||||
import Image from 'next/image'
|
||||
import { useMemo } from 'react'
|
||||
import { CUSTOM_TOKEN_ICONS } from 'utils/constants'
|
||||
|
||||
const TokenLogo = ({
|
||||
bank,
|
||||
size,
|
||||
}: {
|
||||
bank: Bank | undefined
|
||||
size?: number
|
||||
}) => {
|
||||
const { mangoTokens } = useJupiterMints()
|
||||
|
||||
const logoUri = useMemo(() => {
|
||||
if (!bank) return ''
|
||||
const tokenSymbol = bank.name.toLowerCase()
|
||||
const hasCustomIcon = CUSTOM_TOKEN_ICONS[tokenSymbol]
|
||||
if (hasCustomIcon) return `/icons/${tokenSymbol}.svg`
|
||||
let jupiterLogoURI
|
||||
if (mangoTokens?.length) {
|
||||
jupiterLogoURI = mangoTokens.find(
|
||||
(t) => t.address === bank?.mint.toString(),
|
||||
)?.logoURI
|
||||
}
|
||||
return jupiterLogoURI
|
||||
}, [mangoTokens, bank])
|
||||
|
||||
const logoSize = size ? size : 24
|
||||
|
||||
return logoUri ? (
|
||||
<div
|
||||
className={`h-[${logoSize}px] w-[${logoSize}px] rounded-full bg-th-bkg-2`}
|
||||
>
|
||||
<Image alt="" width={logoSize} height={logoSize} src={logoUri} />
|
||||
</div>
|
||||
) : (
|
||||
<QuestionMarkCircleIcon
|
||||
className={`h-[${logoSize}px] w-[${logoSize}px] text-th-fgd-3`}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default TokenLogo
|
|
@ -0,0 +1,71 @@
|
|||
import React, { HTMLAttributes, ReactNode } from 'react'
|
||||
import Tippy, { TippyProps } from '@tippyjs/react'
|
||||
import 'tippy.js/animations/scale.css'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
|
||||
type TooltipProps = {
|
||||
content: ReactNode
|
||||
placement?: TippyProps['placement']
|
||||
className?: string
|
||||
children?: ReactNode
|
||||
delay?: number
|
||||
show?: boolean
|
||||
maxWidth?: string
|
||||
}
|
||||
|
||||
const Tooltip = ({
|
||||
children,
|
||||
content,
|
||||
className,
|
||||
placement = 'top',
|
||||
delay = 0,
|
||||
show = true,
|
||||
maxWidth = '20rem',
|
||||
}: TooltipProps) => {
|
||||
const themeData = mangoStore((s) => s.themeData)
|
||||
if (show) {
|
||||
return (
|
||||
<Tippy
|
||||
animation="scale"
|
||||
placement={placement}
|
||||
appendTo={() => document.body}
|
||||
maxWidth={maxWidth}
|
||||
interactive
|
||||
delay={[delay, 0]}
|
||||
content={
|
||||
content ? (
|
||||
<div
|
||||
className={`${themeData.fonts.body.variable} ${themeData.fonts.display.variable} ${themeData.fonts.mono.variable} font-sans font-sans rounded-md bg-th-bkg-2 p-3 font-body text-xs leading-4 text-th-fgd-3 outline-none focus:outline-none ${className}`}
|
||||
style={{ boxShadow: '0px 0px 8px 0px rgba(0,0,0,0.25)' }}
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
<div className="outline-none focus:outline-none">{children}</div>
|
||||
</Tippy>
|
||||
)
|
||||
} else {
|
||||
return <>{children}</>
|
||||
}
|
||||
}
|
||||
|
||||
const Content = ({
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
className?: string
|
||||
} & HTMLAttributes<HTMLDivElement>) => {
|
||||
return (
|
||||
<div
|
||||
className={`inline-block cursor-help border-b border-dashed border-th-fgd-3 border-opacity-20 hover:border-th-bkg-2 ${className}`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Tooltip.Content = Content
|
||||
|
||||
export default Tooltip
|
|
@ -0,0 +1,105 @@
|
|||
import { Transition } from '@headlessui/react'
|
||||
import { CSSProperties, ElementType, ReactNode } from 'react'
|
||||
|
||||
const transitionEnterStyle = 'transition-all ease-out duration-300'
|
||||
const transitionExitStyle = 'transition-all ease-in duration-300'
|
||||
|
||||
export const EnterRightExitLeft = ({
|
||||
children,
|
||||
className,
|
||||
show,
|
||||
style,
|
||||
}: {
|
||||
children: ReactNode
|
||||
className?: string
|
||||
show: boolean
|
||||
style?: CSSProperties
|
||||
}) => (
|
||||
<Transition
|
||||
appear={true}
|
||||
className={className}
|
||||
show={show}
|
||||
enter={transitionEnterStyle}
|
||||
enterFrom="translate-x-full"
|
||||
enterTo="translate-x-0"
|
||||
leave={transitionExitStyle}
|
||||
leaveFrom="translate-x-0"
|
||||
leaveTo="-translate-x-full"
|
||||
style={style}
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
)
|
||||
|
||||
export const EnterBottomExitBottom = ({
|
||||
children,
|
||||
className,
|
||||
show,
|
||||
}: {
|
||||
children: ReactNode
|
||||
className?: string
|
||||
show: boolean
|
||||
}) => (
|
||||
<Transition
|
||||
appear={true}
|
||||
className={`thin-scroll ${className}`}
|
||||
show={show}
|
||||
enter={transitionEnterStyle}
|
||||
enterFrom="max-h-0"
|
||||
enterTo="max-h-full"
|
||||
leave={transitionExitStyle}
|
||||
leaveFrom="max-h-full"
|
||||
leaveTo="max-h-0"
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
)
|
||||
|
||||
export const FadeInFadeOut = ({
|
||||
children,
|
||||
className,
|
||||
show,
|
||||
}: {
|
||||
children: ReactNode
|
||||
className?: string
|
||||
show: boolean
|
||||
}) => (
|
||||
<Transition
|
||||
appear={true}
|
||||
className={className}
|
||||
show={show}
|
||||
enter={transitionEnterStyle}
|
||||
enterFrom="opacity-0"
|
||||
enterTo="opacity-100"
|
||||
leave={transitionExitStyle}
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
)
|
||||
|
||||
export const FadeInList = ({
|
||||
as = 'div',
|
||||
children,
|
||||
index,
|
||||
}: {
|
||||
as?: ElementType
|
||||
children: ReactNode
|
||||
index: number
|
||||
}) => (
|
||||
<Transition
|
||||
appear={true}
|
||||
as={as}
|
||||
show={true}
|
||||
enter={transitionEnterStyle}
|
||||
enterFrom="opacity-0 border-0"
|
||||
enterTo="opacity-100"
|
||||
leave={transitionExitStyle}
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
style={{ transitionDelay: `${index * 25}ms` }}
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
)
|
|
@ -0,0 +1,27 @@
|
|||
import { useRef, useEffect } from 'react'
|
||||
|
||||
export default function useInterval(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
callback: (...args: any[]) => any,
|
||||
delay: number,
|
||||
) {
|
||||
const savedCallback = useRef<() => void>()
|
||||
|
||||
// Remember the latest callback.
|
||||
useEffect(() => {
|
||||
savedCallback.current = callback
|
||||
}, [callback])
|
||||
|
||||
// Set up the interval.
|
||||
useEffect(() => {
|
||||
function tick() {
|
||||
savedCallback.current && savedCallback.current()
|
||||
}
|
||||
if (delay !== null) {
|
||||
const id = setInterval(tick, delay)
|
||||
return () => {
|
||||
clearInterval(id)
|
||||
}
|
||||
}
|
||||
}, [delay])
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { ArrowLeftIcon } from '@heroicons/react/20/solid'
|
||||
|
||||
const BackButton = ({ onClick }: { onClick: (x: boolean) => void }) => {
|
||||
return (
|
||||
<button
|
||||
onClick={() => onClick(false)}
|
||||
className="absolute left-4 top-4 z-40 w-6 text-th-fgd-4 focus:outline-none focus-visible:text-th-active md:right-2 md:top-2 md:hover:text-th-active"
|
||||
>
|
||||
<ArrowLeftIcon className={`h-6 w-6`} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default BackButton
|
|
@ -0,0 +1,145 @@
|
|||
import React, { Fragment, useMemo } from 'react'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import WalletIcon from '@components/icons/WalletIcon'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { LAST_WALLET_NAME } from 'utils/constants'
|
||||
import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
||||
import { Popover, Transition } from '@headlessui/react'
|
||||
// import Loading from '@components/shared/Loading'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { WalletName, WalletReadyState } from '@solana/wallet-adapter-base'
|
||||
|
||||
export default function ConnectWalletButton({
|
||||
handleShowSetup,
|
||||
}: {
|
||||
handleShowSetup: () => void
|
||||
}) {
|
||||
const { t } = useTranslation('common')
|
||||
const { wallet, wallets, select, connected, connect } = useWallet()
|
||||
const isOnboarded = true
|
||||
const mangoAccountLoading = mangoStore((s) => s.mangoAccount.initialLoad)
|
||||
const [lastWalletName] = useLocalStorageState<WalletName | null>(
|
||||
LAST_WALLET_NAME,
|
||||
'',
|
||||
)
|
||||
|
||||
const detectedWallets = useMemo(() => {
|
||||
return wallets.filter(
|
||||
(w) =>
|
||||
w.readyState === WalletReadyState.Installed ||
|
||||
w.readyState === WalletReadyState.Loadable,
|
||||
)
|
||||
}, [wallets])
|
||||
|
||||
const walletIcon = useMemo(() => {
|
||||
const wallet = wallets.find((w) => w.adapter.name === lastWalletName)
|
||||
return wallet?.adapter.icon || wallets[0]?.adapter.icon
|
||||
}, [wallets, lastWalletName])
|
||||
|
||||
return (
|
||||
<>
|
||||
{isOnboarded && walletIcon ? (
|
||||
<div className="flex">
|
||||
<button
|
||||
onClick={() => {
|
||||
if (wallet) {
|
||||
connect()
|
||||
} else {
|
||||
select(lastWalletName)
|
||||
}
|
||||
}}
|
||||
className="relative flex h-16 rounded-full bg-th-bkg-3 py-2"
|
||||
>
|
||||
<div className="relative z-10 flex h-full items-center justify-center space-x-3 px-4">
|
||||
{connected && mangoAccountLoading ? (
|
||||
<div></div>
|
||||
) : (
|
||||
<div
|
||||
className={`flex h-[28px] w-[28px] items-center justify-center rounded-full ${
|
||||
wallet?.adapter.name === 'Solflare' ? 'bg-black' : ''
|
||||
}`}
|
||||
>
|
||||
<img
|
||||
src={walletIcon}
|
||||
className={`
|
||||
${
|
||||
wallet?.adapter.name === 'Solflare'
|
||||
? 'h-auto w-[20px]'
|
||||
: 'h-auto w-[28px]'
|
||||
}`}
|
||||
alt={`${wallet?.adapter.name} icon`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-left">
|
||||
<div className="mb-1.5 flex font-display text-sm leading-none text-th-fgd-1">
|
||||
{t('connect')}
|
||||
</div>
|
||||
|
||||
<div className="text-xxs font-normal leading-3 text-th-fgd-3">
|
||||
{lastWalletName}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<Popover>
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Popover.Button
|
||||
className={`flex h-16 w-10 items-center justify-center rounded-none border-l border-th-bkg-4 bg-th-bkg-3 text-th-fgd-3 hover:brightness-[1.1] focus:outline-none focus-visible:bg-th-bkg-4`}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
className={`h-6 w-6 flex-shrink-0 ${
|
||||
open ? 'rotate-180' : 'rotate-360'
|
||||
}`}
|
||||
/>
|
||||
</Popover.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-in duration-200"
|
||||
enterFrom="opacity-0 scale-75"
|
||||
enterTo="opacity-100 scale-100"
|
||||
leave="transition ease-out duration-200"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<Popover.Panel className="absolute right-0 top-16 z-20 w-48 rounded-md rounded-t-none bg-th-bkg-2 px-4 py-2.5 outline-none">
|
||||
{detectedWallets.map((wallet, index) => (
|
||||
<button
|
||||
className="flex w-full flex-row items-center justify-between rounded-none py-2 font-normal focus:outline-none focus-visible:text-th-active md:hover:cursor-pointer md:hover:text-th-active"
|
||||
onClick={() => {
|
||||
select(wallet.adapter.name)
|
||||
}}
|
||||
key={wallet.adapter.name + index}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<img
|
||||
src={wallet.adapter.icon}
|
||||
className="mr-2.5 h-5 w-5"
|
||||
alt={`${wallet.adapter.name} icon`}
|
||||
/>
|
||||
{wallet.adapter.name}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</Popover.Panel>
|
||||
</Transition>
|
||||
</>
|
||||
)}
|
||||
</Popover>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
className="relative h-16 rounded-none px-6 font-display text-base text-th-fgd-1"
|
||||
onClick={handleShowSetup}
|
||||
>
|
||||
<div className="relative z-10 flex items-center justify-center">
|
||||
<WalletIcon className="mr-2 h-5 w-5 flex-shrink-0" />
|
||||
{t('connect')}
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
import { Popover, Transition } from '@headlessui/react'
|
||||
import { ArrowRightOnRectangleIcon } from '@heroicons/react/20/solid'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { Fragment, useCallback, useEffect } from 'react'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { notify } from '../../utils/notifications'
|
||||
import ProfileImage from '../profile/ProfileImage'
|
||||
import { abbreviateAddress } from '../../utils/formatting'
|
||||
import { useViewport } from 'hooks/useViewport'
|
||||
import { TV_USER_ID_KEY } from 'utils/constants'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import Loading from '@components/shared/Loading'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
const actions = mangoStore.getState().actions
|
||||
|
||||
const ConnectedMenu = () => {
|
||||
const { t } = useTranslation('common')
|
||||
const { publicKey, disconnect, wallet } = useWallet()
|
||||
const { isDesktop } = useViewport()
|
||||
const [tvUserId, setTvUserId] = useLocalStorageState(TV_USER_ID_KEY, '')
|
||||
|
||||
// const profileDetails = mangoStore((s) => s.profile.details)
|
||||
const loadProfileDetails = mangoStore((s) => s.profile.loadDetails)
|
||||
const groupLoaded = mangoStore((s) => s.groupLoaded)
|
||||
const mangoAccountLoading = mangoStore((s) => s.mangoAccount.initialLoad)
|
||||
|
||||
const handleDisconnect = useCallback(() => {
|
||||
set((state) => {
|
||||
state.activityFeed.feed = []
|
||||
state.mangoAccount.current = undefined
|
||||
state.mangoAccounts = []
|
||||
state.mangoAccount.initialLoad = true
|
||||
state.mangoAccount.openOrders = {}
|
||||
state.mangoAccount.interestTotals = { data: [], loading: false }
|
||||
})
|
||||
disconnect()
|
||||
notify({
|
||||
type: 'info',
|
||||
title: t('wallet-disconnected'),
|
||||
})
|
||||
}, [t, disconnect])
|
||||
|
||||
useEffect(() => {
|
||||
if (publicKey && wallet && groupLoaded) {
|
||||
actions.connectMangoClientWithWallet(wallet)
|
||||
actions.fetchMangoAccounts(publicKey)
|
||||
// actions.fetchTourSettings(publicKey?.toString() as string)
|
||||
actions.fetchProfileDetails(publicKey.toString())
|
||||
actions.fetchWalletTokens(publicKey)
|
||||
if (!tvUserId) {
|
||||
setTvUserId(publicKey.toString())
|
||||
}
|
||||
}
|
||||
}, [publicKey, wallet, groupLoaded, tvUserId, setTvUserId])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popover>
|
||||
<div className="relative">
|
||||
<Popover.Button
|
||||
className={`default-transition h-16 rounded-full ${
|
||||
isDesktop ? 'w-48 px-4' : 'w-16'
|
||||
} hover:bg-th-bkg-2 focus:outline-none focus-visible:bg-th-bkg-3`}
|
||||
>
|
||||
<div
|
||||
className="flex items-center justify-center md:justify-start"
|
||||
id="account-step-one"
|
||||
>
|
||||
{!mangoAccountLoading ? (
|
||||
<ProfileImage
|
||||
imageSize="40"
|
||||
placeholderSize="24"
|
||||
isOwnerProfile
|
||||
/>
|
||||
) : (
|
||||
<Loading className="h-6 w-6" />
|
||||
)}
|
||||
{!loadProfileDetails && isDesktop ? (
|
||||
<div className="ml-2.5 overflow-hidden text-left">
|
||||
<p className="text-xs text-th-fgd-3">
|
||||
{wallet?.adapter.name}
|
||||
</p>
|
||||
<p className="truncate pr-2 text-sm font-bold text-th-fgd-1">
|
||||
{publicKey ? abbreviateAddress(publicKey) : ''}
|
||||
</p>
|
||||
{/* <p className="truncate pr-2 text-sm font-bold capitalize text-th-fgd-1">
|
||||
{profileDetails?.profile_name
|
||||
? profileDetails.profile_name
|
||||
: 'Profile Unavailabe'}
|
||||
</p> */}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</Popover.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-in duration-200"
|
||||
enterFrom="opacity-0 scale-75"
|
||||
enterTo="opacity-100 scale-100"
|
||||
leave="transition ease-out duration-200"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<Popover.Panel className="absolute right-0 top-[61px] z-20 mt-1 w-48 space-y-1.5 rounded-md rounded-t-none bg-th-bkg-2 px-4 py-2.5 focus:outline-none md:rounded-r-none">
|
||||
<button
|
||||
className="flex w-full flex-row items-center rounded-none py-0.5 font-normal focus:outline-none focus-visible:text-th-active md:hover:cursor-pointer md:hover:text-th-fgd-1"
|
||||
onClick={handleDisconnect}
|
||||
>
|
||||
<ArrowRightOnRectangleIcon className="h-4 w-4" />
|
||||
<div className="pl-2 text-left">
|
||||
<div className="pb-0.5">{t('disconnect')}</div>
|
||||
{publicKey ? (
|
||||
<div className="font-mono text-xs text-th-fgd-4">
|
||||
{abbreviateAddress(publicKey)}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</button>
|
||||
</Popover.Panel>
|
||||
</Transition>
|
||||
</div>
|
||||
</Popover>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConnectedMenu
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,31 @@
|
|||
import { useQuery } from '@tanstack/react-query'
|
||||
import { fetchHourlyVolume } from 'utils/account'
|
||||
import useMangoAccount from './useMangoAccount'
|
||||
|
||||
export default function useAccountHourlyVolumeStats() {
|
||||
const { mangoAccountAddress } = useMangoAccount()
|
||||
|
||||
const {
|
||||
data: hourlyVolumeData,
|
||||
isLoading: loadingHourlyVolumeData,
|
||||
isFetching: fetchingHourlyVolumeData,
|
||||
} = useQuery(
|
||||
['hourly-volume', mangoAccountAddress],
|
||||
() => fetchHourlyVolume(mangoAccountAddress),
|
||||
{
|
||||
cacheTime: 1000 * 60 * 10,
|
||||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!mangoAccountAddress,
|
||||
},
|
||||
)
|
||||
|
||||
const loadingHourlyVolume =
|
||||
fetchingHourlyVolumeData || loadingHourlyVolumeData
|
||||
|
||||
return {
|
||||
hourlyVolumeData,
|
||||
loadingHourlyVolume,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { useQuery } from '@tanstack/react-query'
|
||||
import { fetchAccountPerformance } from 'utils/account'
|
||||
import useMangoAccount from './useMangoAccount'
|
||||
import { useMemo } from 'react'
|
||||
import { PerformanceDataItem } from 'types'
|
||||
import { DAILY_MILLISECONDS } from 'utils/constants'
|
||||
|
||||
export default function useAccountPerformanceData() {
|
||||
const { mangoAccountAddress } = useMangoAccount()
|
||||
|
||||
const {
|
||||
data: performanceData,
|
||||
isLoading: loadingPerformanceData,
|
||||
isFetching: fetchingPerformanceData,
|
||||
} = useQuery(
|
||||
['performance', mangoAccountAddress],
|
||||
() => fetchAccountPerformance(mangoAccountAddress, 31),
|
||||
{
|
||||
cacheTime: 1000 * 60 * 10,
|
||||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!mangoAccountAddress,
|
||||
},
|
||||
)
|
||||
|
||||
const rollingDailyData: PerformanceDataItem[] | [] = useMemo(() => {
|
||||
if (!performanceData || !performanceData.length) return []
|
||||
const nowDate = new Date()
|
||||
return performanceData.filter((d) => {
|
||||
const dataTime = new Date(d.time).getTime()
|
||||
return dataTime >= nowDate.getTime() - DAILY_MILLISECONDS
|
||||
})
|
||||
}, [performanceData])
|
||||
|
||||
const performanceLoading = loadingPerformanceData || fetchingPerformanceData
|
||||
|
||||
return {
|
||||
performanceData,
|
||||
rollingDailyData,
|
||||
loadingPerformanceData,
|
||||
fetchingPerformanceData,
|
||||
performanceLoading,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { useQuery } from '@tanstack/react-query'
|
||||
import { MANGO_DATA_API_URL } from 'utils/constants'
|
||||
|
||||
const fetchAllHiddenMangoAccounts = async (): Promise<string[]> => {
|
||||
try {
|
||||
const hideResponse = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/private-accounts`,
|
||||
)
|
||||
const res = await hideResponse.json()
|
||||
return res?.private_accounts ?? []
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch private mango accounts', e)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export function useHiddenMangoAccounts() {
|
||||
const { data: hiddenAccounts, isLoading: loadingHiddenAccounts } = useQuery(
|
||||
['all-hidden-accounts'],
|
||||
() => fetchAllHiddenMangoAccounts(),
|
||||
{
|
||||
cacheTime: 1000 * 60 * 10,
|
||||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
hiddenAccounts,
|
||||
loadingHiddenAccounts,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import { Group } from '@blockworks-foundation/mango-v4'
|
||||
import { CLUSTER } from '@store/mangoStore'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import useMangoGroup from 'hooks/useMangoGroup'
|
||||
import { Token } from 'types/jupiter'
|
||||
import { JUPITER_API_DEVNET, JUPITER_API_MAINNET } from 'utils/constants'
|
||||
|
||||
const fetchJupiterTokens = async (group: Group) => {
|
||||
const url = CLUSTER === 'devnet' ? JUPITER_API_DEVNET : JUPITER_API_MAINNET
|
||||
const response = await fetch(url)
|
||||
const data: Token[] = await response.json()
|
||||
|
||||
const bankMints = Array.from(group.banksMapByName.values()).map((b) =>
|
||||
b[0].mint.toString(),
|
||||
)
|
||||
const mangoTokens = data.filter((t) => bankMints.includes(t.address))
|
||||
|
||||
return {
|
||||
mangoTokens,
|
||||
jupiterTokens: data,
|
||||
}
|
||||
}
|
||||
|
||||
const useJupiterMints = (): {
|
||||
mangoTokens: Token[]
|
||||
jupiterTokens: Token[]
|
||||
isFetching: boolean
|
||||
} => {
|
||||
const { group } = useMangoGroup()
|
||||
|
||||
const res = useQuery(
|
||||
['jupiter-mango-tokens'],
|
||||
() => fetchJupiterTokens(group!),
|
||||
{
|
||||
cacheTime: 1000 * 60 * 10,
|
||||
staleTime: 1000 * 60 * 10,
|
||||
retry: 3,
|
||||
enabled: !!group,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
mangoTokens: res?.data?.mangoTokens || [],
|
||||
jupiterTokens: res?.data?.jupiterTokens || [],
|
||||
isFetching: res?.isFetching || false,
|
||||
}
|
||||
}
|
||||
|
||||
export default useJupiterMints
|
|
@ -0,0 +1,92 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
useMemo,
|
||||
useState,
|
||||
useEffect,
|
||||
useCallback,
|
||||
SetStateAction,
|
||||
Dispatch,
|
||||
} from 'react'
|
||||
|
||||
interface LocalStorageListenersType {
|
||||
[key: string]: Array<Dispatch<SetStateAction<string>>>
|
||||
}
|
||||
|
||||
const localStorageListeners: LocalStorageListenersType = {}
|
||||
|
||||
function useLocalStorageStringState(
|
||||
key: string,
|
||||
defaultState: string,
|
||||
): [string | undefined, (newState: string) => void] {
|
||||
const state =
|
||||
typeof window !== 'undefined'
|
||||
? localStorage.getItem(key) || defaultState
|
||||
: defaultState || ''
|
||||
|
||||
const [, notify] = useState(key + '\n' + state)
|
||||
|
||||
useEffect(() => {
|
||||
if (!localStorageListeners[key]) {
|
||||
localStorageListeners[key] = []
|
||||
}
|
||||
localStorageListeners[key].push(notify)
|
||||
return () => {
|
||||
localStorageListeners[key] = localStorageListeners[key].filter(
|
||||
(listener) => listener !== notify,
|
||||
)
|
||||
if (localStorageListeners[key].length === 0) {
|
||||
delete localStorageListeners[key]
|
||||
}
|
||||
}
|
||||
}, [key])
|
||||
|
||||
const setState = useCallback<(newState: string | null) => void>(
|
||||
(newState) => {
|
||||
if (!localStorageListeners[key]) {
|
||||
localStorageListeners[key] = []
|
||||
}
|
||||
|
||||
if (newState === null) {
|
||||
localStorage.removeItem(key)
|
||||
} else {
|
||||
localStorage.setItem(key, newState)
|
||||
}
|
||||
localStorageListeners[key].forEach((listener) =>
|
||||
listener(key + '\n' + newState),
|
||||
)
|
||||
},
|
||||
[key],
|
||||
)
|
||||
|
||||
return [state, setState]
|
||||
}
|
||||
|
||||
export default function useLocalStorageState<T = any>(
|
||||
key: string,
|
||||
defaultState?: string | number | object | undefined | null | boolean,
|
||||
): [T, (newState: string | number | object | null | boolean) => void] {
|
||||
const [stringState, setStringState] = useLocalStorageStringState(
|
||||
key,
|
||||
JSON.stringify(defaultState),
|
||||
)
|
||||
|
||||
const setState = useCallback(
|
||||
(newState: string | number | object | null | boolean) => {
|
||||
setStringState(JSON.stringify(newState))
|
||||
},
|
||||
[setStringState],
|
||||
)
|
||||
|
||||
const state: T = useMemo(() => {
|
||||
if (stringState) {
|
||||
try {
|
||||
return JSON.parse(stringState)
|
||||
} catch (e) {
|
||||
console.log('Error parsing JSON from localStorage', e)
|
||||
return stringState
|
||||
}
|
||||
}
|
||||
}, [stringState])
|
||||
|
||||
return [state, setState]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
import { MangoAccount } from '@blockworks-foundation/mango-v4'
|
||||
import { PublicKey } from '@solana/web3.js'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
export default function useMangoAccount(): {
|
||||
mangoAccount: MangoAccount | undefined
|
||||
initialLoad: boolean
|
||||
mangoAccountPk: PublicKey | undefined
|
||||
mangoAccountAddress: string
|
||||
} {
|
||||
const mangoAccount = mangoStore((s) => s.mangoAccount.current)
|
||||
|
||||
const initialLoad = mangoStore((s) => s.mangoAccount.initialLoad)
|
||||
|
||||
const mangoAccountPk = useMemo(() => {
|
||||
return mangoAccount?.publicKey
|
||||
}, [mangoAccount?.publicKey])
|
||||
|
||||
const mangoAccountAddress = useMemo(() => {
|
||||
return mangoAccountPk?.toString() || ''
|
||||
}, [mangoAccountPk])
|
||||
|
||||
return {
|
||||
mangoAccount,
|
||||
initialLoad,
|
||||
mangoAccountAddress,
|
||||
mangoAccountPk,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
import mangoStore from '@store/mangoStore'
|
||||
import { useMemo } from 'react'
|
||||
import useMangoAccount from './useMangoAccount'
|
||||
import {
|
||||
PerpOo,
|
||||
PerpPosition,
|
||||
Serum3Orders,
|
||||
TokenPosition,
|
||||
} from '@blockworks-foundation/mango-v4'
|
||||
import { MAX_ACCOUNTS } from 'utils/constants'
|
||||
|
||||
export const getAvaialableAccountsColor = (used: number, total: number) => {
|
||||
const remaining = total - used
|
||||
return remaining >= 4
|
||||
? 'text-th-up'
|
||||
: remaining >= 2
|
||||
? 'text-th-warning'
|
||||
: 'text-th-down'
|
||||
}
|
||||
|
||||
const isAccountSlotFull = (slots: number, max: string) => {
|
||||
const numberMax = Number(max)
|
||||
return slots >= numberMax
|
||||
}
|
||||
|
||||
const getIsAccountSizeFull = () => {
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
if (!mangoAccount) return true
|
||||
return (
|
||||
isAccountSlotFull(
|
||||
mangoAccount.tokens.length,
|
||||
MAX_ACCOUNTS.tokenAccounts!,
|
||||
) &&
|
||||
isAccountSlotFull(
|
||||
mangoAccount.serum3.length,
|
||||
MAX_ACCOUNTS.spotOpenOrders!,
|
||||
) &&
|
||||
isAccountSlotFull(mangoAccount.perps.length, MAX_ACCOUNTS.perpAccounts!) &&
|
||||
isAccountSlotFull(
|
||||
mangoAccount.perpOpenOrders.length,
|
||||
MAX_ACCOUNTS.perpOpenOrders!,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export default function useMangoAccountAccounts() {
|
||||
const { mangoAccountAddress } = useMangoAccount()
|
||||
|
||||
const [usedTokens, usedSerum3, usedPerps, usedPerpOo] = useMemo(() => {
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
if (!mangoAccountAddress || !mangoAccount) return [[], [], [], []]
|
||||
const { tokens, serum3, perps, perpOpenOrders } = mangoAccount
|
||||
const usedTokens: TokenPosition[] = tokens.filter((t) => t.inUseCount)
|
||||
const usedSerum3: Serum3Orders[] = serum3.filter(
|
||||
(s) => s.marketIndex !== 65535,
|
||||
)
|
||||
const usedPerps: PerpPosition[] = perps.filter(
|
||||
(p) => p.marketIndex !== 65535,
|
||||
)
|
||||
const usedPerpOo: PerpOo[] = perpOpenOrders.filter(
|
||||
(p) => p.orderMarket !== 65535,
|
||||
)
|
||||
return [usedTokens, usedSerum3, usedPerps, usedPerpOo]
|
||||
}, [mangoAccountAddress])
|
||||
|
||||
const [totalTokens, totalSerum3, totalPerps, totalPerpOpenOrders] =
|
||||
useMemo(() => {
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
if (!mangoAccountAddress || !mangoAccount) return [[], [], [], []]
|
||||
const { tokens, serum3, perps, perpOpenOrders } = mangoAccount
|
||||
const totalTokens = tokens
|
||||
const totalSerum3 = serum3
|
||||
const totalPerps = perps
|
||||
const totalPerpOpenOrders = perpOpenOrders
|
||||
return [totalTokens, totalSerum3, totalPerps, totalPerpOpenOrders]
|
||||
}, [mangoAccountAddress])
|
||||
|
||||
// const [availableTokens, availableSerum3, availablePerps, availablePerpOo] =
|
||||
// useMemo(() => {
|
||||
// const [usedTokens, usedSerum3, usedPerps, usedPerpOo] =
|
||||
// getUsedMangoAccountAccounts(mangoAccountAddress)
|
||||
// const [totalTokens, totalSerum3, totalPerps, totalPerpOpenOrders] =
|
||||
// getTotalMangoAccountAccounts(mangoAccountAddress)
|
||||
// return [
|
||||
// `${usedTokens}/${totalTokens}`,
|
||||
// `${usedSerum3}/${totalSerum3}`,
|
||||
// `${usedPerps}/${totalPerps}`,
|
||||
// `${usedPerpOo}/${totalPerpOpenOrders}`,
|
||||
// ]
|
||||
// }, [mangoAccountAddress])
|
||||
|
||||
const isAccountFull = useMemo(() => {
|
||||
if (!mangoAccountAddress) return true
|
||||
return getIsAccountSizeFull()
|
||||
}, [mangoAccountAddress])
|
||||
|
||||
return {
|
||||
usedTokens,
|
||||
usedSerum3,
|
||||
usedPerps,
|
||||
usedPerpOo,
|
||||
totalTokens,
|
||||
totalSerum3,
|
||||
totalPerps,
|
||||
totalPerpOpenOrders,
|
||||
isAccountFull,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { Group } from '@blockworks-foundation/mango-v4'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
|
||||
export default function useMangoGroup(): {
|
||||
group: Group | undefined
|
||||
} {
|
||||
const group = mangoStore((s) => s.group)
|
||||
|
||||
return { group }
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import isNetworkSlow from 'utils/network'
|
||||
|
||||
export default function useNetworkSpeed() {
|
||||
const [slowNetwork, setSlowNetwork] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
setSlowNetwork(isNetworkSlow())
|
||||
}, [])
|
||||
|
||||
return slowNetwork
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
|
||||
const useOnlineStatus = () => {
|
||||
const [online, isOnline] = useState(navigator.onLine)
|
||||
|
||||
const setOnline = () => {
|
||||
isOnline(true)
|
||||
}
|
||||
const setOffline = () => {
|
||||
isOnline(false)
|
||||
}
|
||||
|
||||
// Register the event listeners
|
||||
useEffect(() => {
|
||||
window.addEventListener('offline', setOffline)
|
||||
window.addEventListener('online', setOnline)
|
||||
|
||||
// cleanup if we unmount
|
||||
return () => {
|
||||
window.removeEventListener('offline', setOffline)
|
||||
window.removeEventListener('online', setOnline)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return online
|
||||
}
|
||||
|
||||
export default useOnlineStatus
|
|
@ -0,0 +1,116 @@
|
|||
import { Serum3Market } from '@blockworks-foundation/mango-v4'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { useMemo } from 'react'
|
||||
import { floorToDecimal, getDecimalCount } from 'utils/numbers'
|
||||
import useJupiterMints from './useJupiterMints'
|
||||
import useMangoGroup from './useMangoGroup'
|
||||
import { CUSTOM_TOKEN_ICONS } from 'utils/constants'
|
||||
|
||||
export default function useSelectedMarket() {
|
||||
const { group } = useMangoGroup()
|
||||
const selectedMarket = mangoStore((s) => s.selectedMarket.current)
|
||||
const { mangoTokens } = useJupiterMints()
|
||||
|
||||
const marketAddress = useMemo(() => {
|
||||
return selectedMarket?.publicKey.toString()
|
||||
}, [selectedMarket])
|
||||
|
||||
const price: number = useMemo(() => {
|
||||
if (!group) return 0
|
||||
if (selectedMarket instanceof Serum3Market) {
|
||||
const baseBank = group.getFirstBankByTokenIndex(
|
||||
selectedMarket.baseTokenIndex,
|
||||
)
|
||||
const quoteBank = group.getFirstBankByTokenIndex(
|
||||
selectedMarket.quoteTokenIndex,
|
||||
)
|
||||
const market = group.getSerum3ExternalMarket(
|
||||
selectedMarket.serumMarketExternal,
|
||||
)
|
||||
|
||||
return floorToDecimal(
|
||||
baseBank.uiPrice / quoteBank.uiPrice,
|
||||
getDecimalCount(market.tickSize),
|
||||
).toNumber()
|
||||
} else if (selectedMarket) {
|
||||
return selectedMarket._uiPrice
|
||||
} else return 0
|
||||
}, [selectedMarket, group])
|
||||
|
||||
const serumOrPerpMarket = useMemo(() => {
|
||||
const group = mangoStore.getState().group
|
||||
if (!group || !selectedMarket) return
|
||||
|
||||
if (selectedMarket instanceof Serum3Market) {
|
||||
return group?.getSerum3ExternalMarket(selectedMarket.serumMarketExternal)
|
||||
} else {
|
||||
return selectedMarket
|
||||
}
|
||||
}, [selectedMarket])
|
||||
|
||||
const baseSymbol = useMemo(() => {
|
||||
return selectedMarket?.name.split(/-|\//)[0]
|
||||
}, [selectedMarket])
|
||||
|
||||
const baseLogoURI = useMemo(() => {
|
||||
if (!baseSymbol || !mangoTokens.length) return ''
|
||||
const lowerCaseBaseSymbol = baseSymbol.toLowerCase()
|
||||
const hasCustomIcon = CUSTOM_TOKEN_ICONS[lowerCaseBaseSymbol]
|
||||
if (hasCustomIcon) {
|
||||
return `/icons/${lowerCaseBaseSymbol}.svg`
|
||||
} else {
|
||||
const token =
|
||||
mangoTokens.find(
|
||||
(t) => t.symbol.toLowerCase() === lowerCaseBaseSymbol,
|
||||
) ||
|
||||
mangoTokens.find(
|
||||
(t) => t.symbol.toLowerCase()?.includes(lowerCaseBaseSymbol),
|
||||
)
|
||||
if (token) {
|
||||
return token.logoURI
|
||||
}
|
||||
}
|
||||
}, [baseSymbol, mangoTokens])
|
||||
|
||||
const quoteBank = useMemo(() => {
|
||||
const group = mangoStore.getState().group
|
||||
if (!group || !selectedMarket) return
|
||||
const tokenIdx =
|
||||
selectedMarket instanceof Serum3Market
|
||||
? selectedMarket.quoteTokenIndex
|
||||
: selectedMarket?.settleTokenIndex
|
||||
return group?.getFirstBankByTokenIndex(tokenIdx)
|
||||
}, [selectedMarket])
|
||||
|
||||
const quoteSymbol = useMemo(() => {
|
||||
return quoteBank?.name
|
||||
}, [quoteBank])
|
||||
|
||||
const quoteLogoURI = useMemo(() => {
|
||||
if (!quoteSymbol || !mangoTokens.length) return ''
|
||||
const lowerCaseQuoteSymbol = quoteSymbol.toLowerCase()
|
||||
const hasCustomIcon = CUSTOM_TOKEN_ICONS[lowerCaseQuoteSymbol]
|
||||
if (hasCustomIcon) {
|
||||
return `/icons/${lowerCaseQuoteSymbol}.svg`
|
||||
} else {
|
||||
const token = mangoTokens.find(
|
||||
(t) => t.symbol.toLowerCase() === lowerCaseQuoteSymbol,
|
||||
)
|
||||
if (token) {
|
||||
return token.logoURI
|
||||
}
|
||||
}
|
||||
}, [quoteSymbol, mangoTokens])
|
||||
|
||||
return {
|
||||
selectedMarket,
|
||||
selectedMarketAddress: marketAddress,
|
||||
price,
|
||||
serumOrPerpMarket,
|
||||
baseSymbol,
|
||||
quoteBank,
|
||||
quoteSymbol,
|
||||
baseLogoURI,
|
||||
quoteLogoURI,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import { TokenInstructions } from '@project-serum/serum'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import { useMemo } from 'react'
|
||||
import { MIN_SOL_BALANCE } from 'utils/constants'
|
||||
|
||||
export default function useSolBalance() {
|
||||
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
||||
const { connected } = useWallet()
|
||||
const solBalance: number = useMemo(() => {
|
||||
return connected
|
||||
? walletTokens.find((t) =>
|
||||
t.mint.equals(TokenInstructions.WRAPPED_SOL_MINT),
|
||||
)?.uiAmount || 0
|
||||
: 100
|
||||
}, [walletTokens])
|
||||
|
||||
const maxSolDeposit: number = useMemo(() => {
|
||||
return solBalance - MIN_SOL_BALANCE
|
||||
}, [solBalance])
|
||||
|
||||
return { solBalance, maxSolDeposit }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import mangoStore from '@store/mangoStore'
|
||||
import { useMemo } from 'react'
|
||||
import { breakpoints } from 'utils/theme'
|
||||
|
||||
export const useViewport = () => {
|
||||
const width = mangoStore((s) => s.window.width)
|
||||
const height = mangoStore((s) => s.window.height)
|
||||
|
||||
const [isMobile, isTablet, isDesktop] = useMemo(() => {
|
||||
if (!width) return [false, false, false]
|
||||
const mobile = width < breakpoints.sm
|
||||
const tablet = width >= breakpoints.sm && width < breakpoints.md
|
||||
const desktop = width >= breakpoints.md
|
||||
return [mobile, tablet, desktop]
|
||||
}, [width])
|
||||
|
||||
return { width, height, isMobile, isTablet, isDesktop }
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: ['en', 'es', 'ru', 'zh', 'zh_tw'],
|
||||
},
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
const { i18n } = require('./next-i18next.config')
|
||||
const webpack = require('webpack')
|
||||
const { withSentryConfig } = require('@sentry/nextjs')
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
i18n,
|
||||
experimental: {
|
||||
appDir: false,
|
||||
},
|
||||
images: {
|
||||
domains: ['raw.githubusercontent.com', 'arweave.net', 'www.dual.finance'],
|
||||
},
|
||||
reactStrictMode: true,
|
||||
//proxy for openserum api cors
|
||||
rewrites: async () => {
|
||||
return [
|
||||
{
|
||||
source: '/openSerumApi/:path*',
|
||||
destination: 'https://openserum.io/api/serum/:path*',
|
||||
},
|
||||
]
|
||||
},
|
||||
webpack: (config, opts) => {
|
||||
if (!opts.isServer) {
|
||||
// don't resolve 'fs' module on the client to prevent this error on build --> Error: Can't resolve 'fs'
|
||||
config.resolve.fallback = {
|
||||
fs: false,
|
||||
}
|
||||
}
|
||||
|
||||
config.plugins.push(
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
BUILD_ID: JSON.stringify(opts.buildId),
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
return config
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = withSentryConfig(
|
||||
nextConfig,
|
||||
{
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
|
||||
// Suppresses source map uploading logs during build
|
||||
silent: true,
|
||||
|
||||
org: 'mango',
|
||||
project: 'mango-v4-ui',
|
||||
},
|
||||
{
|
||||
// For all available options, see:
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
||||
|
||||
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
||||
widenClientFileUpload: true,
|
||||
|
||||
// Transpiles SDK to be compatible with IE11 (increases bundle size)
|
||||
transpileClientSDK: true,
|
||||
|
||||
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
|
||||
tunnelRoute: '/monitoring',
|
||||
|
||||
// Hides source maps from generated client bundles
|
||||
hideSourceMaps: true,
|
||||
|
||||
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
||||
disableLogger: true,
|
||||
},
|
||||
)
|
|
@ -0,0 +1,133 @@
|
|||
{
|
||||
"name": "mango-v4-ui",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"setup": "yarn install --network-concurrency 1 && npx yarn-deduplicate && yarn allow-scripts && yarn bigint-fix",
|
||||
"ci": "yarn install --frozen-lockfile --network-concurrency 1 --color=always && yarn allow-scripts && yarn bigint-fix",
|
||||
"ci-dupe-check": "npx yarn-deduplicate --list --fail",
|
||||
"bigint-fix": "cd node_modules/bigint-buffer && yarn rebuild && cd ../../",
|
||||
"dev": "rm -rf .next && next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"format": "prettier --check .",
|
||||
"lint": "next lint --quiet",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prepare": "husky install",
|
||||
"lint-all": "yarn typecheck && yarn lint && yarn format",
|
||||
"find:unused": "next-unused"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.x"
|
||||
},
|
||||
"next-unused": {
|
||||
"alias": {
|
||||
"@components": "components/",
|
||||
"@store": "store/"
|
||||
},
|
||||
"include": [
|
||||
"components",
|
||||
"hooks",
|
||||
"utils",
|
||||
"types"
|
||||
],
|
||||
"exclude": [],
|
||||
"entrypoints": []
|
||||
},
|
||||
"dependencies": {
|
||||
"@blockworks-foundation/mango-feeds": "0.1.7",
|
||||
"@blockworks-foundation/mango-v4": "^0.19.13",
|
||||
"@blockworks-foundation/mango-v4-settings": "0.2.6",
|
||||
"@headlessui/react": "1.6.6",
|
||||
"@heroicons/react": "2.0.10",
|
||||
"@metaplex-foundation/js": "0.19.4",
|
||||
"@project-serum/anchor": "0.25.0",
|
||||
"@pythnetwork/client": "2.15.0",
|
||||
"@sentry/nextjs": "7.58.0",
|
||||
"@solana/spl-governance": "0.3.27",
|
||||
"@solana/spl-token": "0.3.7",
|
||||
"@solana/wallet-adapter-base": "0.9.23",
|
||||
"@solana/wallet-adapter-react": "0.15.32",
|
||||
"@solana/wallet-adapter-wallets": "0.19.20",
|
||||
"@switchboard-xyz/solana.js": "2.5.4",
|
||||
"@tanstack/react-query": "4.10.1",
|
||||
"@tippyjs/react": "4.2.6",
|
||||
"@types/howler": "2.2.7",
|
||||
"@web3auth/sign-in-with-solana": "1.0.0",
|
||||
"big.js": "6.2.1",
|
||||
"dayjs": "1.11.9",
|
||||
"decimal.js": "10.4.0",
|
||||
"i18next": "23.2.11",
|
||||
"immer": "9.0.12",
|
||||
"lodash": "4.17.21",
|
||||
"next": "13.4.17",
|
||||
"next-i18next": "14.0.0",
|
||||
"next-themes": "0.2.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-flip-numbers": "3.0.5",
|
||||
"react-i18next": "13.0.2",
|
||||
"react-number-format": "4.9.2",
|
||||
"recharts": "2.5.0",
|
||||
"zustand": "4.1.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@project-serum/anchor": "0.25.0",
|
||||
"@project-serum/serum": "0.13.65",
|
||||
"@solana/web3.js": ">=1.78.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lavamoat/allow-scripts": "2.3.0",
|
||||
"@lavamoat/preinstall-always-fail": "^1.0.0",
|
||||
"@types/big.js": "6.1.6",
|
||||
"@types/js-cookie": "3.0.3",
|
||||
"@types/lodash": "4.14.185",
|
||||
"@types/node": "17.0.23",
|
||||
"@types/react": "18.0.3",
|
||||
"@types/react-dom": "18.0.0",
|
||||
"@types/react-grid-layout": "1.3.2",
|
||||
"@types/react-window": "1.8.5",
|
||||
"@types/recharts": "1.8.24",
|
||||
"@typescript-eslint/eslint-plugin": "5.43.0",
|
||||
"autoprefixer": "10.4.13",
|
||||
"eslint": "8.13.0",
|
||||
"eslint-config-next": "13.4.17",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-react": "7.29.4",
|
||||
"eslint-plugin-react-hooks": "4.4.0",
|
||||
"eslint-plugin-tailwindcss": "3.13.0",
|
||||
"husky": "8.0.1",
|
||||
"next-unused": "0.0.6",
|
||||
"postcss": "8.4.12",
|
||||
"prettier": "3.0.2",
|
||||
"prettier-plugin-tailwindcss": "0.5.3",
|
||||
"tailwindcss": "3.3.3",
|
||||
"typescript": "4.9.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"@coral-xyz/anchor": "^0.27.0",
|
||||
"eslint-config-next/eslint-import-resolver-typescript/tsconfig-paths/json5": "1.0.2"
|
||||
},
|
||||
"lavamoat": {
|
||||
"allowScripts": {
|
||||
"$root$": true,
|
||||
"@lavamoat/preinstall-always-fail": false,
|
||||
"@solana/wallet-adapter-wallets>@solana/wallet-adapter-torus>@toruslabs/solana-embed>@toruslabs/base-controllers>@toruslabs/broadcast-channel>@toruslabs/eccrypto": true,
|
||||
"@solana/wallet-adapter-wallets>@solana/wallet-adapter-torus>@toruslabs/solana-embed>@toruslabs/base-controllers>@toruslabs/broadcast-channel>@toruslabs/eccrypto>secp256k1": true,
|
||||
"@solana/wallet-adapter-wallets>@solana/wallet-adapter-torus>@toruslabs/solana-embed>@toruslabs/base-controllers>ethereumjs-util>ethereum-cryptography>secp256k1": true,
|
||||
"@solana/wallet-adapter-wallets>@solana/wallet-adapter-torus>@toruslabs/solana-embed>@toruslabs/openlogin-jrpc>@toruslabs/openlogin-utils>keccak": true,
|
||||
"@metaplex-foundation/js>@bundlr-network/client>arbundles>secp256k1": true,
|
||||
"@metaplex-foundation/js>@bundlr-network/client>arbundles>keccak": true,
|
||||
"@switchboard-xyz/solana.js>@switchboard-xyz/common>protobufjs": true,
|
||||
"@solana/web3.js>bigint-buffer": false,
|
||||
"@solana/web3.js>rpc-websockets>bufferutil": true,
|
||||
"@solana/web3.js>rpc-websockets>utf-8-validate": true,
|
||||
"@solflare-wallet/pfp>@solana/web3.js>secp256k1": true,
|
||||
"eslint-config-next>eslint-plugin-jsx-a11y>aria-query>@babel/runtime-corejs3>core-js-pure": false,
|
||||
"next-i18next>core-js": false,
|
||||
"react-tsparticles": true,
|
||||
"tsparticles>tsparticles-engine": true,
|
||||
"@sentry/nextjs>@sentry/webpack-plugin>@sentry/cli": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { RektIcon } from '@components/icons/RektIcon'
|
||||
|
||||
export async function getStaticProps({ locale }: { locale: string }) {
|
||||
return {
|
||||
props: {
|
||||
...(await serverSideTranslations(locale, [
|
||||
'common',
|
||||
'notifications',
|
||||
'profile',
|
||||
'search',
|
||||
'settings',
|
||||
])),
|
||||
// Will be passed to the page component as props
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default function Custom404() {
|
||||
const { t } = useTranslation('common')
|
||||
return (
|
||||
<div
|
||||
className="mx-auto flex max-w-xl flex-col items-center justify-center text-center"
|
||||
style={{ height: 'calc(100vh - 80px)' }}
|
||||
>
|
||||
<RektIcon className="mb-4 h-14 w-auto -rotate-6 transform text-th-down" />
|
||||
<h1 className="mt-1 text-3xl text-th-fgd-1 sm:text-4xl">
|
||||
404: {t('404-heading')}
|
||||
</h1>
|
||||
<p className="mt-2 text-lg">{t('404-description')}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue