Skip to content

Commit

Permalink
Deploy points page and pacFinance liquidity sourcing (#209)
Browse files Browse the repository at this point in the history
* save wip

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* amplified order stable version

Signed-off-by: belbazanas <[email protected]>

* delete unused files

Signed-off-by: belbazanas <[email protected]>

* remove unused comment

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* new dynamic amplified order form

Signed-off-by: belbazanas <[email protected]>

* remove log

Signed-off-by: belbazanas <[email protected]>

* stable amplified order

Signed-off-by: belbazanas <[email protected]>

* save edit amplified order wip

Signed-off-by: belbazanas <[email protected]>

* edit amplified order v1

Signed-off-by: belbazanas <[email protected]>

* add feedback fixes

Signed-off-by: belbazanas <[email protected]>

* remove logs

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* fix amplified order infinite approvals

Signed-off-by: belbazanas <[email protected]>

* save minvolume wip + remove logs

Signed-off-by: belbazanas <[email protected]>

* WIP

* save wip

Signed-off-by: belbazanas <[email protected]>

* remove unused separator

Signed-off-by: belbazanas <[email protected]>

* add feedbacks

Signed-off-by: belbazanas <[email protected]>

* update amplified tables after edit + feedbacks

Signed-off-by: belbazanas <[email protected]>

* close sheet after edit dialog

Signed-off-by: belbazanas <[email protected]>

* display errors in bottom
amplifed form

Signed-off-by: belbazanas <[email protected]>

* ui minor changes

Signed-off-by: belbazanas <[email protected]>

* update mangrove sdk+ add expiry date in tables and sheet

Signed-off-by: belbazanas <[email protected]>

* re-arrange the toast messages

Signed-off-by: belbazanas <[email protected]>

* Debug kandel

* fix errors

* fixes

* edit expiry date

Signed-off-by: belbazanas <[email protected]>

* replace retracted by cancelled

Signed-off-by: belbazanas <[email protected]>

* WIP dialog improvements

* check if atleast one offer is open

Signed-off-by: belbazanas <[email protected]>

* add chain id as a dependency to 'strategies' query

* fix maxPrice

* parameters values improvements

* bounty tooltip

* check if atleast one offer is open

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* unwrap eth v1 (#187)

Signed-off-by: belbazanas <[email protected]>

* optimize orbit image

* save wip

Signed-off-by: belbazanas <[email protected]>

* invalidate offers query

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* save wip

Signed-off-by: belbazanas <[email protected]>

* add status to strateiges list

Signed-off-by: belbazanas <[email protected]>

* update amplifyOrder documentation link (#195)

Signed-off-by: belbazanas <[email protected]>

* fix strategies list status

Signed-off-by: belbazanas <[email protected]>

* Plug Incentives api wip

* save update after refill progress

Signed-off-by: belbazanas <[email protected]>

* end points

* enable the menu

* fix build

* edit kandel strategy + re-open

Signed-off-by: belbazanas <[email protected]>

* Add community points and boosts informations into Page points

* remove re-fill row + fix build

Signed-off-by: belbazanas <[email protected]>

* Update form legend and reward display, fix information banner text, and redirect after successful edit

Signed-off-by: belbazanas <[email protected]>

* Refactor leaderboard table and use-table components

* Remove console.log statements and improve boost page

* Add pagination to leaderboard

* Points page: Tables loading improvements, separate user table from leaderboard table and add link to doc

* add total count of traders

* add kandel smart router in UI + fixes (#197)

* Update strategy type to smart in multiple files

Signed-off-by: belbazanas <[email protected]>

* update mangrove sdk and indexer,add strategy smart router hooks,  add new kandel type, update default values

Signed-off-by: belbazanas <[email protected]>

* update overall logics types for build

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

* fix strategies list value + minor text changesB (#198)

Signed-off-by: belbazanas <[email protected]>

* Fix/asana kandel fixes 1 (#199)

* fix strategies list value + minor text changesB

Signed-off-by: belbazanas <[email protected]>

* fix total inventory and update strategies row click redirection

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

* Fix/edit kandel strategy (#200)

* fix edit strategy hook + decimals in dialogs

Signed-off-by: belbazanas <[email protected]>

* remove logs

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

* add metadatas and change points banner text

* Refactor all strategies page to use no. of offers instead of no. of price points

* Fix spread calculation in orderbook.tsx to avoid negative values

* fix level if the user is level 5

* Remove unused code related to priceRatio (#202)

* Remove unused code related to priceRatio

Signed-off-by: belbazanas <[email protected]>

* redirect to edit strategy from strategy list

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

* remove the junk

* fix indexer sdk (#204)

* Fix/minor kandel fixes (#205)

* Update button labels in EditStrategyDialog and useForm

Signed-off-by: belbazanas <[email protected]>

* Update parameters table to display step size and locked bounty

Signed-off-by: belbazanas <[email protected]>

* Update history and parameters components

Signed-off-by: belbazanas <[email protected]>

* Update launch strategy button label to Publish

Signed-off-by: belbazanas <[email protected]>

* Add source icon for pacFinance

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

* Update close strategy dialog message (#206)

Signed-off-by: belbazanas <[email protected]>

* Fix bounty deposit validation (#207)

Signed-off-by: belbazanas <[email protected]>

* Fix/kandel closed strategies (#208)

* Update leaderboard table, change header from Return (%) to PnL (%). Update lockedBounty display in parameters table.

Signed-off-by: belbazanas <[email protected]>

* Remove AverageReturn component from PriceRange

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>

---------

Signed-off-by: belbazanas <[email protected]>
Co-authored-by: Johan le Roch <[email protected]>
Co-authored-by: Mangrove Automation Bot <[email protected]>
Co-authored-by: Maxence Raballand <[email protected]>
  • Loading branch information
4 people authored Mar 28, 2024
1 parent 79ed328 commit c99e7ab
Show file tree
Hide file tree
Showing 140 changed files with 5,661 additions and 1,123 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NEXT_PUBLIC_MARKETS='{"137":[["WMATIC","USDT"],["WETH","USDC"],["USDC","USDT"],[
NEXT_PUBLIC_MANGROVE_CONFIG='{"tokens":{"USDC.T/MGV":{"cashness":1100,"displayedAsPriceDecimals":4,"displayedDecimals":2},"USDT.T/MGV":{"cashness":1101,"displayedAsPriceDecimals":4,"displayedDecimals":2},"WETH.T/MGV":{"cashness":100,"displayedAsPriceDecimals":6,"displayedDecimals":4},"WMATIC.T/MGV":{"cashness":10,"displayedAsPriceDecimals":6,"displayedDecimals":4},"WBTC.T/AAVEv3":{"cashness":200,"displayedAsPriceDecimals":6,"displayedDecimals":4},"DAI.T/AAVEv3":{"cashness":1000,"displayedAsPriceDecimals":6,"displayedDecimals":4},"CRV.T/AAVEv3":{"cashness":50,"displayedAsPriceDecimals":6,"displayedDecimals":4}}}'
NEXT_PUBLIC_POSTHOG_KEY=
NEXT_PUBLIC_POSTHOG_HOST=https://eu.posthog.com
NEXT_PUBLIC_LEADERBOARD_API=
NEXT_PUBLIC_MANGROVE_DATA_API_HOST=
NEXT_PUBLIC_DOMAIN_ADDRESS=
NEXT_PUBLIC_REFERRAL_SERVER_URL=
NEXT_PUBLIC_BLAST_DATA_SERVICE=
Expand Down
2 changes: 1 addition & 1 deletion app/api/addresses/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function GET() {
if (mangroveConfig) {
configuration.updateConfiguration(mangroveConfig)
}
const allAddresses = configuration.addresses.getAllAddressesForAllNetworks();
const allAddresses = configuration.addresses.getAllAddressesForAllNetworks()

return Response.json(allAddresses)
}
6 changes: 6 additions & 0 deletions app/faucet/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from "react"

import { Navbar } from "@/components/navbar"
import { Metadata } from "next"

export const metadata: Metadata = {
title: "Faucet | Mangrove DEX",
description: "Faucet on Mangrove DEX",
}

export default function Layout({ children }: React.PropsWithChildren) {
return (
Expand Down
38 changes: 32 additions & 6 deletions app/points/_components/current-boost.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import InfoTooltip from "@/components/info-tooltip"
import { cn } from "@/utils"
import { getLevels } from "../constants"
import { formatNumber } from "../utils"
import BoxContainer from "./box-container"

type Props = {
className?: string
level?: number
volume?: number
type?: string
boost?: number
previousVolume?: number
}

function formatNFTName(name: string): string {
return name
.replace(/(?!^)([A-Z][a-z])/g, " $1") // Insert a space before each uppercase letter that is not at the start of the string and is not preceded by another uppercase letter
.trim() // Remove any leading or trailing spaces
}

export default function CurrentBoost({
className,
level = 0,
// level = 0,
boost = 1,
previousVolume = 0,
volume = 0,
type,
}: Props) {
const { nextIndex, currentIndex } = getLevels(volume)
const level = currentIndex
console.log("nextIndex", nextIndex, currentIndex)
return (
<BoxContainer className={cn(className)}>
<div className="flex space-x-4">
Expand Down Expand Up @@ -43,7 +56,7 @@ export default function CurrentBoost({
</div>
<div>
<div className="text-sm text-cloud-200">Current boost</div>
<div className="flex items-center">
<div className="flex items-center flex-wrap">
<span
className={cn("font-medium text-[32px]", {
"text-cloud-00": !boost,
Expand All @@ -57,11 +70,24 @@ export default function CurrentBoost({
!level ? "bg-cloud-300" : "text-primary-bush-green",
)}
>
Level {level}
Level {nextIndex}
</span>
{type?.includes("NFT") && (
<span
className={cn(
"ml-3 max-h-[24px] p-1.5 bg-green-bangladesh text-sm rounded-md flex items-center line-clamp-1",
)}
>
{formatNFTName(type)}
<InfoTooltip className="text-white">
You've received a {boost}x boost for holding the{" "}
{formatNFTName(type)}
</InfoTooltip>
</span>
)}
</div>
<div className="text-xs text-cloud-200 flex items-center pt-7">
previous volume {formatNumber(previousVolume)}
previous volume {formatNumber(volume)}
</div>
</div>
</div>
Expand Down
41 changes: 27 additions & 14 deletions app/points/_components/join-program-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import { Text } from "@/components/typography/text"
import { Title } from "@/components/typography/title"
import { Button } from "@/components/ui/button"
import Link from "next/link"
import { useUserRank } from "./leaderboard/use-leaderboard"

const BULLETS = [
"hold $100 equivalent in trading or liquidity provision",
"participation in testnet (hold a Mangrove NFT) or beta mainnet",
]
import { useUserPoints } from "./leaderboard/use-leaderboard"

export function JoinProgramBanner() {
const { data } = useUserRank()
const points = data?.[0]?.total_points ?? 0
const { data } = useUserPoints()
const points = data?.total_points ?? 0

if (Number(points) >= 100) return null

Expand All @@ -22,15 +17,33 @@ export function JoinProgramBanner() {
<div className="space-y-6 p-8 flex-1 flex flex-col justify-center">
<Title variant={"header1"}>Join MS1 Points Program!</Title>
<Title className="text-green-bangladesh" variant={"title3"}>
Become eligible by making the equivalent of $100 in trading volume
(market orders) or generated volume (limit orders).
Start trading now on Mangrove in order to accumulate boosts and
points. You can trade by using market orders, limit orders,
amplified orders and more to come.
</Title>

<span>
<Button variant={"tertiary"} size={"md"} className="px-5" asChild>
<Link href={"/trade"}>Trade now</Link>
<div className="space-x-2">
<span>
<Button variant={"tertiary"} size={"md"} className="px-5" asChild>
<Link href={"/trade"}>Trade now</Link>
</Button>
</span>
<Button
variant={"tertiary"}
size={"md"}
className="px-5 text-l"
asChild
>
<Link
className="text-white"
href={"https://docs.mangrove.exchange/general/points/"}
target="_blank"
rel="noopener noreferrer"
>
Learn more
</Link>
</Button>
</span>
</div>
</div>
<div className="h-auto w-1/2 relative rounded-lg overflow-hidden hidden xl:block">
<img
Expand Down
14 changes: 11 additions & 3 deletions app/points/_components/leaderboard/address.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import Link from "next/link"
import { useAccount } from "wagmi"

import { shortenAddress } from "@/utils/wallet"

export default function Address({ address }: { address: string }) {
const { address: userAddress } = useAccount()
const { chain } = useAccount()
const blockExplorerUrl = chain?.blockExplorers?.default.url
const shortenedAddress = shortenAddress(address)
return (
<div>
<Link
href={`${blockExplorerUrl}/address/${address}`}
target="_blank"
rel="noreferrer"
className="flex space-x-2 items-center underline"
>
{shortenedAddress}
{userAddress === address ? (
<span className="ml-2 text-white bg-green-bangladesh px-2 py-1 rounded-sm text-sm">
<span className="ml-2 text-white bg-green-bangladesh px-2 py-1 rounded-sm text-sm font-roboto">
you
</span>
) : undefined}
</div>
</Link>
)
}
26 changes: 0 additions & 26 deletions app/points/_components/leaderboard/schema.tsx

This file was deleted.

45 changes: 34 additions & 11 deletions app/points/_components/leaderboard/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react"

import { Title } from "@/components/typography/title"
import { DataTable } from "@/components/ui/data-table/data-table"
import { useLeaderboard, useUserRank } from "./use-leaderboard"
import { useLeaderboard, useUserPoints } from "./use-leaderboard"
import { useTable } from "./use-table"

export function Leaderboard() {
Expand All @@ -14,37 +14,60 @@ export function Leaderboard() {
const leaderboardQuery = useLeaderboard({
filters: {
skip: (page - 1) * pageSize,
first: pageSize,
},
})

const useUserRankQuery = useUserRank()
const currentuser = useUserRankQuery.data
const data = React.useMemo(
() => [...(currentuser ?? []), ...(leaderboardQuery.data ?? [])],
[useUserRankQuery.dataUpdatedAt, leaderboardQuery.dataUpdatedAt],
)
const userPointsQuery = useUserPoints()
const currentUser = userPointsQuery.data
const data = React.useMemo(() => {
if (leaderboardQuery.isLoading) return []
return leaderboardQuery.data?.leaderboard ?? []
}, [leaderboardQuery.dataUpdatedAt])

const userData = React.useMemo(() => {
if (userPointsQuery.isLoading) return []
return [userPointsQuery.data] ?? []
}, [userPointsQuery.dataUpdatedAt])

const userTable = useTable({
//@ts-ignore
data: userData,
})

const table = useTable({
data,
//@ts-ignore
data: data,
})

return (
<div className="mt-16 !text-white">
<Title variant={"title1"} className="mb-10">
<Title variant={"title1"} className="mb-5">
Your points
</Title>
<DataTable
skeletonRows={1}
table={userTable}
isError={!!userPointsQuery.error}
isLoading={userPointsQuery.isLoading}
tableRowClasses="text-white"
isRowHighlighted={(row) => row.account === currentUser?.account}
/>
<Title variant={"title1"} className="mt-10 mb-5">
Leaderboard
</Title>
<DataTable
skeletonRows={10}
table={table}
isError={!!leaderboardQuery.error}
isLoading={leaderboardQuery.isLoading}
pagination={{
onPageChange: setPageDetails,
page,
pageSize,
count: 1,
count: leaderboardQuery.data?.leaderboard_length ?? 0,
}}
tableRowClasses="text-white"
isRowHighlighted={(row) => row.account === currentuser?.[0]?.account}
/>
</div>
)
Expand Down
Loading

0 comments on commit c99e7ab

Please sign in to comment.