Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Fix FullRouter deposit issue (#84)
Browse files Browse the repository at this point in the history
* fix full router leverage

* enhancement of 'tempEstimate' mechanism for safety (#74)

* enhancement of 'tempEstimate' mechanism for safety

* some documentation to not confuse future devs

* overshoot first entry for safety

* update session to sandbox and include child calls

* update doc

* fix redundancy

* del temp deletes to keep temp vals available within a session

* del unneeded topLevel check

* show that FullRouter is broken under meta strategies with debt

* fixed test: using fullrouter for metastrategy, so the fullrouter is NOT broken under metastrategies with debt for deploying

* fix strategy naming clash

* Improved cache (#79)

* cache leverage item percentage

* remove end session

* update tests

* include withdrawal fee in meta strategy estimate

* limit slippage estimate

Co-authored-by: Peter Phillips <[email protected]>

Co-authored-by: George Carder <[email protected]>
  • Loading branch information
PeterMPhillips and georgercarder committed May 2, 2022
1 parent a5e245f commit d6541da
Show file tree
Hide file tree
Showing 9 changed files with 609 additions and 104 deletions.
200 changes: 144 additions & 56 deletions contracts/routers/FullRouter.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getNetworks(): NetworksUserConfig {
if (archiveNode)
networks.hardhat.forking = {
url: archiveNode,
blockNumber: 14619730,
blockNumber: 14655540,
}
}
if (mnemonic && infuraApiKey) {
Expand Down
1 change: 1 addition & 0 deletions lib/estimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ export class Estimator {
} else if (tokenOut.toLowerCase() === WETH.toLowerCase()) {
// Withdraw
const strategy = new Contract(tokenIn, IStrategy.abi, this.signer)
amount = amount.sub(amount.mul(2).div(DIVISOR))
return this.withdraw(strategy, amount)
} else {
// Meta strategies always have weth as an input or output
Expand Down
7 changes: 3 additions & 4 deletions lib/mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { Contract, constants } from 'ethers'
import { Contract } from 'ethers'
import { Platform, Administration, Oracles } from './deploy'
import deployments from '../deployments.json'

Expand Down Expand Up @@ -43,14 +43,13 @@ import Leverage2XAdapter from '../artifacts/contracts/adapters/borrow/Leverage2X
import SynthetixAdapter from '../artifacts/contracts/adapters/exchanges/SynthetixAdapter.sol/SynthetixAdapter.json'
import YEarnV2Adapter from '../artifacts/contracts/adapters/vaults/YEarnV2Adapter.sol/YEarnV2Adapter.json'
import BalancerAdapter from '../artifacts/contracts/adapters/exchanges/BalancerAdapter.sol/BalancerAdapter.json'
const { AddressZero } = constants

export class LiveEnvironment {
signer: SignerWithAddress
platform: Platform
adapters: LiveAdapters
routers: LiveRouters
estimators: Estimators
estimators: Estimators

constructor(
signer: SignerWithAddress,
Expand All @@ -70,7 +69,7 @@ export class LiveEnvironment {

export type LiveAdapters = {
aaveV2: Contract
aaveV2Debt: Contract
aaveV2Debt: Contract
balancer: Contract
compound: Contract
curve: Contract
Expand Down
Loading

0 comments on commit d6541da

Please sign in to comment.