Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2024-07-29 12:19:31 +02:00
parent 923f5abd28
commit 1e915ca0bb
15 changed files with 70 additions and 75 deletions

View File

@ -29,6 +29,7 @@
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-function-return-type": "warn"
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-unused-vars": "warn"
}
}

View File

@ -748,9 +748,8 @@ async function createAndPopulateAlt() {
client.program.provider as AnchorProvider,
[extendIx],
);
const sig = await client.program.provider.connection.sendTransaction(
extendTx,
);
const sig =
await client.program.provider.connection.sendTransaction(extendTx);
console.log(`https://explorer.solana.com/tx/${sig}`);
}

View File

@ -7,7 +7,10 @@ export const DEFAULT_VSR_ID = new web3.PublicKey(
);
export class VsrClient {
constructor(public program: Program<Idl>, public devnet?: boolean) {}
constructor(
public program: Program<Idl>,
public devnet?: boolean,
) {}
static async connect(
provider: Provider,

View File

@ -131,9 +131,8 @@ export const tryGetRegistrar = async (
client: VsrClient,
) => {
try {
const existingRegistrar = await client.program.account.registrar.fetch(
registrarPk,
);
const existingRegistrar =
await client.program.account.registrar.fetch(registrarPk);
return existingRegistrar as unknown as Registrar;
} catch (e) {
return null;

View File

@ -284,9 +284,8 @@ async function createAndPopulateAlt() {
client.program.provider as AnchorProvider,
[extendIx],
);
const sig = await client.program.provider.connection.sendTransaction(
extendTx,
);
const sig =
await client.program.provider.connection.sendTransaction(extendTx);
console.log(`https://explorer.solana.com/tx/${sig}`);
}

View File

@ -41,9 +41,8 @@ async function extendTable(
let addressesAlreadyIndexed: PublicKey[] = [];
for (const altAddr of altAddresses) {
const alt = await client.program.provider.connection.getAddressLookupTable(
altAddr,
);
const alt =
await client.program.provider.connection.getAddressLookupTable(altAddr);
if (alt.value?.state.addresses) {
addressesAlreadyIndexed = addressesAlreadyIndexed.concat(
alt.value?.state.addresses,
@ -106,9 +105,8 @@ async function extendTable(
if (DRY_RUN) {
continue;
}
const sig = await client.program.provider.connection.sendTransaction(
extendTx,
);
const sig =
await client.program.provider.connection.sendTransaction(extendTx);
console.log(`https://explorer.solana.com/tx/${sig}`);
}
}

View File

@ -55,9 +55,8 @@ interface OracleInterface {
(async function main(): Promise<never> {
const { group, client, connection, user, userProvider } = await setupMango();
const { sbOnDemandProgram, crossbarClient, queue } = await setupSwitchboard(
client,
);
const { sbOnDemandProgram, crossbarClient, queue } =
await setupSwitchboard(client);
// eslint-disable-next-line no-constant-condition
while (true) {

View File

@ -47,9 +47,8 @@ async function extendTable(
let addressesAlreadyIndexed: PublicKey[] = [];
for (const altAddr of altAddresses) {
const alt = await client.program.provider.connection.getAddressLookupTable(
altAddr,
);
const alt =
await client.program.provider.connection.getAddressLookupTable(altAddr);
if (alt.value?.state.addresses) {
addressesAlreadyIndexed = addressesAlreadyIndexed.concat(
alt.value?.state.addresses,
@ -112,9 +111,8 @@ async function extendTable(
if (DRY_RUN) {
continue;
}
const sig = await client.program.provider.connection.sendTransaction(
extendTx,
);
const sig =
await client.program.provider.connection.sendTransaction(extendTx);
console.log(`https://explorer.solana.com/tx/${sig}`);
}
}

View File

@ -38,9 +38,8 @@ async function main(): Promise<void> {
);
const oracles = oracles1.concat(oracles2);
const ais = await client.program.provider.connection.getMultipleAccountsInfo(
oracles,
);
const ais =
await client.program.provider.connection.getMultipleAccountsInfo(oracles);
const switcboardOracles: PublicKey[] = ais
.map((ai, i) => [isSwitchboardOracle(ai!), oracles[i]])

View File

@ -23,9 +23,10 @@ async function main(): Promise<void> {
);
const oraclePublicKeys = allOracles.map((item) => item[1] as PublicKey);
const ais = await client.program.provider.connection.getMultipleAccountsInfo(
oraclePublicKeys,
);
const ais =
await client.program.provider.connection.getMultipleAccountsInfo(
oraclePublicKeys,
);
const result = ais
.map((ai, idx) => {

View File

@ -17,7 +17,7 @@ import {
PerpPosition,
Serum3Orders,
} from './mangoAccount';
import { PerpMarket, PerpMarketIndex, PerpOrder, PerpOrderSide } from './perp';
import { PerpMarket, PerpMarketIndex, PerpOrderSide } from './perp';
import { MarketIndex, Serum3Market, Serum3Side } from './serum3';
// ░░░░
@ -1401,7 +1401,10 @@ export class HealthCache {
}
export class Prices {
constructor(public oracle: I80F48, public stable: I80F48) {}
constructor(
public oracle: I80F48,
public stable: I80F48,
) {}
public liab(healthType: HealthType | undefined): I80F48 {
if (
@ -1797,8 +1800,8 @@ export class PerpInfo {
healthType == HealthType.init
? settleToken.initScaledAssetWeight
: healthType == HealthType.liquidationEnd
? settleToken.initAssetWeight
: settleToken.maintLiabWeight
? settleToken.initAssetWeight
: settleToken.maintLiabWeight
)
.mul(unweighted)
.mul(settleToken.prices.asset(healthType));
@ -1807,8 +1810,8 @@ export class PerpInfo {
healthType == HealthType.init
? settleToken.initScaledLiabWeight
: healthType == HealthType.liquidationEnd
? settleToken.initLiabWeight
: settleToken.maintLiabWeight
? settleToken.initLiabWeight
: settleToken.maintLiabWeight
)
.mul(unweighted)
.mul(settleToken.prices.liab(healthType));

View File

@ -71,9 +71,8 @@ describe.only('Oracle', () => {
},
); // SOL
const groupAccount = await client.program.account.group.fetch(
MANGO_V4_MAIN_GROUP,
);
const groupAccount =
await client.program.account.group.fetch(MANGO_V4_MAIN_GROUP);
const GROUP = Group.from(MANGO_V4_MAIN_GROUP, groupAccount);
await GROUP.reloadBanks(client);
const fbs = await client.deriveFallbackOracleContexts(GROUP);
@ -89,9 +88,8 @@ describe.only('Oracle', () => {
{ fallbackOracleConfig: 'all' },
);
const groupAccount = await client.program.account.group.fetch(
MANGO_V4_MAIN_GROUP,
);
const groupAccount =
await client.program.account.group.fetch(MANGO_V4_MAIN_GROUP);
const GROUP = Group.from(MANGO_V4_MAIN_GROUP, groupAccount);
await GROUP.reloadBanks(client);
const fbs = await client.deriveFallbackOracleContexts(GROUP);
@ -107,9 +105,8 @@ describe.only('Oracle', () => {
{ fallbackOracleConfig: 'dynamic' },
);
const groupAccount = await client.program.account.group.fetch(
MANGO_V4_MAIN_GROUP,
);
const groupAccount =
await client.program.account.group.fetch(MANGO_V4_MAIN_GROUP);
const GROUP = Group.from(MANGO_V4_MAIN_GROUP, groupAccount);
await GROUP.reloadBanks(client);
const fbs = await client.deriveFallbackOracleContexts(GROUP);

View File

@ -675,8 +675,8 @@ export class BookSide {
return a.priceLots.eq(b.priceLots)
? a.seqNum.lt(b.seqNum) // if prices are equal prefer perp orders in the order they are placed
: type === BookSideType.bids // else compare the actual prices
? a.priceLots.gt(b.priceLots)
: b.priceLots.gt(a.priceLots);
? a.priceLots.gt(b.priceLots)
: b.priceLots.gt(a.priceLots);
}
const fGen = this.fixedItems();

View File

@ -637,7 +637,7 @@ export class MangoClient {
? true
: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
const ix = await this.program.methods
.tokenForceCloseBorrowsWithToken(
@ -758,9 +758,8 @@ export class MangoClient {
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
const dustVaultPk = await getAssociatedTokenAddress(bank.mint, adminPk);
const ai = await this.program.provider.connection.getAccountInfo(
dustVaultPk,
);
const ai =
await this.program.provider.connection.getAccountInfo(dustVaultPk);
const preInstructions: TransactionInstruction[] = [];
if (!ai) {
preInstructions.push(
@ -786,7 +785,7 @@ export class MangoClient {
.remainingAccounts(
[bank.publicKey, bank.vault].map(
(pk) =>
({ pubkey: pk, isWritable: true, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: true, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -1109,7 +1108,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -1608,7 +1607,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -1760,7 +1759,7 @@ export class MangoClient {
pubkey: pk,
isWritable: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
),
)
.instruction();
@ -2103,7 +2102,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -2251,7 +2250,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -2388,7 +2387,7 @@ export class MangoClient {
pubkey: pk,
isWritable: receiverBank.publicKey.equals(pk) ? true : false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
),
)
.instruction();
@ -2951,7 +2950,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3106,7 +3105,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3164,7 +3163,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3258,7 +3257,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3319,7 +3318,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3588,7 +3587,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3640,7 +3639,7 @@ export class MangoClient {
.remainingAccounts(
healthRemainingAccounts.map(
(pk) =>
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: false, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3674,7 +3673,7 @@ export class MangoClient {
.remainingAccounts(
accounts.map(
(pk) =>
({ pubkey: pk, isWritable: true, isSigner: false } as AccountMeta),
({ pubkey: pk, isWritable: true, isSigner: false }) as AccountMeta,
),
)
.instruction();
@ -3775,7 +3774,7 @@ export class MangoClient {
pubkey: pk,
isWritable: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
/*
@ -3978,7 +3977,7 @@ export class MangoClient {
? true
: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
const ix = await this.program.methods
@ -4972,7 +4971,7 @@ export class MangoClient {
? true
: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
return this.program.methods
@ -5047,7 +5046,7 @@ export class MangoClient {
pubkey: pk,
isWritable: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
return await this.program.methods
@ -5080,7 +5079,7 @@ export class MangoClient {
pubkey: pk,
isWritable: false,
isSigner: false,
} as AccountMeta),
}) as AccountMeta,
);
return await this.program.methods

View File

@ -238,8 +238,8 @@ const confirmTransaction = async (
stringifiedError
? stringifiedError
: individualError
? individualError
: 'Unknown error'
? individualError
: 'Unknown error'
}`,
});
}