cleaned up index.ts
This commit is contained in:
parent
bf64c97511
commit
66558f28d7
104
src/index.ts
104
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(
|
||||
// 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,
|
||||
// spotMarket,
|
||||
// payer,
|
||||
// 'sell',
|
||||
// 30000,
|
||||
// 0.1
|
||||
// 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)
|
||||
//
|
||||
// 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()
|
||||
// marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey)
|
||||
// console.log(marginAccount.toPrettyString(mangoGroup))
|
||||
// }
|
||||
// main()
|
||||
|
||||
//
|
||||
// async function testAll() {
|
||||
|
|
Loading…
Reference in New Issue