@mean-finance/call-simulation

0.0.2 • Public • Published

Call Simulation

It's fairly common to try to predict what a transaction might return, or how it would affect other contracts. There are many ways to do so, ranging from complex solutions like Tenderly or Alchemy, to simple static calls. One popular way is through the use of Multicall, which allows to group many different calls into one, therefore avoiding being rate limited by RPCs.

However, there is one area where Multicall might not be the best solution. For example, if you tried to simulate multiple swap transactions to figure out which one would yield better results, a Multicall won't work. Since the first call would modify the storage and transfer tokens between accounts, it could happen than all other quotes would fail. However, it would be interesting to be able to simulate these quotes without actually affecting the state.

And that's where this repository comes into place. The idea is to give existing contracts the ability to simulate calls in a stateless way, so that they can be run independently from each other. Also, it provides the ability to simulate these calls similarly to a Multicall, so as to avoid issues with RPC rate limiting.

Usage

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ pnpm lint

Test

Run the tests:

$ forge test

License

This project is licensed under GLP 3.0.

Package Sidebar

Install

npm i @mean-finance/call-simulation

Weekly Downloads

83

Version

0.0.2

License

none

Unpacked Size

45.2 kB

Total Files

9

Last publish

Collaborators

  • fiboape
  • sambugs
  • 0xged
  • alejoamiras
  • nchamo