Merge branch 'main' into dev

This commit is contained in:
microwavedcola1 2022-08-26 10:09:52 +02:00
commit 3e44dde696
2 changed files with 19 additions and 10 deletions

View File

@ -450,6 +450,7 @@ export class MangoAccount {
let res = 'MangoAccount'; let res = 'MangoAccount';
res = res + '\n pk: ' + this.publicKey.toString(); res = res + '\n pk: ' + this.publicKey.toString();
res = res + '\n name: ' + this.name; res = res + '\n name: ' + this.name;
res = res + '\n owner: ' + this.owner;
res = res + '\n delegate: ' + this.delegate; res = res + '\n delegate: ' + this.delegate;
res = res =

View File

@ -2,7 +2,6 @@ import { AnchorProvider, Wallet } from '@project-serum/anchor';
import { Connection, Keypair } from '@solana/web3.js'; import { Connection, Keypair } from '@solana/web3.js';
import fs from 'fs'; import fs from 'fs';
import { Group } from '../accounts/group'; import { Group } from '../accounts/group';
import { I80F48 } from '../accounts/I80F48';
import { HealthType, MangoAccount } from '../accounts/mangoAccount'; import { HealthType, MangoAccount } from '../accounts/mangoAccount';
import { MangoClient } from '../client'; import { MangoClient } from '../client';
import { MANGO_V4_ID } from '../constants'; import { MANGO_V4_ID } from '../constants';
@ -14,6 +13,7 @@ async function debugUser(
mangoAccount: MangoAccount, mangoAccount: MangoAccount,
) { ) {
console.log(mangoAccount.toString(group)); console.log(mangoAccount.toString(group));
await mangoAccount.reload(client, group); await mangoAccount.reload(client, group);
console.log( console.log(
@ -67,8 +67,6 @@ async function debugUser(
), ),
); );
console.log(group.banksMapByName.get('SOL')[0].mint.toBase58());
async function getMaxWithdrawWithBorrowForTokenUiWrapper(token) { async function getMaxWithdrawWithBorrowForTokenUiWrapper(token) {
console.log( console.log(
`mangoAccount.getMaxWithdrawWithBorrowForTokenUi(group, ${token}) ` + `mangoAccount.getMaxWithdrawWithBorrowForTokenUi(group, ${token}) ` +
@ -147,7 +145,6 @@ async function main() {
); );
const group = await client.getGroupForCreator(admin.publicKey, 2); const group = await client.getGroupForCreator(admin.publicKey, 2);
console.log(`${group.toString()}`);
for (const keypair of [ for (const keypair of [
process.env.MB_PAYER_KEYPAIR, process.env.MB_PAYER_KEYPAIR,
@ -159,18 +156,29 @@ async function main() {
); );
const userWallet = new Wallet(user); const userWallet = new Wallet(user);
console.log(`User ${userWallet.publicKey.toBase58()}`); console.log(`User ${userWallet.publicKey.toBase58()}`);
const mangoAccounts = await client.getMangoAccountsForOwner( const mangoAccounts = await client.getMangoAccountsForOwner(
group, group,
user.publicKey, user.publicKey,
); );
// const mangoAccounts = await Promise.all([
// await client.getMangoAccount({
// publicKey: new PublicKey(
// '6mqHfpJqnXcu6RgDYZSVW9CQXQPFyRYhgvdzvWXN9mPW',
// ),
// } as any),
// ]);
for (const mangoAccount of mangoAccounts) { for (const mangoAccount of mangoAccounts) {
console.log(`MangoAccount ${mangoAccount.publicKey}`); console.log(`MangoAccount ${mangoAccount.publicKey}`);
if ( // if (
'etVgrWPAQe3aUMiuZT32tEMnbtuD2yRxip6eEkSRrLV' === // 'etVgrWPAQe3aUMiuZT32tEMnbtuD2yRxip6eEkSRrLV' ===
// '2UWD1ZBiYdusXgXputE68MBL4Kz47nZptzMn6rLnzn1K' === // '2UWD1ZBiYdusXgXputE68MBL4Kz47nZptzMn6rLnzn1K' ===
// '9B8uwqH8FJqLn9kvGPVb5GEksLvmyXb3B8UKCFtRs5cq' === // '9B8uwqH8FJqLn9kvGPVb5GEksLvmyXb3B8UKCFtRs5cq' ===
mangoAccount.publicKey.toBase58() // mangoAccount.publicKey.toBase58()
) { // )
{
await debugUser(client, group, mangoAccount); await debugUser(client, group, mangoAccount);
} }
} }