Fix formatting

This commit is contained in:
Ed Hennis
2025-07-21 20:37:16 -04:00
parent 43fe49e756
commit 96f2a65f64
8 changed files with 161 additions and 198 deletions

View File

@@ -1333,55 +1333,49 @@ private:
// Equal deposit, tokens rounded to 0
testAMM([&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.tokens = IOUAmount{1, -12},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.tokens = IOUAmount{1, -12},
.err = ter(tecAMM_INVALID_TOKENS)});
});
// Equal deposit limit, tokens rounded to 0
testAMM(
[&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.asset1In = STAmount{USD, 1, -15},
.asset2In = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.asset1In = STAmount{USD, 1, -15},
.asset2In = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
},
{.pool = {{USD(1'000'000), XRP(1'000'000)}},
.features = {features - fixAMMv1_3}});
testAMM([&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.asset1In = STAmount{USD, 1, -15},
.asset2In = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.asset1In = STAmount{USD, 1, -15},
.asset2In = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
});
// Single deposit by asset, tokens rounded to 0
testAMM([&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.asset1In = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.asset1In = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
});
// Single deposit by tokens, tokens rounded to 0
testAMM([&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.tokens = IOUAmount{1, -10},
.asset1In = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.tokens = IOUAmount{1, -10},
.asset1In = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
});
// Single deposit with eprice, tokens rounded to 0
testAMM([&](AMM& amm, Env& env) {
amm.deposit(
DepositArg{
.asset1In = STAmount{USD, 1, -15},
.maxEP = STAmount{USD, 1, -1},
.err = ter(tecAMM_INVALID_TOKENS)});
amm.deposit(DepositArg{
.asset1In = STAmount{USD, 1, -15},
.maxEP = STAmount{USD, 1, -1},
.err = ter(tecAMM_INVALID_TOKENS)});
});
}
@@ -2253,20 +2247,17 @@ private:
XRPAmount{1},
std::nullopt,
ter(tecAMM_INVALID_TOKENS));
ammAlice.withdraw(
WithdrawArg{
.tokens = IOUAmount{1, -10},
.err = ter(tecAMM_INVALID_TOKENS)});
ammAlice.withdraw(
WithdrawArg{
.asset1Out = STAmount{USD, 1, -15},
.asset2Out = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
ammAlice.withdraw(
WithdrawArg{
.tokens = IOUAmount{1, -10},
.asset1Out = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
ammAlice.withdraw(WithdrawArg{
.tokens = IOUAmount{1, -10},
.err = ter(tecAMM_INVALID_TOKENS)});
ammAlice.withdraw(WithdrawArg{
.asset1Out = STAmount{USD, 1, -15},
.asset2Out = XRPAmount{1},
.err = ter(tecAMM_INVALID_TOKENS)});
ammAlice.withdraw(WithdrawArg{
.tokens = IOUAmount{1, -10},
.asset1Out = STAmount{USD, 1, -15},
.err = ter(tecAMM_INVALID_TOKENS)});
});
}
@@ -7565,9 +7556,8 @@ private:
[&](AMM& amm, Env& env) {
auto const err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS)
: ter(tecUNFUNDED_AMM);
amm.deposit(
DepositArg{
.account = alice, .asset1In = amount, .err = err});
amm.deposit(DepositArg{
.account = alice, .asset1In = amount, .err = err});
},
tfee);
test(
@@ -7662,11 +7652,10 @@ private:
STAmount const depositGBP{
GBP, UINT64_C(10'1234567890123456), -16};
ammAlice.deposit(
DepositArg{
.account = bob,
.asset1In = depositEuro,
.asset2In = depositGBP});
ammAlice.deposit(DepositArg{
.account = bob,
.asset1In = depositEuro,
.asset2In = depositGBP});
invariant(ammAlice, env, "dep2", false);
},
{{GBP(30'000), EUR(30'000)}},
@@ -7691,11 +7680,10 @@ private:
STAmount const depositEuro{EUR, 1, exponent};
STAmount const depositGBP{GBP, 1, exponent};
ammAlice.deposit(
DepositArg{
.account = bob,
.asset1In = depositEuro,
.asset2In = depositGBP});
ammAlice.deposit(DepositArg{
.account = bob,
.asset1In = depositEuro,
.asset2In = depositGBP});
invariant(
ammAlice,
env,
@@ -7720,10 +7708,9 @@ private:
Fund::Acct);
env.close();
ammAlice.deposit(
DepositArg{
.account = bob,
.tokens = IOUAmount{10'1234567890123456, -16}});
ammAlice.deposit(DepositArg{
.account = bob,
.tokens = IOUAmount{10'1234567890123456, -16}});
invariant(ammAlice, env, "dep4", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7753,11 +7740,10 @@ private:
Fund::Acct);
env.close();
ammAlice.deposit(
DepositArg{
.account = bob,
.tokens = tokens,
.asset1In = STAmount{EUR, 1, 6}});
ammAlice.deposit(DepositArg{
.account = bob,
.tokens = tokens,
.asset1In = STAmount{EUR, 1, 6}});
invariant(ammAlice, env, "dep5", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7822,12 +7808,11 @@ private:
// tfTwoAsset withdraw mode
testAMM(
[&](AMM& ammAlice, Env& env) {
ammAlice.withdraw(
WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 3'500},
.asset2Out = STAmount{EUR, 15'000},
.flags = tfTwoAsset});
ammAlice.withdraw(WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 3'500},
.asset2Out = STAmount{EUR, 15'000},
.flags = tfTwoAsset});
invariant(ammAlice, env, "with3", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7842,11 +7827,10 @@ private:
// errors
testAMM(
[&](AMM& ammAlice, Env& env) {
ammAlice.withdraw(
WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 1'234},
.flags = tfSingleAsset});
ammAlice.withdraw(WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 1'234},
.flags = tfSingleAsset});
invariant(ammAlice, env, "with4", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7866,15 +7850,13 @@ private:
Fund::Acct);
env.close();
ammAlice.deposit(
DepositArg{
.account = bob, .asset1In = STAmount{GBP, 3'456}});
ammAlice.deposit(DepositArg{
.account = bob, .asset1In = STAmount{GBP, 3'456}});
ammAlice.withdraw(
WithdrawArg{
.account = bob,
.asset1Out = STAmount{GBP, 1'000},
.flags = tfOneAssetWithdrawAll});
ammAlice.withdraw(WithdrawArg{
.account = bob,
.asset1Out = STAmount{GBP, 1'000},
.flags = tfOneAssetWithdrawAll});
invariant(ammAlice, env, "with5", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7885,12 +7867,11 @@ private:
// tfOneAssetLPToken mode
testAMM(
[&](AMM& ammAlice, Env& env) {
ammAlice.withdraw(
WithdrawArg{
.account = alice,
.tokens = 1'000,
.asset1Out = STAmount{GBP, 100},
.flags = tfOneAssetLPToken});
ammAlice.withdraw(WithdrawArg{
.account = alice,
.tokens = 1'000,
.asset1Out = STAmount{GBP, 100},
.flags = tfOneAssetLPToken});
invariant(ammAlice, env, "with6", false);
},
{{GBP(7'000), EUR(30'000)}},
@@ -7901,12 +7882,11 @@ private:
// tfLimitLPToken mode
testAMM(
[&](AMM& ammAlice, Env& env) {
ammAlice.withdraw(
WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 100},
.maxEP = IOUAmount{2},
.flags = tfLimitLPToken});
ammAlice.withdraw(WithdrawArg{
.account = alice,
.asset1Out = STAmount{GBP, 100},
.maxEP = IOUAmount{2},
.flags = tfLimitLPToken});
invariant(ammAlice, env, "with7", true);
},
{{GBP(7'000), EUR(30'000)}},