mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-30 16:05:51 +00:00
progress
This commit is contained in:
committed by
Bronek Kozicki
parent
d09e74e548
commit
1680477e39
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ class Vault_test : public beast::unit_test::suite
|
||||
SUBCASE("MPT cannot transfer")
|
||||
{
|
||||
MPTTester mptt{env, issuer, {.fund = false}};
|
||||
// Locked because that is the default flag.
|
||||
mptt.create();
|
||||
Asset asset = mptt.issuanceID();
|
||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||
|
||||
@@ -82,14 +82,19 @@ VaultDeposit::doApply()
|
||||
if (vault->getFlags() & lsfVaultPrivate)
|
||||
;
|
||||
|
||||
// TODO: transfer amount from account_ to vault.PseudoAccount.
|
||||
// - handles balance of account_ and vault.PseudoAccount
|
||||
// TODO: increase vault.AssetTotal
|
||||
// TODO: increase vault.AssetAvailable
|
||||
// TODO: calculate shares to give account_.
|
||||
// TODO: grant shares from issuance to account_.
|
||||
// - handles increasing account_.balance(vault.Asset)
|
||||
// - handles increasing mptIssuance.OutstandingAmount
|
||||
auto const& vaultAccount = vault->at(sfAccount);
|
||||
// Transfer amount from sender to vault.
|
||||
if (auto ter = accountSend(view(), account_, vaultAccount, amount, j_))
|
||||
return ter;
|
||||
|
||||
vault->at(sfAssetTotal) += amount;
|
||||
vault->at(sfAssetAvailable) += amount;
|
||||
|
||||
auto shares = assetsToSharesDeposit(view(), vault, amount);
|
||||
if (!shares)
|
||||
return shares.error();
|
||||
if (auto ter = accountSend(view(), vaultAccount, account_, *shares, j_))
|
||||
return ter;
|
||||
// TODO: copy mptIssuance.OutstandingAmount to vault.ShareTotal?
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -621,7 +621,7 @@ deleteAMMTrustLine(
|
||||
// From the perspective of a vault,
|
||||
// return the number of shares to give the depositor
|
||||
// when they deposit a fixed amount of assets.
|
||||
[[nodiscard]] Expected<Number, TER>
|
||||
[[nodiscard]] Expected<STAmount, TER>
|
||||
assetsToSharesDeposit(
|
||||
ReadView const& view,
|
||||
std::shared_ptr<SLE> const& vault,
|
||||
|
||||
@@ -2227,7 +2227,7 @@ rippleCredit(
|
||||
saAmount.asset().value());
|
||||
}
|
||||
|
||||
Number
|
||||
static Number
|
||||
getShareTotal(ReadView const& view, std::shared_ptr<SLE> const& vault)
|
||||
{
|
||||
auto issuance =
|
||||
@@ -2235,7 +2235,7 @@ getShareTotal(ReadView const& view, std::shared_ptr<SLE> const& vault)
|
||||
return issuance->at(sfOutstandingAmount);
|
||||
}
|
||||
|
||||
[[nodiscard]] Expected<Number, TER>
|
||||
[[nodiscard]] Expected<STAmount, TER>
|
||||
assetsToSharesDeposit(
|
||||
ReadView const& view,
|
||||
std::shared_ptr<SLE> const& vault,
|
||||
@@ -2247,7 +2247,8 @@ assetsToSharesDeposit(
|
||||
return assets;
|
||||
Number shareTotal = getShareTotal(view, vault);
|
||||
auto shares = shareTotal * (assets / assetTotal);
|
||||
return shares;
|
||||
STAmount amount{MPTAmount{shares}, MPTIssue{vault->at(sfMPTokenIssuanceID)}};
|
||||
return amount;
|
||||
}
|
||||
|
||||
[[nodiscard]] Expected<Number, TER>
|
||||
|
||||
Reference in New Issue
Block a user