Skip to content

Commit

Permalink
plausible edit leverage
Browse files Browse the repository at this point in the history
  • Loading branch information
saml33 committed Aug 13, 2024
1 parent b597b2b commit 607dd50
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
24 changes: 23 additions & 1 deletion components/EditLeverageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { toUiDecimals } from '@blockworks-foundation/mango-v4'
import { simpleSwap } from 'utils/transactions'
import { JLP_BORROW_TOKEN, LST_BORROW_TOKEN } from 'utils/constants'
import { WRAPPED_SOL_MINT } from '@project-serum/serum/lib/token-instructions'
import { usePlausible } from 'next-plausible'

const set = mangoStore.getState().set

Expand Down Expand Up @@ -67,6 +68,7 @@ function EditLeverageForm({
const { t } = useTranslation(['common', 'account'])
const submitting = mangoStore((s) => s.submittingBoost)
const { ipAllowed } = useIpAddress()
const plausible = usePlausible()
const storedLeverage = mangoStore((s) => s.leverage)
const { usedTokens, totalTokens } = useMangoAccountAccounts()
const { jlpGroup, lstGroup } = useMangoGroup()
Expand Down Expand Up @@ -232,6 +234,7 @@ function EditLeverageForm({

if (!group || !stakeBank || !borrowBank || !publicKey || !mangoAccount)
return
plausible('EditLeverageStart')
console.log(mangoAccounts)
set((state) => {
state.submittingBoost = true
Expand Down Expand Up @@ -280,7 +283,14 @@ function EditLeverageForm({
set((state) => {
state.submittingBoost = false
})

plausible('EditLeverageSuccess', {
props: {
editLeverageDesc: `${publicKey.toString()} ${
stakeBank.name
} from ${current_leverage} to ${leverage}x`,
editLeverageWallet: publicKey.toString(),
},
})
await sleep(500)
if (!mangoAccount) {
await actions.fetchMangoAccounts(
Expand All @@ -299,6 +309,15 @@ function EditLeverageForm({
set((state) => {
state.submittingBoost = false
})
plausible('EditLeverageError', {
props: {
editLeverageDesc: `ERROR: ${publicKey.toString()} ${
stakeBank.name
} from ${current_leverage} to ${leverage}x ${e}`,
editLeverageWallet: publicKey.toString(),
editLeverageError: `${e}`,
},
})
if (!isMangoError(e)) return
notify({
title: 'Transaction failed',
Expand All @@ -316,6 +335,9 @@ function EditLeverageForm({
clientContext,
onSuccess,
changeInUSDC,
current_leverage,
leverage,
plausible,
])

const tokenDepositLimitLeft = stakeBank?.getRemainingDepositLimit()
Expand Down
2 changes: 1 addition & 1 deletion components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Layout = ({ children }: { children: ReactNode }) => {
onClick={() => {
plausible('HomeCtaClick', {
props: {
button: 'top bar',
homeCtaButton: 'top bar',
},
})
}}
Expand Down
6 changes: 3 additions & 3 deletions components/home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const HomePage = () => {
onClick={() => {
plausible('HomeCtaClick', {
props: {
button: 'hero panel',
homeCtaButton: 'hero panel',
},
})
}}
Expand Down Expand Up @@ -120,7 +120,7 @@ const HomePage = () => {
onClick={() => {
plausible('HomeCtaClick', {
props: {
button: 'get started',
homeCtaButton: 'get started',
},
})
}}
Expand Down Expand Up @@ -215,7 +215,7 @@ const HomePage = () => {
onClick={() => {
plausible('HomeCtaClick', {
props: {
button: 'top apy bottom panel',
homeCtaButton: 'top apy bottom panel',
},
})
}}
Expand Down

0 comments on commit 607dd50

Please sign in to comment.