Skip to content

Review tokensMinted vs. totalTokensSold to optimise #535

Closed
@adamdossa

Description

@adamdossa

F-OBrien 24 minutes ago
Optimization Suggestion?
I could be wrong here but is there a logic to using tokensMinted instead of totalTokensSold? Are they not essentially the same thing? totalTokensSold only seems to be update after the STO is finaliszed. Instead there currently is an additional function that regularly calculates tokensMinted. If totalTokensSold was update as tokens were minted instead it would save the need for getTokensMinted(), which is called multiple times and recalculates each time. It could simply be replaced with totalTokensSold. This would then allow you to remove getTokensMinted() and also remove the getTokensSold() function as totalTokensSold already has a public getter.
So by adding totalTokensSold = totalTokensSold.add(tierPurchasedTokens) after tierData.mintedTotal = tierData.mintedTotal.add(tierPurchasedTokens) in the _calculateTier function I think it allows this optimization.
The finalize() function could then also be tidied up a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions