Skip to content
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

feat: added docs for multicall [APE-1311] #1617

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ef06fa2
added docs for multicall
Aviksaikat Aug 22, 2023
37a0894
Merge branch 'ApeWorX:main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 23, 2023
e48fece
fix: issues causing dev messages from working on vyper 0.3.9 [APE-132…
antazoey Aug 25, 2023
9ed80f4
Merge branch 'ApeWorX:main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 25, 2023
5c6e35d
made suggested chages
Aviksaikat Aug 25, 2023
ceeb7e1
feat: show plugin name in log messages [APE-1327] (#1628)
antazoey Aug 25, 2023
76181e7
Merge branch 'main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 25, 2023
bd6cf06
Update networks.md (#1629)
0xJchen Aug 28, 2023
66703f0
fix: attempt fixing geth install [APE-1333] (#1634)
antazoey Aug 28, 2023
e456173
Merge branch 'ApeWorX:main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 28, 2023
0e584b3
fix: pluggy (#1633)
antazoey Aug 28, 2023
92b1191
docs for multicall moved to contracts.md
Aviksaikat Aug 28, 2023
eeff46c
Merge branch 'ApeWorX:main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 28, 2023
ddb63ef
fixed mdformat issue
Aviksaikat Aug 28, 2023
3b2eb07
Merge branch 'main' into feat/Add-documentation-for-multicall
antazoey Aug 29, 2023
d6f8e4e
made suggested chages
Aviksaikat Aug 29, 2023
239d3f2
docs: Update docs/userguides/contracts.md
antazoey Aug 29, 2023
371dd32
made suggested chages
Aviksaikat Aug 29, 2023
4e539e2
made suggested chages: method docs removed
Aviksaikat Aug 29, 2023
ad6d440
Merge branch 'main' into feat/Add-documentation-for-multicall
Aviksaikat Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 22 additions & 44 deletions docs/userguides/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ method_id, input_dict = contract.decode_input(bytes_value)
## Multicall

The `ape_ethereum` core plugin comes with a `multi-call` module.
Aviksaikat marked this conversation as resolved.
Show resolved Hide resolved
Yes you're reading this right.
No need to install external modules to do multicall, ape got you covered.
Perform the Multicall call.
This call will trigger again every time the `Call` object is called.

```bash
Raises:
Aviksaikat marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -264,46 +260,6 @@ a, b, ..., z = call() # Performs multicall
result = list(call())
```

### Practical Example

This is a sample example of how you can perform multicall in a real world scenario. This piece of code will perfrom multicall on a `Uniswap V2` pool contract.

```py
from ape_ethereum import multicall
from ape import project

pool = ["0xF4b8A02D4e8D76070bD7092B54D2cBbe90fa72e9","0x80067013d7F7aF4e86b3890489AcAFe79F31a4Cb"]

for pool_address in pools:
uniswap_v2_pair_contract = project.IUniswapV2Pair.at(pool_address)
call.add(uniswap_v2_pair_contract.getReserves)
multicall_result = list(call())

print(multicall_result[0])

# output
[17368643486106939361172, 31867695075486]
```

<!-- ### Encode Multicall Transaction
Encode the Multicall transaction as a ``TransactionAPI`` object, but do not execute it.
Returns:
```js
:class:`~ape.api.transactions.TransactionAPI`
```

```py
from ape_ethereum import multicall

call = multicall.Call()
call.add(contract.myMethod, *call_args)
call.add(contract.myMethod, *call_args)
... # Add as many calls as desired
call.add(contract.myMethod, *call_args)

encoded_call = call.as_transaction()
``` -->

## Multicall Transaction

Create a sequence of calls to execute at once using `eth_sendTransaction` via the Multicall3 contract.
Expand Down Expand Up @@ -336,3 +292,25 @@ a, b, ..., z = txn(sender=my_signer) # Sends the multical transaction
# OR
result = list(txn(sender=my_signer))
```

### Practical Example

This is a sample example of how you can perform multicall in a real world scenario.
antazoey marked this conversation as resolved.
Show resolved Hide resolved
This piece of code will perfrom multicall on a `Uniswap V2` pool contract.

```py
from ape_ethereum import multicall
from ape import project

pool = ["0xF4b8A02D4e8D76070bD7092B54D2cBbe90fa72e9","0x80067013d7F7aF4e86b3890489AcAFe79F31a4Cb"]

for pool_address in pools:
uniswap_v2_pair_contract = project.IUniswapV2Pair.at(pool_address)
call.add(uniswap_v2_pair_contract.getReserves)
multicall_result = list(call())

print(multicall_result[0])

# output
[17368643486106939361172, 31867695075486]
```
Loading