feat: Add MPT support to DEX (#5285)

This commit is contained in:
Gregory Tsipenyuk
2026-04-08 12:17:37 -04:00
committed by GitHub
parent 6d1a5be8d2
commit dfcad69155
223 changed files with 34897 additions and 4228 deletions

View File

@@ -291,7 +291,7 @@ struct BalanceTransfer
bool
has_happened(STAmount const& amt, STAmount const& reward, bool check_payer = true)
{
auto reward_cost = multiply(reward, STAmount(reward_accounts.size()), reward.issue());
auto reward_cost = multiply(reward, STAmount(reward_accounts.size()), reward.asset());
return check_most_balances(amt, reward) &&
(!check_payer || payer_.diff() == -(reward_cost + txFees_));
}
@@ -1503,7 +1503,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj
BEAST_EXPECT(!scEnv.claimID(jvb, 1)); // claim id deleted
BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(3), reward.issue())));
BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(3), reward.asset())));
}
// 4,4 => should succeed
@@ -1528,7 +1528,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj
return result;
}();
STAmount const split_reward_ =
divide(reward, STAmount(signers_.size()), reward.issue());
divide(reward, STAmount(signers_.size()), reward.asset());
mcEnv.tx(create_bridge(mcDoor, jvb)).close();
@@ -1563,7 +1563,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj
BEAST_EXPECT(!scEnv.claimID(jvb, claimID)); // claim id deleted
BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(2), reward.issue())));
BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(2), reward.asset())));
}
// 1,2 => should fail
@@ -3887,7 +3887,7 @@ private:
void
receive(jtx::Account const& acct, STAmount amt, std::uint64_t divisor = 1)
{
if (amt.issue() != xrpIssue())
if (amt.asset() != xrpIssue())
return;
auto it = accounts.find(acct);
if (it == accounts.end())
@@ -3898,18 +3898,18 @@ private:
else
{
it->second.expectedDiff +=
(divisor == 1 ? amt : divide(amt, STAmount(amt.issue(), divisor), amt.issue()));
(divisor == 1 ? amt : divide(amt, STAmount(amt.asset(), divisor), amt.asset()));
}
}
void
spend(jtx::Account const& acct, STAmount amt, std::uint64_t times = 1)
{
if (amt.issue() != xrpIssue())
if (amt.asset() != xrpIssue())
return;
receive(
acct,
times == 1 ? -amt : -multiply(amt, STAmount(amt.issue(), times), amt.issue()));
times == 1 ? -amt : -multiply(amt, STAmount(amt.asset(), times), amt.asset()));
}
void
@@ -4132,7 +4132,7 @@ private:
assert(cr.claim_id - 1 == counters.claim_count);
auto r = cr.reward;
auto reward = divide(r, STAmount(num_attestors), r.issue());
auto reward = divide(r, STAmount(num_attestors), r.asset());
for (auto i : signers)
st.receive(bridge_.signers[i].account, reward);
@@ -4213,7 +4213,7 @@ private:
ChainStateTrack& st = srcState();
jtx::Account const& srcdoor = srcDoor();
if (xfer.amt.issue() != xrpIssue())
if (xfer.amt.asset() != xrpIssue())
{
st.env.tx(pay(srcdoor, xfer.from, xfer.amt));
st.spendFee(srcdoor);
@@ -4233,7 +4233,7 @@ private:
distribute_reward(ChainStateTrack& st)
{
auto r = bridge_.reward;
auto reward = divide(r, STAmount(bridge_.quorum), r.issue());
auto reward = divide(r, STAmount(bridge_.quorum), r.asset());
for (size_t i = 0; i < num_signers; ++i)
{