updated devnet.env

This commit is contained in:
dd 2021-02-07 17:25:08 -05:00
parent b5ccdce2f5
commit bf64c97511
2 changed files with 61 additions and 60 deletions

View File

@ -1,6 +1,6 @@
CLUSTER=devnet
DEX_PROGRAM_ID=9MVDeYQnJmN2Dt7H44Z8cob4bET2ysdNu2uFJcatDJno
KEYPAIR=~/.config/solana/id.json
BTCUSD=D9CBrNncuERiTzQwUVkxCevrM6irHJybeU2NQXtgXRbq
BTCUSD=6pZpjgfwKJhQ93ZYNjbJFtWEaB8kZjErsiGAEXn9WNjn
BTC_WALLET=HLoPtihB8oETm1kkTpx17FEnXm7afQdS4hojTNvbg3Rg
USDC_WALLET=GBBtcVE7WA8qdrHyhWTZkYDaz71EVHsg7wVaca9iq9xs

View File

@ -11,65 +11,66 @@ 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("58hhPAgRgk1BHM1UkvYnJfxpMcoyi3DSoKnkwxuFe47")
// 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))
// }
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() {
// const cluster = "devnet"