Merge branch 'dev'
This commit is contained in:
commit
3a1f6f08ee
|
@ -114,7 +114,7 @@ export class Group {
|
||||||
public async reloadBanks(client: MangoClient, ids?: Id) {
|
public async reloadBanks(client: MangoClient, ids?: Id) {
|
||||||
let banks: Bank[];
|
let banks: Bank[];
|
||||||
|
|
||||||
if (ids) {
|
if (ids && ids.getBanks().length) {
|
||||||
banks = (
|
banks = (
|
||||||
await client.program.account.bank.fetchMultiple(ids.getBanks())
|
await client.program.account.bank.fetchMultiple(ids.getBanks())
|
||||||
).map((account, index) =>
|
).map((account, index) =>
|
||||||
|
@ -143,7 +143,7 @@ export class Group {
|
||||||
|
|
||||||
public async reloadMintInfos(client: MangoClient, ids?: Id) {
|
public async reloadMintInfos(client: MangoClient, ids?: Id) {
|
||||||
let mintInfos: MintInfo[];
|
let mintInfos: MintInfo[];
|
||||||
if (ids) {
|
if (ids && ids.getMintInfos().length) {
|
||||||
mintInfos = (
|
mintInfos = (
|
||||||
await client.program.account.mintInfo.fetchMultiple(ids.getMintInfos())
|
await client.program.account.mintInfo.fetchMultiple(ids.getMintInfos())
|
||||||
).map((account, index) =>
|
).map((account, index) =>
|
||||||
|
@ -212,7 +212,7 @@ export class Group {
|
||||||
|
|
||||||
public async reloadPerpMarkets(client: MangoClient, ids?: Id) {
|
public async reloadPerpMarkets(client: MangoClient, ids?: Id) {
|
||||||
let perpMarkets: PerpMarket[];
|
let perpMarkets: PerpMarket[];
|
||||||
if (ids) {
|
if (ids && ids.getPerpMarkets().length) {
|
||||||
perpMarkets = (
|
perpMarkets = (
|
||||||
await client.program.account.perpMarket.fetchMultiple(
|
await client.program.account.perpMarket.fetchMultiple(
|
||||||
ids.getPerpMarkets(),
|
ids.getPerpMarkets(),
|
||||||
|
|
|
@ -857,6 +857,45 @@ export class MangoClient {
|
||||||
mangoAccount.owner,
|
mangoAccount.owner,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const preInstructions: TransactionInstruction[] = [
|
||||||
|
// ensure withdraws don't fail with missing ATAs
|
||||||
|
await createAssociatedTokenAccountIdempotentInstruction(
|
||||||
|
mangoAccount.owner,
|
||||||
|
mangoAccount.owner,
|
||||||
|
bank.mint,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
let wrappedSolAccount: Keypair | undefined;
|
||||||
|
const postInstructions: TransactionInstruction[] = [];
|
||||||
|
const additionalSigners: Signer[] = [];
|
||||||
|
if (mintPk.equals(WRAPPED_SOL_MINT)) {
|
||||||
|
wrappedSolAccount = new Keypair();
|
||||||
|
const lamports = nativeAmount + 1e7;
|
||||||
|
preInstructions.push(
|
||||||
|
SystemProgram.createAccount({
|
||||||
|
fromPubkey: mangoAccount.owner,
|
||||||
|
newAccountPubkey: wrappedSolAccount.publicKey,
|
||||||
|
lamports,
|
||||||
|
space: 165,
|
||||||
|
programId: TOKEN_PROGRAM_ID,
|
||||||
|
}),
|
||||||
|
initializeAccount({
|
||||||
|
account: wrappedSolAccount.publicKey,
|
||||||
|
mint: WRAPPED_SOL_MINT,
|
||||||
|
owner: mangoAccount.owner,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
postInstructions.push(
|
||||||
|
closeAccount({
|
||||||
|
source: wrappedSolAccount.publicKey,
|
||||||
|
destination: mangoAccount.owner,
|
||||||
|
owner: mangoAccount.owner,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
additionalSigners.push(wrappedSolAccount);
|
||||||
|
}
|
||||||
|
|
||||||
const healthRemainingAccounts: PublicKey[] =
|
const healthRemainingAccounts: PublicKey[] =
|
||||||
this.buildHealthRemainingAccounts(
|
this.buildHealthRemainingAccounts(
|
||||||
AccountRetriever.Fixed,
|
AccountRetriever.Fixed,
|
||||||
|
@ -883,14 +922,9 @@ export class MangoClient {
|
||||||
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
|
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.preInstructions([
|
.preInstructions(preInstructions)
|
||||||
// ensure withdraws don't fail with missing ATAs
|
.postInstructions(postInstructions)
|
||||||
await createAssociatedTokenAccountIdempotentInstruction(
|
.signers(additionalSigners)
|
||||||
mangoAccount.owner,
|
|
||||||
mangoAccount.owner,
|
|
||||||
bank.mint,
|
|
||||||
),
|
|
||||||
])
|
|
||||||
.transaction();
|
.transaction();
|
||||||
// .rpc({ skipPreflight: true });
|
// .rpc({ skipPreflight: true });
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ const MAINNET_MINTS = new Map([
|
||||||
['BTC', '9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E'], // Wrapped Bitcoin (Sollet)
|
['BTC', '9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E'], // Wrapped Bitcoin (Sollet)
|
||||||
['ETH', '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs'], // Ether (Portal)
|
['ETH', '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs'], // Ether (Portal)
|
||||||
['soETH', '2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk'], // Wrapped Ethereum (Sollet)
|
['soETH', '2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk'], // Wrapped Ethereum (Sollet)
|
||||||
['SOL', 'So11111111111111111111111111111111111111112'],
|
['SOL', 'So11111111111111111111111111111111111111112'], // Wrapped SOL
|
||||||
['MSOL', 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'],
|
['MSOL', 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'],
|
||||||
['MNGO', 'MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac'],
|
['MNGO', 'MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac'],
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue