Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-06-03 09:33:40 +02:00
parent 1b4063cd0d
commit 804d4eed57
2 changed files with 1 additions and 19 deletions

View File

@ -36,7 +36,6 @@ import {
Serum3SelfTradeBehavior,
Serum3Side,
} from './accounts/serum3';
import { getTokenDecimals } from './constants/tokens';
import { IDL, MangoV4 } from './mango_v4';
import { MarginTradeWithdraw } from './types';
import {
@ -345,10 +344,8 @@ export class MangoClient {
const healthRemainingAccounts: PublicKey[] =
await this.buildHealthRemainingAccounts(group, mangoAccount, [bank]);
const tokenDecimals = getTokenDecimals(tokenName);
return await this.program.methods
.deposit(toNativeDecimals(amount, tokenDecimals))
.deposit(toNativeDecimals(amount, bank.mintDecimals))
.accounts({
group: group.publicKey,
account: mangoAccount.publicKey,

View File

@ -1,15 +0,0 @@
export const getTokenDecimals = (symbol: string) => {
const tokenMeta = tokens.find((t) => t.symbol === symbol);
if (!tokenMeta) throw new Error('TokenDecimalError: Token not found');
return tokenMeta.decimals;
};
const tokens = [
{ symbol: 'USDC', decimals: 6 },
{ symbol: 'SOL', decimals: 9 },
{ symbol: 'BTC', decimals: 6 },
];
export default tokens;