added more of the fee tier functions
This commit is contained in:
parent
0273db2c5b
commit
fa266a6e89
|
@ -1,7 +1,5 @@
|
||||||
CLUSTER=devnet
|
CLUSTER=devnet
|
||||||
DEX_PROGRAM_ID=7ZTHT7CnBrXiEmGAiTTdAzgu2RdRyP61Knwy2ifGhL1x
|
|
||||||
KEYPAIR=~/.config/solana/id.json
|
KEYPAIR=~/.config/solana/id.json
|
||||||
BTCUSD=6pZpjgfwKJhQ93ZYNjbJFtWEaB8kZjErsiGAEXn9WNjn
|
|
||||||
BTC_WALLET=HLoPtihB8oETm1kkTpx17FEnXm7afQdS4hojTNvbg3Rg
|
BTC_WALLET=HLoPtihB8oETm1kkTpx17FEnXm7afQdS4hojTNvbg3Rg
|
||||||
USDC_WALLET=GBBtcVE7WA8qdrHyhWTZkYDaz71EVHsg7wVaca9iq9xs
|
USDC_WALLET=GBBtcVE7WA8qdrHyhWTZkYDaz71EVHsg7wVaca9iq9xs
|
||||||
BTC=C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6
|
BTC=C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
zeroKey,
|
zeroKey,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { Market, OpenOrders, Orderbook } from '@project-serum/serum';
|
import { Market, OpenOrders, Orderbook } from '@project-serum/serum';
|
||||||
import { TOKEN_PROGRAM_ID } from '@project-serum/serum/lib/token-instructions';
|
import { SRM_DECIMALS, TOKEN_PROGRAM_ID } from '@project-serum/serum/lib/token-instructions';
|
||||||
import { Order } from '@project-serum/serum/lib/market';
|
import { Order } from '@project-serum/serum/lib/market';
|
||||||
import Wallet from '@project-serum/sol-wallet-adapter';
|
import Wallet from '@project-serum/sol-wallet-adapter';
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ export class MangoGroup {
|
||||||
totalBorrows!: number[];
|
totalBorrows!: number[];
|
||||||
maintCollRatio!: number;
|
maintCollRatio!: number;
|
||||||
initCollRatio!: number;
|
initCollRatio!: number;
|
||||||
|
srmVault!: PublicKey;
|
||||||
mintDecimals!: number[];
|
mintDecimals!: number[];
|
||||||
oracleDecimals!: number[];
|
oracleDecimals!: number[];
|
||||||
|
|
||||||
|
@ -421,8 +422,7 @@ export class MangoClient {
|
||||||
{ isSigner: false, isWritable: false, pubkey: TOKEN_PROGRAM_ID },
|
{ isSigner: false, isWritable: false, pubkey: TOKEN_PROGRAM_ID },
|
||||||
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
||||||
...marginAccount.openOrders.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
...marginAccount.openOrders.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
||||||
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey }))
|
||||||
...mangoGroup.tokens.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
|
||||||
]
|
]
|
||||||
const data = encodeMangoInstruction({Withdraw: {quantity: nativeQuantity}})
|
const data = encodeMangoInstruction({Withdraw: {quantity: nativeQuantity}})
|
||||||
|
|
||||||
|
@ -456,7 +456,6 @@ export class MangoClient {
|
||||||
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
||||||
...marginAccount.openOrders.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
...marginAccount.openOrders.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
||||||
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
||||||
...mangoGroup.tokens.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
|
||||||
]
|
]
|
||||||
const data = encodeMangoInstruction({Borrow: {tokenIndex: new BN(tokenIndex), quantity: nativeQuantity}})
|
const data = encodeMangoInstruction({Borrow: {tokenIndex: new BN(tokenIndex), quantity: nativeQuantity}})
|
||||||
|
|
||||||
|
@ -603,7 +602,6 @@ export class MangoClient {
|
||||||
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
...mangoGroup.oracles.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
||||||
...mangoGroup.vaults.map( (pubkey) => ( { isSigner: false, isWritable: true, pubkey })),
|
...mangoGroup.vaults.map( (pubkey) => ( { isSigner: false, isWritable: true, pubkey })),
|
||||||
...tokenAccs.map( (pubkey) => ( { isSigner: false, isWritable: true, pubkey })),
|
...tokenAccs.map( (pubkey) => ( { isSigner: false, isWritable: true, pubkey })),
|
||||||
...mangoGroup.tokens.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })),
|
|
||||||
]
|
]
|
||||||
const data = encodeMangoInstruction({Liquidate: {depositQuantities: depositsBN}})
|
const data = encodeMangoInstruction({Liquidate: {depositQuantities: depositsBN}})
|
||||||
|
|
||||||
|
@ -617,6 +615,38 @@ export class MangoClient {
|
||||||
return await this.sendTransaction(connection, transaction, liqor, additionalSigners)
|
return await this.sendTransaction(connection, transaction, liqor, additionalSigners)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async depositSrm(
|
||||||
|
connection: Connection,
|
||||||
|
programId: PublicKey,
|
||||||
|
mangoGroup: MangoGroup,
|
||||||
|
marginAccount: MarginAccount,
|
||||||
|
owner: Account,
|
||||||
|
srmAccount: PublicKey,
|
||||||
|
|
||||||
|
quantity: number
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const nativeQuantity = uiToNative(quantity, SRM_DECIMALS)
|
||||||
|
|
||||||
|
const keys = [
|
||||||
|
{ isSigner: false, isWritable: true, pubkey: mangoGroup.publicKey },
|
||||||
|
{ isSigner: false, isWritable: true, pubkey: marginAccount.publicKey },
|
||||||
|
{ isSigner: true, isWritable: false, pubkey: owner.publicKey },
|
||||||
|
{ isSigner: false, isWritable: true, pubkey: srmAccount },
|
||||||
|
{ isSigner: false, isWritable: true, pubkey: mangoGroup.srmVault },
|
||||||
|
{ isSigner: false, isWritable: false, pubkey: TOKEN_PROGRAM_ID },
|
||||||
|
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY }
|
||||||
|
]
|
||||||
|
const data = encodeMangoInstruction({DepositSrm: {quantity: nativeQuantity}})
|
||||||
|
|
||||||
|
const instruction = new TransactionInstruction( { keys, data, programId })
|
||||||
|
|
||||||
|
const transaction = new Transaction()
|
||||||
|
transaction.add(instruction)
|
||||||
|
const additionalSigners = []
|
||||||
|
|
||||||
|
return await this.sendTransaction(connection, transaction, owner, additionalSigners)
|
||||||
|
}
|
||||||
|
|
||||||
async placeOrder(
|
async placeOrder(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
programId: PublicKey,
|
programId: PublicKey,
|
||||||
|
|
22
src/ids.json
22
src/ids.json
|
@ -6,11 +6,11 @@
|
||||||
"testnet": "https://testnet.solana.com"
|
"testnet": "https://testnet.solana.com"
|
||||||
},
|
},
|
||||||
"devnet": {
|
"devnet": {
|
||||||
"dex_program_id": "7ZTHT7CnBrXiEmGAiTTdAzgu2RdRyP61Knwy2ifGhL1x",
|
"dex_program_id": "6XffKSLZRxmQcRinmb4K32AegYnmkoTm6TLR2Ezp9FBR",
|
||||||
"fee_symbol": "SRM",
|
"fee_symbol": "SRM",
|
||||||
"mango_groups": {
|
"mango_groups": {
|
||||||
"BTC_ETH_USDC": {
|
"BTC_ETH_USDC": {
|
||||||
"mango_group_pk": "Fc23A6NHH7uaAvVEpKAn4pgJ8FDs4LCSoNcRybPCKKfC",
|
"mango_group_pk": "8YGmg6rNc3bcZ7wDxu5CAhrSFCdJvzJUKjvmQcC7tjTr",
|
||||||
"mint_pks": [
|
"mint_pks": [
|
||||||
"C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
"C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
||||||
"8p968u9m7jZzKSsqxFDqki69MjqdFkwPM9FN4AN8hvHR",
|
"8p968u9m7jZzKSsqxFDqki69MjqdFkwPM9FN4AN8hvHR",
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
"DBiZZ6riT6QVoGVBMBnSsYFwkie1GAxWdac3NCpyrDR1"
|
"DBiZZ6riT6QVoGVBMBnSsYFwkie1GAxWdac3NCpyrDR1"
|
||||||
],
|
],
|
||||||
"spot_market_pks": [
|
"spot_market_pks": [
|
||||||
"FeLCvwGXvd6WYwAFTWaFrXH74uVzHLAtfwpSAU7jn3fu",
|
"DY6X83vWk5VdHQEtVxFdecmEsGXHyLskkeQeo8BHn75s",
|
||||||
"3SuA63cG46PDZCbS2FfS7mMESBQdJwWwhj1QeUAGjpBh"
|
"CQwr1dHHPeoUpzGcQHLtEYE1LdXkszxha8oG6Y7v5KWZ"
|
||||||
],
|
],
|
||||||
"symbols": {
|
"symbols": {
|
||||||
"BTC": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
"BTC": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
||||||
|
@ -30,9 +30,9 @@
|
||||||
"USDC": "Fq939Y5hycK62ZGwBjftLY2VyxqAQ8f1MxRqBMdAaBS7"
|
"USDC": "Fq939Y5hycK62ZGwBjftLY2VyxqAQ8f1MxRqBMdAaBS7"
|
||||||
},
|
},
|
||||||
"vault_pks": [
|
"vault_pks": [
|
||||||
"8WPAJohEVoytU2YkdzDeFyygR3274vU35i7o2XiUvYkT",
|
"FEg4ZjKMJFeKXLatYXpMCmQZGh8GAidy2yCqBVVKGQhA",
|
||||||
"2Sdwi6Q66bmva7e4XBTzuMBSJG6T7TWQKusZcYFmSGxV",
|
"FQTRzLbKpcX3mSGWASD2m2QfAhSDUx4eVYjb2bSFq9ry",
|
||||||
"DXX8Tg8b5KPAqJ9FBymMmTpJHyhtVJ6Zw8Ys2sCaKR5A"
|
"2bQtsdueSHcBmtsbq9NhjegVzXvwU8yLCKkkQXbarEbr"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -42,14 +42,14 @@
|
||||||
"ETH/USDC": "DBiZZ6riT6QVoGVBMBnSsYFwkie1GAxWdac3NCpyrDR1"
|
"ETH/USDC": "DBiZZ6riT6QVoGVBMBnSsYFwkie1GAxWdac3NCpyrDR1"
|
||||||
},
|
},
|
||||||
"spot_markets": {
|
"spot_markets": {
|
||||||
"BTC/USDC": "FeLCvwGXvd6WYwAFTWaFrXH74uVzHLAtfwpSAU7jn3fu",
|
"BTC/USDC": "DY6X83vWk5VdHQEtVxFdecmEsGXHyLskkeQeo8BHn75s",
|
||||||
"ETH/USDC": "3SuA63cG46PDZCbS2FfS7mMESBQdJwWwhj1QeUAGjpBh"
|
"ETH/USDC": "CQwr1dHHPeoUpzGcQHLtEYE1LdXkszxha8oG6Y7v5KWZ"
|
||||||
},
|
},
|
||||||
"symbols": {
|
"symbols": {
|
||||||
"BTC": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
"BTC": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
|
||||||
"ETH": "8p968u9m7jZzKSsqxFDqki69MjqdFkwPM9FN4AN8hvHR",
|
"ETH": "8p968u9m7jZzKSsqxFDqki69MjqdFkwPM9FN4AN8hvHR",
|
||||||
"MSRM": "ZbVY71sQNng1uFNvgimLfWXeWyasDvou9bEcqexzYaT",
|
"MSRM": "934bNdNw9QfE8dXD4mKQiKajYURfSkPhxfYZzpvmygca",
|
||||||
"SRM": "2i6G2zTaJNeuuJUjrFAvdP7xvquDZREubRUWNwB3xsKQ",
|
"SRM": "9FbAMDvXqNjPqZSYt4EWTguJuDrGkfvwr3gSFpiSbX9S",
|
||||||
"USDC": "Fq939Y5hycK62ZGwBjftLY2VyxqAQ8f1MxRqBMdAaBS7",
|
"USDC": "Fq939Y5hycK62ZGwBjftLY2VyxqAQ8f1MxRqBMdAaBS7",
|
||||||
"USDT": "7tSPGVhneTBWZjLGJGZb9V2UntC7T98cwtSLtgcXjeSs"
|
"USDT": "7tSPGVhneTBWZjLGJGZb9V2UntC7T98cwtSLtgcXjeSs"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue