Merge branch 'main' into borrow_limits
This commit is contained in:
commit
5b6d1c4cdf
|
@ -52,8 +52,7 @@
|
||||||
],
|
],
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all"
|
||||||
"printWidth": 120
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@project-serum/serum": "^0.13.20",
|
"@project-serum/serum": "^0.13.20",
|
||||||
|
|
|
@ -27,6 +27,7 @@ import Wallet from '@project-serum/sol-wallet-adapter';
|
||||||
import { makeCancelOrderInstruction, makeSettleFundsInstruction } from './instruction';
|
import { makeCancelOrderInstruction, makeSettleFundsInstruction } from './instruction';
|
||||||
import { Aggregator } from './schema'
|
import { Aggregator } from './schema'
|
||||||
|
|
||||||
|
|
||||||
export class MangoGroup {
|
export class MangoGroup {
|
||||||
publicKey: PublicKey;
|
publicKey: PublicKey;
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ export class MangoGroup {
|
||||||
|
|
||||||
// const oracleAccs = await getMultipleAccounts(connection, this.oracles);
|
// const oracleAccs = await getMultipleAccounts(connection, this.oracles);
|
||||||
// return oracleAccs.map((oa) => decodeAggregatorInfo(oa.accountInfo).submissionValue).concat(1.0)
|
// return oracleAccs.map((oa) => decodeAggregatorInfo(oa.accountInfo).submissionValue).concat(1.0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMarketIndex(spotMarket: Market): number {
|
getMarketIndex(spotMarket: Market): number {
|
||||||
|
@ -84,12 +86,9 @@ export class MangoGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
getBorrowRate(tokenIndex: number): number {
|
getBorrowRate(tokenIndex: number): number {
|
||||||
|
|
||||||
const optimalUtil = 0.7
|
const optimalUtil = 0.7
|
||||||
const optimalRate = 0.1
|
const optimalRate = 0.1
|
||||||
const index = this.indexes[tokenIndex]
|
const index = this.indexes[tokenIndex]
|
||||||
|
|
||||||
|
|
||||||
return 0.0 // TODO
|
return 0.0 // TODO
|
||||||
}
|
}
|
||||||
getDepositRate(tokenIndex: number): number {
|
getDepositRate(tokenIndex: number): number {
|
||||||
|
@ -292,7 +291,9 @@ export class MarginAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MangoClient {
|
export class MangoClient {
|
||||||
|
async initMangoGroup() {
|
||||||
|
throw new Error("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
async sendTransaction(
|
async sendTransaction(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
|
@ -385,7 +386,6 @@ export class MangoClient {
|
||||||
]
|
]
|
||||||
const data = encodeMangoInstruction({Deposit: {quantity: nativeQuantity}})
|
const data = encodeMangoInstruction({Deposit: {quantity: nativeQuantity}})
|
||||||
|
|
||||||
|
|
||||||
const instruction = new TransactionInstruction( { keys, data, programId })
|
const instruction = new TransactionInstruction( { keys, data, programId })
|
||||||
|
|
||||||
const transaction = new Transaction()
|
const transaction = new Transaction()
|
||||||
|
|
|
@ -195,6 +195,7 @@ export function selfTradeBehaviorLayout(property) {
|
||||||
export const MangoInstructionLayout = union(u32('instruction'))
|
export const MangoInstructionLayout = union(u32('instruction'))
|
||||||
|
|
||||||
MangoInstructionLayout.addVariant(0, struct([]), 'InitMangoGroup') // TODO this is unimplemented
|
MangoInstructionLayout.addVariant(0, struct([]), 'InitMangoGroup') // TODO this is unimplemented
|
||||||
|
|
||||||
MangoInstructionLayout.addVariant(1, struct([]), 'InitMarginAccount')
|
MangoInstructionLayout.addVariant(1, struct([]), 'InitMarginAccount')
|
||||||
MangoInstructionLayout.addVariant(2, struct([u64('quantity')]), 'Deposit')
|
MangoInstructionLayout.addVariant(2, struct([u64('quantity')]), 'Deposit')
|
||||||
MangoInstructionLayout.addVariant(3, struct([u64('quantity')]), 'Withdraw')
|
MangoInstructionLayout.addVariant(3, struct([u64('quantity')]), 'Withdraw')
|
||||||
|
@ -234,6 +235,7 @@ MangoInstructionLayout.addVariant(11,
|
||||||
MangoInstructionLayout.addVariant(12, struct([u64('clientId')]), 'CancelOrderByClientId')
|
MangoInstructionLayout.addVariant(12, struct([u64('clientId')]), 'CancelOrderByClientId')
|
||||||
MangoInstructionLayout.addVariant(13, struct([u64('tokenIndex'), u64('borrowLimit')]), 'ChangeBorrowLimit')
|
MangoInstructionLayout.addVariant(13, struct([u64('tokenIndex'), u64('borrowLimit')]), 'ChangeBorrowLimit')
|
||||||
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const instructionMaxSpan = Math.max(...Object.values(MangoInstructionLayout.registry).map((r) => r.span));
|
const instructionMaxSpan = Math.max(...Object.values(MangoInstructionLayout.registry).map((r) => r.span));
|
||||||
export function encodeMangoInstruction(data) {
|
export function encodeMangoInstruction(data) {
|
||||||
|
|
Loading…
Reference in New Issue