Skip to content

[Gas Fix] move token serialize to mintShares #71

@dmvt

Description

@dmvt

Description

The token model is serialized in the join function and then again in mintShares. It would be cheaper to calculate lambdaDash and mDash in Token.mintShares. This avoids duplicate calls to Ecosystem.deserialize and to Token.serialize.

    // mdash
    uint256 lambdaDash = SafeMath.add(token.maxLambdaPurchase, token.lambda);
    uint256 mDash = ElasticMath.mDash(lambdaDash, token.lambda, token.m);

    // serialize the token
    Ecosystem.Instance memory ecosystem = _getEcosystem();
    Token tokenStorage = Token(ecosystem.tokenModelAddress);
    token.m = mDash;
    tokenStorage.serialize(token);

    // tokencontract mint shares
    bool success = tokenContract.mintShares(msg.sender, token.maxLambdaPurchase);
    require(success, 'ElasticDAO: Mint Shares Failed during Join');

Definition of Done

  • mDash and lambdaDash calculations are in the mintShares function
  • Token is not serialized in ElasticDAO.join

Metadata

Metadata

Assignees

Labels

gasgas enhancementhelp wantedExtra attention is neededin progressSomething is actively being worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions