Skip to content

Commit

Permalink
Merge pull request #21 from open-dollar/paraswap
Browse files Browse the repository at this point in the history
Flashloan Prototype
  • Loading branch information
pi0neerpat authored Jul 26, 2024
2 parents 37b940d + 646e9d7 commit a67c58a
Show file tree
Hide file tree
Showing 15 changed files with 478 additions and 519 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@ Proxy action contracts for Open Dollar
- https://book.getfoundry.sh/
- https://contracts.opendollar.com
- https://docs.opendollar.com

## ParaswapSellAdapter Docs

### get max loan and leveraged amount of debt:

IParaswapSellAdapter.getLeveragedDebt(bytes32 _cType, uint256 _initCapital)

### get loan and leveraged amount of debt with percentage buffer:

IParaswapSellAdapter.getLeveragedDebt(bytes32 _cType, uint256 _initCapital, uint256 _percentageBuffer)

### execute leverage flashloan

IParaswapSellAdapter.requestFlashloan(SellParams memory _sellParams, uint256 _initCollateral, uint256 _collateralLoan, uint256 _minDstAmount, uint256 _safeId, bytes32 _cType)
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ src = "src"
out = "out"
libs = ["lib"]
ffi = true
fuzz_runs = 128
optimizer_runs = 5_000

[rpc_endpoints]
mainnet = "${ARB_MAINNET_RPC}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:coverage": "forge coverage --report lcov && lcov --ignore-errors unused --remove lcov.info 'node_modules/*' 'script/*' 'test/*' 'src/contracts/for-test/*' 'src/libraries/*' -o lcov.info.pruned && mv lcov.info.pruned lcov.info && genhtml -o coverage-report lcov.info"
},
"dependencies": {
"@opendollar/contracts": "0.0.0-984c17c2",
"@opendollar/contracts": "0.0.0-00b33fa2",
"@openzeppelin-contracts-3.4.2-solc-0.7": "yarn:@openzeppelin/contracts@^3.4.2",
"@openzeppelin/contracts": "4.9.6",
"@paraswap/sdk": "^6.7.0",
Expand Down
4 changes: 2 additions & 2 deletions script/getSwapRoute.js → script/getSwapTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TO_DECIMALS = args[3];
const SELL_AMOUNT = args[4];
const CALLER = args[5];

async function getSwapRoute(_fromToken, _fromDecimals, _toToken, _toDecimals, _sellAmount, _caller) {
async function getSwapTransaction(_fromToken, _fromDecimals, _toToken, _toDecimals, _sellAmount, _caller) {
const priceRoute = await paraSwapMin.swap.getRate({
srcToken: _fromToken,
srcDecimals: _fromDecimals,
Expand All @@ -38,4 +38,4 @@ async function getSwapRoute(_fromToken, _fromDecimals, _toToken, _toDecimals, _s
process.stdout.write(txParams.data);
}

getSwapRoute(FROM_TOKEN, FROM_DECIMALS, TO_TOKEN, TO_DECIMALS, SELL_AMOUNT, CALLER);
getSwapTransaction(FROM_TOKEN, FROM_DECIMALS, TO_TOKEN, TO_DECIMALS, SELL_AMOUNT, CALLER);
1 change: 0 additions & 1 deletion src/leverage/ExitActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ contract ExitActions is BasicActions {
ODSafeManager.SAFEData memory _safeInfo = ODSafeManager(_manager).safeData(_safeId);
// takes token amount from user's wallet and joins into the safeEngine
_joinCollateral(_collateralJoin, _safeInfo.safeHandler, _collateralAmount);

int256 _deltaDebt = _getGeneratedDeltaDebt(_safeEngine, _safeInfo.collateralType, _safeInfo.safeHandler, _deltaWad);
// locks token amount into the SAFE and generates debt
_modifySAFECollateralization(_manager, _safeId, _collateralAmount.toInt(), _deltaDebt, false);
Expand Down
83 changes: 0 additions & 83 deletions src/leverage/LeverageCalculator.sol

This file was deleted.

Loading

0 comments on commit a67c58a

Please sign in to comment.