Skip to content

feat: add CCALens and TickDataLens#325

Open
zhongeric wants to merge 6 commits intodevfrom
feat/tick-lens
Open

feat: add CCALens and TickDataLens#325
zhongeric wants to merge 6 commits intodevfrom
feat/tick-lens

Conversation

@zhongeric
Copy link
Contributor

No description provided.

@zhongeric zhongeric marked this pull request as ready for review March 3, 2026 21:19
@zhongeric zhongeric requested a review from a team as a code owner March 3, 2026 21:19
mstore(add(offset, 0x20), currencyDemandQ96)
mstore(add(offset, 0x40), requiredCurrencyDemandQ96)
mstore(add(offset, 0x60), currencyRequiredQ96)
mstore(0x40, add(offset, 0x80))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be done once at the end, does not have to happen in every iteration. As far as I can see, there is no memory allocated other then this inside the while loop, only stack variables, so should be safe.

mstore(buffer, idx)
let headerSize := add(0x20, shl(5, idx)) // 32 + idx * 32
let dataSize := shl(7, idx) // idx * 128
mcopy(add(fmp, headerSize), fmp, dataSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

This mcopy is very expensive in this case, since it must copy all of the previously created data in memory to a different location. I understand where you are coming from with this, but you can handle this easier:
The memory setup for an array of a static struct is, as you have correctly documented:
[length][absolute pointer1][absolute pointer2][absolute pointer3][struct content1][struct content2][struct content3]

Reminder, these pointers are absolute values! You can simply continue at the updated free memory pointer with the array length and then point to the previously created structs in memory.
Would something like this:
[struct content1][struct content2][struct content3][length][absolute pointer1][absolute pointer2][absolute pointer3]

Afaik, this should work as well and skips this expensive operation

@zhongeric zhongeric changed the base branch from main to dev March 11, 2026 16:05
refactor: optimize TickDataLens memory handling
Copy link
Contributor Author

@zhongeric zhongeric left a comment

Choose a reason for hiding this comment

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

lgtm, @mgretzke thoughts?

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