Integrating with gtUSDa
gtUSDa is the ERC20 for our flagship stablecoin vault on Base which can be integrated into other DeFi applications. Here is a basic integration guide to incorporate gtUSDa into your protocol or app.
All user interactions with the vault happen on Base. We also have a dedicated frontend for supplying into this vault at app.gauntlet.xyz/vaults/gtusda.
Supplying via Contract Calls
Supplying into gtUSDa is a combination of 2 function calls: an approve call to spend the USDC, and a requestDeposit call.
call
approveon the USDC contract to allow the USDC amount to be spent by the provisioner contractNote that this is not the vault contract itself, as the request runs through the provisioner to issue vault units asynchronously via a solving mechanism (see Entry/Exit with Provisioner for more details)
requestDeposit.requestDepositis an asynchronous operation, the user will submit the USDC to the provisioner and after the request is solved gtUSDa units will be sent back to the users wallet directly. This will generally happen within 6 hours though can take up to as long as 3 days (or otherwise based on deadline). See Entry/Exit with Provisioner for more detailstoken:
0x833589fcd6edb6e08f4c7c32d4f71b54bda02913(USDC contract on base)tokensIn: USDC amount in (decimal adjusted value)
minUnitsOut: This parameter needs to be based on the current price of gtUSDa. To calculate it refer to the PriceAndFeeCalculator contract, specifically the
convertTokenToUnitsfunction call.convertTokenToUnits(0x000000000001CdB57E58Fa75Fe420a0f4D6640D5, 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, tokensIn)-> Returns the decimal adjusted gtUSDa unitsMultiply the above value by 0.97 (some buffer in case there are price changes)
solverTip:
0deadline:
block.timestamp + 259200(3 days in seconds)maxPriceAge:
3600(1 hour in seconds)isFixedPrice:
False
Example Request to deposit 1000 USDC
Call approve on the Base USDC contract to allow the provisioner to spend
call requestDeposit on the provisioner, parameterizing this call is important
Withdrawing via contract calls
To withdraw you similarly need to do an approve call followed by requestRedeem on the Provisioner Contract with the correct parameters.
call
approveon the gtUSDa contract to allow the gtUSDa amount to be spent by the provisioner contractrequestRedeemThis is similarly an asynchronous call where the user provides vaultUnits back to the Provisioner contract and after the request is solved the user will receive USDC in their wallettoken:
0x833589fcd6edb6e08f4c7c32d4f71b54bda02913(USDC contract on base)unitsIn: The amount of vault units you wish to redeem, correctly decimal adjusted. If you want to calculate the
unitsInbased on the USDC value for the user you can again use theconvertTokenToUnitsfunction on the PriceAndFeeCalculator contract as per the deposit call.minTokensOut: This parameter needs to be based on the current price of gtUSDa. To calculate it refer to the PriceAndFeeCalculator contract, specifically the
convertUnitsToTokenfunction.convertUnitsToToken(0x000000000001CdB57E58Fa75Fe420a0f4D6640D5, 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, unitsIn)-> Returns the Decimal adjusted USDC value of the VaultUnitsMultiply the above value by 0.97 (some buffer in case there are price changes)
solverTip:
0deadline:
block.timestamp + 259200(3 days in seconds)maxPriceAge:
3600(1 hour in seconds)isFixedPrice:
False
Example Request to withdraw 1000 USDC
call approve on the gtUSDa contract to allow the provisioner to spend
call requestRedeem on the provisioner, parameterizing this call is important
[ADVANCED] Monitoring and refunding orders
Tracking orders
When an asynchronous order is placed, the user will have an active but unfilled order. To provide additional transparency to users, these orders can be monitored by tracking the following DepositRequested or RedeemRequested events:
Checking when orders are filled
When a deposit or redeem is filled, one of the following events will be emitted in the Provisioner:
Refunding expired orders
If the deadline passes but an order isn't solved (rare), the user has to claim back their USDC or gtUSDa tokens using the refundRequest function.
Getting the User's balance of gtUSDa
Simply call the balanceOf function on gtUSDa with the user's address.
Pricing gtUSDa units in USDC (and vice versa)
We provide simple price conversion utilities between gtUSDa and USDC via the PriceAndFeeCalculator contract.
Specifically there are two functions of relevance
convertTokensToUnits-> Takes in USDC value and returns amount of vaultUnits at current pricevault:
0x000000000001CdB57E58Fa75Fe420a0f4D6640D5(gtUSDa vault contract)token:
0x833589fcd6edb6e08f4c7c32d4f71b54bda02913(USDC contract on base)tokenAmount: Decimal adjusted USDC value (USDC has 6 decimals)
convertUnitsToTokens-> Takes in vaultUnits and returns USDC value at current pricevault:
0x000000000001CdB57E58Fa75Fe420a0f4D6640D5(gtUSDa vault contract)token:
0x833589fcd6edb6e08f4c7c32d4f71b54bda02913(USDC contract on base)unitsAmount: Decimal adjusted gtUSDa value (gtUSDa has 18 decimals)
Fetching the APY of the vault
This one is a little trickier as of right now, but we aim to make this simpler in the future via an API. As of right now the best way to get the APY of the vault is to index the price of the vault units in USDC over a given time period and extrapolate this to a yearly APY number.
Calculating the TVL of the vault
To get the total TVL of the vault use the convertUnitsToTokens function and use the totalSupply of gtUSDa as an input.
Last updated

