Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JoscelynFarr committed Jan 26, 2024
1 parent 7104f58 commit 8371a54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/FundingRateArbitrage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contract FundingRateArbitrage is Ownable {

using SafeERC20 for IERC20;
using SignedDecimalMath for uint256;
using SignedDecimalMath for int256;

address public immutable collateral;
address public immutable jusdBank;
Expand Down Expand Up @@ -90,8 +91,13 @@ contract FundingRateArbitrage is Ownable {
uint256 usdcBuffer = IERC20(usdc).balanceOf(address(this));
uint256 collateralPrice = IJUSDBank(jusdBank).getCollateralPrice(collateral);
(int256 perpNetValue,,,) = JOJODealer(jojoDealer).getTraderRisk(address(this));
return
SafeCast.toUint256(perpNetValue) + collateralAmount.decimalMul(collateralPrice) + usdcBuffer - jusdBorrowed;
if (perpNetValue >= 0) {
return SafeCast.toUint256(perpNetValue) + collateralAmount.decimalMul(collateralPrice) + usdcBuffer
- jusdBorrowed;
} else {
return collateralAmount.decimalMul(collateralPrice) + usdcBuffer
- jusdBorrowed - perpNetValue.abs();
}
}

/// @notice this function is to return the ratio between netValue and totalEarnUSDCBalance
Expand Down

0 comments on commit 8371a54

Please sign in to comment.