Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Increase decimals on vecake card #10932

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/web/src/views/CakeStaking/components/CakeRewardsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
color="success"
fontWeight={800}
value={yourShare}
decimals={2}
decimals={5}
/>
)}
{showYourSharePercentage && (
Expand All @@ -241,7 +241,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
unit="%)"
ml="4px"
value={yourSharePercentage}
decimals={2}
decimals={5}
/>
)}
</>
Expand Down Expand Up @@ -320,7 +320,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
{availableCakePoolCake > 0 && availableCakePoolCake <= 0.01 ? (
<Text bold textAlign="right">{`< 0.01 CAKE`}</Text>
) : (
<Balance unit=" CAKE" textAlign="right" bold value={availableCakePoolCake} decimals={2} />
<Balance unit=" CAKE" textAlign="right" bold value={availableCakePoolCake} decimals={5} />
)}
<Balance
ml="4px"
Expand All @@ -331,7 +331,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
prefix="(~ $"
unit=")"
value={availableCakePoolCakeUsdValue}
decimals={2}
decimals={5}
/>
</Box>
</Flex>
Expand All @@ -349,7 +349,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
{availableRevenueSharingCake > 0 && availableRevenueSharingCake <= 0.01 ? (
<Text bold textAlign="right">{`< 0.01 CAKE`}</Text>
) : (
<Balance unit=" CAKE" textAlign="right" bold value={availableRevenueSharingCake} decimals={2} />
<Balance unit=" CAKE" textAlign="right" bold value={availableRevenueSharingCake} decimals={5} />
)}
<Balance
ml="4px"
Expand All @@ -360,7 +360,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
prefix="(~ $"
unit=")"
value={availableRevenueSharingCakeUsdValue}
decimals={2}
decimals={5}
/>
</Box>
</Flex>
Expand All @@ -378,7 +378,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
{totalAvailableClaim > 0 && totalAvailableClaim <= 0.01 ? (
<Text bold textAlign="right">{`< 0.01 CAKE`}</Text>
) : (
<Balance unit=" CAKE" textAlign="right" bold value={totalAvailableClaim} decimals={2} />
<Balance unit=" CAKE" textAlign="right" bold value={totalAvailableClaim} decimals={5} />
)}
<Balance
ml="4px"
Expand All @@ -389,7 +389,7 @@ export const CakeRewardsCard = ({ onDismiss }) => {
prefix="(~ $"
unit=")"
value={totalAvailableClaimUsdValue}
decimals={2}
decimals={5}
/>
</Box>
</Flex>
Expand Down
21 changes: 11 additions & 10 deletions apps/web/src/views/CakeStaking/hooks/useRevenueSharingProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ export const useRevenueSharingProxy = (
) => {
const { account, chainId } = useAccountActiveChain()
const blockTimestamp = useInitialBlockTimestamp()
const currencyBlockTimestamp = useCurrentBlockTimestamp()
const currentBlockTimestamp = useCurrentBlockTimestamp()

const { data } = useQuery({
queryKey: ['/revenue-sharing-pool-for-cake', contract.address, contract.chain?.id, account],

queryFn: async () => {
if (!account) return undefined
try {
const now = Math.floor(blockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const lastTokenTimestamp = Math.floor(currencyBlockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const lastTokenDistributionTimestamp = Math.floor(currentBlockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const nextDistributionTimestamp = new BigNumber(lastTokenDistributionTimestamp)
.plus(ONE_WEEK_DEFAULT)
.toNumber()

const revenueCalls = [
{
Expand All @@ -56,25 +58,24 @@ export const useRevenueSharingProxy = (
const [revenueResult, claimResult] = await Promise.all([
client.multicall({
contracts: revenueCalls,
allowFailure: true,
allowFailure: false,
Copy link
Collaborator Author

@memoyil memoyil Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw error if call fails that can be retried

}),
contract.simulate.claim([account]),
])

const nextDistributionTimestamp = new BigNumber(lastTokenTimestamp).plus(ONE_WEEK_DEFAULT).toNumber()

return {
balanceOfAt: (revenueResult[0].result as any).toString(),
totalSupplyAt: (revenueResult[1].result as any).toString(),
balanceOfAt: (revenueResult[0] as any).toString(),
totalSupplyAt: (revenueResult[1] as any).toString(),
nextDistributionTimestamp,
lastTokenTimestamp,
lastTokenTimestamp: lastTokenDistributionTimestamp,
availableClaim: claimResult.result.toString(),
}
} catch (error) {
console.error('[ERROR] Fetching Revenue Sharing Pool', error)
return initialData
throw error
Copy link
Collaborator Author

@memoyil memoyil Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to retry if it fails

}
},
enabled: Boolean(blockTimestamp && account),
})

return data ?? initialData
Expand Down
19 changes: 10 additions & 9 deletions apps/web/src/views/Pools/hooks/useRevenueSharingPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useRevenueSharingPool = (): RevenueSharingPool => {
const contract = useRevenueSharingPoolContract({ chainId })
const contractAddress = getRevenueSharingPoolAddress(chainId)
const blockTimestamp = useInitialBlockTimestamp()
const currencyBlockTimestamp = useCurrentBlockTimestamp()
const currentBlockTimestamp = useCurrentBlockTimestamp()

const { data } = useQuery({
queryKey: ['/revenue-sharing-pool', account, chainId],
Expand All @@ -40,7 +40,10 @@ const useRevenueSharingPool = (): RevenueSharingPool => {
if (!account) return undefined
try {
const now = Math.floor(blockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const lastTokenTimestamp = Math.floor(currencyBlockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const lastTokenDistributionTimestamp = Math.floor(currentBlockTimestamp / ONE_WEEK_DEFAULT) * ONE_WEEK_DEFAULT
const nextDistributionTimestamp = new BigNumber(lastTokenDistributionTimestamp)
.plus(ONE_WEEK_DEFAULT)
.toNumber()

const revenueCalls = [
{
Expand All @@ -61,23 +64,21 @@ const useRevenueSharingPool = (): RevenueSharingPool => {
const [revenueResult, claimResult] = await Promise.all([
client.multicall({
contracts: revenueCalls,
allowFailure: true,
allowFailure: false,
}),
contract.simulate.claim([account]),
])

const nextDistributionTimestamp = new BigNumber(lastTokenTimestamp).plus(ONE_WEEK_DEFAULT).toNumber()

return {
balanceOfAt: (revenueResult[0].result as any).toString(),
totalSupplyAt: (revenueResult[1].result as any).toString(),
balanceOfAt: (revenueResult[0] as any).toString(),
totalSupplyAt: (revenueResult[1] as any).toString(),
nextDistributionTimestamp,
lastTokenTimestamp,
lastTokenTimestamp: lastTokenDistributionTimestamp,
availableClaim: claimResult.result.toString(),
}
} catch (error) {
console.error('[ERROR] Fetching Revenue Sharing Pool', error)
return initialData
throw error
}
},

Expand Down
Loading