Skip to content

Commit

Permalink
Claiming rewards decimal issue. (#120)
Browse files Browse the repository at this point in the history
* Claiming rewards decimal issue.

* Fix deps
  • Loading branch information
peiman3 authored Dec 20, 2024
1 parent 2d7fe85 commit cbdacd8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions liquidity/lib/useClaimAllRewards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@chakra-ui/react": "^2.8.2",
"@snx-v3/ContractError": "workspace:*",
"@snx-v3/constants": "workspace:*",
"@snx-v3/txnReducer": "workspace:*",
"@snx-v3/useBlockchain": "workspace:*",
"@snx-v3/useCollateralPriceUpdates": "workspace:*",
Expand Down
9 changes: 8 additions & 1 deletion liquidity/lib/useClaimAllRewards/useClaimAllRewards.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useToast } from '@chakra-ui/react';
import { D18 } from '@snx-v3/constants';
import { ContractError } from '@snx-v3/ContractError';
import { initialState, reducer } from '@snx-v3/txnReducer';
import { useNetwork, useProvider, useSigner } from '@snx-v3/useBlockchain';
Expand Down Expand Up @@ -67,11 +68,17 @@ export function useClaimAllRewards({ accountId }: { accountId?: string }) {
log('synthToken', synthToken);
log('claimableAmount', claimableAmount);
if (synthToken && claimableAmount && claimableAmount.gt(0)) {
const minAmountReceived = claimableAmount
.toBN()
.sub(claimableAmount.toBN().div(100))
.mul(ethers.utils.parseUnits('1', synthToken.token?.decimals))
.div(D18);

transactions.push(
SpotMarketProxyContract.populateTransaction.unwrap(
synthToken.synthMarketId,
claimableAmount.toBN(),
claimableAmount.toBN().sub(claimableAmount.toBN().div(100))
minAmountReceived
)
);
}
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5407,6 +5407,7 @@ __metadata:
dependencies:
"@chakra-ui/react": "npm:^2.8.2"
"@snx-v3/ContractError": "workspace:*"
"@snx-v3/constants": "workspace:*"
"@snx-v3/txnReducer": "workspace:*"
"@snx-v3/useBlockchain": "workspace:*"
"@snx-v3/useCollateralPriceUpdates": "workspace:*"
Expand Down

0 comments on commit cbdacd8

Please sign in to comment.