From 66558f28d7380a438171a3bcd6264f6367789ef5 Mon Sep 17 00:00:00 2001 From: dd Date: Sun, 7 Feb 2021 17:26:42 -0500 Subject: [PATCH] cleaned up index.ts --- src/index.ts | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1f77ead..2bf04e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,65 +11,65 @@ export { NUM_TOKENS } from './layout'; import IDS from "./ids.json"; export { IDS } -async function main() { - const cluster = "devnet"; - const client = new MangoClient(); - const clusterIds = IDS[cluster] - - const connection = new Connection(IDS.cluster_urls[cluster], 'singleGossip') - const mangoGroupPk = new PublicKey(clusterIds.mango_groups.BTC_ETH_USDC.mango_group_pk); - const mangoProgramId = new PublicKey(clusterIds.mango_program_id); - - const mangoGroup = await client.getMangoGroup(connection, mangoGroupPk); - - const keyPairPath = '/home/dd/.config/solana/id.json' - const payer = new Account(JSON.parse(fs.readFileSync(keyPairPath, 'utf-8'))) - - // TODO auto fetch - const marginAccountPk = new PublicKey("DrKz21L9EqmykcEtiX3sY7ibHbVezgSY225upn3UA8Ju") - let marginAccount = await client.getMarginAccount(connection, marginAccountPk) - - console.log(marginAccount.toPrettyString(mangoGroup)) - - const marketIndex = 0 // index for BTC/USDC - const spotMarket = await Market.load( - connection, - mangoGroup.spotMarkets[marketIndex], - {skipPreflight: true, commitment: 'singleGossip'}, - mangoGroup.dexProgramId - ) - - // // margin short 0.1 BTC - // await client.placeOrder( - // connection, - // mangoProgramId, - // mangoGroup, - // marginAccount, - // spotMarket, - // payer, - // 'sell', - // 30000, - // 0.1 - // ) - // - // await spotMarket.matchOrders(connection, payer, 10) - // - await client.settleFunds( - connection, - mangoProgramId, - mangoGroup, - marginAccount, - payer, - spotMarket - ) - // - // 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) - - marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey) - console.log(marginAccount.toPrettyString(mangoGroup)) -} -main() +// async function main() { +// const cluster = "devnet"; +// const client = new MangoClient(); +// const clusterIds = IDS[cluster] +// +// const connection = new Connection(IDS.cluster_urls[cluster], 'singleGossip') +// const mangoGroupPk = new PublicKey(clusterIds.mango_groups.BTC_ETH_USDC.mango_group_pk); +// const mangoProgramId = new PublicKey(clusterIds.mango_program_id); +// +// const mangoGroup = await client.getMangoGroup(connection, mangoGroupPk); +// +// const keyPairPath = '/home/dd/.config/solana/id.json' +// const payer = new Account(JSON.parse(fs.readFileSync(keyPairPath, 'utf-8'))) +// +// // TODO auto fetch +// const marginAccountPk = new PublicKey("DrKz21L9EqmykcEtiX3sY7ibHbVezgSY225upn3UA8Ju") +// let marginAccount = await client.getMarginAccount(connection, marginAccountPk) +// +// console.log(marginAccount.toPrettyString(mangoGroup)) +// +// const marketIndex = 0 // index for BTC/USDC +// const spotMarket = await Market.load( +// connection, +// mangoGroup.spotMarkets[marketIndex], +// {skipPreflight: true, commitment: 'singleGossip'}, +// mangoGroup.dexProgramId +// ) +// +// // // margin short 0.1 BTC +// // await client.placeOrder( +// // connection, +// // mangoProgramId, +// // mangoGroup, +// // marginAccount, +// // spotMarket, +// // payer, +// // 'sell', +// // 30000, +// // 0.1 +// // ) +// // +// // await spotMarket.matchOrders(connection, payer, 10) +// // +// await client.settleFunds( +// connection, +// mangoProgramId, +// mangoGroup, +// marginAccount, +// payer, +// spotMarket +// ) +// // +// // 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) +// +// marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey) +// console.log(marginAccount.toPrettyString(mangoGroup)) +// } +// main() // // async function testAll() {