updated devnet.env
This commit is contained in:
parent
b5ccdce2f5
commit
bf64c97511
|
@ -1,6 +1,6 @@
|
||||||
CLUSTER=devnet
|
CLUSTER=devnet
|
||||||
DEX_PROGRAM_ID=9MVDeYQnJmN2Dt7H44Z8cob4bET2ysdNu2uFJcatDJno
|
DEX_PROGRAM_ID=9MVDeYQnJmN2Dt7H44Z8cob4bET2ysdNu2uFJcatDJno
|
||||||
KEYPAIR=~/.config/solana/id.json
|
KEYPAIR=~/.config/solana/id.json
|
||||||
BTCUSD=D9CBrNncuERiTzQwUVkxCevrM6irHJybeU2NQXtgXRbq
|
BTCUSD=6pZpjgfwKJhQ93ZYNjbJFtWEaB8kZjErsiGAEXn9WNjn
|
||||||
BTC_WALLET=HLoPtihB8oETm1kkTpx17FEnXm7afQdS4hojTNvbg3Rg
|
BTC_WALLET=HLoPtihB8oETm1kkTpx17FEnXm7afQdS4hojTNvbg3Rg
|
||||||
USDC_WALLET=GBBtcVE7WA8qdrHyhWTZkYDaz71EVHsg7wVaca9iq9xs
|
USDC_WALLET=GBBtcVE7WA8qdrHyhWTZkYDaz71EVHsg7wVaca9iq9xs
|
||||||
|
|
119
src/index.ts
119
src/index.ts
|
@ -11,65 +11,66 @@ export { NUM_TOKENS } from './layout';
|
||||||
import IDS from "./ids.json";
|
import IDS from "./ids.json";
|
||||||
export { IDS }
|
export { IDS }
|
||||||
|
|
||||||
//
|
async function main() {
|
||||||
// async function main() {
|
const cluster = "devnet";
|
||||||
// const cluster = "devnet";
|
const client = new MangoClient();
|
||||||
// const client = new MangoClient();
|
const clusterIds = IDS[cluster]
|
||||||
// const clusterIds = IDS[cluster]
|
|
||||||
//
|
const connection = new Connection(IDS.cluster_urls[cluster], 'singleGossip')
|
||||||
// const connection = new Connection(IDS.cluster_urls[cluster], 'singleGossip')
|
const mangoGroupPk = new PublicKey(clusterIds.mango_groups.BTC_ETH_USDC.mango_group_pk);
|
||||||
// const mangoGroupPk = new PublicKey(clusterIds.mango_groups.BTC_ETH_USDC.mango_group_pk);
|
const mangoProgramId = new PublicKey(clusterIds.mango_program_id);
|
||||||
// const mangoProgramId = new PublicKey(clusterIds.mango_program_id);
|
|
||||||
//
|
const mangoGroup = await client.getMangoGroup(connection, mangoGroupPk);
|
||||||
// const mangoGroup = await client.getMangoGroup(connection, mangoGroupPk);
|
|
||||||
//
|
const keyPairPath = '/home/dd/.config/solana/id.json'
|
||||||
// const keyPairPath = '/home/dd/.config/solana/id.json'
|
const payer = new Account(JSON.parse(fs.readFileSync(keyPairPath, 'utf-8')))
|
||||||
// const payer = new Account(JSON.parse(fs.readFileSync(keyPairPath, 'utf-8')))
|
|
||||||
//
|
// TODO auto fetch
|
||||||
// // TODO auto fetch
|
const marginAccountPk = new PublicKey("DrKz21L9EqmykcEtiX3sY7ibHbVezgSY225upn3UA8Ju")
|
||||||
// const marginAccountPk = new PublicKey("58hhPAgRgk1BHM1UkvYnJfxpMcoyi3DSoKnkwxuFe47")
|
let marginAccount = await client.getMarginAccount(connection, marginAccountPk)
|
||||||
// let marginAccount = await client.getMarginAccount(connection, marginAccountPk)
|
|
||||||
//
|
console.log(marginAccount.toPrettyString(mangoGroup))
|
||||||
// console.log(marginAccount.toPrettyString(mangoGroup))
|
|
||||||
//
|
const marketIndex = 0 // index for BTC/USDC
|
||||||
// const marketIndex = 0 // index for BTC/USDC
|
const spotMarket = await Market.load(
|
||||||
// const spotMarket = await Market.load(
|
connection,
|
||||||
// connection,
|
mangoGroup.spotMarkets[marketIndex],
|
||||||
// mangoGroup.spotMarkets[marketIndex],
|
{skipPreflight: true, commitment: 'singleGossip'},
|
||||||
// {skipPreflight: true, commitment: 'singleGossip'},
|
mangoGroup.dexProgramId
|
||||||
// mangoGroup.dexProgramId
|
)
|
||||||
// )
|
|
||||||
//
|
// // margin short 0.1 BTC
|
||||||
// // margin short 0.1 BTC
|
// await client.placeOrder(
|
||||||
// await client.placeOrder(
|
// connection,
|
||||||
// connection,
|
// mangoProgramId,
|
||||||
// mangoProgramId,
|
// mangoGroup,
|
||||||
// mangoGroup,
|
// marginAccount,
|
||||||
// marginAccount,
|
// spotMarket,
|
||||||
// spotMarket,
|
// payer,
|
||||||
// payer,
|
// 'sell',
|
||||||
// 'sell',
|
// 30000,
|
||||||
// 30000,
|
// 0.1
|
||||||
// 0.1
|
// )
|
||||||
// )
|
//
|
||||||
//
|
// await spotMarket.matchOrders(connection, payer, 10)
|
||||||
// await spotMarket.matchOrders(connection, payer, 10)
|
//
|
||||||
//
|
await client.settleFunds(
|
||||||
// await client.settleFunds(
|
connection,
|
||||||
// connection,
|
mangoProgramId,
|
||||||
// mangoProgramId,
|
mangoGroup,
|
||||||
// mangoGroup,
|
marginAccount,
|
||||||
// marginAccount,
|
payer,
|
||||||
// payer,
|
spotMarket
|
||||||
// spotMarket
|
)
|
||||||
// )
|
//
|
||||||
//
|
// await client.settleBorrow(connection, mangoProgramId, mangoGroup, marginAccount, payer, mangoGroup.tokens[2], 5000)
|
||||||
// await client.settleBorrow(connection, mangoProgramId, mangoGroup, marginAccount, payer, mangoGroup.tokens[2], 5000)
|
// await client.settleBorrow(connection, mangoProgramId, mangoGroup, marginAccount, payer, mangoGroup.tokens[0], 1.0)
|
||||||
// await client.settleBorrow(connection, mangoProgramId, mangoGroup, marginAccount, payer, mangoGroup.tokens[0], 1.0)
|
|
||||||
//
|
marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey)
|
||||||
// marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey)
|
console.log(marginAccount.toPrettyString(mangoGroup))
|
||||||
// console.log(marginAccount.toPrettyString(mangoGroup))
|
}
|
||||||
// }
|
main()
|
||||||
|
|
||||||
//
|
//
|
||||||
// async function testAll() {
|
// async function testAll() {
|
||||||
// const cluster = "devnet"
|
// const cluster = "devnet"
|
||||||
|
|
Loading…
Reference in New Issue