Skip to content

Commit

Permalink
Adding the first DCA index to Arbitrum
Browse files Browse the repository at this point in the history
Additional changes
1. made the testing/deployment scripts multi chain for the DCA
2. removed unnecessary code to reduce onchain code size
  • Loading branch information
Daniel Graczer authored and Daniel Graczer committed May 4, 2023
1 parent ffe0a3b commit 40fe182
Show file tree
Hide file tree
Showing 39 changed files with 668 additions and 412 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ jobs:
coverage-check:
name: Coverage Check
runs-on: ubuntu-latest
env:
TESTNET_PRIVATE_KEY: 98cb077f972feb0481f1d894f272c6a1e3c15e272a1658ff716444f465200070
MAINNET_PRIVATE_KEY: 98cb077f972feb0481f1d894f272c6a1e3c15e272a1658ff716444f465200070
TENDERLY_PRIVATE_KEY: 9b0d3fcfc049f7a4683c25abe2c85f9527c37bc0497ea2ec440b3b2e044e922f
TENDERLY_FORK_URL: https://rpc.tenderly.co/fork/159120f7-15b5-49db-9907-c63522197ac2
AVALANCHE_ARCHIVE_NODE_URL: ${{ secrets.AVALANCHE_ARCHIVE_NODE_URL }}
ARBITRUM_ARCHIVE_NODE_URL: ${{ secrets.ARBITRUM_ARCHIVE_NODE_URL }}

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
MAINNET_PRIVATE_KEY: 98cb077f972feb0481f1d894f272c6a1e3c15e272a1658ff716444f465200070
TENDERLY_PRIVATE_KEY: 9b0d3fcfc049f7a4683c25abe2c85f9527c37bc0497ea2ec440b3b2e044e922f
TENDERLY_FORK_URL: https://rpc.tenderly.co/fork/159120f7-15b5-49db-9907-c63522197ac2
AVALANCHE_ARCHIVE_NODE_URL: ${{ secrets.AVALANCHE_ARCHIVE_NODE_URL }}
ARBITRUM_ARCHIVE_NODE_URL: ${{ secrets.ARBITRUM_ARCHIVE_NODE_URL }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
MAINNET_PRIVATE_KEY: 98cb077f972feb0481f1d894f272c6a1e3c15e272a1658ff716444f465200070
TENDERLY_PRIVATE_KEY: 9b0d3fcfc049f7a4683c25abe2c85f9527c37bc0497ea2ec440b3b2e044e922f
TENDERLY_FORK_URL: https://rpc.tenderly.co/fork/159120f7-15b5-49db-9907-c63522197ac2
AVALANCHE_ARCHIVE_NODE_URL: ${{ secrets.AVALANCHE_ARCHIVE_NODE_URL }}
ARBITRUM_ARCHIVE_NODE_URL: ${{ secrets.ARBITRUM_ARCHIVE_NODE_URL }}

steps:
- uses: actions/checkout@v3
Expand Down
40 changes: 40 additions & 0 deletions configs/dca/aribtrum/strategy/CoinBluechip/usdc_dpx_prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"owner": "0x3ed85f0488EdF594F212c5346E7893B42EC33Af7",
"contractName": "CoinBluechip",
"dcaBaseArgs": {
"depositFee": {
"feeReceiver": "0x1810fE48fD49cDfF2F5822e7CFE58B67EB6306c2",
"fee": 50
},
"dcaInvestor": "0xff4d52acf4538e35454e21fc4a1cc91b9dbb050a",
"depositTokenInfo": {
"token": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"decimals": 6
},
"investmentPeriod": 604800,
"lastInvestmentTimestamp": 1678035599,
"minDepositAmount": 1000000,
"positionsLimit": 52,
"router": {
"dex": 0,
"router": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"
},
"depositToBluechipSwapBins": [0, 0],
"depositToBluechipSwapPath": [
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0x6C2C06790b3E3E3c38e12Ee22F8183b37a13EE55"
],
"bluechipToDepositSwapPath": [
"0x6C2C06790b3E3E3c38e12Ee22F8183b37a13EE55",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
]
},
"strategyArgs": [
{
"token": "0x6C2C06790b3E3E3c38e12Ee22F8183b37a13EE55",
"decimals": 18
}
]
}
41 changes: 41 additions & 0 deletions configs/dca/aribtrum/strategy/CoinBluechip/usdc_magic_prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"owner": "0x3ed85f0488EdF594F212c5346E7893B42EC33Af7",
"contractName": "CoinBluechip",
"dcaBaseArgs": {
"depositFee": {
"feeReceiver": "0x1810fE48fD49cDfF2F5822e7CFE58B67EB6306c2",
"fee": 50
},
"dcaInvestor": "0xff4d52acf4538e35454e21fc4a1cc91b9dbb050a",
"depositTokenInfo": {
"token": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"decimals": 6
},
"investmentPeriod": 604800,
"lastInvestmentTimestamp": 1678035599,
"minDepositAmount": 1000000,
"positionsLimit": 52,
"router": {
"dex": 0,
"router": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"
},
"depositToBluechipSwapBins": [0, 0],
"depositToBluechipSwapPath": [
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0x539bde0d7dbd336b79148aa742883198bbf60342"
],
"bluechipToDepositSwapBins": [0, 0],
"bluechipToDepositSwapPath": [
"0x539bde0d7dbd336b79148aa742883198bbf60342",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
]
},
"strategyArgs": [
{
"token": "0x539bde0d7dbd336b79148aa742883198bbf60342",
"decimals": 18
}
]
}
41 changes: 41 additions & 0 deletions configs/dca/aribtrum/strategy/CoinBluechip/usdc_rdnt_prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"owner": "0x3ed85f0488EdF594F212c5346E7893B42EC33Af7",
"contractName": "CoinBluechip",
"dcaBaseArgs": {
"depositFee": {
"feeReceiver": "0x1810fE48fD49cDfF2F5822e7CFE58B67EB6306c2",
"fee": 50
},
"dcaInvestor": "0xff4d52acf4538e35454e21fc4a1cc91b9dbb050a",
"depositTokenInfo": {
"token": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"decimals": 6
},
"investmentPeriod": 604800,
"lastInvestmentTimestamp": 1678035599,
"minDepositAmount": 1000000,
"positionsLimit": 52,
"router": {
"dex": 1,
"router": "0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30"
},
"depositToBluechipSwapBins": [15, 25],
"depositToBluechipSwapPath": [
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0x3082cc23568ea640225c2467653db90e9250aaa0"
],
"bluechipToDepositSwapBins": [25, 15],
"bluechipToDepositSwapPath": [
"0x3082cc23568ea640225c2467653db90e9250aaa0",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
]
},
"strategyArgs": [
{
"token": "0x3082cc23568ea640225c2467653db90e9250aaa0",
"decimals": 18
}
]
}
41 changes: 41 additions & 0 deletions configs/dca/aribtrum/strategy/CoinBluechip/usdc_wBtc_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"owner": "0xFf04026EaBb113A04878F8861902e533A51feb22",
"contractName": "CoinBluechip",
"dcaBaseArgs": {
"depositFee": {
"feeReceiver": "0x4821fCb59f13376eDd7bC82f6eE37785F3A7AB66",
"fee": 50
},
"dcaInvestor": "0xff4d52acf4538e35454e21fc4a1cc91b9dbb050a",
"depositTokenInfo": {
"token": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"decimals": 6
},
"investmentPeriod": 604800,
"lastInvestmentTimestamp": 1681780562,
"minDepositAmount": 1000000,
"positionsLimit": 52,
"router": {
"dex": 3,
"router": "0x7BFd7192E76D950832c77BB412aaE841049D8D9B"
},
"depositToBluechipSwapBins": [15, 10],
"depositToBluechipSwapPath": [
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"
],
"bluechipToDepositSwapBins": [10, 15],
"bluechipToDepositSwapPath": [
"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
]
},
"strategyArgs": [
{
"token": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
"decimals": 8
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions constants/arbitrum/addresses/Tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"usdc": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"wBtc": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
"wEth": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"usdt": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
}
15 changes: 15 additions & 0 deletions constants/arbitrum/addresses/TraderJoe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"router": "0x60aE616a2155Ee3d9A68541Ba4544862310933d4",
"joeToken": "0x6e84a6216ea6dacc71ee8e6b0a5b7322eebc0fdd",
"usdcWAvaxLpToken": "0xf4003F4efBE8691B60249E6afbD307aBE7758adb",
"lbPair": "0x18332988456C4Bd9ABa6698ec748b331516F5A14",
"lbRouter": "0xE3Ffc583dC176575eEA7FD9dF2A7c65F7E23f4C3",
"wAvax_usdc_v1": "0xf4003F4efBE8691B60249E6afbD307aBE7758adb",
"wAvax_usdc_v2": "0xB5352A39C11a81FE6748993D586EC448A01f08b5",
"wAvax_ptp_v1": "0xCDFD91eEa657cc2701117fe9711C9a4F61FEED23",
"wAvax_joe_v2": "0xc01961EdE437Bf0cC41D064B1a3F6F0ea6aa2a40",
"wAvax_gmx_v2": "0x294Dc12a20e0018f77d8E043dad60AF6777F716B",
"wAvax_qi_v2": "0xb577BC082c52D4D0207f5887a3c3A7b92e11a65A",
"wAvax_vtx_v2": "0xf251897d37576D68B38c8f54617BF433853B8630",
"wAvax_bro_v1": "0x4801602FA2cA3F62376F80Cb45e0543507689fE3"
}
32 changes: 3 additions & 29 deletions contracts/beyondFramework/dca/base/DCABaseUpgradeableCutted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InvestQueueLib } from "../libraries/InvestQueueLib.sol";
import { DCAHistoryLib } from "../libraries/DCAHistoryLib.sol";
import { IDCAStrategy } from "../interfaces/IDCAStrategy.sol";
import { SwapLib } from "../libraries/SwapLib.sol";
import { PortfolioAccessBaseUpgradeable } from "./PortfolioAccessBaseUpgradeable.sol";
import { PortfolioAccessBaseUpgradeableCutted } from "./PortfolioAccessBaseUpgradeableCutted.sol";

import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol";
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
Expand All @@ -17,7 +17,7 @@ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/
abstract contract DCABaseUpgradeableCutted is
PausableUpgradeable,
ReentrancyGuardUpgradeable,
PortfolioAccessBaseUpgradeable
PortfolioAccessBaseUpgradeableCutted
{
error TooSmallDeposit();
error PositionsLimitReached();
Expand Down Expand Up @@ -133,7 +133,7 @@ abstract contract DCABaseUpgradeableCutted is
internal
onlyInitializing
{
__PortfolioAccessBaseUpgradeable_init();
__PortfolioAccessBaseUpgradeableCutted_init();
__Pausable_init();
__ReentrancyGuard_init();

Expand Down Expand Up @@ -178,21 +178,6 @@ abstract contract DCABaseUpgradeableCutted is
_deposit(_msgSender(), amount, amountSplit);
}

function depositFor(
address sender,
uint256 amount,
uint8 amountSplit
)
public
virtual
onlyPortfolio
nonReentrant
whenNotPaused
nonEmergencyExited
{
_deposit(sender, amount, amountSplit);
}

function _deposit(
address sender,
uint256 amount,
Expand Down Expand Up @@ -358,17 +343,6 @@ abstract contract DCABaseUpgradeableCutted is
_withdrawAll(_msgSender(), convertBluechipIntoDepositAsset);
}

function withdrawAllFor(
address sender,
bool convertBluechipIntoDepositAsset
) public virtual onlyPortfolio nonReentrant whenNotPaused {
if (isEmergencyExited()) {
_emergencyWithdrawUserDeposit(sender);
return;
}
_withdrawAll(sender, convertBluechipIntoDepositAsset);
}

function _withdrawAll(address sender, bool convertBluechipIntoDepositAsset)
private
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

abstract contract PortfolioAccessBaseUpgradeableCutted is OwnableUpgradeable {
// solhint-disable-next-line
function __PortfolioAccessBaseUpgradeableCutted_init()
internal
onlyInitializing
{
__Ownable_init();
}

address[] public unused;
}
Loading

0 comments on commit 40fe182

Please sign in to comment.