Fix extraction of amount for token account and mm Procfile
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
cfcda705e6
commit
3fe008da8b
2
Procfile
2
Procfile
|
@ -1 +1 @@
|
|||
mm: node dist/cjs/src/scripts/mm/market-maker.js
|
||||
mm: node dist/cjs/scripts/mm/market-maker.js
|
|
@ -1,5 +1,5 @@
|
|||
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
|
||||
import { coder } from '@coral-xyz/anchor/dist/cjs/spl/token';
|
||||
import { getAccount } from '@solana/spl-token';
|
||||
import { Cluster, Connection, Keypair } from '@solana/web3.js';
|
||||
import * as dotenv from 'dotenv';
|
||||
import fs from 'fs';
|
||||
|
@ -75,15 +75,11 @@ async function main(): Promise<void> {
|
|||
for (const bank of await Array.from(banksMapUsingTokenIndex.values()).sort(
|
||||
(a, b) => a.tokenIndex - b.tokenIndex,
|
||||
)) {
|
||||
const vault = I80F48.fromNumber(
|
||||
coder()
|
||||
.accounts.decode(
|
||||
'token',
|
||||
(await client.program.provider.connection.getAccountInfo(bank.vault))!
|
||||
.data,
|
||||
)
|
||||
.amount.toNumber(),
|
||||
const account = await getAccount(
|
||||
client.program.provider.connection,
|
||||
bank.vault,
|
||||
);
|
||||
const vault = I80F48.fromNumber(Number(account.amount));
|
||||
|
||||
const error = vault.sub(
|
||||
(bank as any).indexedDepositsByMangoAccounts
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { BorshAccountsCoder } from '@coral-xyz/anchor';
|
||||
import { Market, Orderbook } from '@project-serum/serum';
|
||||
import { parsePriceData } from '@pythnetwork/client';
|
||||
import { TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
|
||||
import {
|
||||
AccountInfo,
|
||||
AddressLookupTableAccount,
|
||||
|
@ -414,8 +415,12 @@ export class Group {
|
|||
if (!vaultAi) {
|
||||
throw new Error(`Undefined vaultAi for ${vaultPks[i]}`!);
|
||||
}
|
||||
const vaultAmount = coder.decode('token', vaultAi.data).amount;
|
||||
return [vaultPks[i].toBase58(), vaultAmount];
|
||||
const vaultAmount = unpackAccount(
|
||||
vaultPks[i],
|
||||
vaultAi,
|
||||
TOKEN_PROGRAM_ID,
|
||||
).amount;
|
||||
return [vaultPks[i].toBase58(), new BN(Number(vaultAmount))];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue