Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tensor-foundation/amm",
"version": "1.0.1",
"version": "1.0.2",
"description": "Version 2 of the Tensor AMM program.",
"sideEffects": false,
"module": "./dist/src/index.mjs",
Expand Down
17 changes: 13 additions & 4 deletions clients/js/src/hooked/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function getAmountOfBids({
}): number {
if (pool.config.poolType === PoolType.NFT) return 0;
if (pool.config.startingPrice <= 0n) return 0;
if (isMaxTakerSellCountReached(pool)) return 0;

let amountOfBidsWithoutMaxCount: number;
// Trade pool that compounds fees ==> include mm fee (goes back into available balance)
Expand Down Expand Up @@ -188,7 +189,7 @@ export function getAmountOfBids({
}
amountOfBidsWithoutMaxCount = bidCount - 1;
}
return isMaxTakerSellCountReached(pool)
return isMaxTakerSellCountRelevant(pool)
? Math.min(
amountOfBidsWithoutMaxCount,
pool.maxTakerSellCount + pool.priceOffset
Expand Down Expand Up @@ -485,15 +486,23 @@ const cutTo12MantissaDecimals = (
return [adjustedNum, adjustedOffset];
};

function isMaxTakerSellCountReached(
const isMaxTakerSellCountRelevant = (
pool: Pick<Pool, 'priceOffset' | 'maxTakerSellCount' | 'sharedEscrow'>
): boolean {
): boolean => {
return (
pool.priceOffset * -1 === pool.maxTakerSellCount &&
pool.maxTakerSellCount !== 0 &&
!!pool.sharedEscrow &&
pool.sharedEscrow !== DEFAULT_ADDRESS
);
};

function isMaxTakerSellCountReached(
pool: Pick<Pool, 'priceOffset' | 'maxTakerSellCount' | 'sharedEscrow'>
): boolean {
return (
pool.priceOffset * -1 === pool.maxTakerSellCount &&
isMaxTakerSellCountRelevant(pool)
);
}

const isNotFulfillable = ({
Expand Down
Loading