Merge branch 'main' into borrow_limits

This commit is contained in:
dafyddd 2021-02-22 21:54:48 -05:00 committed by GitHub
commit 5b6d1c4cdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -52,8 +52,7 @@
],
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
"trailingComma": "all"
},
"dependencies": {
"@project-serum/serum": "^0.13.20",

View File

@ -27,6 +27,7 @@ import Wallet from '@project-serum/sol-wallet-adapter';
import { makeCancelOrderInstruction, makeSettleFundsInstruction } from './instruction';
import { Aggregator } from './schema'
export class MangoGroup {
publicKey: PublicKey;
@ -63,6 +64,7 @@ export class MangoGroup {
// const oracleAccs = await getMultipleAccounts(connection, this.oracles);
// return oracleAccs.map((oa) => decodeAggregatorInfo(oa.accountInfo).submissionValue).concat(1.0)
}
getMarketIndex(spotMarket: Market): number {
@ -84,12 +86,9 @@ export class MangoGroup {
}
getBorrowRate(tokenIndex: number): number {
const optimalUtil = 0.7
const optimalRate = 0.1
const index = this.indexes[tokenIndex]
return 0.0 // TODO
}
getDepositRate(tokenIndex: number): number {
@ -292,7 +291,9 @@ export class MarginAccount {
}
export class MangoClient {
async initMangoGroup() {
throw new Error("Not Implemented");
}
async sendTransaction(
connection: Connection,
@ -385,7 +386,6 @@ export class MangoClient {
]
const data = encodeMangoInstruction({Deposit: {quantity: nativeQuantity}})
const instruction = new TransactionInstruction( { keys, data, programId })
const transaction = new Transaction()

View File

@ -195,6 +195,7 @@ export function selfTradeBehaviorLayout(property) {
export const MangoInstructionLayout = union(u32('instruction'))
MangoInstructionLayout.addVariant(0, struct([]), 'InitMangoGroup') // TODO this is unimplemented
MangoInstructionLayout.addVariant(1, struct([]), 'InitMarginAccount')
MangoInstructionLayout.addVariant(2, struct([u64('quantity')]), 'Deposit')
MangoInstructionLayout.addVariant(3, struct([u64('quantity')]), 'Withdraw')
@ -234,6 +235,7 @@ MangoInstructionLayout.addVariant(11,
MangoInstructionLayout.addVariant(12, struct([u64('clientId')]), 'CancelOrderByClientId')
MangoInstructionLayout.addVariant(13, struct([u64('tokenIndex'), u64('borrowLimit')]), 'ChangeBorrowLimit')
// @ts-ignore
const instructionMaxSpan = Math.max(...Object.values(MangoInstructionLayout.registry).map((r) => r.span));
export function encodeMangoInstruction(data) {