Skip to content

Commit

Permalink
Feature/withdraw sol mang fix (solana-labs#787)
Browse files Browse the repository at this point in the history
* fix sol

* fix

* fix

* fix

* fix sol deposit to mngo account

* fix withdraw

* fix withdraw mango account
  • Loading branch information
abrzezinski94 authored Jun 24, 2022
1 parent 9a7164a commit b4180f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Strategies/components/WithdrawModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
BN,
makeCloseSpotOpenOrdersInstruction,
makeWithdrawInstruction,
makeWithdraw2Instruction,
MangoAccount,
PublicKey,
} from '@blockworks-foundation/mango-client'
Expand Down Expand Up @@ -182,10 +182,9 @@ const WithdrawModal = ({
initializeAccount({
account: wrappedSolAccount?.publicKey,
mint: WRAPPED_SOL_MINT,
owner: address,
owner: new PublicKey(form.withdrawAddress),
})
)
console.log('1234555')
} else {
//we find true receiver address if its wallet and we need to create ATA the ata address will be the receiver
const { currentAddress: receiverAddress, needToCreateAta } = await getATA(
Expand All @@ -204,7 +203,7 @@ const WithdrawModal = ({
TOKEN_PROGRAM_ID, // always TOKEN_PROGRAM_ID
mintPk, // mint
receiverAddress, // ata
address, // owner of token account
new PublicKey(form.withdrawAddress), // owner of token account
wallet!.publicKey! // fee payer
)
)
Expand Down Expand Up @@ -236,7 +235,7 @@ const WithdrawModal = ({
proposalInstructions.push(closeInstruction)
}

const instruction = makeWithdrawInstruction(
const instruction = makeWithdraw2Instruction(
market.client!.programId,
group.publicKey,
selectedMangoAccount.publicKey,
Expand Down
36 changes: 36 additions & 0 deletions components/instructions/programs/mango.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,42 @@ export const MANGO_INSTRUCTIONS = {
}
},
},
66: {
name: 'Mango v3: Withdraw',
accounts: [
{ name: 'Mango Group' },
{ name: 'Mango account' },
{ name: 'Owner' },
{ name: 'Mango cache' },
{ name: 'Root bank' },
{ name: 'Node bank' },
{ name: 'Token account' },
{ name: 'Receiver Address' },
],
getDataUI: async (
_connection: Connection,
data: Uint8Array,
_accounts: AccountMetaData[]
) => {
const args = MangoInstructionLayout.decode(Buffer.from(data), 0)
.Withdraw2
const mint = await tryGetTokenMint(_connection, _accounts[6].pubkey)
if (mint) {
return (
<>
Amount:{' '}
{getMintDecimalAmountFromNatural(
mint!.account!,
args.quantity
).toFormat()}{' '}
({args.quantity.toNumber()})
</>
)
} else {
return <>{displayAllArgs(args)}</>
}
},
},
4: {
name: 'Mango v3: Add Spot Market',
accounts: [
Expand Down

0 comments on commit b4180f7

Please sign in to comment.