Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] maker-minor funding allocation during socialization #64

Merged
merged 10 commits into from
Aug 17, 2023

Conversation

kbrizzle
Copy link
Collaborator

@kbrizzle kbrizzle commented Aug 4, 2023

Fixes broken allocation of funding between markers and the minor side of the market when the market is in socialization.

  • Also adds all positions tests.

@kbrizzle kbrizzle force-pushed the britz-all-position-tests branch from 5013697 to dd5800e Compare August 4, 2023 05:23
@kbrizzle kbrizzle requested a review from arjun-io August 11, 2023 18:32
@kbrizzle kbrizzle changed the title [WIP] Add all positions unit tests maker-minor funding allocation during socialization Aug 11, 2023
@kbrizzle kbrizzle changed the title maker-minor funding allocation during socialization [Fix] maker-minor funding allocation during socialization Aug 11, 2023
@@ -206,11 +206,11 @@ library VersionLib {

// Redirect net portion of minor's side to maker
if (fromPosition.long.gt(fromPosition.short)) {
fundingValues.fundingMaker = fundingValues.fundingShort.mul(Fixed6Lib.from(fromPosition.skew().abs()));
fundingValues.fundingMaker = fundingValues.fundingShort.mul(Fixed6Lib.from(fromPosition.socializedSkew()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need an abs anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already abs inside the function. This is probably not the ideal name for the method, but I did include a dev comment on what it's doing.

packages/perennial/test/unit/market/Market.test.ts Outdated Show resolved Hide resolved
packages/perennial/test/unit/market/Market.test.ts Outdated Show resolved Hide resolved
@kbrizzle kbrizzle force-pushed the britz-all-position-tests branch from 7e50591 to 54c7a75 Compare August 12, 2023 05:22
@kbrizzle kbrizzle force-pushed the britz-all-position-tests branch from 538e423 to 1c4d142 Compare August 16, 2023 03:50
@github-actions
Copy link

[Payoff] Integration Test Code Coverage Report

Coverage after merging britz-all-position-tests into main will be
100.00%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-payoff/contracts
   PayoffFactory.sol100%100%100%100%
packages/perennial-payoff/contracts/interfaces
   IPayoffFactory.sol100%100%100%100%
packages/perennial-payoff/contracts/payoff
   Giga.sol100%100%100%100%
   Kilo.sol100%100%100%100%
   KiloPowerHalf.sol100%100%100%100%
   KiloPowerTwo.sol100%100%100%100%
   Mega.sol100%100%100%100%
   MegaPowerTwo.sol100%100%100%100%
   Micro.sol100%100%100%100%
   MicroPowerTwo.sol100%100%100%100%
   Milli.sol100%100%100%100%
   MilliPowerHalf.sol100%100%100%100%
   MilliPowerTwo.sol100%100%100%100%
   Nano.sol100%100%100%100%
   PowerHalf.sol100%100%100%100%
   PowerTwo.sol100%100%100%100%

@github-actions
Copy link

[Extensions] Unit Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
82.40%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-extensions/contracts
   MultiInvoker.sol78.28%72.86%85.71%80.37%104, 143–144, 147–149, 151, 156, 222, 224, 233, 273, 273, 275, 278, 287, 287, 289, 292, 310, 312, 312, 312–313, 315, 320, 328–329, 331, 357, 360–362, 377, 382, 405, 77, 80–82
packages/perennial-extensions/contracts/interfaces
   IMultiInvoker.sol100%100%100%100%
packages/perennial-extensions/contracts/types
   TriggerOrder.sol78.26%62.50%100%94.44%34–35, 61–68

@github-actions
Copy link

[Payoff] Unit Test Code Coverage Report

Coverage after merging britz-all-position-tests into main will be
100.00%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-payoff/contracts
   PayoffFactory.sol100%100%100%100%
packages/perennial-payoff/contracts/interfaces
   IPayoffFactory.sol100%100%100%100%
packages/perennial-payoff/contracts/payoff
   Giga.sol100%100%100%100%
   Kilo.sol100%100%100%100%
   KiloPowerHalf.sol100%100%100%100%
   KiloPowerTwo.sol100%100%100%100%
   Mega.sol100%100%100%100%
   MegaPowerTwo.sol100%100%100%100%
   Micro.sol100%100%100%100%
   MicroPowerTwo.sol100%100%100%100%
   Milli.sol100%100%100%100%
   MilliPowerHalf.sol100%100%100%100%
   MilliPowerTwo.sol100%100%100%100%
   Nano.sol100%100%100%100%
   PowerHalf.sol100%100%100%100%
   PowerTwo.sol100%100%100%100%

@github-actions
Copy link

[Vault] Unit Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
32.12%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-vault/contracts
   Vault.sol0%0%0%0%104–105, 114, 116, 116, 116, 123, 125, 125, 125, 130, 130–131, 133–134, 134, 134, 137, 143, 143, 143–144, 144, 144, 146, 148–150, 157, 157–158, 160, 160, 160, 162–166, 171, 171–172, 174–175, 180, 180–183, 190, 190–192, 194–196, 209, 209–211, 213–216, 222–223, 223, 223–226, 228, 246, 246, 246–247, 247, 247, 250, 250, 250–252, 252, 252–254, 254, 254–256, 256, 256–258, 258, 258–260, 260, 260–261, 263, 263, 263, 266, 269–271, 274–276, 278, 292, 292, 292–294, 296, 296, 296, 301–302, 317, 321–324, 326, 332, 336, 336, 336, 340–342, 355, 357, 357, 357, 357, 357, 359, 365–366, 366, 366–369, 369, 369–370, 377, 380, 382, 392, 406, 408–411, 413, 415–418, 421–422, 424–427, 430–431, 434–435, 438–440, 447–449, 456, 456, 456–458, 466, 466, 466, 468–471, 473, 473, 473, 473, 473, 475, 480, 487–489, 499–501, 503–505, 58, 58–59, 61–63, 69, 76, 83, 89, 95–96
   VaultFactory.sol0%0%0%0%23, 27, 27–28, 40, 40–42, 49–50
packages/perennial-vault/contracts/interfaces
   IVault.sol100%100%100%100%
   IVaultFactory.sol100%100%100%100%
packages/perennial-vault/contracts/lib
   StrategyLib.sol0%0%0%0%101–104, 106, 108–109, 111–112, 126–128, 137, 64–66, 68, 70–73, 76, 80, 80, 80–81, 81, 85, 87
packages/perennial-vault/contracts/types
   Account.sol100%100%100%100%
   Checkpoint.sol100%100%100%100%
   Mapping.sol100%100%100%100%
   Registration.sol100%100%100%100%
   VaultParameter.sol100%100%100%100%

@github-actions
Copy link

[Oracle] Unit Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
45.89%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-oracle/contracts
   Oracle.sol100%100%100%100%
   OracleFactory.sol100%100%100%100%
packages/perennial-oracle/contracts/interfaces
   IOracle.sol100%100%100%100%
   IOracleFactory.sol100%100%100%100%
   IPythFactory.sol100%100%100%100%
   IPythOracle.sol100%100%100%100%
packages/perennial-oracle/contracts/pyth
   PythFactory.sol0%0%0%0%104, 104–106, 113–115, 115, 115–116, 38–39, 44, 44–45, 47–48, 53, 53–54, 60, 60–61, 63, 65, 72–73, 73, 76, 82, 87, 87–89, 89, 89–90, 90, 90–91, 91, 91, 93, 98
   PythOracle.sol0%0%0%0%101, 107, 115–116, 122, 122, 122, 122, 122–123, 133, 133, 138, 138, 138–139, 139, 139, 141–142, 144, 144, 144–145, 148, 148, 148–149, 151, 151, 151, 154, 154, 154, 160–162, 164, 177, 177, 177, 182–183, 186, 189–190, 190, 190, 192, 192, 192–193, 193, 193–195, 195, 195, 195, 195, 197–198, 205–208, 210, 222–224, 224, 226, 232, 237, 237, 237–238, 59, 66, 66–68, 70, 70, 70, 72, 76, 81, 81–83, 83, 83, 83, 83–85, 93, 99, 99, 99

@github-actions
Copy link

[Oracle] Integration Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
100.00%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-oracle/contracts
   Oracle.sol100%100%100%100%
   OracleFactory.sol100%100%100%100%
packages/perennial-oracle/contracts/interfaces
   IOracle.sol100%100%100%100%
   IOracleFactory.sol100%100%100%100%
   IPythFactory.sol100%100%100%100%
   IPythOracle.sol100%100%100%100%
packages/perennial-oracle/contracts/pyth
   PythFactory.sol88.68%70%100%100%104, 115, 44, 53, 60, 87
   PythOracle.sol95.69%89.13%100%100%133, 224, 237, 66, 83

@github-actions
Copy link

[Core] Integration Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
92.16%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial/contracts
   Market.sol76.17%57%88.57%85.28%100–101, 106, 113, 120–122, 131, 133, 133, 133–134, 134, 134–136, 136, 136–137, 137, 137, 139, 146, 146, 146, 148–150, 155, 157–158, 160–161, 252–254, 393, 438, 477–478, 478, 478, 478, 487–488, 493–494, 496–497, 501, 507–508, 508, 517, 521, 532, 538–539, 556–557, 60, 605, 610, 83, 92, 99, 99
   MarketFactory.sol60.53%42.86%71.43%70.59%37, 48, 57–58, 64, 66, 72, 75–76, 88, 88, 88–89
packages/perennial/contracts/interfaces
   IMarket.sol100%100%100%100%
   IMarketFactory.sol100%100%100%100%
   IOracleProvider.sol100%100%100%100%
   IOracleProviderFactory.sol100%100%100%100%
   IPayoffProvider.sol100%100%100%100%
packages/perennial/contracts/types
   Global.sol78.57%50%100%100%114–125
   Local.sol80%56.25%83.33%95.65%127–132, 89, 97
   MarketParameter.sol69.57%40.91%100%95%112, 114–115, 117, 119, 121, 121, 121, 121, 133–137
   OracleVersion.sol100%100%100%100%
   Order.sol88.46%70%100%100%73, 79, 98
   Position.sol88.52%60%96.88%98.33%200, 218, 275, 443–452
   ProtocolParameter.sol75%50%100%100%59–60, 66–70
   RiskParameter.sol73.91%50%100%100%133, 138, 143, 145, 150, 152, 154, 156, 166–169
   Version.sol90.18%70.59%100%98.57%192–193, 361–369

@github-actions
Copy link

[Vault] Integration Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
98.91%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-vault/contracts
   Vault.sol96.84%94.12%96.67%98.06%180, 180–183, 247, 263
   VaultFactory.sol85.71%50%100%100%27, 40
packages/perennial-vault/contracts/interfaces
   IVault.sol100%100%100%100%
   IVaultFactory.sol100%100%100%100%
packages/perennial-vault/contracts/lib
   StrategyLib.sol100%100%100%100%
packages/perennial-vault/contracts/types
   Account.sol82.86%50%100%100%126–131
   Checkpoint.sol88.64%68.75%100%100%132, 186, 224–231
   Mapping.sol95.12%80%100%100%100, 95
   Registration.sol81.82%50%100%100%41–42
   VaultParameter.sol87.50%50%100%100%31

@github-actions
Copy link

[Core] Unit Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
92.87%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial/contracts
   Market.sol99.66%99%100%100%83
   MarketFactory.sol0%0%0%0%32–33, 37, 37–38, 43, 48, 48–50, 57–58, 64, 64, 66, 66, 66, 72, 72, 72, 75, 75, 75–76, 79–80, 82, 88, 88, 88–89
packages/perennial/contracts/interfaces
   IMarket.sol100%100%100%100%
   IMarketFactory.sol100%100%100%100%
   IOracleProvider.sol100%100%100%100%
   IOracleProviderFactory.sol100%100%100%100%
   IPayoffProvider.sol100%100%100%100%
packages/perennial/contracts/types
   Global.sol78.57%50%100%100%114–125
   Local.sol80%56.25%83.33%95.65%127–132, 89, 97
   MarketParameter.sol69.57%40.91%100%95%112, 114–115, 117, 119, 121, 121, 121, 121, 133–137
   OracleVersion.sol100%100%100%100%
   Order.sol96.15%90%100%100%73
   Position.sol91.80%66.67%100%100%443–452
   ProtocolParameter.sol0%0%0%0%46–47, 59, 59, 59–60, 60, 60, 64, 66, 66, 66–67, 67, 67–68, 68, 68–69, 69, 69–70, 70, 70, 72
   RiskParameter.sol73.91%50%100%100%133, 138, 143, 145, 150, 152, 154, 156, 166–169
   Version.sol91.96%73.53%100%100%361–369

@github-actions
Copy link

[Extensions] Integration Test Coverage Report

Coverage after merging britz-all-position-tests into main will be
99.20%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/perennial-extensions/contracts
   MultiInvoker.sol96.97%91.43%100%100%156, 275, 289, 357, 377, 77
packages/perennial-extensions/contracts/interfaces
   IMultiInvoker.sol100%100%100%100%
packages/perennial-extensions/contracts/types
   TriggerOrder.sol89.13%83.33%100%94.44%34–35, 61–63

@kbrizzle kbrizzle merged commit 28e34cc into main Aug 17, 2023
@kbrizzle kbrizzle deleted the britz-all-position-tests branch August 17, 2023 03:49
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