# How Does the Grok Token Exploiter Exploit the X Token By Baking His Own Cake And Eating it?

### Strategy One Liner

The bot utilizes the methods of the ERC20 X token to create the arbitrage opportunity between a Uniswap V2 pool and a Uniswap V3 pool, and takes advantage of it, making a profit of $4,844.

### Big Picture

EigenTX Link: <https://bit.ly/3xMOYIt>

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FD2003OvUMDAGebKY91kt%2Fimage.png?alt=media&#x26;token=70f88078-ec80-428d-9d9e-3b52e2b620da" alt=""><figcaption></figcaption></figure>

### Key Steps

**Stage 1: Prep the Uniswap V2 X-WETH pool.**

Step 0: Borrow 6,493,128,478.6032 X from the Uniswap V3 pool of X-WETH.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FmFq0QHvR7y6jhDaedzeU%2Fimage.png?alt=media&#x26;token=3afa8928-f3eb-4bab-9725-2c0b9c975809" alt=""><figcaption></figcaption></figure>

Steps 1-6: Swap 3,431,282,845.8058 X for 23.4081 ETH at UNI-V2, and transfer 34,659,422.6849 X back to X contract as a 1% tax.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2Fw0HrWQPCvOsI3UFMAQic%2Fimage.png?alt=media&#x26;token=345a1b50-e4f0-4603-b56f-267d64f224d4" alt=""><figcaption></figcaption></figure>

Steps 7-12: Swap 34,312,828.4581 X for 0.2006 ETH at UNI-V2, transfer 346,594.2268 X back to X contract as a 1% tax.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FmNTx0VUkg8k5sTCc43e0%2Fimage.png?alt=media&#x26;token=afc2a737-d77b-41fc-8128-1ab462cb8b07" alt=""><figcaption></figcaption></figure>

**Stage 2: Overflow the X contract to create the arbitrage prospect.**

Step 13: Transfer 2,827,595,502.6415 X back to the X contract, bringing the balance of the X token of the X contract to 10,000,346,595.226849.

![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F616519bf-5fcd-443d-b4d6-abcdfe3c769a_1362x275.png)

The simulation on Blocksec shows the effect.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FGe1f3pbabTegiOiFKqKt%2Fimage.png?alt=media&#x26;token=aa3e2757-43a0-4f4b-a1ae-78b3a7cad52b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FOuSHqS9Tsx3dtLmKm7YA%2Fimage.png?alt=media&#x26;token=f48334fb-c000-404f-9f13-157df2ff8e6a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2F3yukd3zwMVT4P7AFAdcQ%2Fimage.png?alt=media&#x26;token=e9fdd4c3-645d-4882-a4c0-ff182359794a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FcGanivSCKZCqp6JgVfbd%2Fimage.png?alt=media&#x26;token=0f8508bc-7079-4e1c-a2f4-5d870dddfe95" alt=""><figcaption></figcaption></figure>

Steps 14-26: Swap 99,000,000 X for 0.2892 ETH at UNI-V2, and transfer 1,000,000 X back to X contract as a 1% tax.

The swapping of X for ETH this time triggers an internal function, X.shouldContractSwap(), returning true, which is the result of the code below:

```
 aboveThreshold = balanceOf(address(this)) >= swapThreshold;
```

The transfer in step 13 satisfies the condition: the balance of X is bigger than the threshold of 10,000,000,000. Before step 13, this code returns False.

You can find it in [the contract of the X token](https://etherscan.io/address/0xa62894d5196bc44e4c3978400ad07e7b30352372#code).

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FkFdOXGKMvIRM8AGhD7B9%2Fimage.png?alt=media&#x26;token=f836aa31-cf0a-466b-95eb-da4aa86df1b8" alt=""><figcaption></figcaption></figure>

Next, the X contract injects 10,000,000,000 X tokens into the Uniswap V2 pool and puts the received ETH to its deployer’s EOA.

**This huge injection of X inflates its value, causing the exchange rate of X against ETH to surge to 342,323,651 X per ETH. The price gap between this Uniswap V2 pool of X-ETH and the Uniswap V3 pool of X-WETH.**

We can split the steps of 14 to 26 as below.

Steps 14-18: X contract transfer 10,000,000,000 X to UNI-V2 and swap X for 41.3756 WETH, unwrap WETH and transfer ETH back to X

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FfR6vEZ0pVetp599F9S23%2Fimage.png?alt=media&#x26;token=26cee61f-1453-4afa-887e-fe5574277ee6" alt=""><figcaption></figcaption></figure>

Steps 19-20: X contract transfer 20.4830 ETH and 20.9020 ETH to an EOA address

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FCqO5WlKAmWIpP1HfISmU%2Fimage.png?alt=media&#x26;token=513d8152-2c24-4c15-b794-82d413cd4598" alt=""><figcaption></figcaption></figure>

Steps 21-26: *To* address finishes the swap operation at Uniswap V2 pool and pays tax.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FOFBbaI5U83BfNNOEB8x2%2Fimage.png?alt=media&#x26;token=56066156-aade-423a-8907-15907a730696" alt=""><figcaption></figcaption></figure>

**Stage 3: Harness arbitrages.**

Step 33: *To* address repays the flash loan, 6,558,059,763.3892 X, to the Uniswap V3 pool of X-WETH.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FzYVZQw5uPXvBMek2KqbF%2Fimage.png?alt=media&#x26;token=37da79fb-b82c-4e87-a21f-6b5528645d70" alt=""><figcaption></figcaption></figure>

Steps 34-39: *To* address swaps 31,457,966.2838 X for 0.1402 ETH at the Uniswap V2 pool, transferring 317,757.2352 X back to X contract as a 1% tax.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FMr1f2ZtaK14PAAyLqycG%2Fimage.png?alt=media&#x26;token=979c54da-2578-4eee-8db7-fe2feb132e34" alt=""><figcaption></figcaption></figure>

Step 40: Borrow 5.1598 WETH from a new Uniswap V3 Pool of USDC-ETH.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2Fz6phGnDl2oRC0b8y81bZ%2Fimage.png?alt=media&#x26;token=3743b9e3-f2e6-4c94-8320-b61a8b65a326" alt=""><figcaption></figcaption></figure>

Steps 41-48: To address swap 5.3 ETH for 1,123,530,803.0087 X at the Uniswap V2 pool, which transfers 11,348,795.99 X back to X contract as a 1% tax.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2Fe9GJZusVR16V0qCaUxTf%2Fimage.png?alt=media&#x26;token=f00c9489-f67d-4bf0-ac31-958a92a58a72" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2Fexm3XmN2hf6FxAd2qtj5%2Fimage.png?alt=media&#x26;token=fc514ae6-9598-464f-a080-398ab0e46a77" alt=""><figcaption></figcaption></figure>

Steps 49-50: Swap 1,123,530,803.0087 X for 7.8274 WETH at the Uniswap V3 pool of X-WETH.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FApGvORrxVgkxfsjcUwNr%2Fimage.png?alt=media&#x26;token=dd45618b-f63b-4f73-89e8-5c09a2b475c7" alt=""><figcaption></figcaption></figure>

Step 51: *To* address repay the flashloan, 5.1624 WETH, to the second UniswapV3Pool.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2FD5YcfCZvDUMD3cOl9Q0g%2Fimage.png?alt=media&#x26;token=a43fa768-0b85-4674-a517-a62a1f608fcd" alt=""><figcaption></figcaption></figure>

Steps 52-53: Unwrap 2.6651 WETH to 2.6651 ETH.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2F0DRPfuLuNhDGMowcoPsD%2Fimage.png?alt=media&#x26;token=56e7b2a8-7251-41a2-bbcc-4af9db1bafe4" alt=""><figcaption></figcaption></figure>

### Key Assets

X, ETH, WETH

### Simplified Illustration

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2F1OLRCjwTvRvIQ1GS8Bn7%2Fimage.png?alt=media&#x26;token=fada9999-fa6a-4b05-a128-041da28a40ea" alt=""><figcaption></figcaption></figure>

### More Details

* From [the contract page on Etherscan](https://etherscan.io/address/0x2256e6a917e3909d5db8796f756a6c25348bf83f), we can see the EOA labeled as GROK Toekn Exploiter did all the transactions.

<figure><img src="https://2783121027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6mxU4QYtlg9O3vnppqQm%2Fuploads%2Fq9IB8UkHANKNUKApSuEN%2Fimage.png?alt=media&#x26;token=2dd4090f-8488-4e81-baef-0648a75e677c" alt=""><figcaption></figcaption></figure>

* 2 transactions involving SPIKE utilized the same strategy to do arbitrages. You can find [more details](https://eigenphi.substack.com/i/146452249/what-about-the-spike) here.&#x20;
