Breaking Down Axelar GMP Transactions on Squid (+ Accounting & Tax Implications)
Composability is one of the most intriguing and magical visions of web3 architecture. But this interstellar web of applications isnât just a dream parroted by anonymous developers - with Axelarâs General Message Passing (GMP) service, itâs a reality on 30+ live blockchains. Now, users can initiate a contract call on one blockchain and execute it on another chain, enabling complete cross-chain communication for any chains that implement the GMP stack. In this article, weâll be diving into GMP basics, an example cross-chain swap, and accounting & tax implications of this new tech.Â
What is Axelar GMP? âĄ
GMP (general message passing) allows users to send messages (also called payloads) securely and efficiently between different chains. There are two main messages that can be sent through GMP:
- callContract() â call a contract on chain B from chain A
- callContractWithToken() â call a contract on chain B from chain A and attach tokens
The âsource chainâ is the original chain (Chain A) where the smart contract is being called, and the âdestination chainâ is the final chain (Chain B) where the transaction is settled. To ensure the messages donât get lost in translation, Axelar protocol sits in the middle and validates these messages as they are relayed. The Axelar docs depict a simplified flow here:
Gateways are smart contracts that pass messages between the source DApp, Axelar protocol, and the destination DApp. The gateways are crucial since validators on Axelar are constantly reading & monitoring these gateway contracts for new messages. Once a message is noticed, validators on Axelar examine the transaction, vote on its legitimacy, and pass on the instructions to the gateway on the final chain. All of the benefits of the proof-of-stake model (i.e. network security through staking to validators, efficiency) are baked into the GMP design.
Not featured in the diagram is the role of relayer addresses. These accounts listen to the gateway contracts to see which messages have been approved via the voting mechanism on Axelar. Once approved, the relayers help the message execute on the destination network (think of them as executive assistants to the gateways!). There are two main relayers: normal and express. If users pay additional fees, their transaction can be settled using the express relay, which cuts down execution time to seconds instead of minutes. If the user is less sensitive about settlement times, they can skip the additional fee and use the normal relayer to get their message across. The express relayer contains much higher liquidity ($445k USD versus $77k USD as of 12/26/23) since it makes temporary loans to end users in order to expedite their transaction (more information on this later).
Axelar also built a nifty gas fee service contract. Executing transactions across multiple chains can get pricey, so Axelar allows users to prepay for gas up front in the native token on the source chain (all of the gas estimates & conversion happens on the backend). Any unused gas is refunded to the customer through the gas contract. If the gas cost is higher than expected, Axelar eats the difference and takes a loss.
In our example, weâll be looking at Squid, an application that enables cross-chain swaps and bridging through GMP. The Squid contracts interact seamlessly with the GMP gateways and relayers to make liquidity across the universe possible.
Cross-Chain Swaps Through Squid đ
For a video overview of this section, see this Loom video that I created!
Besides having an adorably squishy name, Squid protocol is also a useful and sleek DApp powered by Axelar GMP. The basic UI looks like this:
Squid allows users to swap assets across chains using Axelar GMP architecture under the hood. Squid also has the option to âboostâ transactions, which is code for using GMP Express to fasttrack the settlement times. Per Squid, âBoost (GMP Express) is a special feature of Axelar and Squid that reduces transaction time across chains to 5-30 seconds.â Another feature is âarrival gasâ, which swaps a portion of a userâs tokens for native gas on the destination chain.
I recently executed an example transaction to see how the tokens and smart contracts were flowing. By toggling on the âhistoryâ panel of Squid, I accessed the axelarscan block explorer link, which shows the full journey of my test transaction:
My test transaction was swapping 1.1 FTM on Fantom for 0.334015 axlUSDC on Optimism (both EVM compatible chains). The transaction skipped a few steps and settled quickly because I enabled the boost (aka GMP express) on Squid. The virtual voyage can be broken into the following steps:
Step 1: Sent - ContractCallWithToken() initiated on Fantom chain
In this transaction on the source chain, Fantom, 1.1 FTM is leaving my test wallet and heading into the Squid router contracts (0xce16F69375520ab01377ce7B88f5BA8C48F8D666 and 0x4fd39C9E151e50580779bd04B1f7eCc310079fd3). Since native tokens like FTM and ETH canât be used directly in DeFi, Squid is first wrapping my FTM into WFTM. From there, the WFTM is swapped for Orbs (an intermediate token since thereâs no direct pool for WFTM and axlUSDC), which is finally swapped for 0.334015 axlUSDC via Uniswap. The axlUSDC is sent to a null address (0x00âŠ) signifying its burn on the Fantom blockchain.
This transaction is also capturing the gas fee that my address is paying for all the subsequent events to come (i.e. validating on Axelar, settling on Optimism, GMP express, etc). 5.1923 FTM is exiting my wallet and entering the Axelar: Gas Service contract. From here, Axelar is converting that FTM to all of the native gas needed for all future activity related to this payload. Axelar documentation lists all the gateway contract addresses and gas service addresses for all connected chains - if you head to Fantom (Chain ID: 250), the gas service contract is 0x2d5d7d31F671F86C782533cc367F14109a082712, which ties to fantomscan.
In order for this transaction to settle on Optimism, Squid needs to interact with the gateway contract on Fantom. A message needs to drop into the gateway so Axelar (layer one protocol) can read it and kickstart the verification process. Per the docs, the gateway contract on Fantom is 0x304acf330bbE08d1e512eefaa92F6a57871fD895 - although this address isnât present on the âoverviewâ tab, itâs present all over the âlogsâ tab of the same transaction:
To recap step 1:
Step 2: Gas Paid - Gas estimate sent into the gas service contractÂ
The gas process is reviewed above (the first two steps involve the same transaction hash).
Step 3: Express Executed - Transaction settles superficially using GMP express
We made it to Optimism! Since we used the âboostâ feature on Squid, this step of the transaction looks a little different than a normal swap:
The âfromâ address is 0xe743a49f04f2f77eb2d3b753ae3ad599de8cea84, which is the address of the express relayer referenced in part one. This address is the helper account that smooths the GMP process and ensures tokens land in the right place. The 0.334015 axlUSDC passes from the relayer into the Squid address and from there, finally swims into my address. On the âlogsâ tab, the first function thatâs being called is ExpressExecutedWithToken(), and it breaks down the source chain, source address, unique payload hash for the transaction and the token symbol.
This step is the temporary loan mentioned above. The axlUSDC hasnât actually journeyed to Optimism yet - rather, the express relayer is dipping into its own pocket to front the swap. My address gets the 0.334015 axlUSDC, but technically the relayer is still owed that amount from Squid at a later date.
Step 4: Confirmed - Axelar blockchain reviews the transaction for legitimacy
Going back to our original diagram, weâre now in this step of the process:
Our swap is in the belly of the layer one protocol, Axelar. We need this step so that reputable validators on Axelar can confirm the transaction is legitimate and secure. Validators vote using their stake weight and give the approve/deny verdict once theyâve examined the payload coming from the gateway contract (in our example, Stakin is reviewing our swap). Once validated, Axelar talks to the gateway contract on the destination chain:
Step 5: Approved - Axelar approval is communicated to the destination chain
In this step, the gateway on the destination chain receives the approval from Axelar network (the âpayload is marked as approvedâ). From here, the transaction can be settled and the express relayer can receive its loaned tokens back.Â
Step 6: Executed - Temporary loan is repaid to the express relayer
The saga of the rogue axlUSDC tokens is complete! The normal relayer account (0xd36aac0c9676e984d72823fb662ce94d3ab5e551) interacts with the Squid router to send the principal amount of axlUSDC back into the express relayer account. The ExpressExecutionWithTokenFulfilled() function is called on the Squid contract and finally, all parties are satisfied. If express GMP wasnât used, this step would be sending the swapped tokens into my wallet, instead of the loan repayment (and step 3 wouldnât exist).
The cross-chain swaps get hairy quickly, but itâs important to remember the diagram from step one. Squid is a cousin to Uniswap and Sushiswap - it simply has additional functionality that accesses a broader range of blockchains. With this innovation, crypto is inching closer to the multi-chain future we envisioned years ago. âš
Accounting & Tax Implications on Squid đ§ź
This section will be pithy since thereâs nothing tricky to add here - Squid is a platform for swaps, so the accounting and tax rules are the same as normal swaps. Translated to USD, the standard swap entry is:
Crossing blockchains conveniently doesnât change the entry since the assets arenât new; rather, the underlying technology is. Gas fees are expensed as incurred and also include a gain/loss component.
The tax side is similarly banal. Any gain/loss is a capital in nature and subjected to the holding period netting rules. Gas fees are normal deductions for businesses and nondeductible for hobbyists playing around with GMP for fun (as we all do!).
Life is a (GMP) Highway đ
The beauty of GMP is how efficient it is. Digital assets are not physically moving between chains - rather, data and function calls (the âpayloadsâ) are. This dramatically reduces settlement times / gas fees and is also more secure (i.e. thereâs not a herd of assets waiting to be exploited in a bridging contract). GMP functionality is complex yet extremely effective, and weâre excited to use it more in the future. To dig even deeper, we recommend these resources:
- Contract addresses across all connected chains
- Intro to GMP
- Squid contract addresses
- Express relayer address
- Normal relayer address
- Documentation on how the express relayer works
- Example Squid transaction with a refund
Happy GMP-ing!