Skip to content

Commit

Permalink
fix: update default prices for currencies and adjust balance check fo…
Browse files Browse the repository at this point in the history
…r token transfers
  • Loading branch information
yarre-uk committed Jan 28, 2025
1 parent f42201c commit 44bfac2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export const currencies = {
address: wSolMint,
decimals: 9,
tips: [0.01, 0.05, 0.1, 0.5],
defaultPrice: 0.003,
defaultPrice: 0.05,
},
usdcMint: {
address: usdcMint,
decimals: 6,
tips: [5, 10, 20, 100],
defaultPrice: 1,
defaultPrice: 10,
},
usdtMint: {
address: usdtMint,
decimals: 6,
tips: [5, 10, 20, 100],
defaultPrice: 1,
defaultPrice: 10,
},
};

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/contracts/write/use-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useSend = () => {

const tokenBalanceInfo = tokens?.find((token) => token.mint === currencies[tokenName].address.toString());

if (!tokenBalanceInfo || Number(tokenBalanceInfo.amount) < amount) {
if (!tokenBalanceInfo || Number(tokenBalanceInfo.amount) < amount * 1e6) {
throw new Error('Insufficient funds');
}

Expand Down Expand Up @@ -70,6 +70,8 @@ const useSend = () => {
const fee = await rawTx.getEstimatedFee(connection);
const solBalance = tokens?.find((token) => token.mint === wSolMint.toBase58())?.amount;

console.log(solBalance, fee);

if (fee && solBalance && Number(solBalance) < fee) {
throw new Error('Insufficient funds');
}
Expand Down

0 comments on commit 44bfac2

Please sign in to comment.