-
Notifications
You must be signed in to change notification settings - Fork 22
fix(index-dtf): bps-precise fee distribution during deployment #1075
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
Open
lcamargof
wants to merge
2
commits into
master
Choose a base branch
from
devin/1785878219-index-deploy-fee-bps-precision
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { | ||
| encodeAbiParameters, | ||
| encodeFunctionData, | ||
| parseAbi, | ||
| zeroAddress, | ||
| type Address, | ||
| } from 'viem' | ||
| import { test, expect, type DtfHarness } from '../../../harness' | ||
|
|
||
| // Index DTF deploy wizard — Fees & Distribution precision. The DAO fee registry | ||
| // can take a fractional cut of revenue (BSC takes 1/3 → 33.33%); the wizard must | ||
| // show and split it on the same 0.01% grid its share inputs accept, or the shares | ||
| // can never total 100% and every recipient portion drifts. | ||
| test.use({ wallet: false }) | ||
|
|
||
| const INDEX_DEPLOYER = '0x4D201a6e5BF975E2CEE9e5cbDfc803C0Ff122073' // mainnet — the form's default chain | ||
| const FEE_REGISTRY = '0x1234567890123456789012345678901234567890' as Address | ||
| const DAO_FEE_REGISTRY = '0x9980cb23' // daoFeeRegistry() | ||
| const FEE_DETAILS_ABI = parseAbi([ | ||
| 'function getFeeDetails(address rToken) view returns (address recipient, uint256 feeNumerator, uint256 feeDenominator, uint256 feeFloor)', | ||
| ]) | ||
|
|
||
| // No folio exists yet, so the wizard reads the deployer's registry with the zero | ||
| // address. numerator/denominator = 1/3 → 33.333…% of revenue. | ||
| async function openFeesStep(harness: DtfHarness) { | ||
| harness.mock | ||
| .ethCall( | ||
| INDEX_DEPLOYER, | ||
| DAO_FEE_REGISTRY, | ||
| encodeAbiParameters([{ type: 'address' }], [FEE_REGISTRY]) | ||
| ) | ||
| .ethCall( | ||
| FEE_REGISTRY, | ||
| encodeFunctionData({ | ||
| abi: FEE_DETAILS_ABI, | ||
| functionName: 'getFeeDetails', | ||
| args: [zeroAddress], | ||
| }), | ||
| encodeAbiParameters( | ||
| [ | ||
| { type: 'address' }, | ||
| { type: 'uint256' }, | ||
| { type: 'uint256' }, | ||
| { type: 'uint256' }, | ||
| ], | ||
| [FEE_REGISTRY, 1n, 3n, 0n] | ||
| ) | ||
| ) | ||
|
|
||
| const { page } = harness | ||
| await page.goto('/internal/deploy') | ||
| await page.getByTestId('deploy-step-revenue-distribution').click() | ||
|
|
||
| // 1/3 of revenue on the 0.01% grid — NOT the integer-truncated 33%. | ||
| await expect(page.getByTestId('deploy-platform-fee')).toHaveText('33.33 %', { | ||
| timeout: 15_000, | ||
| }) | ||
|
|
||
| return page | ||
| } | ||
|
|
||
| test('deploy fees: hundredths-of-a-percent shares close the allocation @smoke @mobile', async ({ | ||
| harness, | ||
| }) => { | ||
| const page = await openFeesStep(harness) | ||
|
|
||
| await page.getByTestId('deploy-share-deployerShare').fill('0.01') | ||
| await page.getByTestId('deploy-share-governanceShare').fill('66.66') | ||
|
|
||
| await expect(page.getByTestId('deploy-remaining-allocation')).toHaveText('0%') | ||
| }) | ||
|
|
||
| test('deploy fees: even distribution allocates the whole non-platform pot', async ({ | ||
| harness, | ||
| }) => { | ||
| const page = await openFeesStep(harness) | ||
|
|
||
| await page.getByTestId('deploy-even-distribution').click() | ||
|
|
||
| // 66.67% over two participants — the last one absorbs the odd basis point. | ||
| await expect(page.getByTestId('deploy-share-deployerShare')).toHaveValue( | ||
| '33.33' | ||
| ) | ||
| await expect(page.getByTestId('deploy-share-governanceShare')).toHaveValue( | ||
| '33.34' | ||
| ) | ||
| await expect(page.getByTestId('deploy-remaining-allocation')).toHaveText('0%') | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Add lifecycle assertions for the deploy route.
This spec only asserts loaded-state behavior. It does not cover L0 blank, L1 skeleton, L2 partial resolution, L3 completion, or unexpected reflows. Add these assertions for desktop and the
@mobileproject before treating this as route coverage. As per coding guidelines, “Test every page through loading phases L0 blank, L1 skeleton, L2 independently resolving partial data, and L3 fully loaded behavior; assert zero unexpected reflows.”🤖 Prompt for AI Agents
Source: Coding guidelines