Skip to content

Commit

Permalink
no checks for withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
jimarek committed Mar 28, 2024
1 parent ee7890d commit ebd82c5
Showing 1 changed file with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,52 +82,4 @@ static ImmutableAmmWithdraw.Builder builder() {
*/
@JsonProperty("LPTokensIn")
Optional<IssuedCurrencyAmount> lpTokensIn();

@Value.Immutable
@JsonSerialize(as = ImmutableAmmWithdraw.class)
@JsonDeserialize(as = ImmutableAmmWithdraw.class)
abstract class AbstractAmmWithdraw implements AmmWithdraw {

@Value.Check
void checkFieldPresenceBasedOnFlags() {
boolean lpTokenPresent = lpTokensIn().isPresent();
boolean amountPresent = amount().isPresent();
boolean amount2Present = amount2().isPresent();
boolean effectivePricePresent = effectivePrice().isPresent();

if (flags().tfLpToken()) {
Preconditions.checkState(
lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent,
"If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."
);
} else if (flags().tfWithdrawAll()) {
Preconditions.checkState(
!lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent,
"If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."
);
} else if (flags().tfTwoAsset()) {
Preconditions.checkState(
!lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent,
"If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."
);
} else if (flags().tfSingleAsset() || flags().tfOneAssetWithdrawAll()) {
Preconditions.checkState(
!lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent,
"If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice cannot " +
"be present."
);
} else if (flags().tfOneAssetLpToken()) {
Preconditions.checkState(
lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent,
"If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."
);
} else if (flags().tfLimitLpToken()) {
Preconditions.checkState(
!lpTokenPresent && amountPresent && !amount2Present && effectivePricePresent,
"If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."
);
}
}

}
}

0 comments on commit ebd82c5

Please sign in to comment.