Skip to content

Commit

Permalink
handle price impact in other tcs function
Browse files Browse the repository at this point in the history
  • Loading branch information
riordanp committed Aug 9, 2024
1 parent 3c9c05f commit 404d3bf
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4624,14 +4624,28 @@ export class MangoClient {

// TODO: The max premium should likely be computed differently
if (!maxPricePremiumPercent) {
const buyTokenPriceImpact = group.getPriceImpactByTokenIndex(
buyBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);
const sellTokenPriceImpact = group.getPriceImpactByTokenIndex(
sellBank.tokenIndex,
liqorTcsChunkSizeInUsd,
);
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,
);

if (buyTokenPriceImpact <= 0 || sellTokenPriceImpact <= 0) {
throw new Error(
Expand Down

0 comments on commit 404d3bf

Please sign in to comment.