GMI USDC Zap

How USDC Gets Zapped to GMI

When a user with USDC hits the Deposit button on the GMI front end, a data payload is built for use in a multicall that gets sent to the GMX Architecture. This payload includes the specific GM token that the USDC will be exchanged for. This is automatically determined in the GMI front end logic, which picks whatever GM asset currently has the lowest deposit fee. The specific contract that is then called within GMX is the ExchangeRouter. From here, tokens are transferred to the DepositVault. Here is an excerpt from the GMX V2 docs: "To create a deposit, tokens need to first be transferred to the DepositVault, ExchangeRouter.createDeposit can then be called after. The transfer of tokens and the calling of ExchangeRouter.createDeposit should be done in a single transaction, otherwise the tokens may be transferred out by other users." One of the parameters in the createDeposit() call is a callbackContract address. This callbackContract is our GMIZap contract, which has an afterDepositExecution() function. Once the USDC tokens have gone through a series of trials, tribulations, and obstacles to get into the GMX vaults, the GM asset tokens along with some event data are sent to the GMIZap contract and the afterDepositExecution() function is called. This function finally calls the deposit() function on the GM Index, and the GM tokens are deposited.

Last updated