DSProxy Target
Last updated
Was this helpful?
Last updated
Was this helpful?
The Hifi protocol is architected it in such a way that every function does one job only, and does it well. This is called separation of concerns - which makes it easier to reason about how the protocol behaves, and it generally gives better security guarantees.
Modularization comes with a cost though. In order to provide a good user experience in our web interface, we ought to batch multiple contract calls into one. This is where comes into play - a smart contract wallet designed to solve the issue.
For brevity, we won't expound on the technical properties of DSProxy here. Refer to this on StackExchange for a detailed explanation. The main takeaways are:
DSProxy is a smart contract wallet
There is a so-called "target contract" that contains composite calls, to which the DSProxy makes delegate calls.
Is it the target contract that we will document in the sections below.
Gas usage is not deterministic due to requisite calls to third-party Erc20 tokens and special cases whereby the storage properties get set to zero. We provide the table below for guidance only:
Action
Typical Gas Cost
Borrow
<170K
Borrow And Sell FyTokens
<400K
Deposit Collateral
<130K
Deposit And Lock Collateral
<160K
Deposit And Lock Collateral And Borrow
<230K
Deposit And Lock Collateral And Borrow And Sell FyTokens
<420K
Free Collateral
<110K
Free And Withdraw Collateral
<170K
Lock Collateral
<40K
Lock Collateral And Borrow
<330K
Open Vault
<60K
Redeem FyTokens
<110K
Repay Borrow
<100K
Sell Underlying And Repay Borrow
<330K
Supply Underlying
<180K
Supply Underlying And Repay Borrow
<180K
Withdraw Collateral
<80K
Wrap Eth And Deposit Collateral
<90K
Wrap Eth And Deposit And Lock Collateral
<120K
Wrap Eth And Deposit And Lock Collateral And Borrow
<270K
The contract that enables trading on the Balancer Exchange.
The contract that enables wrapping ETH into ERC-20 form.
Borrows fyTokens.
fyToken
: The address of the FyToken contract.
borrowAmount
: The amount of fyTokens to borrow.
Borrows fyTokens and sells them on Balancer in exchange for underlying. Emits a "BorrowAndSellFyTokens" event.
fyToken
: The address of the FyToken contract.
borrowAmount
: The amount of fyTokens to borrow.
underlyingAmount
: The amount of underlying to sell fyTokens for.
Deposits collateral into the "BalanceSheet" contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit.
Requirements:
The caller must have allowed the DSProxy to spend "collateralAmount" tokens.
Deposits and locks collateral into the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit and lock.
Requirements:
The caller must have allowed the DSProxy to spend "collateralAmount" tokens.
Deposits and locks collateral into the vault via the BalanceSheet contract, draws debt via the FyToken contract and sells it on Balancer in exchange for underlying.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit and lock.
borrowAmount
: The amount of fyTokens to borrow.
underlyingAmount
The amount of underlying to sell fyTokens for.
Requirements:
The caller must have allowed the DSProxy to spend "collateralAmount" tokens.
Frees collateral from the vault in the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to free.
Frees collateral from the vault and withdraws it from the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to free and withdraw.
Locks collateral in the vault in the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to lock.
Locks collateral into the vault in the BalanceSheet contract and draws debt via the FyToken contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to lock.
borrowAmount
: The amount of fyTokens to borrow.
underlyingAmount
: The amount of underlying to sell fyTokens for.
Open the vaults in the BalanceSheet contract for the given fyToken.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
Redeems fyTokens in exchange for underlying tokens.
fyToken
: The address of the FyToken contract.
fyTokenAmount
: The amount of fyTokens to redeem.
Requirements:
The caller must have allowed the DSProxy to spend "repayAmount" fyTokens.
Repays the fyToken borrow.
fyToken
: The address of the FyToken contract.
repayAmount
: The amount of fyTokens to repay.
Requirements:
The caller must have allowed the DSProxy to spend "repayAmount" fyTokens.
Market sells underlying and repays the borrows via the FyToken contract.
fyToken
: The address of the FyToken contract.
underlyingAmount
: The amount of underlying to sell.
repayAmount
: The amount of fyTokens to repay.
Requirements:
The caller must have allowed the DSProxy to spend "underlyingAmount" tokens.
fyToken
: The address of the FyToken contract.
underlyingAmount
: The amount of underlying to supply.
Supplies the underlying to the RedemptionPool contract, mints fyTokens and repays the borrow.
fyToken
: The address of the FyToken contract.
underlyingAmount
: The amount of underlying to supply.
Requirements:
The caller must have allowed the DSProxy to spend "underlyingAmount" tokens.
Withdraws collateral from the vault in the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to withdraw.
Wraps ETH into WETH and deposits into the BalanceSheet contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit.
Wraps ETH into WETH, deposits and locks collateral into the BalanceSheet contract and draws debt via the FyToken contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit and lock.
Wraps ETH into WETH, deposits and locks collateral into the vault in the BalanceSheet contract and draws debt via the FyToken contract.
balanceSheet
: The address of the BalanceSheet contract.
fyToken
: The address of the FyToken contract.
collateralAmount
: The amount of collateral to deposit and lock.
borrowAmount
: The amount of fyTokens to borrow.
underlyingAmount
: The amount of underlying to sell fyTokens for.