Skip to content

Commit

Permalink
funding rate arbitrage
Browse files Browse the repository at this point in the history
  • Loading branch information
JoscelynFarr committed Jan 10, 2024
1 parent adf7aca commit 4103ea6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deployment/ArbitrumSepoliaTestnet2023-12-16.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"PrimaryAssetDecimal": 6,
"SecondaryAsset": "0xDd29a69462a08006Fda068D090b44B045958C5B7",
"FundingRateUpdateLimiter": "0x5f8e53f1306426ebd665fb800742d740e3d0acd1",
"DepositStableCoin": "0xe804cd55893a6066c21d1fa0f58a06309fb3d2ea",
"DepositStableCoinToDealer": "0xe804cd55893a6066c21d1fa0f58a06309fb3d2ea",
"JUSDBank": "0xb0D9Ce393f3483449be357EF715a3492858f8a5E",
"JUSDRepayHelper": "0x3755d362774fc08c30cdd1a305e1c8107e2046d2",
"JUSDExchange": "0x33a317a875Bc23af2E083555E5E46e3ac559C40A",
Expand Down
7 changes: 4 additions & 3 deletions src/FundingRateArbitrage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ contract FundingRateArbitrage is Ownable {
function deposit(uint256 amount) external {
require(amount != 0, "deposit amount is zero");
uint256 feeAmount = amount.decimalMul(depositFeeRate);
uint256 earnUSDCAmount = amount.decimalDiv(getIndex());
IERC20(usdc).transferFrom(msg.sender, address(this), amount);
if (feeAmount > 0) {
amount -= feeAmount;
IERC20(usdc).transfer(owner(), feeAmount);
IERC20(usdc).transferFrom(msg.sender, owner(), feeAmount);
}
uint256 earnUSDCAmount = amount.decimalDiv(getIndex());
IERC20(usdc).transferFrom(msg.sender, address(this), amount);
JOJODealer(jojoDealer).deposit(0, amount, msg.sender);
earnUSDCBalance[msg.sender] += earnUSDCAmount;
jusdOutside[msg.sender] += amount;
Expand Down Expand Up @@ -307,6 +307,7 @@ contract FundingRateArbitrage is Ownable {
WithdrawalRequest storage request = withdrawalRequests[requestIDList[i]];
require(!request.isExecuted, "request has been executed");
uint256 USDCAmount = request.earnUSDCAmount.decimalMul(index);
require(USDCAmount >= withdrawSettleFee, "USDCAmount need to bigger than withdrawSettleFee");
uint256 feeAmount = (USDCAmount - withdrawSettleFee).decimalMul(withdrawFeeRate) + withdrawSettleFee;
if (feeAmount > 0) {
IERC20(usdc).transfer(owner(), feeAmount);
Expand Down

0 comments on commit 4103ea6

Please sign in to comment.