Skip to content

Commit

Permalink
Fixes from review
Browse files Browse the repository at this point in the history
Signed-off-by: microwavedcola1 <[email protected]>
  • Loading branch information
microwavedcola1 committed Aug 22, 2024
1 parent 1eb06af commit 2357a7f
Showing 1 changed file with 10 additions and 36 deletions.
46 changes: 10 additions & 36 deletions ts/client/src/accounts/mangoAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,6 @@ export class MangoAccount {
return tp ? tp.balanceUi(bank) : 0;
}

public getTokenInUseCount(bank: Bank): number {
const tp = this.getToken(bank.tokenIndex);
if (
this.publicKey.equals(
new PublicKey('HBVZhx5hEaeANvDdd6pPMzAPoPjk8Gxm6uEUM5xrje6p'),
)
) {
console.log(tp);
}
return tp?.inUseCount ?? 0;
}

/**
*
* @param bank
Expand Down Expand Up @@ -1275,7 +1263,7 @@ export class MangoAccount {
'\n tokens:' +
JSON.stringify(
this.tokens
.filter((token) => token.isActive())
.filter((token, i) => token.isActive())

Check failure on line 1266 in ts/client/src/accounts/mangoAccount.ts

View workflow job for this annotation

GitHub Actions / Lint

'i' is defined but never used. Allowed unused args must match /^_/u
.map((token, i) => token.toString(group, i)),
null,
4,
Expand Down Expand Up @@ -2262,32 +2250,18 @@ export class TokenConditionalSwap {
liqorTcsChunkSizeInUsd = 1000;
}

const buyTokenPriceImpact =
buyBank.tokenIndex == 0
? group.getPriceImpactByTokenIndex(
sellBank.tokenIndex,
liqorTcsChunkSizeInUsd,
'ask',
)
: group.getPriceImpactByTokenIndex(
buyBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);
const sellTokenPriceImpact =
sellBank.tokenIndex == 0
? group.getPriceImpactByTokenIndex(
buyBank.tokenIndex,
liqorTcsChunkSizeInUsd,
'bid',
)
: group.getPriceImpactByTokenIndex(
buyBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);
const buyTokenPriceImpact = group.getPriceImpactByTokenIndex(
buyBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);
const sellTokenPriceImpact = group.getPriceImpactByTokenIndex(
sellBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);

if (buyTokenPriceImpact <= 0 || sellTokenPriceImpact <= 0) {
throw new Error(
`Error computing slippage/premium for token conditional swap!`,
`Error compitong slippage/premium for token conditional swap!`,
);
}

Expand Down

0 comments on commit 2357a7f

Please sign in to comment.