Skip to content

Commit

Permalink
Add extra input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoguerios committed Jan 29, 2025
1 parent ab82723 commit 15626ee
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/entities/inputValidator/boosted/inputValidatorBoosted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PoolStateWithUnderlyings } from '@/entities/types';
import { InputValidatorBase } from '../inputValidatorBase';
import { AddLiquidityKind } from '@/entities/addLiquidity/types';
import { AddLiquidityBoostedInput } from '@/entities/addLiquidityBoosted/types';
import { isSameAddress } from '@/utils';

export class InputValidatorBoosted extends InputValidatorBase {
validateAddLiquidityBoosted(
Expand Down Expand Up @@ -31,5 +32,28 @@ export class InputValidatorBoosted extends InputValidatorBase {
}
});
}

if (addLiquidityInput.kind === AddLiquidityKind.Proportional) {
// if referenceAmount is not the BPT, it must be included in tokensIn
if (
!isSameAddress(
addLiquidityInput.referenceAmount.address,
poolState.address,
)
) {
if (
addLiquidityInput.tokensIn.findIndex((tokenIn) =>
isSameAddress(
tokenIn,
addLiquidityInput.referenceAmount.address,
),
) === -1
) {
throw new Error(
'tokensIn must contain referenceAmount token address',
);
}
}
}
}
}

0 comments on commit 15626ee

Please sign in to comment.