Skip to content

Add MT_FLOWRATE type family and MoneyEvent#2065

Closed
divyaranjan1905 wants to merge 7 commits intosuperfluid-org:devfrom
divyaranjan1905:dev
Closed

Add MT_FLOWRATE type family and MoneyEvent#2065
divyaranjan1905 wants to merge 7 commits intosuperfluid-org:devfrom
divyaranjan1905:dev

Conversation

@divyaranjan1905
Copy link

This PR adds a FlowRate type family to MonetaryTypes, which had been mentioned as a FIXME previously.

Moreover, this PR also adds a new type of MoneyEvent that is able to take a snapshot of change whenever a change occurs. There's also a new representation of an account with AccountState. This one might be unnecessary, but it's mostly for exemplification purposes.

deltaEvents is the crucial function that provides the delta of two AccountState as a MoneyEvent but I've also added two other functions: validateTimeline and settleSnapshots which would be useful later on as we do more operations with MoneyEvent.

@hellwolf
Copy link
Contributor

test/Money/Theory/TestMonetaryTypes.hs:36:63: error:
    • No instance for (Arbitrary (MT_FLOWRATE TestMonetaryTypes))
        arising from a use of ‘arbitrary’
    • In the second argument of ‘(<*>)’, namely ‘arbitrary’
      In the expression:
        BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
      In an equation for ‘arbitrary’:
          arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |
36 |     arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |                                                               ^^^^^^^^^

did you run test yet? Just need to add an Abitrary instance to the flow rate. Also, I wouldn't use floating number for it, since it will introduce the testing technique of dealing with imprecise numbers

@divyaranjan1905
Copy link
Author

divyaranjan1905 commented Apr 30, 2025

test/Money/Theory/TestMonetaryTypes.hs:36:63: error:
    • No instance for (Arbitrary (MT_FLOWRATE TestMonetaryTypes))
        arising from a use of ‘arbitrary’
    • In the second argument of ‘(<*>)’, namely ‘arbitrary’
      In the expression:
        BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
      In an equation for ‘arbitrary’:
          arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |
36 |     arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |                                                               ^^^^^^^^^

did you run test yet? Just need to add an Abitrary instance to the flow rate.

Apologies, I hadn't. The cabal.project.freeze was posing some issues, got it to work now and pushed the changes. cabal test makes no complaints anymore.

@divyaranjan1905
Copy link
Author

test/Money/Theory/TestMonetaryTypes.hs:36:63: error:
    • No instance for (Arbitrary (MT_FLOWRATE TestMonetaryTypes))
        arising from a use of ‘arbitrary’
    • In the second argument of ‘(<*>)’, namely ‘arbitrary’
      In the expression:
        BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
      In an equation for ‘arbitrary’:
          arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |
36 |     arbitrary = BasicParticle <$> arbitrary <*> arbitrary <*> arbitrary
   |                                                               ^^^^^^^^^

Also, I wouldn't use floating number for it, since it will introduce the testing technique of dealing with imprecise numbers

Oh, which part are you referring to? MT_FLOWRATE is Integral like others. Are you referring to something else?

@hellwolf
Copy link
Contributor

Also, I wouldn't use floating number for it, since it will introduce the testing technique of dealing with imprecise numbers

Oh, which part are you referring to? MT_FLOWRATE is Integral like others. Are you referring to something else?

It was from the CI report. Now it passes: https://github.com/superfluid-org/protocol-monorepo/actions/runs/14755380283/job/41422904441?pr=2065

@hellwolf hellwolf marked this pull request as draft May 7, 2025 11:35
@hellwolf
Copy link
Contributor

I will close this one for now to do some refactoring first. Meanwhile, https://github.com/yolc-dev/yolc-semantic-money is being built to integrate semantic money with Yolc.

@hellwolf hellwolf closed this May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants