162 Commits

Author SHA1 Message Date
tim
f1e602d414 Liquidity Party adapter 2025-12-10 15:53:45 -04:00
Tamara
eaca47479b feat: Simulate txs against RPC (#261)
* feat: (WIP) Simulate txs against RPC

* fix: include test_executor_addresses.json

We should probably fetch this from execution instead. Will do later

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: Add simulating execution using debug_traceCall

Decoded amount out from execution and compared with the one from simulation
Allow for printing the execution traces
Moved all execution methods into execution.rs
Created traces.rs (heavily clauded) that prints the traces nicely and gets the function selectors frm 4byte (I decided not to use EtherscanIdentifier from foundry because adding foundry as a dependency is really heavy and I expect problems because of it)

Temporary: hardcoded storage slots for test_weighted_pool_v4 to pass

#time 1h 55m

* feat: Use BalanceSlotDetector and AllowanceSlotDetector from tycho_ethereum

#time 1h 14m

* fix: Improve traces.rs

#time 2m

* feat: Add skip_execution

Also get tycho router bytecode at compile time

#time 22m

* test: Skip tests that are before the Shanghai upgrade

Remove unnecessary TODOs

#time 35m

* feat: Point tycho dependencies to specific commits

#time 9m

* fix: Set historical_trade to true in TychoRouterEncoderBuilder

#time 41m


#time 0m

* feat: Improve traces.rs (use foundry instead of 4bytes)

Improved the format of the printed trace as well

#time 1h 7m

* fix: After merge fixes

#time 3m

* feat: Use new executors_addresses in tycho-execution and read it at startup

#time 1h 25m

* feat: Create a new flag to enable execution_traces

#time 9m

* fix: Small code, log and trace improvements

Add trying to decode method's calldatas in tracing

#time 1m

* fix: Simplify simulate_transactions_with_tracing by introducing a new method: bytes_to_fixed_32

#time 13m

* fix: After merge fixes

#time 1m

* fix: Include executor's bytecode at compile time

#time 11m

---------

Co-authored-by: TAMARA LIPOWSKI <data.lipowski@extaccount.com>
Co-authored-by: Diana Carvalho <diana@propellerheads.xyz>
2025-09-23 15:57:43 +01:00
adrian
e1d0c58e64 test: add ci workflow for substreams tests 2025-09-17 10:27:44 +02:00
adrian
b4bf7b770a chore: add missing evm file 2025-09-16 11:31:19 +02:00
adrian
d728440048 feat: add evm and wasm files 2025-09-16 11:31:19 +02:00
adrian
fc38403d28 test: add executors runtime bytecode 2025-09-09 11:56:27 +02:00
Zizou
08e5794de0 remove comments (#226)
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2025-06-27 12:11:10 +02:00
Domenico
7f9a995e8a Curve Adapter (Stable and Crypto Swap) (#29)
* feat: Initial manifest structure

* feat: Adapter initial development and price function implementation

* feat: Implemented getPoolIDs

* feat: Implemented getTokens

* feat: Implemented getCapabilities

* feat: Implemented getLimits

* feat: Implemented swap

* feat: Created Adapter version for CurveV2 pools uint256

* fix: Review Fixes

* chore: Formatted code and code adjustments

* feat: Separated contracts and finished tests for Curve Exchange(Crypto and StableSwap)

* feat: Adjusted naming and formatted tests code

* chore: Initial merging of swaps

* merge CurveCryptoSwapAdapter and CurveStableSwapAdapter into CurveAdapter

* Fix and Test: fixes on CurveAdapter.sol and created CurveAdapter.t.sol

* review and fixes

* removed unused test and parameters

* chore: Initial MetaPool underlying swap and ETH native implementation

* chore: expanded swap and sell functions to support seap for underlying tokens and LPS

* chore: expanded functionalities of CurveAdapter and fixed getTokens function

* fix: fixed registry.is_meta

* chore: fixes

* chore: extended adapter and implementing tests for new pools

* chore: updated Adapter, implementing final tests

* fixing eth transfer

* fix and tests: fixed adapter and finishing tests implementation

* using adapter with try catch

* feat: Final fixes for pools support, using try-catch

* chore: Removed chunk files

* chore: Formatted code and removed unused condition

* fix: Fixed calculatedAmount in sell function when receiveToken=ETH

* chore: Adjusted ETH pools check

* corrected metaregistry address

* fix: fixed int128 conversion to unit256

* feat: Removed registry from adapter

* feat: Implemented price()

* fix: Propeller review fixes

* review fixes

* fix: Final fixes for custom custom int128 pools

* chore: Removed unused test

* fix: Fixed price error in custom pools

* feat: Improved isInt128Pool function to support any coin

* fix: Fixed price for custom pools using ETH balance when token0 is WETH

* fix: Fixed price function and added AdapterTest support in test

* fix: Fixed divisions in getPriceAt

* feat: Added secondary ETH pool support, e.g. stETH

* refactor(curve-adapter): Avoid calling WETH contract if possible. (#65)

* refactor(curve-adapter): Avoid calling WETH contract if possible.

This PR aims to use native ETH instead of WETH when possible, this is to avoid having to index WETH contract.

* style(adapter): apply `forge fmt`

* refactor(curve): change limit factor to 2

---------

Co-authored-by: Florian Pellissier <111426680+flopell@users.noreply.github.com>

* refactor: fix Curve Adapter test after rebase

* fix: remove PriceFunction capability for Curve

This was wrongly implemented: it return the price for a quote and not the marginal price after the swap.

* refactor: improve adapter test and fix failing test for etherfi

---------

Co-authored-by: domenicodev <domenico.romeo3919@gmail.com>
Co-authored-by: mp-web3 <mp.web3.t@gmail.com>
Co-authored-by: Zizou <111426680+zizou0x@users.noreply.github.com>
Co-authored-by: Florian Pellissier <111426680+flopell@users.noreply.github.com>
Co-authored-by: Diana Carvalho <diana@propellerheads.xyz>
2025-06-27 12:03:32 +02:00
Alan Höng
1885467616 Fix typo 2025-06-26 11:53:32 +01:00
kayibal
c31d4728cf docs: Clarify price as marginal price explicitly 2025-06-26 11:53:32 +01:00
Louise Poole
58324a199f chore: fix typos 2025-06-26 12:33:31 +02:00
mrBovo
fc0fb1e540 BalancerV3: SwapAdapter and Substreams (#126)
* feat: add balancer swapAdapter and Substreams

* fix: undo tycho-substreams logs, ignore abi on rustmft

* ci: prevent warnings from failing CI

* ci: skip size check on CI

* chore: forge fmt

* feat: vault balance from storage

Vault contract tokenBalance message are set according to the vault
storage changes in the `_reserveOf` storage variable VaultStorage.sol
contract
This was the culprit that caused the failure in simulation since
balancer enforces the invariant that `token.balanceOf(vault_addr) == _reservesOf[token]`

* ci: warnings

* fix: avoid duplicated balance changes

* fix: order by ordinal

* chore: format

* feat: extract new contracts before extracting balance changes

* feat: skip unnecessary steps if no balance change is found

* refactor: filter out account balances for tokens that aren't part of any protocol components.

On the indexer side, when we receive an account balance, we need to know about the token. This commit ensure that the token was introduced before we emit any account balance with it.

* refactor: don't index liquidity buffers.

Liquidity buffers rely on rate providers. Therefore we need DCI (feature to be able to index previously created contract) to deal with them.

* refactor: cleanup tests and add docstrings

* chore: lock tycho-substreams version

* ci: set Foundry workflow to use stable foundry

* feat(DCI): Add DCI Entrypoints to BalancerV3 components (#218)

* refactor: fix typo in weighted_pool_factory_contract name

* feat: add rate_providers static attributes

* feat: add DCI entrypoints to BalancerV3 components

* fix: set default trade price to Fraction(0, 1)

* feat: remove buffers as components

Buffers are to be used internally by Boosted pools (stable/weighted pools that use ERC4626 tokens). They are not to be treated as a separate swap component.

* test: update test blocks

Extend tests some tests block range to ensure liquidity was added to the pool and can be simulated on

* feat: remove buffers as components

Remove balance updates for buffer components

* feat: listen for pool pause/unpause events

* chore: formating

* fix: encoding call data

* test: update Balancer V3 tests to use DCI

* test: set indexer log level to info

* docs: add comment on support of boosted pools

* feat: update balancer v3 package version

---------

Co-authored-by: Thales <thales@datarevenue.com>
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Co-authored-by: Louise Poole <louise@datarevenue.com>
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
2025-06-26 12:19:39 +02:00
greendianasaur
cfbf6812bd chore: Remove old execution and encoding files (#221)
They are unused now. See https://github.com/propeller-heads/tycho-execution for the new workflow
2025-06-24 13:37:00 +00:00
Zach
fb0a57bf07 feat: Add Maverick V2 adapter and substreams (#167)
Co-authored-by: Thales <thales@datarevenue.com>
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2025-05-23 17:07:15 +02:00
kayibal
d49b3f59cb Add new SwapAdapter interface.
This new interface allos the pool id to exceed 32 bytes. Some protocol have more complex pool ids that exceed 32 bytes this adds support for these.

 Additionally, it allows passing additional data if required. This allows more sophisticated features such as fee reduction or potentially offchain data that is required during swap simulation.
2025-03-11 18:39:32 -05:00
Zizou
64ca72cfa9 feat(balancer): add missing weighted factories (#103)
* feat(balancer): add weigthed pool factory v1

* feat(balancer): add weigthed pool factory v2 and v3

* fix(evm): fix compilation bug due to a bugged solc version

---------

Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2024-10-31 11:24:10 +00:00
Domenico
e484ea28ca Sdk implementation: Sfrax adapter and substream (#91)
* feat: initial setup

* feat: implemented getCapabilities and getTokens

* chore: adjusted getPoolIds

* feat: Initial implementation of getLimits()

* feat: implemented getLimits, getTokens and internal functions for amounts

* feat: implemented price

* feat: implemented swap function

* fix and test: fixed minor issues on adapter and setup test

* debugging price function

* fix: debugged price function and fixed getPriceAt function

* test: testOneIncreasingPriceFoundFraxV3SFrax

* fix: debugging and fixing buy function

* fix: fixed getPriceAt

* test: testing post trade price

* fix: Fixed getPriceAt

* fix: Fixed getLimits

* fix: Fixed prices and improved readability

* fix: Fixed price and transfers in swap

* feat: Finished tests

* chore: Changed approve to safeIncreaseAllowance

* feat: created substream for staked frax

* feat: remove useless files

* feat: fixed dependencies in cargo.toml

* feat: rename folder

* feat: updated cargo.lock

* feat: changed lib.rs, added modules.rs

* feat: update modules.rs with corrects addresses

* feat: rename folder in ethereum-sfrax

* feat: remove useless comments, change locked asset address, rename

* feat: undo changes on mod.rs in ethereum-balancer

* feat: rename variable

* feat: update substreams/cargo.toml

* feat: modify ristfmt.toml

* feat: performed code formatting

* feat: modify src/abi

* feat: performed formatting with nightly

* feat: fix addition opeation

* feat: adjust code with for i, f

* feat: performed fmt inside ethereum-sfrax folder

* feat: performed clippy

* feat: fix with clippy warning suggests

* feat: undo any change in ethereum-balancer

* feat: change stakedfrax_contract.rs

* fix: stakedfrax_contract.rs

* feat: add blank line

* feat: add #[allow(clippy::all)] on ethereum-sfrax/src/abi/mod.rs

* feat: update comments on pool_factories.rs

* feat: update cargo.toml and substreams.yaml

* feat: add tycho evm in pb folder

* feat: add params to take contracts' addresses

* feat: add logic to map rewards_cycle

* feat: performed fmt and fix versioning

* feat: remove useless functions

* feat: add logic to track rewards_to_distribute

* feat: passing CI

* fix: substreams.yaml

* feat: fixed params in manifest

Co-authored-by: mrBovo <bovo.ignazio@proton.me>

* feat: fixed error in map_relative_balances function

* feat: passing CI checks

* fix: 🐛 hex-binary address encoding + refactoring vault-> underlying map

* style: 💄 fix formatting

* feat: Implemented testPoolBehaviour

* alignment with propeller main

* Update forge-std submodule reference to include ds-test

* files update to match propeller/main

* creating integration_test fir sfrax

* fixed FraxV3SFraxAdapter.sol import paths

* updated with correct addresses FraxV3SFraxAdapter manifest.yaml

* updated sfrax manifest.yaml

* updated to support sdk

* integration_test sfrax updated

* fix: 🐛 add reward processing

* chore: ♻️ minor cleanups

* fix: Fixed adapter limits

* fix: fix adapter and substream sdk tests

* fix: Fixed CI errors

* chore: fmt

* chore: Removed unused line

* fix: Fixed clippy warnings

* chore: formatted with rustup

* chore: Removed unused line

* chore: post-build formatting

* chore: Formatting using different toolchain vesion

* chore: 💄 format

* chore: 💄 format 2

* chore: Using static address for frax

* feat: Added second constructor param for sfrax

* fix: Fixed limits on frax sell

* chore: Fixed merge conflict with sfraxeth

* chore: Remove sfraxeth_contract changes

* chore: Fixed EOFs

* fix: Fixed fmt on stakedfrax contract

---------

Co-authored-by: mp-web3 <mp.web3.t@gmail.com>
Co-authored-by: gabrir99 <gabri.ruini@gmail.com>
Co-authored-by: mrBovo <bovo.ignazio@proton.me>
Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>
Co-authored-by: mrBovo <bovoignazio.dev@gmail.com>
Co-authored-by: Mattia <mp.web3@gmail.com>
2024-10-25 18:53:06 +01:00
Mattia Papa
3013cd9bfd Sfraxeth adapter and substream with SDK integration (#87)
* first commit

* feat: implemented get tokens and improved modifier

* feat: added missing functions (to implement)

* feat: implemented getPoolIds

* feat: implemented getCapabilities

* feat: implemented getLimits function

* fix: fixed constructor

* feat and fix: implemented testGetLimitsFraxEthV3 and fixed getLimits

* feat: implementing getPriceAt function

* feat and fix: finished implementing getPriceAt, fixed modifier

* feat: price function and tests implemented

* fix: removed onlySupportedTokens modifier from getPriceAt and applied it in price and swap function

* feat: implemented sell, buy, and swap functions

* implementing final tests

* aligned with main branch

* fixes

* fix: Review Fixes

* feat: 🎨 sfraxeth substream initial scaffolding

* fix: 🎨 protocol component creation at deployment block

* build: 💚 cargo build

* feat: 🎨 map proper event to balance changes

* fix: 🚚 remove unnecessary files

* fix: 💚 ci checks

Due to the CI checks requiring the latest rust nightly, the rust-lang organisation
introduced new doc related rules. This commit fixes the CI errors by making
the necessary changes to the comments in substreams-balancer comments

* fix: 🐛 wasm output name

* fix: 🐛 update starting block = deployment block -1

* feat: 🎨 add store for reward cycles and update balances accounting after after deposit before Withdraw

* feat: 🎨 finish setting up block reward logic

* docs: 📝 add comments on extra module

* build: 📌 adapt dependencies to workspace dependencies

setting prost-types to workspace version causes build errors

* feat: 🎨 add support for several EVM compatible networks

* fix: 🐛 update balance delta accounting logic following the `NextRewardCycle` event only

* fix: 🐛 hex address string param encoding

* fix: 🐛 deployment transaction check

* ci: 💚 ci check passing

* fix: 🐛 issues with hex-binary encoding

* refactor: ♻️ address mappings for various networks

* fix: 💚 formatting

* feat: Implemented testPoolBehaviour

* chore: Removed unused comments

* feat: ⬆️ update to recent sdk

* feat: 🎨 testing setup

* test:  setup test environminte for sfraxeth

* fix: 🐛 unwrap error in map_protocol_changes

* build: ⬆️ update rust version

* build:  remove unnecessary deps

* build: 🚚 remove unnecessary pb/tycho

* fix: 🐛 remove balance owner attribute

* fix: 🐛 remove unnecessary static attributes

* fix: 🐛 remove manual updates

* fix: 🔥 remove unused data model from contract.proto

* fix: 🐛 filter by known components

* feat:  use store delta for reward change accounting

* refactor: ♻️ remove shallow create vault component

* feat:  replace is_deployment_tx logic with simpler txn match

* test:  manual testing with inspection against etherscan

https://etherscan.io/address/0xac3E018457B222d93114458476f3E3416Abbe38F#events

* ci: 💚 ci checks

* fix: 🐛 map_protocol_components output data

* fix: 🐛 output type on map_protocol_changes

* test: 🧪 skip balance checks

* fixed FraxV3FrxEthAdapter arguments for constructor in manifest.yaml

* fix: 🐛 adapter error with overflow/underflow and addresses

* restore: restored previous adater version

* fix: set minimum swap amount to prevent overflow/underflow

* fix: set minimum swap amount only for sfrxETH -> frxETH

* improve: added print block_number to runner.py when get_amout_out fails

* removed console.log

* alignment with propeller main

* Update forge-std submodule reference to include ds-test

* installed protosim_py 0.21.0

* commented out minimum swap amount for sfrxEth -> frxEth pair

* updated adapter limits

* working on fixes

* fix: Adjust getLimits according to protocol limitation.

Previously limits were estimated with token supplies, this commit simplifies limits and adjusts them so they correspond closely with what is supported by the sfrxETH contract.

* chore: fmt

* wip: Changed ubuntu to 20.04, fmt adapters

* wip: Updated python tests

* wip: Trying with ubuntu: latest

* chore: fmt adapters

* wip: Using ubuntu 20.04

* chore: Switched back to ubuntu-latest

---------

Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>
Co-authored-by: domenicodev <domenico.romeo3919@gmail.com>
Co-authored-by: kayibal <alan@datarevenue.com>
Co-authored-by: domenicodev <domenico.rom3@gmail.com>
2024-10-23 14:17:45 +01:00
kayibal
3a93a55a46 doc: fix formatting 2024-10-23 13:00:59 +01:00
kayibal
f129f217e5 docs: Document the meaning of limits array 2024-10-23 10:45:22 +01:00
kayibal
42f66c22cf docs: Document the meaning of limits array 2024-10-23 10:44:53 +01:00
zizou
d3cfc5d509 fix(evm-compilation): enable via IR
This is needed to compile Curve executor.
2024-10-07 10:32:44 +02:00
Diana Carvalho
a6caf84f55 feat: Add execution for curve
- Add CurveSwapStructEncoder and tests
- Add CurveSwapExecutorExposed and tests
  - Add needed interfaces

#time 0m


#time 0m

#time 0m
2024-09-05 13:19:31 +01:00
Diana Carvalho
813f0fe9c8 chore: Rename SwapExecutorTest 2024-08-26 11:57:36 +01:00
Diana Carvalho
e49af99b1f chore: Add BalancerSwapExecutor 2024-08-23 18:24:34 +01:00
Diana Carvalho
299a872160 feat(ISwapExecutor): Add ISwapExecutor and docs 2024-08-22 16:17:06 +01:00
Florian Pellissier
bc2cd6bab2 refactor(testing): miscellaneous improvements and bugfixes
Includes bugfix on `tycho-indexer-client` and `protosim_py`, a script to simplify setting up testing python env and cli improvements. Also add support for building runtime for SwapAdapters with many args that was bugged before.
2024-08-19 11:56:52 +02:00
Pierre
b3e3672172 Revert "ENG-3406: Add new bytes parameter to swap" 2024-08-08 22:24:35 +02:00
PierreMkt
07ca52b2ff chore(adapters): Address PR review
keep mock data as empty bytes
2024-08-05 13:56:28 -04:00
PierreMkt
36c7e94e00 Merge branch 'refs/heads/main' into pm/eng-3406-add-swap-bytes-param 2024-08-05 10:44:55 -04:00
czanella
1ab96ce292 Update other failing tests 2024-08-05 10:32:43 +01:00
czanella
30bd0c2a5c Fix some assertions in integration test
The foundation is:
marginal price > executed price > price after swap.

And this check is verified for multiple amounts
2024-08-03 10:54:25 +01:00
czanella
9411fc2b67 Discount fees from USV2 getPriceAt logic
add marginal price capability
2024-08-03 10:53:25 +01:00
PierreMkt
6f41147f91 feat(adapters): decode reduceFee bool from bytes data
TODO: apply reduce fee logic
2024-08-02 12:49:37 -04:00
PierreMkt
ec903734e0 test(adapters): Fix balancer getCapabilities test
returns HardLimits too
2024-08-02 12:00:54 -04:00
PierreMkt
034d5ac8c2 feat(adapters): Add new bytes parameter to swap
that allows arbitrary data to be passed
2024-08-02 11:55:00 -04:00
kayibal
ac22ed583f fix(balancer): Support ComposableStablePools on SwapAdapter.
Add support for CSP pools. The main issue here was that Limits for BPT tokens would be too high since the pool has the complete supply of the token preminted.

Not quite sure if the limit for buying the BPT token is set correctly but I guess you can try to buy the whole supply.
2024-07-29 15:25:30 +01:00
czanella
1f509897ef Make balance hard limits work correctly. Add back capability 2024-07-19 10:27:36 +01:00
czanella
260fd7fbb5 Address PR review 2024-07-19 09:16:42 +01:00
czanella
772566c590 Add marginal price capability and update integration tests
Balancer now passes the test
Some misc aesthetics
2024-07-18 16:12:50 +01:00
czanella
5831aecc96 Implement adapter integration test and use it on uniswap and balancer 2024-07-17 15:03:31 +01:00
Florian Pellissier
9e851534ce fix(script): Fix build runtime script to handle empty constructor 2024-07-17 10:37:16 +02:00
Louise Poole
cf7516df25 Format 2024-04-15 17:42:30 +01:00
Louise Poole
45dc7aa457 Fix prices function 2024-04-15 17:41:16 +01:00
Louise Poole
306293764c Fix tests 2024-04-15 16:56:19 +01:00
Louise Poole
98857be305 Fix balancer price and capabilities 2024-04-15 16:18:48 +01:00
pistomat
1b2e183a85 Remove test console logs 2024-04-13 11:17:03 +00:00
pistomat
54e4c9f92e chore: forge fmt 2024-04-13 11:11:34 +00:00
pistomat
1738ca7bd2 Fix merge issues 2024-04-13 11:11:20 +00:00
pistomat
9ba2286826 Merge pull request #23 from propeller-heads/mp/formatting
Fix the format check CI
2024-04-13 10:12:41 +00:00