Smart contracts documentation
Bloinx Smart contracts
- 1.Create a saving round
- 1.The user that creates the saving round will have the administrator role, they must indicate the number of guests, the amount of the payment(per turn), the periodicity and invite others to participate in their round.
- 2.Take into account that you will not be able to modify this data and that each guest can only register for one turn of the round.
- 1.In the registration stage, users will be able to select a turn and must make a payment in advance as a security deposit that will be reimbursed according to payment fulfillment.
- 2.The admin is responsible to verify that the registered addresses correspond to those of their guests. In case a guest is not in the correct round, they will be able to remove them.
- 3.Important: once the round has started, no changes in the users is possible.
- 3.Payments and withdrawals
- 1.When the round starts, all the guests will have the days you indicated in periodicity to make the first payment. The person on the first turn does not pay.
- 2.Once the payment time has passed, the guest in the first turn will be able to collect the accumulated fund. This is repeated for the number of participants in the round.
- 3.If one of your guests does not pay on time, the initial fee will be taken from them to cover their contribution for that turn.
- 4.The first time a guest does not pay on time, they will not have his initial fee at the end of the round. And it will not affect the other guests.
- 5.From the second time that a guest does not pay on time, they will impact the amount that all guests will receive at the end of the round.
- 6.If users have pending payments, they can catch up while the round is running.
- 4.End of the round
- 1.At the end of the round, what is in the safety deposit pool will be distributed among users with timely payments.
- 5.Round out of funds
- 1.If several users miss payments the round could run out of funds to pay the person in turn. If this is the case, the total balance of the round smart contract will be sent to a general account.
This factory pattern smart contract is used to
If the Round creation method is executed correctly, the function returns the address of the new smart contract (SavingGroups).
contractInstance.methods.createRound(warranty, saving, groupSize, payTime,token)
The Value of childRound returns the address of the new SavingGroups smart contract. This value changes each time a round is created.
The SavingGroups.sol smart contract features the Stages Enum, enums are a way to create user-defined data types and are implicitly convertible to integers.
The smart contract features a struct with the user information so the smart contract can manage the round correctly. The users are stored in a mapping.
The smart contract has 6 mandatory parameters shown in the following table.
The constructor is executed only once in the smart contract deployment, that comes from the CreateRound function in Main.sol.
Inside the constructor the amounts of _saveAmount and _cashIn are converted to the unit of wei.
The constructor has 3 main validations:
- 1.Validates that the administrator address is non-zero or null.
- 2.Validates that the group size is greater than one and less than or equal to ten.
- 3.Validates that the time given by the user is greater than zero and is multiplied by the seconds in a day.
Example: _payTime = 2 -> 2 * 86,400 = 2 days.
Events within Saving Groups.
Events are a simplified way of sending information to external systems like a frontend or a subgraph.
The fee cost is currently calculated in the constructor:
feeCost = (saveAmount / 10000) * 500;
It corresponds to 5%. And it is transferred to the Team Bloinx wallet