Router Contract Implementation

Router Contract

As some of you might be aware, we have been developing a router contract to improve UX when interacting with the protocol. Essentially, it allows to combine multiple actions into one transaction when interacting with the protocol’s contracts, opening the door for new functionalities. The downside is that it creates a one-stop contract for a lot of protocol interactions.

General Functionality

As said above, the goal of this contract is to combine actions to improve user experience. For example, we could imagine features like depositing collateral + staking or claiming interest + staking.

With the current draft implementation, almost any combinations of the following actions can be performed:

  • Claiming all rewards from gauges of types 0 & 1
  • Claming weekly interest
  • Depositing tokens into a gauge (staking)
  • Minting agEUR
  • Depositing collateral against sanTokens
  • Withdrawing tokens from sanTokens
  • Opening a perpetual position
  • Adding collateral to a position

Additionally, these actions could be performed from any token, as the router includes a function to swap through UniswapV3 or 1Inch into one of the accepted collateral.

Use Cases

In general, any use cases combining the actions listed above can be performed. However, not all of them will be implemented in the app.

We are currently working on integrating the most convenient ones, among which:

  • Claim All ANGLE rewards: ability to claim all rewards from gauges 0 & 1 in one transaction
  • Deposit collateral & stake: ability to deposit collateral into the protocol, and stake on the corresponding liquidity gauge at the same time. This could also potentially be done from any token.
  • Claim Weekly Interest and Stake: ability to claim the weekly distributed sanUSDC/EUR and stake them directly in the associated gauge.
  • Claim Weekly Interest and Mint: ability to claim the weekly distributed sanUSDC/EUR and mint agEUR directly in one transaction.
  • Mint from any token: allow users to mint agEUR using any token that can be swapped against one of the accepted collateral through UniswapV3 or 1Inch.
  • OpenPerp from any token: allow users to open perpetuals using any token that can be swapped against one of the accepted collateral through UniswapV3 or 1Inch.

Technical Details

mixer() function

The router is written such that there is a mixer() function that can be called with a set of arguments, including the different actions it can perform and their parameters.

This will be detailed in the developers docs as soon as we make the contract public, a few days before deployment.

Permit signature VS approval transaction

To allow contracts to spend funds, users are usually required to sign an approval transaction. The router changes that by using the permit signature from the EIP-2912 instead of an approval transaction, reducing gas cost and waiting time for users. Note that this is only available for tokens which contracts contain the permit() function.

Ideally, users would need to sign a message before each transaction to approve the spending of the required amount of funds.


The goal is to make these use cases available as soon as possible, while making sure that the contract is thoroughly tested and verified.

Let us know your thoughts!

2 Likes

Sounds great to me, as a small fish holding VeAngle it may be a wee while until I can do these actions without this.

2 Likes

The router has been deployed on ETH mainnet at 0xBB755240596530be0c1DE5DFD77ec6398471561d!

Blog Post

You can find all the information in our blog post:

Dev Doc

And more details about the contract in our developers documentation.

Features

From launch

Here are the features that have been implemented at launch:

  • deposit and stake
  • Claim interest and stake
  • Claim interest and mint agEUR
  • Claim ANGLE from all gauges of type 0 (boosted) and 1 (perpetuals)
  • Claim and lock ANGLE

The router also adds support for permit signatures instead of approval transactions for USDC and FEI.

Next features

  • Buy ANGLE with the best liquidity route from any token
  • Mint, deposit, and open position from any token: this will allow users to come in to the protocol using any token, that will be swap against one of the accepted collateral through 1inch.

Hope you enjoy the improved UX!