JoinSEEDS / seeds-smart-contracts

Smart contracts for SEEDS - A Regenerative Civilization Building Game.
https://docs.google.com/document/d/1C4w9Ol8VGabCIcQDVPDrwcTRoJXBqhrb7VjslwQbUGU/edit#heading=h.6f4sxygso816
MIT License
20 stars 6 forks source link

Harvest Protocol Instrumentation (#371) #386

Closed EdwinFajardoB closed 3 years ago

EdwinFajardoB commented 3 years ago

Added the following actions:

Added the following tables:

Added tests.

Contracts that need to be deployed:

Settings don't have to be updated nor permissions.

These actions don't affect the existing tables and they don't modify their information.


Example of usage

Each of these actions receives a map defined as following: typedef std::map<name, std::variant<asset, uint64_t, double, int64_t, string>> logmap

After running any of these actions a new entry in the log_group_table is created. It generates a new log group. The tables logs_table and log_rewards_table are scoped by log_group.

To delete a log group the action resetlogs can be called normally

To delete all the log groups, there is the action resetlgroups

lgrunhrvst

This action emulates the behavior of runharvest.

It will call ldsthvstusrs, ldsthvstorgs and ldsthvstrgns to emulate the harvest distribution to users, orgs and regions respectively. It will fill the log table with detailed information, to see only the distribution each account received the rewards table is more appropriate.

Optional parameters: Parameter Type Description
mintrate int64 The mintrate to use in the harvest distribution
poolbsize uint64 Pool size. The amount of dSeeds on the pool contract
usrsperc float64 Percentage for users' bucket
rgnsperc float64 Percentage for regions' bucket
orgsperc float64 Percentage for organizations' bucket
globperc float64 Percentage for global dho's bucket
batchsize uint64 Batch size to use in the distribution of the buckets. If not provided the value 20 is used

If any of the optional parameters above is not provided, its respective value on chain is used. For example if mintrate is not given, then the mint rate in the mint_rate_table is used.

Example

Call action with parameters:

./cleos push action harvst.seeds lgrunhrvst '{
    "log_map": [
        {
            "key":"mintrate",
            "value":["int64", 1000000]
        },
        {
            "key":"batchsize",
            "value":["uint64", 40]
        }
    ]
}' -p harvst.seeds@active

Call action without parameters:

./cleos push action harvst.seeds lgrunhrvst '{"log_map":[]}' -p harvst.seeds@active

lgcalcmqevs

This action emulates the behavior of calcmqevs.

Optional parameters: Parameter Type Description
day uint64 Timestamp of the start day. If no provided the today's timestamp is used
mooncycle uint64 Duration in seconds of a moon cycle. The real Monthly QEV calculation takes 1 moon cycle of information, we kept the name moon cycle to point out which piece of code it emulates but this variable is meant to provide a variable window for the cut off day in the monthly qev log action

If any of these parameters aren't provided the real value on chain is used.

Example

Call action with parameters:

./cleos push action harvst.seeds lgcalcmqevs '{
    "log_map": [
        {
            "key":"day",
            "value":["uint64", 1000000]
        },
        {
            "key":"mooncycle",
            "value":["uint64", 2000000]
        }
    ]
}' -p harvst.seeds@active

Call action without parameters:

./cleos push action harvst.seeds lgcalcmqevs '{"log_map":[]}' -p harvst.seeds@active

lgcalmntrte

This action emulates the behavior of calcmintrate.

Optional parameters: Parameter Type Description
pqevqvol uint64 Previous Monthly QEV. Integer with 4 decimals of precision
cqevqvol uint64 Current Monthly QEV. Integer with 4 decimals of precision
pcsupply uint64 Previous Circulating Supply. Integer with 4 decimals of precision
ccsupply uint64 Current Circulating Supply. Integer with 4 decimals of precision
inflrate float64 Inflation rate

If a parameter is not provided its value on chain is used.

Example

Call action with parameters:

./cleos push action harvst.seeds lgcalmntrte '{
    "log_map": [
        {
            "key":"pqevqvol",
            "value":["uint64", 1000]
        },
        {
            "key":"cqevqvol",
            "value":["uint64", 2000]
        },
        {
            "key":"pcsupply",
            "value":["uint64", 50000]
        },
        {
            "key":"ccsupply",
            "value":["uint64", 60000]
        },
        {
            "key":"inflrate",
            "value":["float64", 0.1]
        }
    ]
}' -p harvst.seeds@active

Call action without parameters:

./cleos push action harvst.seeds lgcalmntrte '{"log_map":[]}' -p harvst.seeds@active
n13 commented 3 years ago

Looks good.. I will play with this