ts: Use sendAndConfirmTransaction instead of anchor's .rpc() (#432)
This allows us to configure a prioritization fee for these calls.
This commit is contained in:
parent
40696f40a1
commit
628feafcb0
|
@ -99,7 +99,7 @@ export class MangoClient {
|
||||||
/// Transactions
|
/// Transactions
|
||||||
private async sendAndConfirmTransaction(
|
private async sendAndConfirmTransaction(
|
||||||
ixs: TransactionInstruction[],
|
ixs: TransactionInstruction[],
|
||||||
alts: AddressLookupTableAccount[],
|
alts: AddressLookupTableAccount[] = [],
|
||||||
opts: any = {},
|
opts: any = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return await sendTransaction(
|
return await sendTransaction(
|
||||||
|
@ -122,14 +122,15 @@ export class MangoClient {
|
||||||
insuranceMintPk: PublicKey,
|
insuranceMintPk: PublicKey,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
|
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.groupCreate(groupNum, testing ? 1 : 0, version)
|
.groupCreate(groupNum, testing ? 1 : 0, version)
|
||||||
.accounts({
|
.accounts({
|
||||||
creator: adminPk,
|
creator: adminPk,
|
||||||
payer: adminPk,
|
payer: adminPk,
|
||||||
insuranceMint: insuranceMintPk,
|
insuranceMint: insuranceMintPk,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction([ix]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async groupEdit(
|
public async groupEdit(
|
||||||
|
@ -141,7 +142,7 @@ export class MangoClient {
|
||||||
version?: number,
|
version?: number,
|
||||||
depositLimitQuote?: BN,
|
depositLimitQuote?: BN,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.groupEdit(
|
.groupEdit(
|
||||||
admin ?? null,
|
admin ?? null,
|
||||||
fastListingAdmin ?? null,
|
fastListingAdmin ?? null,
|
||||||
|
@ -154,25 +155,33 @@ export class MangoClient {
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ixGateSet(
|
public async ixGateSet(
|
||||||
group: Group,
|
group: Group,
|
||||||
ixGateParams: IxGateParams,
|
ixGateParams: IxGateParams,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.ixGateSet(buildIxGate(ixGateParams))
|
.ixGateSet(buildIxGate(ixGateParams))
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async groupClose(group: Group): Promise<TransactionSignature> {
|
public async groupClose(group: Group): Promise<TransactionSignature> {
|
||||||
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
|
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.groupClose()
|
.groupClose()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -181,7 +190,11 @@ export class MangoClient {
|
||||||
solDestination: (this.program.provider as AnchorProvider).wallet
|
solDestination: (this.program.provider as AnchorProvider).wallet
|
||||||
.publicKey,
|
.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getGroup(groupPk: PublicKey): Promise<Group> {
|
public async getGroup(groupPk: PublicKey): Promise<Group> {
|
||||||
|
@ -267,7 +280,7 @@ export class MangoClient {
|
||||||
netBorrowLimitWindowSizeTs: number,
|
netBorrowLimitWindowSizeTs: number,
|
||||||
netBorrowLimitPerWindowQuote: number,
|
netBorrowLimitPerWindowQuote: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.tokenRegister(
|
.tokenRegister(
|
||||||
tokenIndex,
|
tokenIndex,
|
||||||
name,
|
name,
|
||||||
|
@ -292,7 +305,11 @@ export class MangoClient {
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
rent: SYSVAR_RENT_PUBKEY,
|
rent: SYSVAR_RENT_PUBKEY,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async tokenRegisterTrustless(
|
public async tokenRegisterTrustless(
|
||||||
|
@ -302,7 +319,7 @@ export class MangoClient {
|
||||||
tokenIndex: number,
|
tokenIndex: number,
|
||||||
name: string,
|
name: string,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.tokenRegisterTrustless(tokenIndex, name)
|
.tokenRegisterTrustless(tokenIndex, name)
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -313,7 +330,11 @@ export class MangoClient {
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
rent: SYSVAR_RENT_PUBKEY,
|
rent: SYSVAR_RENT_PUBKEY,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async tokenEdit(
|
public async tokenEdit(
|
||||||
|
@ -324,7 +345,7 @@ export class MangoClient {
|
||||||
const bank = group.getFirstBankByMint(mintPk);
|
const bank = group.getFirstBankByMint(mintPk);
|
||||||
const mintInfo = group.mintInfosMapByTokenIndex.get(bank.tokenIndex)!;
|
const mintInfo = group.mintInfosMapByTokenIndex.get(bank.tokenIndex)!;
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.tokenEdit(
|
.tokenEdit(
|
||||||
params.oracle,
|
params.oracle,
|
||||||
params.oracleConfig,
|
params.oracleConfig,
|
||||||
|
@ -366,7 +387,11 @@ export class MangoClient {
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
} as AccountMeta,
|
} as AccountMeta,
|
||||||
])
|
])
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async tokenDeregister(
|
public async tokenDeregister(
|
||||||
|
@ -477,7 +502,7 @@ export class MangoClient {
|
||||||
mintPk: PublicKey,
|
mintPk: PublicKey,
|
||||||
price: number,
|
price: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.stubOracleCreate({ val: I80F48.fromNumber(price).getData() })
|
.stubOracleCreate({ val: I80F48.fromNumber(price).getData() })
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -485,14 +510,18 @@ export class MangoClient {
|
||||||
mint: mintPk,
|
mint: mintPk,
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stubOracleClose(
|
public async stubOracleClose(
|
||||||
group: Group,
|
group: Group,
|
||||||
oracle: PublicKey,
|
oracle: PublicKey,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.stubOracleClose()
|
.stubOracleClose()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -500,7 +529,11 @@ export class MangoClient {
|
||||||
solDestination: (this.program.provider as AnchorProvider).wallet
|
solDestination: (this.program.provider as AnchorProvider).wallet
|
||||||
.publicKey,
|
.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stubOracleSet(
|
public async stubOracleSet(
|
||||||
|
@ -508,14 +541,18 @@ export class MangoClient {
|
||||||
oraclePk: PublicKey,
|
oraclePk: PublicKey,
|
||||||
price: number,
|
price: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.stubOracleSet({ val: I80F48.fromNumber(price).getData() })
|
.stubOracleSet({ val: I80F48.fromNumber(price).getData() })
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
oracle: oraclePk,
|
oracle: oraclePk,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getStubOracle(
|
public async getStubOracle(
|
||||||
|
@ -636,7 +673,7 @@ export class MangoClient {
|
||||||
perpCount: number,
|
perpCount: number,
|
||||||
perpOoCount: number,
|
perpOoCount: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.accountExpand(tokenCount, serum3Count, perpCount, perpOoCount)
|
.accountExpand(tokenCount, serum3Count, perpCount, perpOoCount)
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -644,7 +681,11 @@ export class MangoClient {
|
||||||
owner: (this.program.provider as AnchorProvider).wallet.publicKey,
|
owner: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async editMangoAccount(
|
public async editMangoAccount(
|
||||||
|
@ -673,14 +714,18 @@ export class MangoClient {
|
||||||
mangoAccount: MangoAccount,
|
mangoAccount: MangoAccount,
|
||||||
freeze: boolean,
|
freeze: boolean,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.accountToggleFreeze(freeze)
|
.accountToggleFreeze(freeze)
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
account: mangoAccount.publicKey,
|
account: mangoAccount.publicKey,
|
||||||
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMangoAccount(
|
public async getMangoAccount(
|
||||||
|
@ -1145,7 +1190,7 @@ export class MangoClient {
|
||||||
marketIndex: number,
|
marketIndex: number,
|
||||||
name: string,
|
name: string,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.serum3RegisterMarket(marketIndex, name)
|
.serum3RegisterMarket(marketIndex, name)
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -1156,7 +1201,11 @@ export class MangoClient {
|
||||||
quoteBank: quoteBank.publicKey,
|
quoteBank: quoteBank.publicKey,
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3deregisterMarket(
|
public async serum3deregisterMarket(
|
||||||
|
@ -1174,7 +1223,7 @@ export class MangoClient {
|
||||||
this.program.programId,
|
this.program.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.serum3DeregisterMarket()
|
.serum3DeregisterMarket()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -1183,7 +1232,11 @@ export class MangoClient {
|
||||||
solDestination: (this.program.provider as AnchorProvider).wallet
|
solDestination: (this.program.provider as AnchorProvider).wallet
|
||||||
.publicKey,
|
.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3GetMarkets(
|
public async serum3GetMarkets(
|
||||||
|
@ -1239,7 +1292,7 @@ export class MangoClient {
|
||||||
externalMarketPk.toBase58(),
|
externalMarketPk.toBase58(),
|
||||||
)!;
|
)!;
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.serum3CreateOpenOrders()
|
.serum3CreateOpenOrders()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -1250,7 +1303,11 @@ export class MangoClient {
|
||||||
owner: (this.program.provider as AnchorProvider).wallet.publicKey,
|
owner: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3CreateOpenOrdersIx(
|
public async serum3CreateOpenOrdersIx(
|
||||||
|
@ -1695,7 +1752,7 @@ export class MangoClient {
|
||||||
(this.program.account.eventQueue as any)._idlAccount,
|
(this.program.account.eventQueue as any)._idlAccount,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.perpCreateMarket(
|
.perpCreateMarket(
|
||||||
perpMarketIndex,
|
perpMarketIndex,
|
||||||
name,
|
name,
|
||||||
|
@ -1734,7 +1791,8 @@ export class MangoClient {
|
||||||
eventQueue: eventQueue.publicKey,
|
eventQueue: eventQueue.publicKey,
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
})
|
})
|
||||||
.preInstructions([
|
.instruction();
|
||||||
|
const preInstructions = [
|
||||||
// book sides
|
// book sides
|
||||||
SystemProgram.createAccount({
|
SystemProgram.createAccount({
|
||||||
programId: this.program.programId,
|
programId: this.program.programId,
|
||||||
|
@ -1743,8 +1801,7 @@ export class MangoClient {
|
||||||
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
||||||
bookSideSize,
|
bookSideSize,
|
||||||
),
|
),
|
||||||
fromPubkey: (this.program.provider as AnchorProvider).wallet
|
fromPubkey: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
.publicKey,
|
|
||||||
newAccountPubkey: bids.publicKey,
|
newAccountPubkey: bids.publicKey,
|
||||||
}),
|
}),
|
||||||
SystemProgram.createAccount({
|
SystemProgram.createAccount({
|
||||||
|
@ -1754,8 +1811,7 @@ export class MangoClient {
|
||||||
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
||||||
bookSideSize,
|
bookSideSize,
|
||||||
),
|
),
|
||||||
fromPubkey: (this.program.provider as AnchorProvider).wallet
|
fromPubkey: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
.publicKey,
|
|
||||||
newAccountPubkey: asks.publicKey,
|
newAccountPubkey: asks.publicKey,
|
||||||
}),
|
}),
|
||||||
// event queue
|
// event queue
|
||||||
|
@ -1766,13 +1822,17 @@ export class MangoClient {
|
||||||
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
await this.program.provider.connection.getMinimumBalanceForRentExemption(
|
||||||
eventQueueSize,
|
eventQueueSize,
|
||||||
),
|
),
|
||||||
fromPubkey: (this.program.provider as AnchorProvider).wallet
|
fromPubkey: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
.publicKey,
|
|
||||||
newAccountPubkey: eventQueue.publicKey,
|
newAccountPubkey: eventQueue.publicKey,
|
||||||
}),
|
}),
|
||||||
])
|
];
|
||||||
.signers([bids, asks, eventQueue])
|
return await this.sendAndConfirmTransaction(
|
||||||
.rpc();
|
[...preInstructions, ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
{
|
||||||
|
additionalSigners: [bids, asks, eventQueue],
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async perpEditMarket(
|
public async perpEditMarket(
|
||||||
|
@ -1782,7 +1842,7 @@ export class MangoClient {
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.perpEditMarket(
|
.perpEditMarket(
|
||||||
params.oracle,
|
params.oracle,
|
||||||
params.oracleConfig,
|
params.oracleConfig,
|
||||||
|
@ -1821,7 +1881,11 @@ export class MangoClient {
|
||||||
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
admin: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
perpMarket: perpMarket.publicKey,
|
perpMarket: perpMarket.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async perpCloseMarket(
|
public async perpCloseMarket(
|
||||||
|
@ -1830,7 +1894,7 @@ export class MangoClient {
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.perpCloseMarket()
|
.perpCloseMarket()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -1842,7 +1906,11 @@ export class MangoClient {
|
||||||
solDestination: (this.program.provider as AnchorProvider).wallet
|
solDestination: (this.program.provider as AnchorProvider).wallet
|
||||||
.publicKey,
|
.publicKey,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async perpGetMarkets(group: Group): Promise<PerpMarket[]> {
|
public async perpGetMarkets(group: Group): Promise<PerpMarket[]> {
|
||||||
|
@ -1916,7 +1984,7 @@ export class MangoClient {
|
||||||
perpMarketIndex: PerpMarketIndex,
|
perpMarketIndex: PerpMarketIndex,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.perpZeroOutForMarket()
|
.perpZeroOutForMarket()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -1924,7 +1992,11 @@ export class MangoClient {
|
||||||
perpMarket: perpMarket.publicKey,
|
perpMarket: perpMarket.publicKey,
|
||||||
admin: group.admin,
|
admin: group.admin,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// perpPlaceOrder ix returns an optional, custom order id,
|
// perpPlaceOrder ix returns an optional, custom order id,
|
||||||
|
@ -2289,7 +2361,7 @@ export class MangoClient {
|
||||||
limit: number,
|
limit: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex);
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.perpConsumeEvents(new BN(limit))
|
.perpConsumeEvents(new BN(limit))
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -2302,7 +2374,11 @@ export class MangoClient {
|
||||||
({ pubkey: pk, isWritable: true, isSigner: false } as AccountMeta),
|
({ pubkey: pk, isWritable: true, isSigner: false } as AccountMeta),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async perpConsumeAllEvents(
|
public async perpConsumeAllEvents(
|
||||||
|
@ -2515,7 +2591,7 @@ export class MangoClient {
|
||||||
const bank = group.getFirstBankByMint(mintPk);
|
const bank = group.getFirstBankByMint(mintPk);
|
||||||
const mintInfo = group.mintInfosMapByMint.get(mintPk.toString())!;
|
const mintInfo = group.mintInfosMapByMint.get(mintPk.toString())!;
|
||||||
|
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.tokenUpdateIndexAndRate()
|
.tokenUpdateIndexAndRate()
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -2530,7 +2606,11 @@ export class MangoClient {
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
} as AccountMeta,
|
} as AccountMeta,
|
||||||
])
|
])
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// liquidations
|
/// liquidations
|
||||||
|
@ -2612,7 +2692,7 @@ export class MangoClient {
|
||||||
index: number,
|
index: number,
|
||||||
pks: PublicKey[],
|
pks: PublicKey[],
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.program.methods
|
const ix = await this.program.methods
|
||||||
.altExtend(index, pks)
|
.altExtend(index, pks)
|
||||||
.accounts({
|
.accounts({
|
||||||
group: group.publicKey,
|
group: group.publicKey,
|
||||||
|
@ -2620,7 +2700,11 @@ export class MangoClient {
|
||||||
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
payer: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||||
addressLookupTable,
|
addressLookupTable,
|
||||||
})
|
})
|
||||||
.rpc();
|
.instruction();
|
||||||
|
return await this.sendAndConfirmTransaction(
|
||||||
|
[ix],
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async healthRegionBeginIx(
|
public async healthRegionBeginIx(
|
||||||
|
|
|
@ -29,6 +29,7 @@ async function main() {
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
{
|
{
|
||||||
idsSource: 'get-program-accounts',
|
idsSource: 'get-program-accounts',
|
||||||
|
prioritizationFee: 5,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ async function main() {
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
{
|
{
|
||||||
idsSource: 'get-program-accounts',
|
idsSource: 'get-program-accounts',
|
||||||
|
prioritizationFee: 5,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ async function main() {
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
{
|
{
|
||||||
idsSource: 'get-program-accounts',
|
idsSource: 'get-program-accounts',
|
||||||
|
prioritizationFee: 5,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
console.log(`User ${userWallet.publicKey.toBase58()}`);
|
console.log(`User ${userWallet.publicKey.toBase58()}`);
|
||||||
|
|
|
@ -31,6 +31,7 @@ async function main() {
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
{
|
{
|
||||||
idsSource: 'get-program-accounts',
|
idsSource: 'get-program-accounts',
|
||||||
|
prioritizationFee: 5,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
console.log(`User ${userWallet.publicKey.toBase58()}`);
|
console.log(`User ${userWallet.publicKey.toBase58()}`);
|
||||||
|
|
Loading…
Reference in New Issue