TWAMM streams
Available on Go-Gateway and Cloud API
Time-weighted automated market makers aka TWAMMs (pronounced "tee-wham") are a special class of AMMs that execute orders over multiple blocks, a concept introduced by researchers at Paradigm together with the inventor of Uniswap.
TWAMMs aim to help traders on Ethereum execute large orders with minimal slippage and low gas fees without negatively affecting the price. The first, and currently only, TWAMM by Cron Finance.
Each TWAMM instance facilitates trading between a particular pair of assets, for example, ETH and USDC. The TWAMM contains an embedded AMM, a standard constant-product market maker for those two assets. Traders can submit long-term orders to the TWAMM, which are orders to buy or sell a fixed amount of one of the assets over a fixed number of blocks.
The execution of long-term orders pushes the embedded AMM's price away from prices on other markets over time. When this happens, searchers can trade against the embedded AMM's price to bring it back in line, ensuring good execution for long-term orders.
Users of bloXroute TWAMM services are entitled to a discounted fee (see details below). The discounted fee provides arbitrage opportunities earlier than arbitrage from the mempool without TWAMM discounted fee.
bloXroute provides several new data streams to enable users to see and act fast when opportunities come up. Additional details about the various streams can be found below.
Using the TWAMM bloXroute service will give you access not only to the fastest data stream but also to a 50% TWAMM transaction fee discount.
Payment for the service is 10% of MEV profit to be paid to bloXroute as part of the arbitrage transaction.
- When capturing the arbitrage a searcher should include an internal transaction that is paying 10% of the MEV profit to the bloXroute wallet.
- To ensure faster execution, no check is being done prior to the execution of the transaction. However, searchers that will not comply with the program will be removed from it and will not receive the discount.
- Payment should be paid to the following address: 0x965df5ff6116c395187e288e5c87fb96cfb8141c
This endpoint provides the actual status of each TWAMM instance (also referred to as “pool”).
Response Event
Field | Type | Description |
---|---|---|
blockHeight | uint64 | Current Ethereum block height. |
virtualPool | virtualPool | See virtualPool below for details. |
virtualPool
Field | Type | Description |
---|---|---|
poolID | string | The index id of the pool. |
token0Symbol | string | The symbol of one token in the pool. |
token0Address | string | The address of one token in the pool. |
virtualToken0Reserve | unit64 | The expected reserve amount of one token in the pool, considering the virtual TWAMM events. |
token1Symbol | string | The symbol of another token in the pool. |
token1Address | string | The address of another token in the pool. |
virtualToken1Reserve | unit64 | The expected reserve amount of the another token in the pool, considering the virtual TWAMM events. |
salesRateToken0 | unit64 | The amount of token 0 being sold this block. |
salesRateToken1 | unit64 | The amount of token 1 being sold this block. |
orders | orders | See orders below for detail. |
orders
Field | Type | Description |
---|---|---|
orderID | uint64 | Unique ID for the order. |
sender | string | The initiator address of the transaction. |
tokenIn | string | Swap in token symbol. |
tokenOut | string | Swap out token symbol. |
startBlock | unit64 | The block height where this TWAMM swap started. |
endBlock | uint64 | The block height where this TWAMM swap is expected to be finished. |
Event Example
{
"blockHeight:16799598",
"pool": {
"poolID": "0x69269Fe1945e018727Dd301790a465E357a9063B",
"token0Symbol":"USDC",
"token0Address":"0x07865c6E87B9F70255377e024ace6630C1Eaa37F",
"virtualToken0Reserve":85093566,
"token1Symbol":"WETH",
"token1Address":"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"virtualToken1Reserve":18446744073579229056,
"salesRateToken0":"18557",
"orders": [{
"sender":"0xFD59D945c10C6884eB88787E27f3083C6336aB7A"
"tokenIn":"USDC"
"tokenOut":"WETH"
"originalInAmount":10000000
"virtualInAmount":10000000
"startBlock":16799597
"endBlock":16800368
}]
}
}
This endpoint returns any transaction interacting with a TWAMM instance. Including creating new orders, canceling orders, etc.
Response Event
Field | Type | Description |
---|---|---|
blockHeight | uint64 | Current Ethereum block height. |
order | order | See order below for details. |
orders
Field | Type | Description |
---|---|---|
confirmationLevel | string | The confirmation level of the order transaction. The value could be CL_UNKNOWN, CL_NEW, CL_PENDING, CL_BLOCK. |
orderType | string | The type of the order. The value could be OT_UNKNOWN, OT_NEW, OT_CANCEL. |
swapTyep | string | The type of the swap. The value could be ST_LONG_TERM, ST_PARTNER_SWAP, ST_UNKNOWN. |
poolID | string | The index id of the pool. |
sender | string | The initiator address of the transaction. |
tokenIn | string | Swap in token symbol. |
tokenOut | string | Swap out token symbol. |
amount | unit64 | Amount of the swap in token. |
adjustedAmount | double | Amount of the swap in token, converted to human readable with decimals. |
intervals | uint64 | Numbers of the intervals for this order. |
blockCount | uint64 | Number of blocks (derived from intervals) |
Event Example
{
"blockHeight":"8819399",
"order":{
"confirmationLevel":"CL_PENDING",
"orderType":"OT_NEW",
"swapType":"ST_LONG_TERM",
"poolID":"0x69269Fe1945e018727Dd301790a465E357a9063B",
"sender":"0x4836668594Ad7a6bae5ed39Eec1A0eB9e1e01dB6",
"tokenIn":"0x07865c6E87B9F70255377e024ace6630C1Eaa37F",
"tokenOut":"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"amount":"1000000",
"adjustedAmount":1000000,
"intervals":"3",
"blockCount":"771",
"txHash":"0xe2…96d7"
}
}
This endpoint updates on changes to the TWAMM instance, commonly as a result of staking and/or withdrawing funds from the pool.
Response Event
Field | Type | Description |
---|---|---|
blockHeight | uint64 | Current Ethereum block height. |
pool | pool | See pool below for details. |
pool
Field | Type | Description |
---|---|---|
poolID | string | The index id of the pool. |
token0Symbol | string | The symbol of one token in the pool. |
token0Address | string | The address of one token in the pool. |
virtualToken0Reserve | uint64 | The mathematical expectation reserve amount of one token in the pool. |
token1Symbol | string | The symbol of another token in the pool. |
token1Address | string | The address of another token in the pool. |
virtualToken1Reserve | uint64 | The mathematical expectation reserve amount of another token in the pool. |
salesRate | double | The current sales of the tokens. |
Event Example
{
"blockHeight":"8819406",
"Pool":{
"poolID":"0x0000000000000000000000000000000000000000",
"token0Symbol":"USDC",
"token0Address":"0x0000000000000000000000000000000000000000",
"virtualToken0Reserve":"2085217688",
"token1Symbol":"WETH",
"token1Address":"0x0000000000000000000000000000000000000000",
"virtualToken1Reserve":"191837791780446553",
"salesRate":18557
}
}
As of 5/3/2023, there are 2 instances running supported streams for TWAMM, one on ethereum mainnet, and the other on goerli ethereum testnet.
Network | IP |
---|---|
Mainnet Cloud API IP | 54.157.119.190 |
Testnet Cloud API | 47.90.133.153 |
In order to run the streams, you are going to need an authorization header that works with cloud API. Then, follow these instructions:
wscat -c wss://cloud-api-ip/ws -H "Authorization:Auth-header" --no-check
If the IP address and authorization header work, you should see a successful connection response.
Connected (press CTRL+C to quit)
>
Here are some sample commands to use the TWAMM streams (for each stream):
{"id": 1, "method": "subscribe", "params": ["virtualPool", {"include": ["0x28d56210D3682F89dD3AF3542F7a05259358bb22"]}]}
{"id": 1, "method": "subscribe", "params": ["orderPool", {"include": ["0x28d56210D3682F89dD3AF3542F7a05259358bb22"]}]}
{"id": 1, "method": "subscribe", "params": ["orderPool", {"include": []}]}
The virtualPool and orderPool stream allow you to specify different pools you want to subscribe to by their pool address
As of 5/3/2023, here are useful launched pools
0x0018C32D85D8AebEA2eFbE0b0F4a4Eb9e4F1C8C9
USDC/WETH (goerli testnet): https://goerli.etherscan.io/address/0x28d56210D3682F89dD3AF3542F7a05259358bb22#internaltx
0x28d56210D3682F89dD3AF3542F7a05259358bb22
Last modified 1mo ago