update type names; fix flashLoan client fn
This commit is contained in:
parent
a151dea893
commit
719b944f89
|
@ -35,9 +35,9 @@ export class MangoAccount {
|
|||
obj.group,
|
||||
obj.owner,
|
||||
obj.delegate,
|
||||
obj.tokens as { values: TokenAccountDto[] },
|
||||
obj.serum3 as { values: Serum3AccountDto[] },
|
||||
obj.perps as { accounts: PerpAccountDto[] },
|
||||
obj.tokens as { values: TokenPositionDto[] },
|
||||
obj.serum3 as { values: Serum3PositionDto[] },
|
||||
obj.perps as { accounts: PerpPositionDto[] },
|
||||
obj.beingLiquidated,
|
||||
obj.isBankrupt,
|
||||
obj.accountNum,
|
||||
|
@ -52,9 +52,9 @@ export class MangoAccount {
|
|||
public group: PublicKey,
|
||||
public owner: PublicKey,
|
||||
public delegate: PublicKey,
|
||||
tokens: { values: TokenAccountDto[] },
|
||||
serum3: { values: Serum3AccountDto[] },
|
||||
perps: { accounts: PerpAccountDto[] },
|
||||
tokens: { values: TokenPositionDto[] },
|
||||
serum3: { values: Serum3PositionDto[] },
|
||||
perps: { accounts: PerpPositionDto[] },
|
||||
beingLiquidated: number,
|
||||
isBankrupt: number,
|
||||
accountNum: number,
|
||||
|
@ -125,7 +125,7 @@ export class MangoAccount {
|
|||
|
||||
export class TokenPosition {
|
||||
static TokenIndexUnset: number = 65535;
|
||||
static from(dto: TokenAccountDto) {
|
||||
static from(dto: TokenPositionDto) {
|
||||
return new TokenPosition(
|
||||
I80F48.from(dto.indexedPosition),
|
||||
dto.tokenIndex,
|
||||
|
@ -179,7 +179,7 @@ export class TokenPosition {
|
|||
}
|
||||
}
|
||||
|
||||
export class TokenAccountDto {
|
||||
export class TokenPositionDto {
|
||||
constructor(
|
||||
public indexedPosition: I80F48Dto,
|
||||
public tokenIndex: number,
|
||||
|
@ -190,7 +190,7 @@ export class TokenAccountDto {
|
|||
|
||||
export class Serum3Orders {
|
||||
static Serum3MarketIndexUnset = 65535;
|
||||
static from(dto: Serum3AccountDto) {
|
||||
static from(dto: Serum3PositionDto) {
|
||||
return new Serum3Orders(
|
||||
dto.openOrders,
|
||||
dto.marketIndex,
|
||||
|
@ -207,7 +207,7 @@ export class Serum3Orders {
|
|||
) {}
|
||||
}
|
||||
|
||||
export class Serum3AccountDto {
|
||||
export class Serum3PositionDto {
|
||||
constructor(
|
||||
public openOrders: PublicKey,
|
||||
public marketIndex: number,
|
||||
|
@ -219,7 +219,7 @@ export class Serum3AccountDto {
|
|||
|
||||
export class PerpPositions {
|
||||
static PerpMarketIndexUnset = 65535;
|
||||
static from(dto: PerpAccountDto) {
|
||||
static from(dto: PerpPositionDto) {
|
||||
return new PerpPositions(
|
||||
dto.marketIndex,
|
||||
dto.basePositionLots.toNumber(),
|
||||
|
@ -242,7 +242,7 @@ export class PerpPositions {
|
|||
) {}
|
||||
}
|
||||
|
||||
export class PerpAccountDto {
|
||||
export class PerpPositionDto {
|
||||
constructor(
|
||||
public marketIndex: number,
|
||||
public reserved: [],
|
||||
|
|
|
@ -1212,12 +1212,11 @@ export class MangoClient {
|
|||
])
|
||||
.flat();
|
||||
|
||||
const banks = Array.from(group.banksMap.values());
|
||||
const bankPks = banks.map((b) => b.publicKey.toString());
|
||||
const bankIndex = bankPks.indexOf(inputBank.publicKey.toString());
|
||||
const keys = instructions.map((ix) => ix.keys).flat();
|
||||
const vaultIndex = keys.findIndex((k) => k.pubkey.equals(inputBank.vault));
|
||||
|
||||
const withdraws: FlashLoanWithdraw[] = [
|
||||
{ index: 3, amount: toU64(amountIn, 9) },
|
||||
{ index: vaultIndex, amount: toU64(amountIn, inputBank.mintDecimals) },
|
||||
];
|
||||
|
||||
let cpiDatas = [];
|
||||
|
@ -1250,7 +1249,7 @@ export class MangoClient {
|
|||
);
|
||||
|
||||
return await this.program.methods
|
||||
.flashLoan(withdraws, [cpiDatas])
|
||||
.flashLoan(withdraws, cpiDatas)
|
||||
.accounts({
|
||||
group: group.publicKey,
|
||||
account: mangoAccount.publicKey,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Group } from './accounts/group';
|
|||
import {
|
||||
MangoAccount,
|
||||
TokenPosition,
|
||||
TokenAccountDto,
|
||||
TokenPositionDto,
|
||||
} from './accounts/mangoAccount';
|
||||
import { StubOracle } from './accounts/oracle';
|
||||
import { MangoClient } from './client';
|
||||
|
@ -22,7 +22,7 @@ export {
|
|||
StubOracle,
|
||||
MangoAccount,
|
||||
TokenPosition as TokenAccount,
|
||||
TokenAccountDto,
|
||||
TokenPositionDto,
|
||||
MangoClient,
|
||||
MANGO_V4_ID,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue