Skip to content

Commit

Permalink
Organized the directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
radar bear committed Aug 26, 2024
1 parent b1b01ed commit dffe9cb
Show file tree
Hide file tree
Showing 47 changed files with 96 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ See `newSubaccount()` in [SubaccountFactory.sol](./src/subaccount/SubaccountFact

## Lending System

There are only one core smart contracts: [JUSDBank.sol](./src/JUSDBank.sol).
There are only one core smart contracts: [JUSDBank.sol](./src/JUSDBank/JUSDBank.sol).

- `JUSDBank.sol` is the core accounting sheet of the whole collateral lending system and contains all "external" functions.

Expand Down
2 changes: 1 addition & 1 deletion script/deployDepositStableCoin.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "../lib/forge-std/src/Script.sol";
import "../src/DepositStableCoinToDealer.sol";
import "../src/helpers/DepositStableCoinToDealer.sol";

contract DepositStableCoinToDealerScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployDistrobutor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "../lib/forge-std/src/Script.sol";
import "../src/MerkleDistributorWithDeadline.sol";
import "../src/token/MerkleDistributorWithDeadline.sol";

contract MerkleDistributorWithDeadlineScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployFlashLiquidate.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/FlashLoanLiquidate.sol";
import "../src/JUSDBank/FlashLoanLiquidate.sol";

contract FlashLiquidateScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployFlashRepay.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/FlashLoanRepay.sol";
import "../src/JUSDBank/FlashLoanRepay.sol";

contract FlashRepayScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployFundingRateArbitrageScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/FundingRateArbitrage.sol";
import "../src/fundingRateArbitrage/FundingRateArbitrage.sol";

contract FundingRateArbitrageScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployFundingRateLimiter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "../lib/forge-std/src/Script.sol";
import "../src/FundingRateUpdateLimiter.sol";
import "../src/fundingRateLimiter/FundingRateUpdateLimiter.sol";

contract FundingRateUpdateLimiterScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployGeneralRepay.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/GeneralRepay.sol";
import "../src/JUSDBank/GeneralRepay.sol";

contract GeneralRepayScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployJUSDBank.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/JUSDBank.sol";
import "../src/JUSDBank/JUSDBank.sol";

contract JUSDBankScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployJUSDExchange.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/JUSDExchange.sol";
import "../src/JUSDBank/JUSDExchange.sol";

contract JUSDExchangeScript is Script {
// add this to be excluded from coverage report
Expand Down
2 changes: 1 addition & 1 deletion script/deployJUSDRepayHelper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/JUSDRepayHelper.sol";
import "../src/JUSDBank/JUSDRepayHelper.sol";

contract JUSDRepayHelperScript is Script {
// add this to be excluded from coverage report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pragma solidity ^0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IJUSDExchange.sol";
import "./libraries/SignedDecimalMath.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IJUSDExchange.sol";
import "../libraries/SignedDecimalMath.sol";

contract FlashLoanLiquidate is Ownable {
using SafeERC20 for IERC20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IJUSDExchange.sol";
import "./libraries/SignedDecimalMath.sol";
import "./token/JWrapMUSDC.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IJUSDExchange.sol";
import "../libraries/SignedDecimalMath.sol";
import "../token/JWrapMUSDC.sol";

interface MTokenInter {
function redeem(uint256 redeemTokens) external returns (uint256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IJUSDExchange.sol";
import "./libraries/SignedDecimalMath.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IJUSDExchange.sol";
import "../libraries/SignedDecimalMath.sol";

interface MTokenInterface {
function redeem(uint redeemTokens) external returns (uint);
Expand Down
6 changes: 3 additions & 3 deletions src/FlashLoanRepay.sol → src/JUSDBank/FlashLoanRepay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pragma solidity ^0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IJUSDExchange.sol";
import "./libraries/SignedDecimalMath.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IJUSDExchange.sol";
import "../libraries/SignedDecimalMath.sol";

contract FlashLoanRepay is Ownable {
using SafeERC20 for IERC20;
Expand Down
4 changes: 2 additions & 2 deletions src/GeneralRepay.sol → src/JUSDBank/GeneralRepay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IJUSDExchange.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IJUSDExchange.sol";

pragma solidity ^0.8.19;

Expand Down
8 changes: 4 additions & 4 deletions src/JUSDBank.sol → src/JUSDBank/JUSDBank.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDBank.sol";
import "./interfaces/IFlashLoanReceive.sol";
import "./interfaces/IDealer.sol";
import "./interfaces/internal/IPriceSource.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IFlashLoanReceive.sol";
import "../interfaces/IDealer.sol";
import "../interfaces/internal/IPriceSource.sol";
import "./JUSDOperation.sol";
import "./JUSDView.sol";
import "./JUSDBankStorage.sol";
Expand Down
6 changes: 3 additions & 3 deletions src/JUSDBankStorage.sol → src/JUSDBank/JUSDBankStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./libraries/FlashLoanReentrancyGuard.sol";
import "./libraries/SignedDecimalMath.sol";
import "./libraries/Types.sol";
import "../libraries/FlashLoanReentrancyGuard.sol";
import "../libraries/SignedDecimalMath.sol";
import "../libraries/Types.sol";

abstract contract JUSDBankStorage is Ownable, ReentrancyGuard, FlashLoanReentrancyGuard {
using SignedDecimalMath for uint256;
Expand Down
6 changes: 3 additions & 3 deletions src/JUSDExchange.sol → src/JUSDBank/JUSDExchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IJUSDExchange.sol";
import "./interfaces/IDealer.sol";
import "./libraries/Errors.sol";
import "../interfaces/IJUSDExchange.sol";
import "../interfaces/IDealer.sol";
import "../libraries/Errors.sol";

contract JUSDExchange is IJUSDExchange, Ownable {
using SafeERC20 for IERC20;
Expand Down
2 changes: 1 addition & 1 deletion src/JUSDMulticall.sol → src/JUSDBank/JUSDMulticall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

pragma solidity ^0.8.19;

import "./libraries/SignedDecimalMath.sol";
import "../libraries/SignedDecimalMath.sol";
import "./JUSDBank.sol";

/// @notice User's multi-step operation on the JUSDBank like: deposit and borrow
Expand Down
4 changes: 2 additions & 2 deletions src/JUSDOperation.sol → src/JUSDBank/JUSDOperation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

pragma solidity ^0.8.19;

import "./libraries/Errors.sol";
import "./libraries/SignedDecimalMath.sol";
import "../libraries/Errors.sol";
import "../libraries/SignedDecimalMath.sol";
import "./JUSDBankStorage.sol";

/// @notice Owner-only functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IJUSDExchange.sol";
import "../interfaces/IJUSDExchange.sol";
import "./JUSDBank.sol";

pragma solidity ^0.8.19;
Expand Down
6 changes: 3 additions & 3 deletions src/JUSDView.sol → src/JUSDBank/JUSDView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

pragma solidity ^0.8.19;

import "./interfaces/IJUSDBank.sol";
import "./interfaces/internal/IPriceSource.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/internal/IPriceSource.sol";
import "../libraries/SignedDecimalMath.sol";
import "./JUSDBankStorage.sol";
import "./libraries/SignedDecimalMath.sol";

abstract contract JUSDView is JUSDBankStorage, IJUSDBank {
using SignedDecimalMath for uint256;
Expand Down
2 changes: 1 addition & 1 deletion src/DegenDealer.sol → src/degen/DegenDealer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

pragma solidity ^0.8.19;

import "./interfaces/IDealer.sol";
import "../interfaces/IDealer.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "./JOJODealer.sol";
import "./libraries/SignedDecimalMath.sol";
import "./interfaces/internal/IPriceSource.sol";
import "../JOJODealer.sol";
import "../libraries/SignedDecimalMath.sol";
import "../interfaces/internal/IPriceSource.sol";

pragma solidity ^0.8.19;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/internal/IPriceSource.sol";
import "./interfaces/IDealer.sol";
import "./interfaces/IPerpetual.sol";
import "./libraries/Types.sol";
import "./libraries/SignedDecimalMath.sol";
import "../interfaces/internal/IPriceSource.sol";
import "../interfaces/IDealer.sol";
import "../interfaces/IPerpetual.sol";
import "../libraries/Types.sol";
import "../libraries/SignedDecimalMath.sol";

/// @notice Limiting funding rate change speed
/// Mainly for preventing JOJO's backend errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "./libraries/brevis/IBrevisProof.sol";
import "./libraries/brevis/BrevisApp.sol";
import "./interfaces/internal/IPriceSource.sol";
import "./interfaces/IDealer.sol";
import "./interfaces/IPerpetual.sol";
import "./libraries/Types.sol";
import "./libraries/SignedDecimalMath.sol";
import "../libraries/brevis/IBrevisProof.sol";
import "../libraries/brevis/BrevisApp.sol";
import "../interfaces/internal/IPriceSource.sol";
import "../interfaces/IDealer.sol";
import "../interfaces/IPerpetual.sol";
import "../libraries/Types.sol";
import "../libraries/SignedDecimalMath.sol";

/// @notice Limiting funding rate change speed
/// Mainly for preventing JOJO's backend errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IDealer.sol";
import "../interfaces/IDealer.sol";

interface IWETH {
function deposit() external payable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./DegenDealer.sol";
import "../degen/DegenDealer.sol";

interface IWETH {
function deposit() external payable;
Expand Down
2 changes: 1 addition & 1 deletion src/oracle/EarnOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pragma solidity ^0.8.19;


import "../FundingRateArbitrage.sol";
import "../fundingRateArbitrage/FundingRateArbitrage.sol";

contract EarnOracle {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

pragma solidity ^0.8.9;

import "./JOJODealer.sol";
import "./libraries/EIP712.sol";
import "./libraries/Types.sol";
import "./libraries/Trading.sol";
import "./libraries/SignedDecimalMath.sol";
import "./interfaces/IDealer.sol";
import "./interfaces/IPerpetual.sol";
import "./interfaces/internal/IPriceSource.sol";
import "../JOJODealer.sol";
import "../libraries/EIP712.sol";
import "../libraries/Types.sol";
import "../libraries/Trading.sol";
import "../libraries/SignedDecimalMath.sol";
import "../interfaces/IDealer.sol";
import "../interfaces/IPerpetual.sol";
import "../interfaces/internal/IPriceSource.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract PriceFollowOrder is Ownable {
Expand Down
16 changes: 8 additions & 8 deletions src/support/FlattenHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

pragma solidity ^0.8.19;

import "../DegenDepositHelper.sol";
import "../FlashLoanLiquidate.sol";
import "../FlashLoanRepay.sol";
import "../FundingRateUpdateLimiter.sol";
import "../FundingRateArbitrage.sol";
import "../degen/DegenDepositHelper.sol";
import "../JUSDBank/FlashLoanLiquidate.sol";
import "../JUSDBank/FlashLoanRepay.sol";
import "../fundingRateLimiter/FundingRateUpdateLimiter.sol";
import "../fundingRateArbitrage/FundingRateArbitrage.sol";
import "../JOJODealer.sol";
import "../DegenDealer.sol";
import "../JUSDBank.sol";
import "../degen/DegenDealer.sol";
import "../JUSDBank/JUSDBank.sol";
import "../Perpetual.sol";
import "../MerkleDistributorWithDeadline.sol";
import "../token/MerkleDistributorWithDeadline.sol";
import "../oracle/EmergencyOracle.sol";
import "../oracle/OracleAdaptor.sol";
import "../subaccount/SubaccountFactory.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/support/HelperContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/IJUSDBank.sol";
import "../interfaces/IPerpetual.sol";
import "../libraries/Types.sol";
import "../FundingRateArbitrage.sol";
import "../fundingRateArbitrage/FundingRateArbitrage.sol";

contract HelperContract {
JOJODealer public jojoDealer;
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit dffe9cb

Please sign in to comment.