Skip to content

feat(multi-atm): perfectly linear accrual#56

Merged
adam-hotait merged 1 commit intomainfrom
feat/multi-atm-v2-perfectly-linear
Feb 27, 2026
Merged

feat(multi-atm): perfectly linear accrual#56
adam-hotait merged 1 commit intomainfrom
feat/multi-atm-v2-perfectly-linear

Conversation

@adam-hotait
Copy link
Copy Markdown
Contributor

@adam-hotait adam-hotait commented Feb 17, 2026

Current situation

The MultiATM contract facilitates asset swaps (e.g., USTBL <> USDC) based on on-chain Oracle prices. To mitigate sandwich attacks during Oracle update blocks, the contract currently employs a spread-based logic:

  • Buying USTBL (with USDC): Uses the maximum of the two most recent Oracle prices.
  • Selling USTBL (for USDC): Uses the minimum of the two most recent Oracle prices.

This "min/max" logic prevents sandwich attackers from profiting from the price delta immediately before and after an Oracle update.

Multi-Hop Swaps. The contract supports swaps between any two assets provided an Oracle Path exists (e.g., eurSPKCCEURCUSDCUSTBL). The price is calculated by traversing the vertices of the path, which is provided as a parameter by the user during the function call.

Objective of the feature: Linear Yield Accrual

We aim to introduce instant yield accrual for specific assets that exhibit linear Net Asset Value (NAV) growth, such as MMF shares (e.g., USTBL, EUTBL). For these Linear Accruing Pairs, we will replace the min/max logic with a linear extrapolation based on the current block timestamp. This allows for a single, fair price for both buys and sells that reflects real-time yield growth between Oracle updates. For such identified pairs, the price function need to be updated to:

$$Price_{t} = P_{latest} + (T_{current} - T_{latest}) \cdot R_{accrual}$$

Where:

  • $P_{latest}$: Most recent Oracle price.
  • $T_{current}$: Current block timestamp.
  • $T_{latest}$: Timestamp of the most recent Oracle update.
  • $R_{accrual}$: The rate of accrual derived from the two most recent Oracle data points.

@adam-hotait adam-hotait self-assigned this Feb 17, 2026
Copilot AI review requested due to automatic review settings February 17, 2026 10:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional “linear yield” pricing mode to MultiATM, where the swap price is derived via linear extrapolation from the last two oracle rounds (instead of min/max bounding), and extends the test suite to validate the new behavior.

Changes:

  • Extend pair configuration and events to include a linearYield flag.
  • Implement linear extrapolation pricing path in MultiATM using the two latest oracle rounds.
  • Update and expand tests to cover linear-yield pricing behavior and updated pair details/event args.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
contracts/token/MultiATM.sol Adds linearYield to pair config, updates ABI (event + view), and introduces linear extrapolation pricing logic.
test/main.test.js Updates existing expectations for the new flag and adds extensive regression/swap tests for linear-yield pricing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contracts/token/MultiATM.sol
Comment thread contracts/token/MultiATM.sol Outdated
Comment thread contracts/token/MultiATM.sol Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
Comment thread test/main.test.js Outdated
@adam-hotait adam-hotait force-pushed the feat/multi-atm-v2-perfectly-linear branch 2 times, most recently from b580207 to 56d0c50 Compare February 24, 2026 16:57
@adam-hotait adam-hotait requested a review from Amxx February 24, 2026 16:58
@adam-hotait adam-hotait changed the base branch from main to use-typescript February 27, 2026 14:23
@adam-hotait adam-hotait changed the base branch from use-typescript to main February 27, 2026 14:23
@adam-hotait adam-hotait force-pushed the feat/multi-atm-v2-perfectly-linear branch from 56d0c50 to 957c21a Compare February 27, 2026 14:24
@adam-hotait adam-hotait merged commit d26f97c into main Feb 27, 2026
1 check passed
@adam-hotait adam-hotait deleted the feat/multi-atm-v2-perfectly-linear branch February 27, 2026 14:25
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.

4 participants