Skip to content

Commit

Permalink
Add getFees function
Browse files Browse the repository at this point in the history
  • Loading branch information
icyblob committed Dec 19, 2024
1 parent 05f8096 commit bcd0ca6
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions src/contracts/MsVault.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct MSVAULT : public ContractBase
sint32 i;
};

// Procedures and functions' structs
struct registerVault_input
{
uint16 vaultType;
Expand Down Expand Up @@ -291,6 +292,34 @@ struct MSVAULT : public ContractBase
uint64 totalDistributedToShareholders;
};

struct getFees_input
{
};
struct getFees_output
{
uint64 registeringFee;
uint64 releaseFee;
uint64 releaseResetFee;
uint64 holdingFee;
uint64 depositFee; // currently always 0
};

struct BEGIN_EPOCH_locals
{
uint64 i;
resetReleaseRequests_input rr_in;
resetReleaseRequests_output rr_out;
resetReleaseRequests_locals rr_locals;
Vault v;
};


struct END_EPOCH_locals
{
uint64 i;
Vault v;
};

protected:
// Contract states
array<Vault, MSVAULT_MAX_VAULTS> vaults;
Expand Down Expand Up @@ -700,21 +729,20 @@ struct MSVAULT : public ContractBase
output.totalDistributedToShareholders = state.totalDistributedToShareholders;
_

PUBLIC_FUNCTION(getFees)
output.registeringFee = MSVAULT_REGISTERING_FEE;
output.releaseFee = MSVAULT_RELEASE_FEE;
output.releaseResetFee = MSVAULT_RELEASE_RESET_FEE;
output.holdingFee = MSVAULT_HOLDING_FEE;
output.depositFee = 0; // currently always 0, but we still need to return it for viewing purpose
_

INITIALIZE
state.numberOfActiveVaults = 0;
state.totalRevenue = 0;
state.totalDistributedToShareholders = 0;
_

struct BEGIN_EPOCH_locals
{
uint64 i;
resetReleaseRequests_input rr_in;
resetReleaseRequests_output rr_out;
resetReleaseRequests_locals rr_locals;
Vault v;
};

BEGIN_EPOCH_WITH_LOCALS
for (locals.i = 0; locals.i < MSVAULT_MAX_VAULTS; locals.i++)
{
Expand All @@ -729,12 +757,6 @@ struct MSVAULT : public ContractBase
}
_

struct END_EPOCH_locals
{
uint64 i;
Vault v;
};

END_EPOCH_WITH_LOCALS
for (locals.i = 0; locals.i < MSVAULT_MAX_VAULTS; locals.i++)
{
Expand Down Expand Up @@ -780,5 +802,6 @@ struct MSVAULT : public ContractBase
REGISTER_USER_FUNCTION(getBalanceOf, 7);
REGISTER_USER_FUNCTION(getVaultName, 8);
REGISTER_USER_FUNCTION(getRevenueInfo, 9);
REGISTER_USER_FUNCTION(getFees, 10);
_
};

0 comments on commit bcd0ca6

Please sign in to comment.