$200 to $15k with LUNA

Victor Evangelista

Victor Evangelista / Oct 28, 2022

Crypto • 4-minute read

Luna Chart

It was a beautiful sunny afternoon in Mountain View, CA on May 12th, 2022. That’s when my phone began blowing up, sparking 48 hours of trading and coding.

LUNA had plunged 99% from its all time high price of $116 all the way down to $0.006! Clearly, this was a historic moment in the crypto world.

Prefacing for the Uninitiated

There were plenty of stories of people losing money buying the dip. This begged the question, “How can I enter with the lowest possible risk?“.

Over the course of the following 48 hours, some friends and I monitored LUNA meticulously. It didn’t take long to notice the supply of LUNA had gone from 350 million tokens to 6.5 trillion. Hyperinflation. The $40 billion market cap now sat at a measly $1 billion and decremented by the minute.

It wasn’t until 5:15 AM the next morning I saw it- the lowest possible entry I could imagine, and may ever see. At a price of 0.0000000002 BTC, or $0.000006 USD, the market cap of LUNA sat at $39 MILLION. There was no time to lose throwing in some gambling money, or about $200 (regret).

I was able to nab about 35 million LUNA. Over the next two days, the price of Luna began skyrocketing thousands of percent points, where I eventually sold LUNA at about $0.0003 for $9,000. However, that doesn’t add up to $15k!

What About the Other $6,000?

Have you ever heard of arbitrage?

Explained simply, it’s the concept where an asset is traded in two or more markets taking advantage of their price differences to generate profit. Buy low sell high! When LUNA crashed, ALL of the Terra ecosystem crashed, including assets from the Anchor Protocol, and Astroport.

In some instances, the price of ASTRO was 4 TIMES higher on traditional centralized exchanges like CoinEx and MEXC. As the price of Terra assets dropped on the network, centralized exchanges failed to catch up.

Whoever spotted the arbitrage opportunity and traded first won, and bots are fast. We needed a way to compete.

Spoiler alert, the rest came from arbitrage trading. After setting aside about $2,000 of the initial profit for arbitrage trading, the additional profits were about $6,000.

Hacking Together a Trading Bot

I’m going to go over this at a high level.

For an arbitrage trading bot to function, it needs access to buying, selling, and withdrawing assets. Unfortunately, most exchanges halted the withdrawal of LUNA on D-Day. I got around this by purchasing WLUNA on Uniswap (Decentralized Exchanges FTW).

The steps to manually get LUNA off of an exchange for more flexibility were as follows:

  1. Sell LUNA and purchase ETH on the market.
  2. Move ETH to an Ethereum wallet.
  3. Buy WLUNA on Uniswap with Ethereum wallet.
  4. Transform the WLUNA to regular LUNA via Mirror Protocol.

For the sake of speed, we would need to manually create some strategies for specific pairs to be prepared for. I had two:

  1. Buying ASTRO on Astroport for cheap and selling on MEXC or CoinEx for profit
  2. Buying ANC on Astroport for cheap and selling on MEXC or CoinEx for profit

Now onto the bot flow:

  1. We need access to the current prices of the coins we’re watching across multiple markets. We can to do this by pinging the following intermittently:
    1. MEXC API
    2. CoinEx API
    3. Astroport Contract
    4. Locked down market API
  2. Aggregate prices, and determine if there’s an arbitrage opportunity.
    1. Is there a price discrepancy of at least 20% between a pair of exchanges?
    2. If so, begin. Otherwise, continue pinging for prices.
  3. Initiate the arbitrage trade.
    1. Verify there are sufficient funds on the Terra Wallet.
    2. Buy ASSET via LUNA/ASSET pair on Astroport via swap.
    3. Withdraw ASSET from Terra Wallet depositing to the target market.
    4. Sell ASSET for UST on target market.
    5. Send UST to locked down market.
    6. Trade UST to USDT on locked down market.
    7. ???
    8. Profit!

An example of the process:

  1. Buy ASTRO with LUNA on Astroport
  2. Withdraw ASTRO from Terra wallet depositing to MEXC
  3. Sell ASTRO for LUNA on MEXC for UST.
  4. Send UST to locked down market.
  5. Sell UST for USDT on locked down market.

All in all, I definitely should have put in more. 😄


Related Article