├── .editorconfig ├── .env.example ├── .github ├── actions │ └── install │ │ └── action.yml ├── dataflow-simple.png ├── incentiveflow-simple.png └── workflows │ ├── build-wiki.yml │ ├── foundry.yml │ ├── release.yml │ └── report-coverage.yml ├── .gitignore ├── .gitmodules ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── audits └── 2024-08-halborn-core.pdf ├── codecov.yml ├── contracts ├── Deployer.sol ├── core │ ├── StablecoinBase.sol │ ├── ZaiBitcoin.sol │ ├── ZaiEther.sol │ ├── ZaiStablecoin.sol │ ├── direct-deposit │ │ ├── Constants.sol │ │ ├── README.md │ │ ├── hub │ │ │ ├── DDHubBase.sol │ │ │ ├── DDHubL1.sol │ │ │ └── layer2 │ │ │ │ ├── DDHubL2Base.sol │ │ │ │ ├── DDHubL2Optimism.sol │ │ │ │ ├── DDHubL2ZkPolygonEVM.sol │ │ │ │ └── DDHubL2ZkSync.sol │ │ ├── plans │ │ │ └── DDOperatorPlan.sol │ │ └── pools │ │ │ ├── DDBase.sol │ │ │ ├── DDMetaMorpho.sol │ │ │ ├── DDPrivateMorphoLoan.sol │ │ │ ├── DDZeroLendV1.sol │ │ │ └── layer2 │ │ │ ├── DDBaseL2.sol │ │ │ ├── DDLayerZeroHub.sol │ │ │ ├── DDOptimismHub.sol │ │ │ └── DDZkPolygonEVMHub.sol │ ├── psm │ │ ├── PegStabilityModule.sol │ │ ├── PegStabilityModuleBase.sol │ │ ├── PegStabilityModuleYield.sol │ │ └── README.md │ ├── safety-pool │ │ └── SafetyPool.sol │ └── utils │ │ └── MultiStakingRewardsERC4626.sol ├── governance │ ├── MAHA.sol │ ├── MAHAProxy.sol │ ├── MAHATimelockController.sol │ ├── WAGMIE.sol │ ├── locker │ │ ├── BaseLocker.sol │ │ ├── LockerLP.sol │ │ ├── LockerToken.sol │ │ ├── MigrateTokenLocks.sol │ │ └── staking │ │ │ ├── OmnichainStakingBase.sol │ │ │ ├── OmnichainStakingLP.sol │ │ │ ├── OmnichainStakingToken.sol │ │ │ └── VotingPowerCombined.sol │ ├── omnichain │ │ ├── OmnichainGovernanceExecutorL2.sol │ │ └── OmnichainProposalSenderL1.sol │ └── oracle │ │ └── LPOracle.sol ├── interfaces │ ├── IStablecoin.sol │ ├── core │ │ ├── IDDHub.sol │ │ ├── IDDPlan.sol │ │ ├── IDDPool.sol │ │ ├── IMultiStakingRewardsERC4626.sol │ │ ├── IMultiTokenRewards.sol │ │ ├── IMultiTokenRewardsWithWithdrawalDelay.sol │ │ ├── IPegStabilityModule.sol │ │ └── ISafetyPool.sol │ ├── errors │ │ ├── ConnextErrors.sol │ │ └── PSMErrors.sol │ ├── events │ │ ├── ConnextEvents.sol │ │ ├── DDEventsLib.sol │ │ ├── PSMEventsLib.sol │ │ ├── SafetyPoolEvents.sol │ │ └── ZAIEventsLib.sol │ ├── governance │ │ ├── IAggregatorV3Interface.sol │ │ ├── IGauge.sol │ │ ├── ILPOracle.sol │ │ ├── ILocker.sol │ │ ├── IOmnichainStaking.sol │ │ ├── IPythOracle.sol │ │ └── IWETH.sol │ └── periphery │ │ ├── IStablecoinOFT.sol │ │ ├── connext │ │ ├── IConnext.sol │ │ ├── IL1BridgeConnext.sol │ │ ├── IL2DepositConnext.sol │ │ ├── IXERC20.sol │ │ └── IXERC20Lockbox.sol │ │ ├── curve │ │ ├── ICurveStableSwapNG.sol │ │ └── ICurveTwoCrypto.sol │ │ ├── dex │ │ ├── IAerodromePool.sol │ │ ├── IAerodromeRouter.sol │ │ └── IUniswapV2Pair.sol │ │ ├── layerzero │ │ ├── IL0EndpointV2.sol │ │ ├── IL2DepositCollateralL0.sol │ │ └── IStargate.sol │ │ ├── leverage │ │ ├── ILoopingStrategy.sol │ │ ├── ISwapper.sol │ │ └── IWNative.sol │ │ └── morpho │ │ ├── IMorpho.sol │ │ └── IMorphoFlashLoanCallback.sol ├── mocks │ ├── MockAggregator.sol │ ├── MockConnext.sol │ ├── MockCurvePool.sol │ ├── MockERC20.sol │ ├── MockERC4626.sol │ ├── MockLayerZero.sol │ └── MockOmnichainStaking.sol └── periphery │ ├── BuyBackBurnMaha.sol │ ├── Erc20RecoverProxy.sol │ ├── UsdzMigrator.sol │ ├── arbitrage │ ├── ZAIArbitrageBot.sol │ └── ZAIConnextArbitrageBot.sol │ ├── crons │ ├── BaseBridgeCron.sol │ ├── L1RestakingSweeperCron.sol │ ├── L2RestakingSweeperCron.sol │ ├── ZaiFeeCollectorCron.sol │ └── sUSDeCollectorCron.sol │ ├── leverage │ ├── AaveV3LoopingStrategy.sol.dis │ ├── BaseLeverage.sol │ ├── MorphoLeverageMainnet.sol │ └── implementations │ │ └── MorphoLeveragePendleMainnet.sol │ ├── oracles │ ├── AerodromeLPOracle.sol │ ├── DumbAggregatorOracle.sol │ ├── FixedPriceOracle.sol │ ├── MorphoFixedPriceOracle.sol │ └── MorphoFixedPriceOracleProxy.sol │ ├── restaking │ └── layerzero │ │ ├── L1BridgeCollateralL0.sol │ │ ├── L2DepositCollateralL0.sol │ │ ├── LayerZeroCustomOFT.sol │ │ ├── LayerZeroCustomOFTAdapter.sol │ │ ├── StakedZaiOFTWithRestaking.sol │ │ └── ZaiOFTWithRestaking.sol │ ├── staking │ └── StakingLPRewards.sol │ ├── ui-helpers │ ├── BalancesUIHelper.sol │ ├── GovernanceUiHelper.sol │ └── PoolUIHelper.sol │ ├── wrappers │ ├── WrappedAerodromeGauge.sol │ └── WrappedStakingLPRewards.sol │ └── zaps │ ├── ZapBase.sol │ └── implementations │ ├── base │ ├── ZapAerodromeBase.sol │ ├── ZapAerodromePoolMAHA.sol │ ├── ZapAerodromePoolUSDC.sol │ └── ZapMintBase.sol │ └── ethereum │ ├── ZapBaseEthereum.sol │ ├── ZapCurvePoolBase.sol │ ├── ZapCurvePoolMAHA.sol │ ├── ZapCurvePoolUSDC.sol │ ├── ZapCurvePoolsZAI.sol │ ├── ZapMintMainnet.sol │ └── ZapSafetyPool.sol ├── deploy ├── base │ ├── governance-token.ts │ ├── usdzusdc-aero-morpho-fixed-oracle.ts │ ├── usdzusdc-aero-oracle.ts │ ├── zai-maha-aerodrome-stake.ts │ ├── zai-usdc-aerodrome-stake.ts │ ├── zap-aerodrome-maha.ts │ ├── zap-aerodrome-usdc.ts │ └── zap-mint.ts ├── bsc │ └── governance-token.ts ├── cron │ ├── l1-restaking-sweeper-cron.ts │ └── l2-restaking-sweeper-cron.ts ├── deploy-testnet.ts ├── deploy-wagmie.ts ├── deployer.ts ├── gov-omnichain │ ├── deploy-l1.ts │ └── deploy-l2.ts ├── helpers │ ├── balanceUIHelper.ts │ └── poolUIHelper.ts ├── hubs │ ├── ddhub-base-lz.ts │ └── ddhub-okx-lz.ts ├── impl-psm.ts ├── impl-safetypool.ts ├── impl-stakinglprewards.ts ├── mainnet │ ├── ddhub-morpho-pool.ts │ ├── ddhub-zerolend-rwa-pool.ts │ ├── ddhub.ts │ ├── psm-susde-cron.ts │ ├── psm-susde.ts │ ├── szai.ts │ ├── usdz-migrator.ts │ ├── usdzmaha-curve-stake.ts │ ├── zai-maha-curve-stake.ts │ ├── zai-szai-curve-stake.ts │ ├── zai-usdc-curve-stake.ts │ ├── zap-curve-maha.ts │ ├── zap-curve-szai.ts │ ├── zap-curve-usdc.ts │ ├── zap-mint.ts │ └── zap-safetypool.ts ├── oft │ ├── oft-l1-bridge.ts │ ├── oft-l2-bridge.ts │ ├── oft-maha-adapter.ts │ ├── oft-maha.ts │ ├── oft-szai-adapter.ts │ ├── oft-szai.ts │ ├── oft-zai-adapter.ts │ └── oft-zai.ts ├── oracles │ └── fixed-price-oracle.ts ├── others │ └── erc20-recovery-proxy.ts ├── utils │ └── staking-lp.ts └── zai.ts ├── deployments ├── arbitrum │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHATimelockController.json │ ├── ProxyAdmin.json │ ├── StargateUSDCPool.json │ ├── USDC.json │ └── ZaiStablecoin.json ├── base │ ├── .chainId │ ├── AerodromeRouter.json │ ├── BalancesUIHelper.json │ ├── Deployer.json │ ├── FixedPriceOracle.json │ ├── GnosisSafe.json │ ├── GovernanceUiHelper.json │ ├── L2DepositCollateralL0-Impl.json │ ├── L2DepositCollateralL0-Proxy.json │ ├── L2DepositCollateralL0.json │ ├── LP-Token-ZAIMAHA.json │ ├── LP-Token-ZAIUSDC.json │ ├── LockerToken.json │ ├── LockerTokenImpl.json │ ├── MAHA.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── OmnichainStakingToken-v2.json │ ├── OmnichainStakingToken.json │ ├── OmnichainStakingTokenImpl.json │ ├── PoolUIHelper.json │ ├── ProxyAdmin.json │ ├── StakedZaiOFTWithRestaking.json │ ├── StakingLPRewards-Impl.json │ ├── StakingLPRewards-sZAIMAHA-Proxy.json │ ├── StakingLPRewards-sZAIMAHA.json │ ├── StakingLPRewards-sZAIUSDC-Proxy.json │ ├── StakingLPRewards-sZAIUSDC.json │ ├── StargateUSDCPool.json │ ├── USDC.json │ ├── WETH.json │ ├── ZERO.json │ ├── ZaiStablecoin.json │ ├── ZaiStablecoinOFT.json │ ├── ZapAerodromePoolMAHA.json │ ├── ZapAerodromePoolUSDC.json │ ├── ZapMintBase.json │ └── sZAI.json ├── blast │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHATimelockController.json │ └── ProxyAdmin.json ├── bsc │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── GovernanceUiHelper.json │ ├── LockerToken-Impl.json │ ├── LockerToken-Proxy.json │ ├── LockerToken.json │ ├── MAHA.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── OmnichainStakingToken-Impl.json │ ├── OmnichainStakingToken-Proxy.json │ ├── OmnichainStakingToken.json │ ├── ProxyAdmin.json │ ├── WAGMIE.json │ ├── WBNB.json │ └── ZaiStablecoin.json ├── linea │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── ProxyAdmin.json │ └── ZaiStablecoin.json ├── mainnet │ ├── .chainId │ ├── BalancesUIHelper.json │ ├── DDHub-Proxy.json │ ├── DDHub.json │ ├── DDHubL1-Impl.json │ ├── DDLayerZeroHub-Base-LZ-Proxy.json │ ├── DDLayerZeroHub-Base-LZ.json │ ├── DDLayerZeroHub-Impl.json │ ├── DDLayerZeroHub-OKX-LZ-Proxy.json │ ├── DDLayerZeroHub-OKX-LZ.json │ ├── DDOperatorPlan-Base-LZ.json │ ├── DDOperatorPlan-OKX-LZ.json │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── L1BridgeCollateralL0.json │ ├── LP-Token-ZAIMAHA.json │ ├── LP-Token-ZAIUSDC.json │ ├── LP-Token-ZAIsZAI.json │ ├── MAHA.json │ ├── MAHAOFTAdapter.json │ ├── MAHATimelockController.json │ ├── PegStabilityModule-sUSDe-Proxy.json │ ├── PegStabilityModule-sUSDe.json │ ├── PegStabilityModuleYield-Impl.json │ ├── PoolUIHelper.json │ ├── ProxyAdmin.json │ ├── SafetyPool-Impl.json │ ├── SafetyPool-sZAI-Proxy.json │ ├── SafetyPool-sZAI.json │ ├── StakingLPRewards-Impl.json │ ├── StakingLPRewards-sZAIMAHA-Proxy.json │ ├── StakingLPRewards-sZAIMAHA.json │ ├── StakingLPRewards-sZAIUSDC-Proxy.json │ ├── StakingLPRewards-sZAIUSDC.json │ ├── StakingLPRewards-sZAIsZAI-Proxy.json │ ├── StakingLPRewards-sZAIsZAI.json │ ├── USDC.json │ ├── UsdzMigrator.json │ ├── ZAI.json │ ├── ZaiStablecoin.json │ ├── ZaiStablecoinOFT.json │ ├── ZaiStablecoinOFTAdapter.json │ ├── ZapCurvePoolMAHA.json │ ├── ZapCurvePoolUSDC.json │ ├── ZapCurvePoolsZAI.json │ ├── ZapMintMainnet.json │ ├── ZapSafetyPool.json │ ├── sUSDe.json │ ├── sUSDeCollectorCron.json │ └── sZAI.json ├── optimism │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHATimelockController.json │ └── ProxyAdmin.json ├── scroll │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHATimelockController.json │ └── ProxyAdmin.json ├── sonic │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── ProxyAdmin.json │ ├── ZAI.json │ └── ZaiStablecoin.json ├── unichain │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── ProxyAdmin.json │ ├── ZAI.json │ └── ZaiStablecoin.json └── xlayer │ ├── .chainId │ ├── Deployer.json │ ├── GnosisSafe.json │ ├── MAHA.json │ ├── MAHAOFT.json │ ├── MAHATimelockController.json │ ├── ZaiStablecoin.json │ └── ZaiStablecoinOFT.json ├── execute └── .gitkeep ├── foundry.toml ├── hardhat.config.ts ├── package.json ├── scripts ├── create2 │ ├── create2.ts │ ├── helpers.ts │ ├── proxyAdmin.ts │ ├── psm-usdc.ts │ ├── psm-usdt.ts │ ├── safety-pool.ts │ ├── staking-lp.ts │ ├── timelock.ts │ ├── xerc20-impl.ts │ ├── xerc20-zai-local.ts │ ├── xerc20-zai-remote.ts │ └── zai.ts ├── governance │ ├── deploy-governance-base.ts │ ├── deploy-governance-uihelper.ts │ ├── migrate-mahax.ts │ ├── snapshot-test.csv │ └── snapshot.csv ├── guess │ ├── _helpers.ts │ ├── proxyAdmin.ts │ ├── psm-usdc.ts │ ├── psm-usdt.ts │ ├── safety-pool.ts │ ├── staking-lp.ts │ ├── timelock.ts │ ├── xerc20-impl.ts │ ├── xerc20-zai-local.ts │ ├── xerc20-zai-remote.ts │ └── zai.ts ├── helpers.ts ├── move-locks.ts ├── odos │ ├── helpers │ │ ├── odos.ts │ │ └── path.ts │ ├── prepare-tx-oft-l1-adapter.ts │ └── prepare-tx-susde-cron.ts ├── prepare-timelock.ts ├── prepareTimelockScript.ts ├── test-mint-redeem-susde.ts ├── test-mint-redeem-usdc.ts ├── test-mint-szai.ts ├── timelock │ ├── register-hub.ts │ └── upgrade-mahax.ts ├── utils.ts └── verify │ ├── save-tokens.ts │ ├── verify-timelock.ts │ └── verify-zai.ts ├── tasks ├── layerzero │ ├── check-oft-ownership.ts │ ├── config.ts │ ├── connect-oft.ts │ ├── dvn-deployments.json │ ├── lz-chain-deployments.json │ ├── print-ofts.ts │ ├── setup-oft-all.ts │ ├── setup-oft.ts │ ├── setup-omnigov.ts │ ├── skip-oft-tx.ts │ ├── test-oft-adapter-multichain.ts │ ├── test-oft-adapter.ts │ ├── test-restake-l0.ts │ ├── transfer-gov-ownership.ts │ ├── transfer-ofts-ownership.ts │ └── utils.ts └── misc │ ├── audit-ownerships.ts │ ├── deploy-contract.ts │ ├── migrate-timelock-ownership.ts │ └── notify-rewards.ts ├── test ├── certora │ └── .gitkeep └── foundry │ ├── DDHubTest.fees.sol │ ├── DDHubTest.risk.sol │ ├── DDHubTest.shutdown.sol │ ├── DDHubTest.simple.sol │ ├── DDOperatorPlanTest.sol │ ├── MultiStakingRewardsERC4626Test.boosted.sol │ ├── MultiStakingRewardsERC4626Test.simple.sol │ ├── PegStabilityModuleFork.sol │ ├── PegStabilityModuleTest.sol │ ├── PegStabilityModuleYieldTest.sol │ ├── SafetyPoolTest.sol │ ├── ZaiStablecoinTest.sol │ ├── base │ ├── BaseDDHubTest.sol │ ├── BaseGovernanceTest.sol │ ├── BaseMorphoTest.sol │ ├── BasePsmTest.sol │ ├── BasePsmYieldTest.sol │ ├── BaseUsdzTest.sol │ └── BaseZaiTest.sol │ ├── governance │ ├── LockerTokenTest.sol │ ├── MigrateTokenLocks.sol │ └── OmnichainStakingTokenTest.sol │ ├── hubs │ └── DDZeroLendV1Test.sol │ └── periphery │ ├── oracles │ ├── AerodromeLPOracleTest.sol │ └── MorphoFixedPriceOracleTest.sol │ └── uihelpers │ └── PoolUIHelperTest.sol ├── tsconfig.json ├── web3-functions └── fees-distribute-mainnet │ ├── index.ts │ ├── schema.json │ └── userArgs.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # All files 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = 2 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [*.sol] 14 | indent_size = 2 15 | 16 | [*.tree] 17 | indent_size = 1 18 | 19 | [*.spec] 20 | indent_size = 4 21 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | SEED_PHRASE="test test test test test test test test test test test junk" 2 | 3 | # used by foundry 4 | MAINNET_RPC_URL=https://rpc.ankr.com/eth 5 | 6 | ARBISCAN_KEY= 7 | BASESCAN_KEY= 8 | BLASTSCAN_KEY= 9 | BSCSCAN_KEY= 10 | ETHERSCAN_KEY= 11 | LINEASCAN_KEY= 12 | OP_ETHERSCAN_KEY= 13 | SCROLLSCAN_KEY= 14 | -------------------------------------------------------------------------------- /.github/actions/install/action.yml: -------------------------------------------------------------------------------- 1 | name: Install repository 2 | description: Install the repository dependencies 3 | 4 | runs: 5 | using: composite 6 | 7 | steps: 8 | - name: Install node 9 | uses: actions/setup-node@v4 10 | with: 11 | node-version: 20 12 | cache: yarn 13 | registry-url: "https://registry.npmjs.org" 14 | 15 | - name: Install Foundry 16 | uses: foundry-rs/foundry-toolchain@v1 17 | 18 | - name: Install dependencies 19 | run: yarn install --frozen-lockfile 20 | shell: bash 21 | -------------------------------------------------------------------------------- /.github/dataflow-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahaxyz/contracts/159435eb4810a0cb28da976bd0c2136c7655c218/.github/dataflow-simple.png -------------------------------------------------------------------------------- /.github/incentiveflow-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahaxyz/contracts/159435eb4810a0cb28da976bd0c2136c7655c218/.github/incentiveflow-simple.png -------------------------------------------------------------------------------- /.github/workflows/build-wiki.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build the wiki page for the repository 2 | name: Build Wiki 3 | 4 | concurrency: 5 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} 6 | cancel-in-progress: true 7 | 8 | on: 9 | push: 10 | branches: [master, develop] 11 | 12 | jobs: 13 | wiki-build: 14 | runs-on: ubuntu-latest 15 | name: Create the wiki page 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | submodules: recursive 21 | 22 | - uses: ./.github/actions/install 23 | 24 | - name: Generate Docs 25 | run: SKIP_LOAD=true yarn docs 26 | 27 | - name: Deploy to Wiki Pages 28 | id: deployment 29 | uses: peaceiris/actions-gh-pages@v4 30 | with: 31 | personal_token: ${{ secrets.PERSONAL_TOKEN }} 32 | publish_dir: ./docs 33 | publish_branch: master 34 | external_repository: mahaxyz/contracts.wiki 35 | -------------------------------------------------------------------------------- /.github/workflows/foundry.yml: -------------------------------------------------------------------------------- 1 | name: Foundry 2 | 3 | on: 4 | push: 5 | 6 | env: 7 | FOUNDRY_PROFILE: ci 8 | 9 | jobs: 10 | check: 11 | name: Foundry project 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | with: 17 | submodules: recursive 18 | 19 | - uses: ./.github/actions/install 20 | 21 | - name: Run Forge build 22 | run: | 23 | forge --version 24 | forge build 25 | echo MAINNET_RPC_URL=${{ secrets.MAINNET_RPC_URL }} >> .env 26 | echo BASE_RPC_URL=${{ secrets.BASE_RPC_URL }} >> .env 27 | id: build 28 | 29 | - name: Run Forge tests 30 | run: yarn test:forge 31 | id: test 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Please 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | permissions: 8 | contents: write 9 | pull-requests: write 10 | 11 | jobs: 12 | release-please: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: googleapis/release-please-action@v4 16 | id: release 17 | with: 18 | release-type: node 19 | 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | with: 23 | submodules: recursive 24 | if: ${{ steps.release.outputs.release_created }} 25 | 26 | - uses: ./.github/actions/install 27 | if: ${{ steps.release.outputs.release_created }} 28 | 29 | - name: Publish to NPM 30 | run: | 31 | echo MAINNET_RPC_URL=${{ secrets.MAINNET_RPC_URL }} >> .env 32 | echo BASE_RPC_URL=${{ secrets.BASE_RPC_URL }} >> .env 33 | npm publish 34 | if: ${{ steps.release.outputs.release_created }} 35 | env: 36 | NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} 37 | -------------------------------------------------------------------------------- /.github/workflows/report-coverage.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run the coverage reports and publish it on github pages. 2 | name: Coverage & Gas Report 3 | 4 | concurrency: 5 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} 6 | cancel-in-progress: true 7 | 8 | on: 9 | push: 10 | branches: [master, develop] 11 | 12 | permissions: 13 | contents: read 14 | pages: write 15 | id-token: write 16 | 17 | jobs: 18 | coverage: 19 | runs-on: ubuntu-latest 20 | name: Build Coverage & Gas Report 21 | steps: 22 | # setup env 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | with: 26 | submodules: recursive 27 | 28 | - name: Install lcov 29 | run: sudo apt-get -y install lcov 30 | shell: bash 31 | 32 | - uses: ./.github/actions/install 33 | 34 | - name: Setup Pages 35 | uses: actions/configure-pages@v5 36 | 37 | - name: Run coverage 38 | run: | 39 | echo MAINNET_RPC_URL=${{ secrets.MAINNET_RPC_URL }} >> .env 40 | echo BASE_RPC_URL=${{ secrets.BASE_RPC_URL }} >> .env 41 | yarn compile 42 | yarn coverage:html 43 | 44 | # Deploy to gh pages 45 | - name: Upload artifact 46 | uses: actions/upload-pages-artifact@v3 47 | with: 48 | path: "./coverage" 49 | 50 | - name: Deploy to GitHub Pages 51 | id: deployment 52 | uses: actions/deploy-pages@v4 53 | 54 | - name: Upload coverage reports to Codecov 55 | uses: codecov/codecov-action@v4.0.1 56 | with: 57 | token: ${{ secrets.CODECOV_TOKEN }} 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !/broadcast 2 | .cache 3 | .cache/ 4 | .dynamodb/ 5 | .env 6 | .env.test 7 | .eslintcache 8 | .fusebox/ 9 | .grunt 10 | .lock-wscript 11 | .next 12 | .node_repl_history 13 | .npm 14 | .nuxt 15 | .nyc_output 16 | .rpt2_cache/ 17 | .rts2_cache_cjs/ 18 | .rts2_cache_es/ 19 | .rts2_cache_umd/ 20 | .serverless/ 21 | .tern-port 22 | .vscode 23 | .vuepress/dist 24 | .yarn-integrity 25 | *.lcov 26 | *.log 27 | *.pid 28 | *.pid.lock 29 | *.seed 30 | *.tgz 31 | *.tsbuildinfo 32 | /broadcast/**/dry-run/ 33 | /broadcast/*/31337/ 34 | abi 35 | artifacts 36 | artifacts-zk 37 | bower_components 38 | build/Release 39 | cache 40 | cache-zk 41 | coverage 42 | dist 43 | docs/ 44 | forge-build 45 | generated-abi 46 | guess-pk.ts 47 | hardhat-dependency-compiler/ 48 | jspm_packages/ 49 | lcov.info 50 | lerna-debug.log* 51 | lib-cov 52 | logs 53 | node_modules/ 54 | npm-debug.log* 55 | out/ 56 | pids 57 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 58 | scripts/*.json 59 | scripts/data/*.json 60 | solcInputs 61 | execute/*.json 62 | typechain-types/ 63 | types 64 | typings/ 65 | yarn-debug.log* 66 | yarn-error.log* 67 | target 68 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "lib/metamorpho"] 5 | path = lib/metamorpho 6 | url = https://github.com/morpho-org/metamorpho 7 | [submodule "lib/morpho-blue"] 8 | path = lib/morpho-blue 9 | url = https://github.com/morpho-org/morpho-blue 10 | [submodule "lib/morpho-blue-oracles"] 11 | path = lib/morpho-blue-oracles 12 | url = https://github.com/morpho-org/morpho-blue-oracles 13 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | artifacts/build-info 2 | forge-build/Vm.sol 3 | -------------------------------------------------------------------------------- /audits/2024-08-halborn-core.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahaxyz/contracts/159435eb4810a0cb28da976bd0c2136c7655c218/audits/2024-08-halborn-core.pdf -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | # sample regex patterns 2 | ignore: 3 | - "contracts/tests" 4 | - "contracts/mocks" 5 | - "contracts/periphery" 6 | - "test" 7 | -------------------------------------------------------------------------------- /contracts/Deployer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | contract Deployer { 17 | event Deploy(address addr); 18 | 19 | function deploy(bytes memory bytecode, uint256 _salt) external { 20 | address addr; 21 | assembly { 22 | addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) 23 | if iszero(extcodesize(addr)) { revert(0, 0) } 24 | } 25 | 26 | emit Deploy(addr); 27 | } 28 | 29 | function deployWithAssert(bytes memory bytecode, uint256 _salt, address target) external { 30 | address addr; 31 | assembly { 32 | addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) 33 | if iszero(extcodesize(addr)) { revert(0, 0) } 34 | } 35 | 36 | require(addr == target, "Deployer: INVALID_TARGET"); 37 | 38 | emit Deploy(addr); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /contracts/core/ZaiBitcoin.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // The Stable Money of the Ethermind 11 | 12 | // Website: https://maha.xyz 13 | // Discord: https://discord.gg/mahadao 14 | // Twitter: https://twitter.com/mahaxyz_ 15 | 16 | pragma solidity 0.8.21; 17 | 18 | import {StablecoinBase} from "./StablecoinBase.sol"; 19 | 20 | /** 21 | * @title Zai Bitcoin "BTCz" 22 | * @author maha.xyz 23 | * @notice Represents ZAI bitcoin. 24 | */ 25 | contract ZaiBitcoin is StablecoinBase { 26 | constructor(address _owner) StablecoinBase("ZAI Bitcoin", "BTCz", _owner) { 27 | // nothing 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /contracts/core/ZaiEther.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // The Stable Money of the Ethermind 11 | 12 | // Website: https://maha.xyz 13 | // Discord: https://discord.gg/mahadao 14 | // Twitter: https://twitter.com/mahaxyz_ 15 | 16 | pragma solidity 0.8.21; 17 | 18 | import {StablecoinBase} from "./StablecoinBase.sol"; 19 | 20 | /** 21 | * @title Zai Ether "ETHz" 22 | * @author maha.xyz 23 | * @notice Represents ZAI ether. 24 | */ 25 | contract ZaiEther is StablecoinBase { 26 | constructor(address _owner) StablecoinBase("ZAI Ether", "ETHz", _owner) { 27 | // nothing 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /contracts/core/ZaiStablecoin.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // The Stable Money of the Ethermind 11 | 12 | // Website: https://maha.xyz 13 | // Discord: https://discord.gg/mahadao 14 | // Twitter: https://twitter.com/mahaxyz_ 15 | 16 | pragma solidity 0.8.21; 17 | 18 | import {StablecoinBase} from "./StablecoinBase.sol"; 19 | 20 | /** 21 | * @title Zai Stablecoin "ZAI" 22 | * @author maha.xyz 23 | * @notice Represents the ZAI stablecoin. 24 | */ 25 | contract ZaiStablecoin is StablecoinBase { 26 | constructor(address _owner) StablecoinBase("ZAI Stablecoin", "ZAI", _owner) { 27 | // nothing 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/Constants.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | library Constants { 17 | uint256 internal constant WAD = 10 ** 18; 18 | uint256 internal constant RAY = 10 ** 27; 19 | uint256 internal constant MAXINT256 = uint256(type(int256).max); 20 | uint256 internal constant SAFEMAX = MAXINT256 / RAY; 21 | } 22 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/README.md: -------------------------------------------------------------------------------- 1 | # Direct Deposit Module 2 | 3 | The Zai Direct Deposit (DDM) Module is a specialized liquidty contract that is handle liqudity provisioning of ZAI across various lending pools (like ZeroLend, Morpho, Aave etc..). The DD module is roughly inspired by MakerDAO's DAI Direct Deposit Module (D3M). 4 | 5 | The DD module consists of three components. 6 | 7 | - The Direct Deposit Hub ([DDHub.sol](./DDHub.sol)): The hub mainly for responsible for managing all the various pools 8 | - A Direct Deposit Pool (like the [MetaMorpho](./pools/DDMetaMorpho.sol) pool): Pools that implement the logic of supplying and withdrawing from various pools 9 | - A Direct Deposit Plan ([DDOperatorPlan.sol](./plans/DDOperatorPlan.sol)): Plans that manage the supply of ZAI across the various pools 10 | 11 | To ensure the safety of the DD module, multiple levels of debt ceilings are kept in place so that a particular plan or pool does not beyond it's desired thresholds. The debt minted by a particular is always the minimum of the various debt ceilings. 12 | 13 | - **Global Debt Ceiling**: A global debt ceiling is implemented at the [hub](./DDHub.sol) to ensure that the entirity of the ZAI minted by the protocol is never more than a certain threshold. This is a paramter that can only be set by governance 14 | 15 | - **Pool Debt Ceiling**: An individual pool-level debt ceiling is further implemented to ensure that each pool has it's own limits. 16 | 17 | - **Pool Plan Target**: Each pools has a plan which decides how much ideal exposure the pools should have in terms of ZAI. 18 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/hub/DDHubL1.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDHubBase} from "./DDHubBase.sol"; 17 | 18 | /** 19 | * @title A Direct Deposit Hub 20 | * @author maha.xyz 21 | * @notice This is the main contract responsible for managing pools. 22 | */ 23 | contract DDHubL1 is DDHubBase { 24 | function _mint(uint256 amount, address dest) internal virtual override { 25 | zai.mint(dest, amount); 26 | } 27 | 28 | function _burn(uint256 amount, address dest) internal virtual override { 29 | zai.burn(dest, amount); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/hub/layer2/DDHubL2Base.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDHubBase} from "../DDHubBase.sol"; 17 | 18 | /** 19 | * @title A L2 Direct Deposit Hub 20 | * @author maha.xyz 21 | * @notice This is the main contract responsible for managing pools on layer 2s. 22 | * @dev Holds bridged ZAI from the L1 23 | */ 24 | abstract contract DDHubL2Base is DDHubBase { 25 | /// @dev Keeps track of how much ZAI was artificially minted 26 | uint256 public minted; 27 | 28 | /// @dev The destination on the L1 29 | address public destinationL1; 30 | 31 | function _mint(uint256 amount, address dest) internal virtual override { 32 | minted += amount; 33 | zai.transfer(dest, amount); 34 | } 35 | 36 | function _burn(uint256 amount, address dest) internal virtual override { 37 | minted -= amount; 38 | if (dest != address(this)) { 39 | zai.transferFrom(dest, address(this), amount); 40 | } 41 | } 42 | 43 | function setDestinationL1(address dest) external onlyRole(DEFAULT_ADMIN_ROLE) { 44 | destinationL1 = dest; 45 | } 46 | 47 | /// @notice Withdraws the pending zai tokens into the L1 contract 48 | function withdrawToL1(uint256 amt) external onlyRole(EXECUTOR_ROLE) { 49 | _withdrawToL1(amt); 50 | } 51 | 52 | function _withdrawToL1(uint256 amt) internal virtual; 53 | } 54 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/hub/layer2/DDHubL2Optimism.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDHubL2Base} from "./DDHubL2Base.sol"; 17 | 18 | /** 19 | * @title A L2 Direct Deposit Hub for Optimism-based chains 20 | * @author maha.xyz 21 | */ 22 | contract DDHubL2Optimism is DDHubL2Base { 23 | function _withdrawToL1(uint256 amt) internal virtual override { 24 | // todo 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/hub/layer2/DDHubL2ZkPolygonEVM.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDHubL2Base} from "./DDHubL2Base.sol"; 17 | 18 | /** 19 | * @title A L2 Direct Deposit Hub for Polygon zkEVM-based chains 20 | * @author maha.xyz 21 | */ 22 | contract DDHubL2ZkPolygonEVM is DDHubL2Base { 23 | function _withdrawToL1(uint256 amt) internal virtual override { 24 | // todo 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/hub/layer2/DDHubL2ZkSync.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDHubL2Base} from "./DDHubL2Base.sol"; 17 | 18 | /** 19 | * @title A L2 Direct Deposit Hub for ZkSync-based chains 20 | * @author maha.xyz 21 | */ 22 | contract DDHubL2ZkSync is DDHubL2Base { 23 | function _withdrawToL1(uint256 amt) internal virtual override { 24 | // todo 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/pools/DDBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IStablecoin} from "../../../interfaces/IStablecoin.sol"; 17 | import {IDDPool} from "../../../interfaces/core/IDDPool.sol"; 18 | import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol"; 19 | 20 | abstract contract DDBase is IDDPool { 21 | /// @notice The ZAI Stablecoin 22 | IStablecoin public zai; 23 | 24 | /// @notice The Direct Deposit module hub 25 | address public hub; 26 | 27 | address internal me; 28 | 29 | function __DDBBase_init(address _zai, address _hub) internal { 30 | zai = IStablecoin(_zai); 31 | hub = _hub; 32 | me = address(this); 33 | } 34 | 35 | modifier onlyHub() { 36 | if (msg.sender != hub) revert NotAuthorized(); 37 | _; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/pools/layer2/DDOptimismHub.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDBaseL2} from "./DDBaseL2.sol"; 17 | 18 | /** 19 | * @title A Direct Deposit Module that sends the newly minted ZAI to a hub on a layer 2 via an optimism bridge 20 | * @author maha.xyz 21 | */ 22 | contract DDOptimismHub is DDBaseL2 { 23 | // https://github.com/base-org/guides/blob/main/bridge/native/README.md 24 | function proveBridgeWithdrawal() external { 25 | // todo 26 | } 27 | 28 | // https://github.com/base-org/guides/blob/main/bridge/native/README.md 29 | function finalizeBridgeWithdrawal() external { 30 | // todo 31 | } 32 | 33 | function _depositToBridge(address to, uint256 amount) internal virtual override { 34 | // todo 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contracts/core/direct-deposit/pools/layer2/DDZkPolygonEVMHub.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DDBaseL2} from "./DDBaseL2.sol"; 17 | 18 | /** 19 | * @title A Direct Deposit Module that sends the newly minted ZAI to a hub on a layer 2 via a Polygon zkEVM Bridge 20 | * @author maha.xyz 21 | */ 22 | contract DDZkPolygonEVMHub is DDBaseL2 { 23 | function proveBridgeWithdrawal() external { 24 | // todo 25 | } 26 | 27 | function finalizeBridgeWithdrawal() external { 28 | // todo 29 | } 30 | 31 | function _depositToBridge(address to, uint256 amount) internal virtual override { 32 | // todo 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /contracts/core/psm/README.md: -------------------------------------------------------------------------------- 1 | # Peg Stability Module (PSM) 2 | 3 | The Peg Stability Module (PSM) is a smart contract that is roughly inspired by MakerDAO's PSM. It allow for instant minting of ZAI with some kind of collateral at a fixed rate. 4 | -------------------------------------------------------------------------------- /contracts/governance/MAHA.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 17 | import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; 18 | import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; 19 | 20 | contract MAHA is ERC20Burnable, ERC20Permit { 21 | constructor() ERC20("MahaDAO", "MAHA") ERC20Permit("MahaDAO") { 22 | _mint(msg.sender, 10_000_000 * 10 ** decimals()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /contracts/governance/WAGMIE.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ██╗ ██╗ █████╗ ██████╗ ███╗ ███╗██╗███████╗ 4 | // ██║ ██║██╔══██╗██╔════╝ ████╗ ████║██║██╔════╝ 5 | // ██║ █╗ ██║███████║██║ ███╗██╔████╔██║██║█████╗ 6 | // ██║███╗██║██╔══██║██║ ██║██║╚██╔╝██║██║██╔══╝ 7 | // ╚███╔███╔╝██║ ██║╚██████╔╝██║ ╚═╝ ██║██║███████╗ 8 | // ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚══════╝ 9 | 10 | // Website: https://wagmie.com 11 | // Telegram: https://t.me/wagmiecom 12 | // Twitter: https://x.com/wagmie_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 17 | import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; 18 | import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; 19 | 20 | contract WAGMIE is ERC20Burnable, ERC20Permit { 21 | constructor() ERC20("WAGMIE", "WAGMIE") ERC20Permit("WAGMIE") { 22 | _mint(msg.sender, 1_000_000_000 * 10 ** decimals()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /contracts/governance/locker/LockerLP.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {BaseLocker} from "./BaseLocker.sol"; 17 | 18 | contract LockerLP is BaseLocker { 19 | function initialize(address _token, address _staking) external initializer { 20 | __BaseLocker_init("Locked MAHA/ETH LP", "MAHAETHX", _token, _staking, 365 * 86_400); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /contracts/governance/locker/LockerToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {BaseLocker} from "./BaseLocker.sol"; 17 | 18 | contract LockerToken is BaseLocker { 19 | function initialize(address _token, address _staking) external initializer { 20 | __BaseLocker_init("Locked MAHA Tokens", "MAHAX", _token, _staking, 4 * 365 * 86_400); 21 | } 22 | 23 | /// @notice Update the start date of a lock 24 | /// @param _id The lock id 25 | /// @param _startDate The new start date 26 | /// @dev This function can only be called by the staking contract 27 | function updateLockDates(uint256 _id, uint256 _startDate, uint256 _endDate) external { 28 | require(msg.sender == address(staking), "!_staking"); 29 | _locked[_id].start = _startDate; 30 | _locked[_id].end = _endDate; 31 | _locked[_id].power = _calculatePower(_locked[_id]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /contracts/interfaces/core/IDDPlan.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | /** 17 | * @title DD Plan Interface 18 | * @author maha.xyz, makerdao 19 | * @notice Plan contracts are contracts that the Hub uses to determine how much to change its position. 20 | */ 21 | interface IDDPlan { 22 | event Disable(); 23 | 24 | /** 25 | * @notice Determines what the position should be based on current assets 26 | * and the custom plan rules. 27 | * @param currentAssets asset balance from a specific pool in Dai [wad] 28 | * denomination 29 | * @return uint256 target assets the Hub should wind or unwind to in Dai 30 | */ 31 | function getTargetAssets(uint256 currentAssets) external view returns (uint256); 32 | 33 | /** 34 | * @notice Reports whether the plan is active 35 | */ 36 | function active() external view returns (bool); 37 | 38 | /** 39 | * @notice Disables the plan so that it would instruct the Hub to unwind 40 | * its entire position. 41 | * @dev Implementation should be permissioned. 42 | */ 43 | function disable() external; 44 | } 45 | -------------------------------------------------------------------------------- /contracts/interfaces/core/IMultiTokenRewardsWithWithdrawalDelay.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IMultiStakingRewardsERC4626} from "./IMultiStakingRewardsERC4626.sol"; 17 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 18 | 19 | interface IMultiTokenRewardsWithWithdrawalDelay is IMultiStakingRewardsERC4626 { 20 | event WithdrawalQueueUpdated(uint256 indexed amt, uint256 indexed unlockTime, address indexed caller); 21 | 22 | function queueWithdrawal(uint256 shares) external; 23 | 24 | function withdrawalDelay() external view returns (uint256); 25 | 26 | function withdrawalAmount(address who) external view returns (uint256); 27 | 28 | function withdrawalTimestamp(address who) external view returns (uint256); 29 | 30 | function cancelWithdrawal() external; 31 | } 32 | -------------------------------------------------------------------------------- /contracts/interfaces/core/ISafetyPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 17 | 18 | /** 19 | * @title Safety Pool 20 | * @author maha.xyz 21 | * @notice This is the main contract responsible for paying for bad debt. 22 | */ 23 | interface ISafetyPool { 24 | function coverBadDebt(uint256 amount) external; 25 | 26 | function initialize( 27 | address _zai, 28 | address _governance, 29 | address _rewardToken1, 30 | address _rewardToken2, 31 | uint256 _rewardsDuration, 32 | address _stakingBoost 33 | ) external; 34 | 35 | function MANAGER_ROLE() external view returns (bytes32); 36 | } 37 | -------------------------------------------------------------------------------- /contracts/interfaces/errors/ConnextErrors.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | library ConnextErrors { 17 | /// @dev Error for 0x0 address inputs 18 | error InvalidZeroInput(); 19 | 20 | /// @dev error when function returns 0 amount 21 | error InvalidZeroOutput(); 22 | 23 | /// @dev Error when the sender is not expected 24 | error InvalidSender(address expectedSender, address actualSender); 25 | 26 | /// @dev Error when the token received over the bridge is not the one expected 27 | error InvalidTokenReceived(); 28 | 29 | /// @dev Error for invalid bridge fee share configuration 30 | error InvalidBridgeFeeShare(uint256 bridgeFee); 31 | 32 | /// @dev Error for invalid sweep batch size 33 | error InvalidSweepBatchSize(uint256 batchSize); 34 | 35 | /// @dev Error when sending ETH fails 36 | error TransferFailed(); 37 | 38 | /// @dev Error when an unauthorized address tries to call the bridge function on the L2 39 | error UnauthorizedBridgeSweeper(); 40 | 41 | /// @dev Error when trade does not meet minimum output amount 42 | error InsufficientOutputAmount(); 43 | } 44 | -------------------------------------------------------------------------------- /contracts/interfaces/errors/PSMErrors.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 17 | 18 | /** 19 | * @title PSMErrors 20 | * @author maha.xyz 21 | * @notice This library defines errors for the PSM contract 22 | */ 23 | library PSMErrors { 24 | /// @notice Error when supply cap is reached 25 | error SupplyCapReached(); 26 | 27 | /// @notice Error when debt cap is reached 28 | error DebtCapReached(); 29 | 30 | /// @notice Error when address is not set 31 | error NotZeroAddress(); 32 | 33 | /// @notice Error when value is zero 34 | error NotZeroValue(); 35 | } 36 | -------------------------------------------------------------------------------- /contracts/interfaces/events/DDEventsLib.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IDDHub} from "../core/IDDHub.sol"; 17 | import {IDDPlan} from "../core/IDDPlan.sol"; 18 | import {IDDPool} from "../core/IDDPool.sol"; 19 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 20 | 21 | /** 22 | * @title DDEventsLib 23 | * @author maha.xyz 24 | * @notice This library defines events for the Direct Deposit contract 25 | */ 26 | library DDEventsLib { 27 | // --- Events --- 28 | event BurnDebt(IDDPool indexed pool, uint256 amt); 29 | event MintDebt(IDDPool indexed pool, uint256 amt); 30 | event Fees(IDDPool indexed pool, uint256 amt); 31 | event PoolInfoUpdated(IDDPool indexed pool, IDDHub.PoolInfo info); 32 | } 33 | -------------------------------------------------------------------------------- /contracts/interfaces/events/SafetyPoolEvents.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | /** 17 | * @title SafetyPoolEvents 18 | * @author maha.xyz 19 | * @notice This library defines events for the SafetyPool contract 20 | */ 21 | library SafetyPoolEvents { 22 | // --- Events --- 23 | event BadDebtCovered(uint256 indexed amt, address indexed caller); 24 | event WithdrawalQueueUpdated(uint256 indexed amt, uint256 indexed unlockTime, address indexed caller); 25 | } 26 | -------------------------------------------------------------------------------- /contracts/interfaces/events/ZAIEventsLib.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 17 | 18 | library ZAIEventsLib { 19 | // todo 20 | } 21 | -------------------------------------------------------------------------------- /contracts/interfaces/governance/IAggregatorV3Interface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | interface IAggregatorV3Interface { 17 | function decimals() external view returns (uint8); 18 | 19 | function description() external view returns (string memory); 20 | 21 | function getAnswer(uint256) external view returns (int256); 22 | 23 | function getTimestamp(uint256) external view returns (uint256); 24 | 25 | function latestAnswer() external view returns (int256); 26 | 27 | function latestTimestamp() external view returns (uint256); 28 | 29 | function version() external pure returns (uint256); 30 | 31 | function getRoundData(uint80 _roundId) 32 | external 33 | view 34 | returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); 35 | 36 | function latestRoundData() 37 | external 38 | view 39 | returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); 40 | } 41 | -------------------------------------------------------------------------------- /contracts/interfaces/governance/ILPOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | interface ILPOracle { 17 | /// @notice Gets the price of the liquidity pool token. 18 | /// @dev This function fetches reserves from the Nile AMM and uses a pre-defined price for tokens to calculate the LP 19 | /// token price. 20 | /// @return price The price of the liquidity pool token. 21 | function getPrice() external view returns (uint256 price); 22 | 23 | /// @notice Computes the square root of a given number using the Babylonian method. 24 | /// @dev This function uses an iterative method to compute the square root of a number. 25 | /// @param x The number to compute the square root of. 26 | /// @return y The square root of the given number. 27 | function sqrt(uint256 x) external pure returns (uint256 y); 28 | } 29 | -------------------------------------------------------------------------------- /contracts/interfaces/governance/IPythOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IAggregatorV3Interface} from "./IAggregatorV3Interface.sol"; 17 | 18 | interface IPythOracle is IAggregatorV3Interface { 19 | function priceId() external view returns (bytes32); 20 | 21 | function pyth() external view returns (address); 22 | 23 | function updateFeeds(bytes[] calldata priceUpdateData) external payable; 24 | } 25 | -------------------------------------------------------------------------------- /contracts/interfaces/governance/IWETH.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.20; 3 | 4 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 5 | 6 | interface IWETH is IERC20 { 7 | function deposit() external payable; 8 | 9 | function withdraw(uint256 wad) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/IStablecoinOFT.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 17 | 18 | interface IStablecoinOFT is IERC20 { 19 | function setRestaker(address _restaking) external; 20 | 21 | function restakingMint(address _to, uint256 _amount) external; 22 | } 23 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/connext/IConnext.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | interface IConnext { 17 | function xcall( 18 | uint32 _destination, 19 | address _to, 20 | address _asset, 21 | address _delegate, 22 | uint256 _amount, 23 | uint256 _slippage, 24 | bytes calldata _callData 25 | ) external payable returns (bytes32); 26 | 27 | function xcall( 28 | uint32 _destination, 29 | address _to, 30 | address _asset, 31 | address _delegate, 32 | uint256 _amount, 33 | uint256 _slippage, 34 | bytes calldata _callData, 35 | uint256 _relayerFee 36 | ) external returns (bytes32); 37 | 38 | function xcallIntoLocal( 39 | uint32 _destination, 40 | address _to, 41 | address _asset, 42 | address _delegate, 43 | uint256 _amount, 44 | uint256 _slippage, 45 | bytes calldata _callData 46 | ) external payable returns (bytes32); 47 | 48 | // used by the smart contract to swap tokens 49 | function swapExact( 50 | bytes32 canonicalId, 51 | uint256 amountIn, 52 | address assetIn, 53 | address assetOut, 54 | uint256 minAmountOut, 55 | uint256 deadline 56 | ) external payable returns (uint256); 57 | } 58 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/connext/IL1BridgeConnext.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | interface IL1BridgeConnext { 17 | /** 18 | * @notice Accepts collateral from the bridge 19 | * @dev This function will take all collateral and deposit it into maha 20 | * The ZAI from the deposit will be sent to the lockbox to be wrapped into xZAI 21 | * The xZAI will be burned so that the xZAI on the L2 can be unwrapped for ZAI later 22 | */ 23 | function xReceive( 24 | bytes32 _transferId, 25 | uint256 _amount, 26 | address _asset, 27 | address _originSender, 28 | uint32 _origin, 29 | bytes memory 30 | ) external returns (bytes memory); 31 | } 32 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/curve/ICurveStableSwapNG.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 17 | 18 | interface ICurveStableSwapNG is IERC20 { 19 | function add_liquidity( 20 | uint256[] memory _amounts, 21 | uint256 _min_mint_amount, 22 | address _receiver 23 | ) external returns (uint256); 24 | 25 | function calc_token_amount(uint256[] memory _amounts, bool _is_deposit) external returns (uint256); 26 | } 27 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/curve/ICurveTwoCrypto.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 17 | 18 | interface ICurveTwoCrypto is IERC20 { 19 | function add_liquidity(uint256[2] memory amounts, uint256 minLp) external returns (uint256); 20 | 21 | function calc_token_amount(uint256[2] memory _amounts, bool _is_deposit) external returns (uint256); 22 | } 23 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/layerzero/IL0EndpointV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | struct SetConfigParam { 17 | uint32 eid; 18 | uint32 configType; 19 | bytes config; 20 | } 21 | 22 | interface IL0EndpointV2 { 23 | function delegates(address) external view returns (address); 24 | 25 | function setConfig(address, address, SetConfigParam[] calldata) external; 26 | 27 | function getConfig(address, address, uint32, uint32) external view returns (bytes memory); 28 | 29 | function skip( 30 | address _oapp, //the Oapp address 31 | uint32 _srcEid, //source chain endpoint id 32 | bytes32 _sender, //the byte32 format of sender address 33 | uint64 _nonce // the message nonce you wish to skip to 34 | ) external; 35 | 36 | function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external; 37 | 38 | function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib); 39 | 40 | function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool); 41 | 42 | function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external; 43 | 44 | function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault); 45 | 46 | function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external; 47 | 48 | function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry); 49 | } 50 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/layerzero/IStargate.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import { 17 | IOFT, 18 | MessagingFee, 19 | MessagingReceipt, 20 | OFTReceipt, 21 | SendParam 22 | } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol"; 23 | 24 | enum StargateType { 25 | Pool, 26 | OFT 27 | } 28 | 29 | struct Ticket { 30 | uint56 ticketId; 31 | bytes passenger; 32 | } 33 | 34 | /// @title Interface for Stargate. 35 | /// @notice Defines an API for sending tokens to destination chains. 36 | interface IStargate is IOFT { 37 | /// @dev This function is same as `send` in OFT interface but returns the ticket data if in the bus ride mode, 38 | /// which allows the caller to ride and drive the bus in the same transaction. 39 | function sendToken( 40 | SendParam calldata _sendParam, 41 | MessagingFee calldata _fee, 42 | address _refundAddress 43 | ) external payable returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt, Ticket memory ticket); 44 | 45 | /// @notice Returns the Stargate implementation type. 46 | function stargateType() external pure returns (StargateType); 47 | } 48 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/leverage/ISwapper.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: None 2 | pragma solidity ^0.8.19; 3 | 4 | interface ISwapper { 5 | struct SwapExactInParams { 6 | address from; // token to swap from 7 | address to; // token to swap to 8 | bytes data; // swap data (ex: path, deadline, etc.) 9 | } 10 | 11 | struct SwapExactOutParams { 12 | address from; // token to swap from 13 | address to; // token to swap to 14 | uint256 amtOut; // amt to receive 15 | bytes data; // swap data (ex: path, deadline, etc.) 16 | } 17 | 18 | /// @notice using balanceOf of swapper contract to swap. caller need to check slippage by themselves 19 | function swapExactIn(SwapExactInParams calldata data) external; 20 | 21 | /// @notice using balanceOf of swapper contract to swap. caller need to check slippage by themselves 22 | function swapExactOut(SwapExactOutParams calldata data) external; 23 | 24 | function ROUTER() external returns (address); 25 | } 26 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/leverage/IWNative.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | interface IWNative { 17 | function deposit() external payable; 18 | 19 | function withdraw(uint256 wad) external; 20 | } 21 | -------------------------------------------------------------------------------- /contracts/interfaces/periphery/morpho/IMorphoFlashLoanCallback.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | /// @title IMorphoFlashLoanCallback 17 | /// @notice Interface that users willing to use `flashLoan`'s callback must implement. 18 | interface IMorphoFlashLoanCallback { 19 | /// @notice Callback called when a flash loan occurs. 20 | /// @dev The callback is called only if data is not empty. 21 | /// @param assets The amount of assets that was flash loaned. 22 | /// @param data Arbitrary data passed to the `flashLoan` function. 23 | function onMorphoFlashLoan(uint256 assets, bytes calldata data) external; 24 | } 25 | -------------------------------------------------------------------------------- /contracts/mocks/MockAggregator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 17 | 18 | contract MockAggregator is Ownable { 19 | int256 public latestAnswer; 20 | 21 | constructor(int256 _answer) Ownable(msg.sender) { 22 | latestAnswer = _answer; 23 | } 24 | 25 | function setAnswer(int256 _answer) external onlyOwner { 26 | latestAnswer = _answer; 27 | } 28 | 29 | function decimals() external pure returns (uint8) { 30 | return 8; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/mocks/MockERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 17 | 18 | contract MockERC20 is ERC20 { 19 | uint8 public decimals_; 20 | 21 | constructor(string memory _name, string memory _symbol, uint8 _decimals) ERC20(_name, _symbol) { 22 | // nothing 23 | decimals_ = _decimals; 24 | } 25 | 26 | function mint(address _to, uint256 _amount) external { 27 | _mint(_to, _amount); 28 | } 29 | 30 | function burn(address _to, uint256 _amount) external { 31 | _burn(_to, _amount); 32 | } 33 | 34 | function decimals() public view virtual override returns (uint8) { 35 | return decimals_; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /contracts/mocks/MockERC4626.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.20; 3 | 4 | import {IERC20, ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import {ERC4626} from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; 6 | 7 | contract ERC4626Mock is ERC4626 { 8 | constructor(address underlying) ERC20("ERC4626Mock", "E4626M") ERC4626(IERC20(underlying)) {} 9 | 10 | function mint(address account, uint256 amount) external { 11 | _mint(account, amount); 12 | } 13 | 14 | function burn(address account, uint256 amount) external { 15 | _burn(account, amount); 16 | } 17 | } -------------------------------------------------------------------------------- /contracts/mocks/MockLayerZero.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | contract MockLayerZero { 17 | function setDelegate(address) external { 18 | // nothing 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /contracts/mocks/MockOmnichainStaking.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {OmnichainStakingBase} from "../governance/locker/staking/OmnichainStakingBase.sol"; 17 | 18 | contract MockOmnichainStaking is OmnichainStakingBase { 19 | function init() external reinitializer(1) { 20 | address[] memory _rewardTokens; 21 | super.__OmnichainStakingBase_init("TEST", "TESTvp", address(this), address(this), _rewardTokens, 0, address(0)); 22 | } 23 | 24 | function initWithData( 25 | address _locker, 26 | address _weth, 27 | address _rewardToken1, 28 | uint256 _rewardsDuration, 29 | address _distributor 30 | ) external reinitializer(1) { 31 | address[] memory _rewardTokens = new address[](2); 32 | _rewardTokens[0] = _rewardToken1; 33 | _rewardTokens[1] = _weth; 34 | super.__OmnichainStakingBase_init("TEST", "TESTvp", _locker, _weth, _rewardTokens, _rewardsDuration, _distributor); 35 | } 36 | 37 | function mint(address _to, uint256 _amount) external { 38 | _mint(_to, _amount); 39 | _delegate(_to, _to); 40 | } 41 | 42 | function burn(address _to, uint256 _amount) external { 43 | _burn(_to, _amount); 44 | _delegate(_to, _to); 45 | } 46 | 47 | function underlying() external view returns (address) { 48 | return address(this); 49 | } 50 | 51 | function _getTokenPower(uint256 amount) internal pure override returns (uint256 power) { 52 | power = amount; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /contracts/periphery/Erc20RecoverProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity 0.8.21; 3 | 4 | import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; 5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | 7 | /// @notice Contract to recover a ERC20 token from a proxy contract to a wallet 8 | contract Erc20RecoverProxy is OwnableUpgradeable { 9 | function initialize(address _usdc, address _owner) external reinitializer(99) { 10 | IERC20 usdc = IERC20(_usdc); 11 | usdc.transfer(_owner, usdc.balanceOf(address(this))); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/periphery/UsdzMigrator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 17 | 18 | contract UsdzMigrator { 19 | IERC20 public old; 20 | IERC20 public zai; 21 | 22 | constructor(address _old, address _zai) { 23 | old = IERC20(_old); 24 | zai = IERC20(_zai); 25 | } 26 | 27 | function migrate(uint256 amount) external { 28 | require(old.transferFrom(msg.sender, address(this), amount), "Transfer failed"); 29 | require(zai.transfer(msg.sender, amount), "Transfer failed"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/periphery/arbitrage/ZAIConnextArbitrageBot.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // The Stable Money of the Ethermind 11 | 12 | // Website: https://maha.xyz 13 | // Discord: https://discord.gg/mahadao 14 | // Twitter: https://twitter.com/mahaxyz_ 15 | 16 | pragma solidity 0.8.21; 17 | 18 | import {IStablecoin} from "../../interfaces/IStablecoin.sol"; 19 | import {IPegStabilityModule} from "../../interfaces/core/IPegStabilityModule.sol"; 20 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 21 | 22 | /** 23 | * @title ZAI Connext Arbitrage Bot 24 | * @author maha.xyz 25 | * @notice A permission-less arbitrage bot will execute an arbitrage trade cross-chain using Connext 26 | */ 27 | contract ZAIConnextArbitrageBot { 28 | IStablecoin public zai; 29 | IPegStabilityModule public psm; 30 | 31 | constructor(address _zai, address _psm) { 32 | zai = IStablecoin(_zai); 33 | psm = IPegStabilityModule(_psm); 34 | } 35 | 36 | /** 37 | * @notice Executes an arbitrage trade to mint or burn ZAI stablecoin 38 | */ 39 | function arbitrage() external { 40 | // todo 41 | } 42 | 43 | function _buy(uint256 amount) internal { 44 | // todo 45 | } 46 | 47 | function _sell(uint256 amount) internal { 48 | // todo 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /contracts/periphery/crons/L1RestakingSweeperCron.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 17 | import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; 18 | 19 | interface IL1BridgeCollateralL0 { 20 | function process() external; 21 | } 22 | 23 | contract L1RestakingSweeperCron is Ownable { 24 | address public usdc; 25 | uint256 public limit; 26 | IL1BridgeCollateralL0 public depositCollateralL0; 27 | 28 | constructor(address _usdc, uint256 _limit, address _depositCollateralL0, address _governance) Ownable(_governance) { 29 | usdc = _usdc; 30 | limit = _limit; 31 | depositCollateralL0 = IL1BridgeCollateralL0(_depositCollateralL0); 32 | } 33 | 34 | function setSweepLimit(uint256 _limit) public onlyOwner { 35 | limit = _limit; 36 | } 37 | 38 | function usdcToSweep() public view returns (uint256) { 39 | return IERC20(usdc).balanceOf(address(depositCollateralL0)); 40 | } 41 | 42 | function shouldExecute() public view returns (bool) { 43 | return usdcToSweep() >= limit; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /contracts/periphery/leverage/implementations/MorphoLeveragePendleMainnet.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ILoopingStrategy} from "../../../interfaces/periphery/leverage/ILoopingStrategy.sol"; 17 | import {IMorpho, MorphoLeverageMainnet} from "../MorphoLeverageMainnet.sol"; 18 | import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; 19 | 20 | /// @title MorphoLeveragePendleMainnet 21 | /// @author maha.xyz 22 | /// @notice Leverages contract on Morpho with Pendle PT Tokens 23 | contract MorphoLeveragePendleMainnet is MorphoLeverageMainnet { 24 | using SafeERC20 for IERC20; 25 | 26 | constructor( 27 | address _morpho, 28 | IMorpho.MarketParams memory _marketParams 29 | ) MorphoLeverageMainnet(_morpho, _marketParams, address(0)) {} 30 | } 31 | -------------------------------------------------------------------------------- /contracts/periphery/oracles/FixedPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DumbAggregatorOracle, IAggregatorV3Interface} from "./DumbAggregatorOracle.sol"; 17 | 18 | /// @title FixedPriceOracle 19 | /// @author maha.xyz 20 | /// @notice A contract that returns a fixed price 21 | contract FixedPriceOracle is DumbAggregatorOracle { 22 | int256 private immutable price_; 23 | 24 | constructor(int256 _price, uint8 _decimals) DumbAggregatorOracle(_decimals, "Fixed Price Oracle") { 25 | price_ = _price; 26 | } 27 | 28 | function getPrice() public view override returns (int256 price) { 29 | price = price_; 30 | } 31 | 32 | function getPriceFor(uint256 amount) public view returns (int256) { 33 | return (latestAnswer() * int256(amount)) / int256(1 * 10 ** decimals()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contracts/periphery/oracles/MorphoFixedPriceOracle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {DumbAggregatorOracle, IAggregatorV3Interface} from "./DumbAggregatorOracle.sol"; 17 | 18 | /// @title FixedPriceOracle 19 | /// @author maha.xyz 20 | /// @notice A contract that returns a fixed price 21 | contract MorphoFixedPriceOracle is DumbAggregatorOracle { 22 | int256 private price_; 23 | 24 | constructor(int256 _price, uint8 _decimals) DumbAggregatorOracle(_decimals, "Fixed Price Oracle") { 25 | price_ = _price; 26 | } 27 | 28 | function getPrice() public view override returns (int256 _price) { 29 | _price = price_; 30 | } 31 | 32 | function initialize(int256 _price, uint8 _decimals) external { 33 | price_ = _price; 34 | decimals_ = _decimals; 35 | } 36 | 37 | function getPriceFor(uint256 amount) public view returns (int256) { 38 | return (latestAnswer() * int256(amount)) / int256(1 * 10 ** decimals()); 39 | } 40 | 41 | /// Returns the price of 1 asset of collateral token quoted in 1 asset of loan token, scaled by 1e36. 42 | function price() external view returns (uint256 _price) { 43 | _price = uint256(latestAnswer()) * 1e36 / (1 * 10 ** decimals()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /contracts/periphery/oracles/MorphoFixedPriceOracleProxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; 17 | 18 | /// @title MorphoFixedPriceOracleProxy 19 | /// @author maha.xyz 20 | /// @notice A contract that returns a fixed price for morpho; 21 | contract MorphoFixedPriceOracleProxy is Initializable { 22 | uint256 private _price; 23 | uint256 private _decimals; 24 | 25 | function getPrice() public view returns (uint256 price_) { 26 | price_ = _price; 27 | } 28 | 29 | function initialize(uint256 price_, uint8 decimals_) external initializer { 30 | _price = price_; 31 | _decimals = decimals_; 32 | } 33 | 34 | function getPriceFor(uint256 amount) public view returns (uint256) { 35 | return (_price * amount) / (1 * 10 ** _decimals); 36 | } 37 | 38 | /// Returns the price of 1 asset of collateral token quoted in 1 asset of loan token, scaled by 1e36. 39 | function price() external view returns (uint256 price_) { 40 | price_ = _price * 1e36 / (1 * 10 ** _decimals); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contracts/periphery/restaking/layerzero/LayerZeroCustomOFT.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {OFT} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFT.sol"; 17 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 18 | 19 | import {ERC20FlashMint} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol"; 20 | import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; 21 | 22 | contract LayerZeroCustomOFT is OFT, ERC20FlashMint, ERC20Permit { 23 | mapping(address => bool) public blacklist; 24 | bool public paused; 25 | 26 | constructor( 27 | string memory name, 28 | string memory symbol, 29 | address _lzEndpoint 30 | ) OFT(name, symbol, _lzEndpoint, msg.sender) Ownable(msg.sender) ERC20Permit(symbol) { 31 | _mint(msg.sender, 1e18); 32 | _burn(msg.sender, 1e18); 33 | } 34 | 35 | function toggleBlacklist(address who, bool what) external onlyOwner { 36 | blacklist[who] = what; 37 | } 38 | 39 | function togglePause(bool what) external onlyOwner { 40 | paused = what; 41 | } 42 | 43 | function _update(address from, address to, uint256 value) internal virtual override { 44 | require(!blacklist[from], "blacklisted"); 45 | require(!blacklist[to], "blacklisted"); 46 | require(!paused, "paused"); 47 | super._update(from, to, value); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /contracts/periphery/restaking/layerzero/LayerZeroCustomOFTAdapter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {OFT} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFT.sol"; 17 | import {OFTAdapter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFTAdapter.sol"; 18 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 19 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 20 | 21 | contract LayerZeroCustomOFTAdapter is OFTAdapter { 22 | constructor( 23 | address _token, // a deployed, already existing ERC20 token address 24 | address _layerZeroEndpoint // local endpoint address 25 | ) OFTAdapter(_token, _layerZeroEndpoint, msg.sender) Ownable(msg.sender) {} 26 | 27 | function recall(address _token) external onlyOwner { 28 | IERC20(_token).transfer(msg.sender, IERC20(_token).balanceOf(address(this))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/periphery/restaking/layerzero/StakedZaiOFTWithRestaking.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {LayerZeroCustomOFT} from "./LayerZeroCustomOFT.sol"; 17 | 18 | contract StakedZaiOFTWithRestaking is LayerZeroCustomOFT { 19 | address public restaker; 20 | 21 | constructor(address _lzEndpoint, address _owner) LayerZeroCustomOFT("Staked ZAI", "sZAI", _lzEndpoint) { 22 | _transferOwnership(_owner); 23 | endpoint.setDelegate(_owner); 24 | _mint(msg.sender, 69_000 ether); 25 | _burn(msg.sender, 69_000 ether); 26 | } 27 | 28 | function setRestakerSZAI(address _restaking) external onlyOwner { 29 | restaker = _restaking; 30 | } 31 | 32 | function restakingMint(address _to, uint256 _amount) external { 33 | require(msg.sender == restaker, "!restaker"); 34 | _mint(_to, _amount); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contracts/periphery/restaking/layerzero/ZaiOFTWithRestaking.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {LayerZeroCustomOFT} from "./LayerZeroCustomOFT.sol"; 17 | 18 | contract ZaiOFTWithRestaking is LayerZeroCustomOFT { 19 | address public restaker; 20 | 21 | constructor(address _lzEndpoint, address _owner) LayerZeroCustomOFT("ZAI Stablecoin", "ZAI", _lzEndpoint) { 22 | _transferOwnership(_owner); 23 | endpoint.setDelegate(_owner); 24 | _mint(msg.sender, 69_420 ether); 25 | _burn(msg.sender, 69_420 ether); 26 | } 27 | 28 | function setRestakerZAI(address _restaking) external onlyOwner { 29 | restaker = _restaking; 30 | } 31 | 32 | function restakingMint(address _to, uint256 _amount) external { 33 | require(msg.sender == restaker, "!restaker"); 34 | _mint(_to, _amount); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contracts/periphery/staking/StakingLPRewards.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {MultiStakingRewardsERC4626} from "../../core/utils/MultiStakingRewardsERC4626.sol"; 17 | 18 | contract StakingLPRewards is MultiStakingRewardsERC4626 { 19 | function initialize( 20 | string memory _name, 21 | string memory _symbol, 22 | address _stakingToken, 23 | address _governance, 24 | address _rewardToken1, 25 | address _rewardToken2, 26 | uint256 _rewardsDuration, 27 | address _staking 28 | ) external reinitializer(1) { 29 | __MultiStakingRewardsERC4626_init( 30 | _name, _symbol, _stakingToken, 21 days, _governance, _rewardToken1, _rewardToken2, _rewardsDuration, _staking 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /contracts/periphery/wrappers/WrappedAerodromeGauge.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {MultiStakingRewardsERC4626} from "../../core/utils/MultiStakingRewardsERC4626.sol"; 17 | 18 | contract WrappedAerodromeGauge is MultiStakingRewardsERC4626 { 19 | // function initialize( 20 | // string memory _name, 21 | // string memory _symbol, 22 | // address _stakingToken, 23 | // address _governance, 24 | // address _rewardToken1, 25 | // address _rewardToken2, 26 | // uint256 _rewardsDuration, 27 | // address _staking, 28 | // address _gauge 29 | // ) external reinitializer(1) { 30 | // __StakingLPRewards_init( 31 | // _name, _symbol, _stakingToken, _governance, _rewardToken1, _rewardToken2, _rewardsDuration, _staking 32 | // ); 33 | // } 34 | } 35 | -------------------------------------------------------------------------------- /contracts/periphery/zaps/implementations/base/ZapAerodromeBase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IAerodromeRouter} from "../../../../interfaces/periphery/dex/IAerodromeRouter.sol"; 17 | import {IAerodromePool} from "../../../../interfaces/periphery/dex/IAerodromePool.sol"; 18 | 19 | import {IL2DepositCollateralL0} from "../../../../interfaces/periphery/layerzero/IL2DepositCollateralL0.sol"; 20 | import {IERC20Metadata, ZapBase} from "../../ZapBase.sol"; 21 | 22 | contract ZapAerodromeBase is ZapBase { 23 | IL2DepositCollateralL0 public bridge; 24 | IAerodromeRouter public router; 25 | address public factory; 26 | 27 | constructor(address _staking, address _bridge, address _router) ZapBase(_staking) { 28 | bridge = IL2DepositCollateralL0(_bridge); 29 | router = IAerodromeRouter(_router); 30 | 31 | zai = IERC20Metadata(address(bridge.oft())); 32 | collateral = IERC20Metadata(address(bridge.depositToken())); 33 | 34 | // nothing 35 | zai.approve(address(pool), type(uint256).max); 36 | 37 | decimalOffset = 10 ** (18 - collateral.decimals()); 38 | 39 | // give approvals 40 | zai.approve(address(router), type(uint256).max); 41 | collateral.approve(address(router), type(uint256).max); 42 | collateral.approve(address(bridge), type(uint256).max); 43 | 44 | factory = IAerodromePool(address(pool)).factory(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /contracts/periphery/zaps/implementations/ethereum/ZapBaseEthereum.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {IPegStabilityModule} from "../../../../interfaces/core/IPegStabilityModule.sol"; 17 | import {ZapBase} from "../../ZapBase.sol"; 18 | import {IERC20Metadata} from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol"; 19 | 20 | abstract contract ZapBaseEthereum is ZapBase { 21 | IPegStabilityModule public psm; 22 | 23 | constructor(address _staking, address _psm) ZapBase(_staking) { 24 | psm = IPegStabilityModule(_psm); 25 | 26 | zai = IERC20Metadata(address(psm.zai())); 27 | collateral = IERC20Metadata(address(psm.collateral())); 28 | 29 | decimalOffset = 10 ** (18 - collateral.decimals()); 30 | 31 | // give approvals 32 | zai.approve(address(pool), type(uint256).max); 33 | collateral.approve(address(pool), type(uint256).max); 34 | collateral.approve(address(psm), type(uint256).max); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /deploy/base/usdzusdc-aero-morpho-fixed-oracle.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const proxyAdminD = await hre.deployments.get("ProxyAdmin"); 6 | 7 | const price = 2n * 10n ** 24n; 8 | 9 | await deployProxy( 10 | hre, 11 | "MorphoFixedPriceOracleProxy", 12 | [price, 18], 13 | proxyAdminD.address, 14 | "AerodromeLPOracle-MorphoFixed-USDCUSDz" 15 | ); 16 | } 17 | 18 | main.tags = ["LPOracle-Aero-Morpho-Fixed-sUSDZUSDC"]; 19 | export default main; 20 | -------------------------------------------------------------------------------- /deploy/base/usdzusdc-aero-oracle.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const oracleA = "0xeAA79aaC2decf71F07c3208Df05B198d09c9F971"; 6 | const oracleB = "0xeAA79aaC2decf71F07c3208Df05B198d09c9F971"; 7 | const pool = "0x72d509aff75753aaad6a10d3eb98f2dbc58c480d"; 8 | 9 | await deployContract( 10 | hre, 11 | "AerodromeLPOracle", 12 | [oracleA, oracleB, pool], 13 | "AerodromeLPOracle-USDCUSDz" 14 | ); 15 | } 16 | 17 | main.tags = ["LPOracle-Aero-sUSDZUSDC"]; 18 | export default main; 19 | -------------------------------------------------------------------------------- /deploy/base/zai-maha-aerodrome-stake.ts: -------------------------------------------------------------------------------- 1 | import { deployLpStaking } from "../utils/staking-lp"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | assert(hre.network.name === "base", "Wrong network"); 7 | const { deployments } = hre; 8 | const lpD = await deployments.get("LP-Token-ZAIMAHA"); 9 | await deployLpStaking(hre, "Staked ZAI/MAHA Pool", "sZAIMAHA", lpD.address); 10 | } 11 | 12 | main.tags = ["StakingLPRewards-Aerodrome-ZAI-MAHA"]; 13 | export default main; 14 | -------------------------------------------------------------------------------- /deploy/base/zai-usdc-aerodrome-stake.ts: -------------------------------------------------------------------------------- 1 | import { deployLpStaking } from "../utils/staking-lp"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | assert(hre.network.name === "base", "Wrong network"); 7 | const { deployments } = hre; 8 | const lpD = await deployments.get("LP-Token-ZAIUSDC"); 9 | await deployLpStaking(hre, "Staked ZAI/USDC Pool", "sZAIUSDC", lpD.address); 10 | } 11 | 12 | main.tags = ["StakingLPRewards-Aerodrome-ZAI-USDC"]; 13 | export default main; 14 | -------------------------------------------------------------------------------- /deploy/base/zap-aerodrome-maha.ts: -------------------------------------------------------------------------------- 1 | import { MaxUint256 } from "ethers"; 2 | import { ethers } from "hardhat"; 3 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 4 | import { deployContract, waitForTx } from "../../scripts/utils"; 5 | import assert from "assert"; 6 | 7 | async function main(hre: HardhatRuntimeEnvironment) { 8 | assert(hre.network.name === "base", "Wrong network"); 9 | const { deployments } = hre; 10 | 11 | const ODOS_ROUTER_BASE = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1"; 12 | 13 | const args = [ 14 | (await deployments.get("StakingLPRewards-sZAIMAHA")).address, 15 | (await deployments.get("L2DepositCollateralL0")).address, 16 | (await deployments.get("AerodromeRouter")).address, 17 | ODOS_ROUTER_BASE, 18 | (await deployments.get("MAHA")).address, 19 | ]; 20 | 21 | await deployContract( 22 | hre, 23 | "ZapAerodromePoolMAHA", 24 | args, 25 | "ZapAerodromePoolMAHA" 26 | ); 27 | } 28 | 29 | main.tags = ["ZapAerodromePoolMAHA"]; 30 | export default main; 31 | -------------------------------------------------------------------------------- /deploy/base/zap-aerodrome-usdc.ts: -------------------------------------------------------------------------------- 1 | import { MaxUint256 } from "ethers"; 2 | import { ethers } from "hardhat"; 3 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 4 | import { deployContract, waitForTx } from "../../scripts/utils"; 5 | import assert from "assert"; 6 | 7 | async function main(hre: HardhatRuntimeEnvironment) { 8 | assert(hre.network.name === "base", "Wrong network"); 9 | const { deployments } = hre; 10 | 11 | const ODOS_ROUTER_BASE = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1"; 12 | 13 | const args = [ 14 | (await deployments.get("StakingLPRewards-sZAIUSDC")).address, 15 | (await deployments.get("L2DepositCollateralL0")).address, 16 | (await deployments.get("AerodromeRouter")).address, 17 | ODOS_ROUTER_BASE, 18 | ]; 19 | 20 | const zapD = await deployContract( 21 | hre, 22 | "ZapAerodromePoolUSDC", 23 | args, 24 | "ZapAerodromePoolUSDC" 25 | ); 26 | 27 | const zap = await ethers.getContractAt("ZapAerodromePoolUSDC", zapD.address); 28 | const usdc = await ethers.getContractAt( 29 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 30 | ( 31 | await deployments.get("USDC") 32 | ).address 33 | ); 34 | 35 | // await waitForTx(await usdc.approve(zap.target, MaxUint256)); 36 | // await waitForTx(await zap.zapIntoLP(1e6, 0)); 37 | } 38 | 39 | main.tags = ["ZapAerodromePoolUSDC"]; 40 | export default main; 41 | -------------------------------------------------------------------------------- /deploy/base/zap-mint.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("L2DepositCollateralL0")).address, 9 | "0x19cEeAd7105607Cd444F5ad10dd51356436095a1", // address _odos, 10 | ]; 11 | 12 | await deployContract(hre, "ZapMintBase", args, "ZapMintBase"); 13 | } 14 | 15 | main.tags = ["ZapMintBase"]; 16 | export default main; 17 | -------------------------------------------------------------------------------- /deploy/cron/l1-restaking-sweeper-cron.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy } from "../../scripts/utils"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | assert(hre.network.name === "mainnet", "Wrong network"); 7 | const { deployments } = hre; 8 | 9 | const [deployer] = await hre.ethers.getSigners(); 10 | 11 | const proxyAdminD = await deployments.get("ProxyAdmin"); 12 | const usdcD = await deployments.get("USDC"); 13 | const l2DepositCollateralL0 = await deployments.get("L1BridgeCollateralL0"); 14 | 15 | const params = [ 16 | usdcD.address, // address _usdc, 17 | 15000 * 1e6, // uint256 _limit, 18 | l2DepositCollateralL0.address, // address _depositCollateralL0, 19 | deployer.address, // address _governance 20 | ]; 21 | 22 | await deployProxy( 23 | hre, 24 | "L1RestakingSweeperCron", 25 | params, 26 | proxyAdminD.address, 27 | `L1RestakingSweeperCron` 28 | ); 29 | } 30 | 31 | main.tags = ["L1RestakingSweeperCron"]; 32 | export default main; 33 | -------------------------------------------------------------------------------- /deploy/cron/l2-restaking-sweeper-cron.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy } from "../../scripts/utils"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | assert(hre.network.name !== "mainnet", "Wrong network"); 7 | const { deployments } = hre; 8 | 9 | const [deployer] = await hre.ethers.getSigners(); 10 | 11 | const proxyAdminD = await deployments.get("ProxyAdmin"); 12 | const usdcD = await deployments.get("USDC"); 13 | const l2DepositCollateralL0 = await deployments.get("L2DepositCollateralL0"); 14 | 15 | const params = [ 16 | "0xD55DF40ee700D1999bF3935fC3611a0E2853256f", // address _gelatoooooo, 17 | usdcD.address, // address _usdc, 18 | 5000 * 1e6, // uint256 _limit, 19 | l2DepositCollateralL0.address, // address _depositCollateralL0, 20 | deployer.address, // address _governance 21 | ]; 22 | 23 | await deployProxy( 24 | hre, 25 | "L2RestakingSweeperCron", 26 | params, 27 | proxyAdminD.address, 28 | `L2RestakingSweeperCron` 29 | ); 30 | } 31 | 32 | main.tags = ["L2RestakingSweeperCron"]; 33 | export default main; 34 | -------------------------------------------------------------------------------- /deploy/deploy-wagmie.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | await deployContract(hre, "WAGMIE", [], "WAGMIE"); 6 | } 7 | 8 | main.tags = ["WAGMIE"]; 9 | export default main; 10 | -------------------------------------------------------------------------------- /deploy/deployer.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | await deployContract(hre, "Deployer", [], "Deployer"); 6 | } 7 | 8 | main.tags = ["Deployer"]; 9 | export default main; 10 | -------------------------------------------------------------------------------- /deploy/gov-omnichain/deploy-l1.ts: -------------------------------------------------------------------------------- 1 | // npx hardhat deploy --tags OmnichainProposalSenderL1 --network mainnet 2 | 3 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 4 | import { deployContract } from "../../scripts/utils"; 5 | import { config } from "../../tasks/layerzero/config"; 6 | import assert from "assert"; 7 | 8 | async function main(hre: HardhatRuntimeEnvironment) { 9 | assert(hre.network.name === "mainnet", "wrong network"); 10 | const [deployer] = await hre.ethers.getSigners(); 11 | 12 | const params = [ 13 | config[hre.network.name].libraries.endpoint, // address _endpoint, 14 | deployer.address, // address _owner 15 | ]; 16 | 17 | await deployContract( 18 | hre, 19 | "OmnichainProposalSenderL1", 20 | params, 21 | `OmnichainProposalSenderL1` 22 | ); 23 | } 24 | 25 | main.tags = ["OmnichainProposalSenderL1"]; 26 | export default main; 27 | -------------------------------------------------------------------------------- /deploy/gov-omnichain/deploy-l2.ts: -------------------------------------------------------------------------------- 1 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network base 2 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network zircuit 3 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network linea 4 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network xlayer 5 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network blast 6 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network arbitrum 7 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network blast 8 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network bsc 9 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network optimism 10 | // npx hardhat deploy --tags OmnichainGovernanceExecutorL2 --network scroll 11 | 12 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 13 | import { deployContract } from "../../scripts/utils"; 14 | import { config } from "../../tasks/layerzero/config"; 15 | import assert from "assert"; 16 | 17 | async function main(hre: HardhatRuntimeEnvironment) { 18 | assert(hre.network.name !== "mainnet", "wrong network"); 19 | 20 | const [deployer] = await hre.ethers.getSigners(); 21 | 22 | const params = [ 23 | config[hre.network.name].libraries.endpoint, // address _endpoint, 24 | deployer.address, // address _owner 25 | ]; 26 | 27 | await deployContract( 28 | hre, 29 | "OmnichainGovernanceExecutorL2", 30 | params, 31 | `OmnichainGovernanceExecutorL2` 32 | ); 33 | } 34 | 35 | main.tags = ["OmnichainGovernanceExecutorL2"]; 36 | export default main; 37 | -------------------------------------------------------------------------------- /deploy/helpers/balanceUIHelper.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | await deployContract(hre, "BalancesUIHelper", [], `BalancesUIHelper`); 6 | } 7 | 8 | main.tags = ["BalancesUIHelper"]; 9 | export default main; 10 | -------------------------------------------------------------------------------- /deploy/helpers/poolUIHelper.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const usdcD = await deployments.get("USDC"); 8 | const mahaD = await deployments.get("MAHA"); 9 | const zaiD = await deployments.get("ZaiStablecoin"); 10 | const sZAID = await deployments.get("sZAI"); 11 | 12 | await deployContract( 13 | hre, 14 | "PoolUIHelper", 15 | [mahaD.address, zaiD.address, sZAID.address, usdcD.address], 16 | `PoolUIHelper` 17 | ); 18 | } 19 | 20 | main.tags = ["PoolUIHelper"]; 21 | export default main; 22 | -------------------------------------------------------------------------------- /deploy/hubs/ddhub-base-lz.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract, deployProxy } from "../../scripts/utils"; 3 | import assert from "assert"; 4 | import { config } from "../../tasks/layerzero/config"; 5 | import { zeroPadValue } from "ethers"; 6 | 7 | async function main(hre: HardhatRuntimeEnvironment) { 8 | const { deployments } = hre; 9 | assert(hre.network.name === "mainnet", "Wrong network"); 10 | 11 | const [deployer] = await hre.ethers.getSigners(); 12 | const proxyAdminD = await deployments.get("ProxyAdmin"); 13 | const ddHubD = await deployments.get("DDHub"); 14 | const zaiD = await deployments.get("ZaiStablecoin"); 15 | const adapterD = await deployments.get("ZaiStablecoinOFTAdapter"); 16 | 17 | const destinationL2 = "0x7427E82f5abCbcA2a45cAfE6e65cBC1FADf9ad9D"; 18 | const safeL1 = "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC"; 19 | 20 | const params = [ 21 | ddHubD.address, // address _hub, 22 | zaiD.address, // address _zai, 23 | zeroPadValue(destinationL2, 32), // bytes32 _destinationL2, 24 | adapterD.address, // address _oftAdapter, 25 | config.base.eid, // uint32 _dstEid 26 | ]; 27 | 28 | await deployProxy( 29 | hre, 30 | "DDLayerZeroHub", 31 | params, 32 | proxyAdminD.address, 33 | `DDLayerZeroHub-Base-LZ` 34 | ); 35 | 36 | await deployContract( 37 | hre, 38 | "DDOperatorPlan", 39 | [ 40 | 3600, // uint48 _initialDelay, 41 | deployer.address, // address _governance 42 | 10n ** 24n, // uint256 _targetAssets, - 1mn ZAI 43 | ], 44 | `DDOperatorPlan-Base-LZ` 45 | ); 46 | } 47 | 48 | main.tags = ["DeployDDHub-Base-LZ"]; 49 | export default main; 50 | -------------------------------------------------------------------------------- /deploy/hubs/ddhub-okx-lz.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract, deployProxy } from "../../scripts/utils"; 3 | import assert from "assert"; 4 | import { config } from "../../tasks/layerzero/config"; 5 | import { zeroPadValue } from "ethers"; 6 | 7 | async function main(hre: HardhatRuntimeEnvironment) { 8 | const { deployments } = hre; 9 | assert(hre.network.name === "mainnet", "Wrong network"); 10 | 11 | const [deployer] = await hre.ethers.getSigners(); 12 | const proxyAdminD = await deployments.get("ProxyAdmin"); 13 | const ddHubD = await deployments.get("DDHub"); 14 | const zaiD = await deployments.get("ZaiStablecoin"); 15 | const adapterD = await deployments.get("ZaiStablecoinOFTAdapter"); 16 | 17 | const destinationL2 = "0x12eB0D746E6b3172d467a606ac071D86b6747E7A"; 18 | const safeL1 = "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC"; 19 | 20 | const params = [ 21 | ddHubD.address, // address _hub, 22 | zaiD.address, // address _zai, 23 | zeroPadValue(destinationL2, 32), // bytes32 _destinationL2, 24 | adapterD.address, // address _oftAdapter, 25 | config.xlayer.eid, // uint32 _dstEid 26 | ]; 27 | 28 | await deployProxy( 29 | hre, 30 | "DDLayerZeroHub", 31 | params, 32 | proxyAdminD.address, 33 | `DDLayerZeroHub-OKX-LZ` 34 | ); 35 | 36 | await deployContract( 37 | hre, 38 | "DDOperatorPlan", 39 | [ 40 | 3600, // uint48 _initialDelay, 41 | deployer.address, // address _governance 42 | 10n ** 24n, // uint256 _targetAssets, - 1mn ZAI 43 | ], 44 | `DDOperatorPlan-OKX-LZ` 45 | ); 46 | } 47 | 48 | main.tags = ["DeployDDHub-OKX-LZ"]; 49 | export default main; 50 | -------------------------------------------------------------------------------- /deploy/impl-psm.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments, getNamedAccounts } = hre; 6 | const { deploy } = deployments; 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const psmImpl = await deploy("PegStabilityModule-impl", { 10 | from: deployer, 11 | contract: "PegStabilityModule", 12 | args: [], 13 | autoMine: true, 14 | log: true, 15 | }); 16 | 17 | if (network.name !== "hardhat") { 18 | await hre.run("verify:verify", { 19 | address: psmImpl.address, 20 | }); 21 | } 22 | } 23 | 24 | main.tags = ["PegStabilityModule"]; 25 | export default main; 26 | -------------------------------------------------------------------------------- /deploy/impl-safetypool.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments, getNamedAccounts } = hre; 6 | const { deploy } = deployments; 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const contract = await deploy("SafetyPool-impl", { 10 | from: deployer, 11 | contract: "SafetyPool", 12 | args: [], 13 | autoMine: true, 14 | log: true, 15 | }); 16 | 17 | if (network.name !== "hardhat") { 18 | await hre.run("verify:verify", { 19 | address: contract.address, 20 | }); 21 | } 22 | } 23 | 24 | main.tags = ["SafetyPool"]; 25 | export default main; 26 | -------------------------------------------------------------------------------- /deploy/impl-stakinglprewards.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments, getNamedAccounts } = hre; 6 | const { deploy } = deployments; 7 | const { deployer } = await getNamedAccounts(); 8 | 9 | const contract = await deploy("StakingLPRewards-impl", { 10 | from: deployer, 11 | contract: "StakingLPRewards", 12 | args: [], 13 | autoMine: true, 14 | log: true, 15 | }); 16 | 17 | if (network.name !== "hardhat") { 18 | await hre.run("verify:verify", { 19 | address: contract.address, 20 | }); 21 | } 22 | } 23 | 24 | main.tags = ["StakingLPRewards"]; 25 | export default main; 26 | -------------------------------------------------------------------------------- /deploy/mainnet/ddhub-morpho-pool.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract, deployProxy, waitForTx } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const [deployer] = await hre.ethers.getSigners(); 8 | const proxyAdminD = await deployments.get("ProxyAdmin"); 9 | const zaiD = await deployments.get("ZaiStablecoin"); 10 | const vault = "0x8a0D114B72A5ba5ABF37283EF98708945db4423e"; 11 | 12 | const hubD = await deployments.get("DDHub"); 13 | const hub = await hre.ethers.getContractAt("DDHub", hubD.address); 14 | const zai = await hre.ethers.getContractAt("ZaiStablecoin", zaiD.address); 15 | 16 | const debtCeiling = 100000n * 10n ** 18n; 17 | 18 | const pool = await deployProxy( 19 | hre, 20 | "DDMetaMorpho", 21 | [ 22 | hub.target, // address _hub, 23 | zaiD.address, // address _zai, 24 | vault, // address _vault 25 | ], 26 | proxyAdminD.address, 27 | `DDMetaMorpho` 28 | ); 29 | 30 | const plan = await deployContract( 31 | hre, 32 | "DDOperatorPlan", 33 | [ 34 | 3600, // uint48 _initialDelay, 35 | deployer.address, // address _governance 36 | ], 37 | `DDOperatorPlan` 38 | ); 39 | 40 | await waitForTx( 41 | await hub.registerPool(pool.address, plan.address, debtCeiling) 42 | ); 43 | await waitForTx(await zai.grantManagerRole(hub.target)); 44 | } 45 | 46 | main.tags = ["DDMetaMorpho"]; 47 | export default main; 48 | -------------------------------------------------------------------------------- /deploy/mainnet/ddhub.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const [deployer] = await hre.ethers.getSigners(); 8 | const proxyAdminD = await deployments.get("ProxyAdmin"); 9 | const zaiD = await deployments.get("ZaiStablecoin"); 10 | const safe = "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC"; 11 | 12 | const params = [ 13 | safe, // address _feeCollector, 14 | 1000000n * 10n ** 18n, // uint256 _globalDebtCeiling, 15 | zaiD.address, // address _zai, 16 | deployer.address, // address _governance 17 | ]; 18 | 19 | await deployProxy(hre, "DDHubL1", params, proxyAdminD.address, `DDHub`); 20 | } 21 | 22 | main.tags = ["DeployDDHubL1"]; 23 | export default main; 24 | -------------------------------------------------------------------------------- /deploy/mainnet/psm-susde-cron.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { DeployFunction } from "hardhat-deploy/types"; 3 | import { deployContract } from "../../scripts/utils"; 4 | 5 | const main: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 6 | const { deployments } = hre; 7 | const szaiD = await deployments.get("SafetyPool-sZAI"); 8 | const psm = await deployments.get("PegStabilityModule-sUSDe"); 9 | const safe = await deployments.get("GnosisSafe"); 10 | const oftAdapter = await deployments.get("ZaiStablecoinOFTAdapter"); 11 | 12 | const params = [ 13 | psm.address, 14 | szaiD.address, 15 | oftAdapter.address, 16 | safe.address, // address _treasury, 17 | safe.address, // address _mahaBuybacks, 18 | 997, // uint256 _remoteSlippage, 19 | safe.address, // address _remoteAddr, 20 | 30184, // uint32 _dstEID 21 | ]; 22 | await deployContract(hre, "sUSDeCollectorCron", params, `sUSDeCollectorCron`); 23 | }; 24 | 25 | export default main; 26 | main.tags = ["sUSDeCollectorCron"]; 27 | -------------------------------------------------------------------------------- /deploy/mainnet/psm-susde.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { DeployFunction } from "hardhat-deploy/types"; 3 | import { parseEther } from "ethers"; 4 | import { deployProxy } from "../../scripts/utils"; 5 | 6 | const main: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 7 | const { getNamedAccounts, deployments } = hre; 8 | const { deployer } = await getNamedAccounts(); 9 | 10 | const proxyAdminD = await deployments.get("ProxyAdmin"); 11 | const zaiD = await deployments.get("ZaiStablecoin"); 12 | const feeDistributorAddress = await deployments.get("sUSDeCollectorCron"); 13 | 14 | const collateral = "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497"; // sUSDe 15 | const governance = deployer; 16 | const supplyCap = parseEther("10000000"); 17 | const debtCap = parseEther("10000000"); 18 | const mintFeeBps = 0; //1% 19 | const redeemFeeBps = 1000; // 1% 20 | 21 | const params = [ 22 | zaiD.address, 23 | collateral, 24 | governance, 25 | supplyCap, 26 | debtCap, 27 | mintFeeBps, 28 | redeemFeeBps, 29 | feeDistributorAddress.address, 30 | ]; 31 | 32 | await deployProxy( 33 | hre, 34 | "PegStabilityModuleYield", 35 | params, 36 | proxyAdminD.address, 37 | `PegStabilityModule-sUSDe` 38 | ); 39 | }; 40 | 41 | export default main; 42 | main.tags = ["PegStabilityModule-SUSDE"]; 43 | -------------------------------------------------------------------------------- /deploy/mainnet/szai.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { DeployFunction } from "hardhat-deploy/types"; 3 | import { ZeroAddress } from "ethers"; 4 | import { deployProxy } from "../../scripts/utils"; 5 | 6 | const main: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 7 | const { getNamedAccounts, deployments } = hre; 8 | const { deployer } = await getNamedAccounts(); 9 | 10 | const proxyAdminD = await deployments.get("ProxyAdmin"); 11 | const zaiD = await deployments.get("ZaiStablecoin"); 12 | const usdc = await deployments.get("USDC"); 13 | const maha = await deployments.get("MAHA"); 14 | 15 | const params = [ 16 | zaiD.address, // address _stablecoin, 17 | deployer, // address _governance, 18 | usdc.address, // address _rewardToken1, 19 | maha.address, // address _rewardToken2, 20 | 86400 * 7, // uint256 _rewardsDuration, 21 | ZeroAddress, // address _stakingBoost 22 | ]; 23 | 24 | await deployProxy( 25 | hre, 26 | "SafetyPool", 27 | params, 28 | proxyAdminD.address, 29 | `SafetyPool-sZAI`, 30 | "0xbAd5D5073c18F43E986FDcF3c011646f3b481360" // wallet to deploy from 31 | ); 32 | }; 33 | 34 | export default main; 35 | main.tags = ["SafetyPool-sZAI"]; 36 | -------------------------------------------------------------------------------- /deploy/mainnet/usdz-migrator.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { DeployFunction } from "hardhat-deploy/types"; 3 | import { deployContract } from "../../scripts/utils"; 4 | 5 | const main: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 6 | const { deployments } = hre; 7 | const zaiD = await deployments.get("ZaiStablecoin"); 8 | 9 | const params = [ 10 | "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0", // old USDz address 11 | zaiD.address, // address _stablecoin, 12 | ]; 13 | 14 | await deployContract(hre, "UsdzMigrator", params, `UsdzMigrator`); 15 | }; 16 | 17 | export default main; 18 | main.tags = ["UsdzMigrator"]; 19 | -------------------------------------------------------------------------------- /deploy/mainnet/usdzmaha-curve-stake.ts: -------------------------------------------------------------------------------- 1 | import { ZeroAddress } from "ethers"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | import { deployProxy } from "../../scripts/utils"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | const { deployments } = hre; 7 | 8 | const proxyAdminD = await deployments.get("ProxyAdmin"); 9 | const safe = "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC"; 10 | const usdcD = await deployments.get("USDC"); 11 | const mahaD = await deployments.get("MAHA"); 12 | 13 | const token = await hre.ethers.getContractAt( 14 | "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol:IERC20Metadata", 15 | "0x6ee1955afb64146b126162b4ff018db1eb8f08c3" 16 | ); 17 | 18 | const name = await token.name(); 19 | const symbol = await token.symbol(); 20 | 21 | const params = [ 22 | `Staked ${name}`, // string memory _name, 23 | `s${symbol}`, // string memory _symbol, 24 | token.target, // address _stakingToken, 25 | safe, // address _governance, 26 | usdcD.address, // address _rewardToken1, 27 | mahaD.address, // address _rewardToken2, 28 | 86400 * 7, // uint256 _rewardsDuration, 29 | ZeroAddress, // address _staking 30 | ]; 31 | 32 | await deployProxy( 33 | hre, 34 | "StakingLPRewards", 35 | params, 36 | proxyAdminD.address, 37 | `StakingLPRewards-${params[1]}` 38 | ); 39 | 40 | await deployments.save(`LP-Token-${symbol}`, { 41 | address: token.target.toString(), 42 | abi: token.interface.format(true), 43 | }); 44 | } 45 | 46 | main.tags = ["StakingLPRewards-Curve-sUSDZMAHA"]; 47 | export default main; 48 | -------------------------------------------------------------------------------- /deploy/mainnet/zai-maha-curve-stake.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy, waitForTx } from "../../scripts/utils"; 3 | import { MaxUint256, ZeroAddress } from "ethers"; 4 | import assert from "assert"; 5 | 6 | async function main(hre: HardhatRuntimeEnvironment) { 7 | assert(hre.network.name === "mainnet", "Wrong network"); 8 | const { deployments } = hre; 9 | 10 | const [deployer] = await hre.ethers.getSigners(); 11 | const proxyAdminD = await deployments.get("ProxyAdmin"); 12 | const mahaD = await deployments.get("MAHA"); 13 | const zaiD = await deployments.get("ZAI"); 14 | const lpD = await deployments.get("LP-Token-ZAIMAHA"); 15 | const safe = await deployments.get("GnosisSafe"); 16 | const timelockD = await deployments.get("MAHATimelockController"); 17 | 18 | const name = "Staked ZAI/MAHA Pool"; // string memory _name, 19 | const symbol = "sZAIMAHA"; // string memory _symbol, 20 | 21 | const params = [ 22 | name, 23 | symbol, 24 | lpD.address, // address _stakingToken, 25 | timelockD.address, // address _governance, 26 | zaiD.address, // address _rewardToken1, 27 | mahaD.address, // address _rewardToken2, 28 | 86400 * 7, // uint256 _rewardsDuration, 29 | ZeroAddress, // address _staking 30 | ]; 31 | 32 | const contractD = await deployProxy( 33 | hre, 34 | "StakingLPRewards", 35 | params, 36 | proxyAdminD.address, 37 | `StakingLPRewards-${symbol}` 38 | ); 39 | 40 | const lp = await hre.ethers.getContractAt("StakingLPRewards", lpD.address); 41 | const contract = await hre.ethers.getContractAt( 42 | "StakingLPRewards", 43 | contractD.address 44 | ); 45 | 46 | const balance = await lp.balanceOf(deployer.address); 47 | if (balance > 0n) { 48 | await waitForTx(await lp.approve(contract.target, MaxUint256)); 49 | await waitForTx(await contract.mint(balance, safe.address)); 50 | } 51 | } 52 | 53 | main.tags = ["StakingLPRewards-Curve-ZAI-MAHA"]; 54 | export default main; 55 | -------------------------------------------------------------------------------- /deploy/mainnet/zai-szai-curve-stake.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy, waitForTx } from "../../scripts/utils"; 3 | import { MaxUint256, ZeroAddress } from "ethers"; 4 | import assert from "assert"; 5 | 6 | async function main(hre: HardhatRuntimeEnvironment) { 7 | assert(hre.network.name === "mainnet", "Wrong network"); 8 | const { deployments } = hre; 9 | 10 | const [deployer] = await hre.ethers.getSigners(); 11 | const proxyAdminD = await deployments.get("ProxyAdmin"); 12 | const mahaD = await deployments.get("MAHA"); 13 | const zaiD = await deployments.get("ZAI"); 14 | const lpD = await deployments.get("LP-Token-ZAIsZAI"); 15 | const safe = await deployments.get("GnosisSafe"); 16 | const timelockD = await deployments.get("MAHATimelockController"); 17 | 18 | const name = "Staked ZAI/sZAI Pool"; // string memory _name, 19 | const symbol = "sZAIsZAI"; // string memory _symbol, 20 | 21 | const params = [ 22 | name, 23 | symbol, 24 | lpD.address, // address _stakingToken, 25 | timelockD.address, // address _governance, 26 | zaiD.address, // address _rewardToken1, 27 | mahaD.address, // address _rewardToken2, 28 | 86400 * 7, // uint256 _rewardsDuration, 29 | ZeroAddress, // address _staking 30 | ]; 31 | 32 | const contractD = await deployProxy( 33 | hre, 34 | "StakingLPRewards", 35 | params, 36 | proxyAdminD.address, 37 | `StakingLPRewards-${symbol}` 38 | ); 39 | 40 | const lp = await hre.ethers.getContractAt("StakingLPRewards", lpD.address); 41 | const contract = await hre.ethers.getContractAt( 42 | "StakingLPRewards", 43 | contractD.address 44 | ); 45 | 46 | const balance = await lp.balanceOf(deployer.address); 47 | if (balance > 0n) { 48 | await waitForTx(await lp.approve(contract.target, MaxUint256)); 49 | await waitForTx(await contract.mint(balance, safe.address)); 50 | } 51 | } 52 | 53 | main.tags = ["StakingLPRewards-Curve-ZAI-sZAI"]; 54 | export default main; 55 | -------------------------------------------------------------------------------- /deploy/mainnet/zai-usdc-curve-stake.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy, waitForTx } from "../../scripts/utils"; 3 | import { MaxUint256, ZeroAddress } from "ethers"; 4 | import assert from "assert"; 5 | 6 | async function main(hre: HardhatRuntimeEnvironment) { 7 | assert(hre.network.name === "mainnet", "Wrong network"); 8 | const { deployments } = hre; 9 | 10 | const [deployer] = await hre.ethers.getSigners(); 11 | const proxyAdminD = await deployments.get("ProxyAdmin"); 12 | const mahaD = await deployments.get("MAHA"); 13 | const zaiD = await deployments.get("ZAI"); 14 | const lpD = await deployments.get("LP-Token-ZAIUSDC"); 15 | const safe = await deployments.get("GnosisSafe"); 16 | const timelockD = await deployments.get("MAHATimelockController"); 17 | 18 | const name = "Staked ZAI/USDC Pool"; // string memory _name, 19 | const symbol = "sZAIUSDC"; // string memory _symbol, 20 | 21 | const params = [ 22 | name, 23 | symbol, 24 | lpD.address, // address _stakingToken, 25 | timelockD.address, // address _governance, 26 | zaiD.address, // address _rewardToken1, 27 | mahaD.address, // address _rewardToken2, 28 | 86400 * 7, // uint256 _rewardsDuration, 29 | ZeroAddress, // address _staking 30 | ]; 31 | 32 | const contractD = await deployProxy( 33 | hre, 34 | "StakingLPRewards", 35 | params, 36 | proxyAdminD.address, 37 | `StakingLPRewards-${symbol}` 38 | ); 39 | 40 | const lp = await hre.ethers.getContractAt("StakingLPRewards", lpD.address); 41 | const contract = await hre.ethers.getContractAt( 42 | "StakingLPRewards", 43 | contractD.address 44 | ); 45 | 46 | const balance = await lp.balanceOf(deployer.address); 47 | if (balance > 0n) { 48 | await waitForTx(await lp.approve(contract.target, MaxUint256)); 49 | await waitForTx(await contract.mint(balance, safe.address)); 50 | } 51 | } 52 | 53 | main.tags = ["StakingLPRewards-Curve-ZAI-USDC"]; 54 | export default main; 55 | -------------------------------------------------------------------------------- /deploy/mainnet/zap-curve-maha.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("StakingLPRewards-sZAIMAHA")).address, 9 | (await deployments.get("PegStabilityModule-sUSDe")).address, 10 | (await deployments.get("MAHA")).address, 11 | "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559", // address _odos, 12 | ]; 13 | 14 | await deployContract(hre, "ZapCurvePoolMAHA", args, "ZapCurvePoolMAHA"); 15 | } 16 | 17 | main.tags = ["ZapCurvePoolMAHA"]; 18 | export default main; 19 | -------------------------------------------------------------------------------- /deploy/mainnet/zap-curve-szai.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("StakingLPRewards-sZAIsZAI")).address, 9 | (await deployments.get("PegStabilityModule-sUSDe")).address, 10 | (await deployments.get("sZAI")).address, 11 | "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559", // address _odos, 12 | ]; 13 | 14 | await deployContract(hre, "ZapCurvePoolsZAI", args, "ZapCurvePoolsZAI"); 15 | } 16 | 17 | main.tags = ["ZapCurvePoolsZAI"]; 18 | export default main; 19 | -------------------------------------------------------------------------------- /deploy/mainnet/zap-curve-usdc.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("StakingLPRewards-sZAIUSDC")).address, 9 | (await deployments.get("PegStabilityModule-sUSDe")).address, 10 | (await deployments.get("USDC")).address, 11 | "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559", // address _odos, 12 | ]; 13 | 14 | await deployContract(hre, "ZapCurvePoolUSDC", args, "ZapCurvePoolUSDC"); 15 | } 16 | 17 | main.tags = ["ZapCurvePoolUSDC"]; 18 | export default main; 19 | -------------------------------------------------------------------------------- /deploy/mainnet/zap-mint.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("PegStabilityModule-sUSDe")).address, 9 | "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559", // address _odos, 10 | ]; 11 | 12 | await deployContract(hre, "ZapMintMainnet", args, "ZapMintMainnet"); 13 | } 14 | 15 | main.tags = ["ZapMintMainnet"]; 16 | export default main; 17 | -------------------------------------------------------------------------------- /deploy/mainnet/zap-safetypool.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const args = [ 8 | (await deployments.get("sZAI")).address, 9 | (await deployments.get("ZAI")).address, 10 | "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559", // address _odos, 11 | ]; 12 | 13 | await deployContract(hre, "ZapSafetyPool", args, "ZapSafetyPool"); 14 | } 15 | 16 | main.tags = ["ZapSafetyPool"]; 17 | export default main; 18 | -------------------------------------------------------------------------------- /deploy/oft/oft-l1-bridge.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | assert(hre.network.name === "mainnet", "wrong network"); 7 | const psm = await hre.deployments.get("PegStabilityModule-sUSDe"); 8 | const adapter = await hre.deployments.get("ZaiStablecoinOFTAdapter"); 9 | 10 | const odos = "0xcf5540fffcdc3d510b18bfca6d2b9987b0772559"; // address _odos, 11 | 12 | await deployContract( 13 | hre, 14 | "L1BridgeCollateralL0", 15 | [psm.address, adapter.address, odos], 16 | "L1BridgeCollateralL0" 17 | ); 18 | } 19 | 20 | main.tags = ["L1BridgeCollateralL0"]; 21 | export default main; 22 | -------------------------------------------------------------------------------- /deploy/oft/oft-l2-bridge.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy, waitForTx } from "../../scripts/utils"; 3 | import { get } from "../../scripts/guess/_helpers"; 4 | import { ZeroAddress, zeroPadValue } from "ethers"; 5 | import assert from "assert"; 6 | 7 | async function main(hre: HardhatRuntimeEnvironment) { 8 | assert(hre.network.name !== "mainnet", "wrong network"); 9 | const l1Contract = get("L1BridgeCollateralL0", "mainnet"); 10 | const zaiD = await hre.deployments.get("ZaiStablecoinOFT"); 11 | const usdc = await hre.deployments.get("USDC"); 12 | const stargate = await hre.deployments.getOrNull("StargateUSDCPool"); 13 | const { deployments, getNamedAccounts } = hre; 14 | const { deployer } = await getNamedAccounts(); 15 | 16 | const { address: proxyAdmin } = await deployments.get("ProxyAdmin"); 17 | 18 | const zai = await hre.ethers.getContractAt( 19 | "ZaiOFTWithRestaking", 20 | zaiD.address 21 | ); 22 | const l1ContractPadded = zeroPadValue(l1Contract, 32); 23 | 24 | const restaker = await deployProxy( 25 | hre, 26 | "L2DepositCollateralL0", 27 | [ 28 | zaiD.address, 29 | usdc.address, // IERC20 _depositToken, 30 | stargate ? stargate.address : ZeroAddress, // IStargate _stargate, 31 | l1ContractPadded, // bytes32 _bridgeTargetAddress, 32 | deployer, // address _governance, 33 | 1e6, // uint256 _rate, 34 | 1000000000000000, // uint256 _slippage - 0.1% 35 | ], 36 | proxyAdmin, 37 | "L2DepositCollateralL0" 38 | ); 39 | 40 | await waitForTx(await zai.setRestakerZAI(restaker.address)); 41 | } 42 | 43 | main.tags = ["L2DepositCollateralL0"]; 44 | export default main; 45 | -------------------------------------------------------------------------------- /deploy/oft/oft-maha-adapter.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import { config } from "../../tasks/layerzero/config"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | const mahaD = await hre.deployments.get("MAHA"); 7 | await deployContract( 8 | hre, 9 | "LayerZeroCustomOFTAdapter", 10 | [mahaD.address, config[hre.network.name].libraries.endpoint], 11 | "MAHAOFTAdapter" 12 | ); 13 | } 14 | 15 | main.tags = ["MAHAOFTAdapter"]; 16 | export default main; 17 | -------------------------------------------------------------------------------- /deploy/oft/oft-maha.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import { config } from "../../tasks/layerzero/config"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | const contract = await deployContract( 7 | hre, 8 | "LayerZeroCustomOFT", 9 | ["MAHA.xyz", "MAHA", config[hre.network.name].libraries.endpoint], 10 | "MAHAOFT" 11 | ); 12 | 13 | const zai = await hre.ethers.getContractAt( 14 | "LayerZeroCustomOFT", 15 | contract.address 16 | ); 17 | 18 | if (!(await hre.deployments.getOrNull("MAHA"))) { 19 | await hre.deployments.save("MAHA", { 20 | abi: zai.interface.format(true), 21 | address: contract.address, 22 | }); 23 | } 24 | } 25 | 26 | main.tags = ["MAHAOFT"]; 27 | export default main; 28 | -------------------------------------------------------------------------------- /deploy/oft/oft-szai-adapter.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import { config } from "../../tasks/layerzero/config"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | const zaiD = await hre.deployments.get("ZaiStablecoin"); 7 | await deployContract( 8 | hre, 9 | "LayerZeroCustomOFTAdapter", 10 | [zaiD.address, config[hre.network.name].endpoint], 11 | "ZaiStablecoinOFTAdapter" 12 | ); 13 | } 14 | 15 | main.tags = ["StakedZaiStablecoinOFTAdapter"]; 16 | export default main; 17 | -------------------------------------------------------------------------------- /deploy/oft/oft-szai.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import { config } from "../../tasks/layerzero/config"; 4 | import assert from "assert"; 5 | 6 | async function main(hre: HardhatRuntimeEnvironment) { 7 | const [, , deployer] = await hre.ethers.getSigners(); 8 | assert( 9 | deployer.address.toLowerCase() == 10 | "0xbad5d5073c18f43e986fdcf3c011646f3b481360", 11 | "!deployer" 12 | ); 13 | 14 | const mahaDeployer = "0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"; 15 | 16 | const contract = await deployContract( 17 | hre, 18 | "StakedZaiOFTWithRestaking", 19 | [config[hre.network.name].libraries.endpoint, mahaDeployer], 20 | "StakedZaiOFTWithRestaking", 21 | "0xbAd5D5073c18F43E986FDcF3c011646f3b481360" 22 | ); 23 | 24 | const zai = await hre.ethers.getContractAt( 25 | "StakedZaiOFTWithRestaking", 26 | contract.address 27 | ); 28 | 29 | if (!(await hre.deployments.getOrNull("sZAI"))) { 30 | await hre.deployments.save("sZAI", { 31 | abi: zai.interface.format(true), 32 | address: contract.address, 33 | }); 34 | } 35 | } 36 | 37 | main.tags = ["StakedZaiStablecoinOFT"]; 38 | export default main; 39 | -------------------------------------------------------------------------------- /deploy/oft/oft-zai-adapter.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | import { config } from "../../tasks/layerzero/config"; 4 | import assert from "assert"; 5 | 6 | async function main(hre: HardhatRuntimeEnvironment) { 7 | const zaiD = await hre.deployments.get("ZaiStablecoin"); 8 | assert( 9 | hre.network.name === "mainnet", 10 | "This script should only be run on mainnet" 11 | ); 12 | 13 | await deployContract( 14 | hre, 15 | "LayerZeroCustomOFTAdapter", 16 | [zaiD.address, config[hre.network.name].libraries.endpoint], 17 | "ZaiStablecoinOFTAdapter" 18 | ); 19 | } 20 | 21 | main.tags = ["ZaiStablecoinOFTAdapter"]; 22 | export default main; 23 | -------------------------------------------------------------------------------- /deploy/oracles/fixed-price-oracle.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | await deployContract(hre, "FixedPriceOracle", [1e8, 8], "FixedPriceOracle"); 6 | } 7 | 8 | main.tags = ["FixedPriceOracle"]; 9 | export default main; 10 | -------------------------------------------------------------------------------- /deploy/others/erc20-recovery-proxy.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract, deployProxy, waitForTx } from "../../scripts/utils"; 3 | 4 | async function main(hre: HardhatRuntimeEnvironment) { 5 | const { deployments } = hre; 6 | 7 | const plan = await deployContract( 8 | hre, 9 | "Erc20RecoverProxy", 10 | [], 11 | `Erc20RecoverProxy` 12 | ); 13 | 14 | const proxy = await hre.ethers.getContractAt( 15 | "Erc20RecoverProxy", 16 | plan.address 17 | ); 18 | 19 | console.log( 20 | await proxy.initialize.populateTransaction( 21 | "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", 22 | "0x77cd66d59ac48a0E7CE54fF16D9235a5fffF335E" 23 | ) 24 | ); 25 | } 26 | 27 | main.tags = ["Erc20RecoverProxy"]; 28 | export default main; 29 | -------------------------------------------------------------------------------- /deploy/utils/staking-lp.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployProxy, waitForTx } from "../../scripts/utils"; 3 | import { MaxUint256, ZeroAddress } from "ethers"; 4 | 5 | export async function deployLpStaking( 6 | hre: HardhatRuntimeEnvironment, 7 | name: string, 8 | symbol: string, 9 | lpD: string 10 | ) { 11 | const { deployments } = hre; 12 | 13 | const [deployer] = await hre.ethers.getSigners(); 14 | const proxyAdminD = await deployments.get("ProxyAdmin"); 15 | const mahaD = await deployments.get("MAHA"); 16 | const zaiD = await deployments.get("ZaiStablecoinOFT"); 17 | const safe = await deployments.get("GnosisSafe"); 18 | const timelockD = await deployments.get("MAHATimelockController"); 19 | 20 | const params = [ 21 | name, 22 | symbol, 23 | lpD, // address _stakingToken, 24 | timelockD.address, // address _governance, 25 | zaiD.address, // address _rewardToken1, 26 | mahaD.address, // address _rewardToken2, 27 | 86400 * 7, // uint256 _rewardsDuration, 28 | ZeroAddress, // address _staking 29 | ]; 30 | 31 | const contractD = await deployProxy( 32 | hre, 33 | "StakingLPRewards", 34 | params, 35 | proxyAdminD.address, 36 | `StakingLPRewards-${symbol}` 37 | ); 38 | 39 | const lp = await hre.ethers.getContractAt("StakingLPRewards", lpD); 40 | const contract = await hre.ethers.getContractAt( 41 | "StakingLPRewards", 42 | contractD.address 43 | ); 44 | 45 | const balance = await lp.balanceOf(deployer.address); 46 | if (balance > 0n) { 47 | await waitForTx(await lp.approve(contract.target, MaxUint256)); 48 | await waitForTx(await contract.mint(balance, safe.address)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /deploy/zai.ts: -------------------------------------------------------------------------------- 1 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 2 | import { deployContract } from "../scripts/utils"; 3 | import assert from "assert"; 4 | 5 | async function main(hre: HardhatRuntimeEnvironment) { 6 | const [deployer] = await hre.ethers.getSigners(); 7 | assert( 8 | deployer.address.toLowerCase() == 9 | "0x35b6e5db7ccc13ce934763067cb4a86ab41e7665", 10 | "!deployer" 11 | ); 12 | 13 | const mahaDeployer = "0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"; 14 | // assert((await deployer.getNonce()) == 0, "!deployer.nonce != 0"); 15 | 16 | const contract = await deployContract( 17 | hre, 18 | "contracts/core/ZaiStablecoin.sol:ZaiStablecoin", 19 | [mahaDeployer], 20 | "ZaiStablecoinOFT" 21 | ); 22 | 23 | const zai = await hre.ethers.getContractAt("ZaiStablecoin", contract.address); 24 | 25 | if (!(await hre.deployments.getOrNull("ZaiStablecoin"))) { 26 | await hre.deployments.save("ZaiStablecoin", { 27 | abi: zai.interface.format(true), 28 | address: contract.address, 29 | }); 30 | } 31 | } 32 | 33 | main.tags = ["ZaiStablecoin"]; 34 | export default main; 35 | -------------------------------------------------------------------------------- /deployments/arbitrum/.chainId: -------------------------------------------------------------------------------- 1 | 42161 -------------------------------------------------------------------------------- /deployments/arbitrum/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/arbitrum/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/arbitrum/USDC.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0xaf88d065e77c8cc2239327c5edb3a432268e5831", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/base/.chainId: -------------------------------------------------------------------------------- 1 | 8453 -------------------------------------------------------------------------------- /deployments/base/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/base/LP-Token-ZAIMAHA.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x96A0EC12A9F3bEabFf9Bb59c3F33EE439dAF2a85", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ], 16 | "numDeployments": 1 17 | } 18 | -------------------------------------------------------------------------------- /deployments/base/LP-Token-ZAIUSDC.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x93EdC603D7A2eA03518Ac55219cAD320010a58e4", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ], 16 | "numDeployments": 2 17 | } 18 | -------------------------------------------------------------------------------- /deployments/base/MAHA.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x554bba833518793056CF105E66aBEA330672c0dE", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/base/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/base/USDC.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/base/WETH.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x4200000000000000000000000000000000000006", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/base/ZERO.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x458ad5b487f4442245e4c5ea7249009e607a5583", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/blast/.chainId: -------------------------------------------------------------------------------- 1 | 81457 -------------------------------------------------------------------------------- /deployments/blast/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/blast/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/bsc/.chainId: -------------------------------------------------------------------------------- 1 | 56 -------------------------------------------------------------------------------- /deployments/bsc/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/bsc/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/linea/.chainId: -------------------------------------------------------------------------------- 1 | 59144 -------------------------------------------------------------------------------- /deployments/linea/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/linea/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/mainnet/.chainId: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /deployments/mainnet/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/mainnet/LP-Token-ZAIMAHA.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7d2dffa9e903b8377c96196da424c7965b06bcc3", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ], 16 | "numDeployments": 1 17 | } 18 | -------------------------------------------------------------------------------- /deployments/mainnet/LP-Token-ZAIUSDC.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x4a0c954d0f19269f4fc5c217821c6150a8870ad4", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ], 16 | "numDeployments": 2 17 | } 18 | -------------------------------------------------------------------------------- /deployments/mainnet/LP-Token-ZAIsZAI.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x53ad9268a66cef20a4c458d759eee5aa55be1140", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ], 16 | "numDeployments": 2 17 | } 18 | -------------------------------------------------------------------------------- /deployments/mainnet/MAHA.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x745407c86df8db893011912d3ab28e68b62e49b0", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/mainnet/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x6900064e7a3920c114e25b5fe4780f26520e3231", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690002da1f2d828d72aa89367623df7a432e85a9" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/mainnet/USDC.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/mainnet/sUSDe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/mainnet/sZAI.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000195D5e3201Cf73C9Ae4a1559244DF38D47C", 3 | "abi": [ 4 | "event Approval(address indexed,address indexed,uint256)", 5 | "event Transfer(address indexed,address indexed,uint256)", 6 | "function allowance(address,address) view returns (uint256)", 7 | "function approve(address,uint256) returns (bool)", 8 | "function balanceOf(address) view returns (uint256)", 9 | "function decimals() view returns (uint8)", 10 | "function name() view returns (string)", 11 | "function symbol() view returns (string)", 12 | "function totalSupply() view returns (uint256)", 13 | "function transfer(address,uint256) returns (bool)", 14 | "function transferFrom(address,address,uint256) returns (bool)" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /deployments/optimism/.chainId: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /deployments/optimism/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/optimism/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/scroll/.chainId: -------------------------------------------------------------------------------- 1 | 534352 -------------------------------------------------------------------------------- /deployments/scroll/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/scroll/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/sonic/.chainId: -------------------------------------------------------------------------------- 1 | 146 -------------------------------------------------------------------------------- /deployments/sonic/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/sonic/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/unichain/.chainId: -------------------------------------------------------------------------------- 1 | 130 -------------------------------------------------------------------------------- /deployments/unichain/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /deployments/unichain/ProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x69000c978701fc4427d4baf749f10a5cec582863", 3 | "abi": [ 4 | "constructor(address)", 5 | "error OwnableInvalidOwner(address)", 6 | "error OwnableUnauthorizedAccount(address)", 7 | "event OwnershipTransferred(address indexed,address indexed)", 8 | "function UPGRADE_INTERFACE_VERSION() view returns (string)", 9 | "function owner() view returns (address)", 10 | "function renounceOwnership()", 11 | "function transferOwnership(address)", 12 | "function upgradeAndCall(address,address,bytes) payable" 13 | ], 14 | "args": [ 15 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 16 | ], 17 | "numDeployments": 1 18 | } -------------------------------------------------------------------------------- /deployments/xlayer/.chainId: -------------------------------------------------------------------------------- 1 | 196 -------------------------------------------------------------------------------- /deployments/xlayer/GnosisSafe.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x7202136d70026DA33628dD3f3eFccb43F62a2469", 3 | "abi": [] 4 | } 5 | -------------------------------------------------------------------------------- /execute/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahaxyz/contracts/159435eb4810a0cb28da976bd0c2136c7655c218/execute/.gitkeep -------------------------------------------------------------------------------- /scripts/create2/create2.ts: -------------------------------------------------------------------------------- 1 | import { ethers, keccak256 } from "ethers"; 2 | 3 | export const buildBytecode = ( 4 | constructorTypes: any[], 5 | constructorArgs: any[], 6 | contractBytecode: string 7 | ) => 8 | `${contractBytecode}${encodeParams(constructorTypes, constructorArgs).slice( 9 | 2 10 | )}`; 11 | 12 | const buildCreate2Address = ( 13 | factoryAddress: string, 14 | saltHex: string, 15 | byteCode: string 16 | ) => { 17 | return `0x${keccak256( 18 | `0x${["ff", factoryAddress, saltHex, keccak256(byteCode)] 19 | .map((x) => x.replace(/0x/, "")) 20 | .join("")}` 21 | ).slice(-40)}`.toLowerCase(); 22 | }; 23 | 24 | const saltToHex = (salt: string | number) => ethers.id(salt.toString()); 25 | 26 | const encodeParams = (dataTypes: any[], data: any[]) => { 27 | const abiCoder = new ethers.AbiCoder(); 28 | return abiCoder.encode(dataTypes, data); 29 | }; 30 | 31 | export function getCreate2Address({ 32 | factoryAddress, 33 | salt, 34 | contractBytecode, 35 | constructorTypes = [] as string[], 36 | constructorArgs = [] as any[], 37 | }: { 38 | salt: string | number; 39 | factoryAddress: string; 40 | contractBytecode: string; 41 | constructorTypes?: string[]; 42 | constructorArgs?: any[]; 43 | }) { 44 | return buildCreate2Address( 45 | factoryAddress, 46 | saltToHex(salt), 47 | buildBytecode(constructorTypes, constructorArgs, contractBytecode) 48 | ); 49 | } 50 | -------------------------------------------------------------------------------- /scripts/create2/proxyAdmin.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | import { get } from "../guess/_helpers"; 3 | import { executeCreate2 } from "./helpers"; 4 | 5 | async function main() { 6 | const constructorArgs: any[] = [ 7 | get("MAHATimelockController", hre.network.name), 8 | ]; 9 | 10 | await executeCreate2( 11 | "ProxyAdmin", 12 | "ProxyAdmin", 13 | constructorArgs, 14 | hre.network.name, 15 | "0x86a0f351e764fdbad44e9da5c2796da3fbebddd97dba18ca9306b519fce81bfc", 16 | "0x69000c978701fc4427d4baf749f10a5cec582863" 17 | ); 18 | } 19 | 20 | // We recommend this pattern to be able to use async/await everywhere 21 | // and properly handle errors. 22 | main().catch((error) => { 23 | console.error(error); 24 | process.exitCode = 1; 25 | }); 26 | -------------------------------------------------------------------------------- /scripts/create2/psm-usdc.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { get } from "../guess/_helpers"; 3 | import { executeCreate2Proxy } from "./helpers"; 4 | import assert from "assert"; 5 | 6 | async function main() { 7 | assert(network.name === "mainnet", "not mainnet"); 8 | 9 | const implArgs: any[] = [ 10 | "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0", // address _zai, 11 | "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // address _collateral, 12 | "0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b", // address _governance, 13 | 1e6, // uint256 _newRate, 14 | 100000000n * 10n ** 6n, // uint256 _supplyCap, 15 | 100000000n * 10n ** 18n, // uint256 _debtCap, 16 | 0, // uint256 _mintFeeBps, 17 | 300, // uint256 _redeemFeeBps, 18 | "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC", // address _feeDestination 19 | ]; 20 | 21 | await executeCreate2Proxy( 22 | "PegStabilityModule-USDC", 23 | "PegStabilityModule-USDC-Proxy", 24 | "PegStabilityModule", 25 | implArgs, 26 | get("PegStabilityModule-impl", "mainnet"), 27 | "mainnet", 28 | "0x7d6b5946c8a05e39fba146ac3459084bd594027a89980c3d197347cd7140cfad", 29 | "0x69000052a82e218ccb61fe6e9d7e3f87b9c5916f" 30 | ); 31 | } 32 | 33 | // We recommend this pattern to be able to use async/await everywhere 34 | // and properly handle errors. 35 | main().catch((error) => { 36 | console.error(error); 37 | process.exitCode = 1; 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/create2/psm-usdt.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { get } from "../guess/_helpers"; 3 | import { executeCreate2Proxy } from "./helpers"; 4 | import assert from "assert"; 5 | 6 | async function main() { 7 | assert(network.name === "mainnet", "not mainnet"); 8 | 9 | const implArgs: any[] = [ 10 | "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0", // address _zai, 11 | "0xdac17f958d2ee523a2206206994597c13d831ec7", // address _collateral, 12 | "0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b", // address _governance, 13 | 1e6, // uint256 _newRate, 14 | 100000000n * 10n ** 6n, // uint256 _supplyCap, 15 | 100000000n * 10n ** 18n, // uint256 _debtCap, 16 | 0, // uint256 _mintFeeBps, 17 | 300, // uint256 _redeemFeeBps, 18 | "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC", // address _feeDestination 19 | ]; 20 | 21 | await executeCreate2Proxy( 22 | "PegStabilityModule-USDT", 23 | "PegStabilityModule-USDT-Proxy", 24 | "PegStabilityModule", 25 | implArgs, 26 | get("PegStabilityModule-impl", "mainnet"), 27 | "mainnet", 28 | "0x7e8fb0add4a06b3338408ee58cad371d97539af6e9ae9671213152017b6e43f4", 29 | "0x690006c6bcd62d06b935050729b3004e962ba708" 30 | ); 31 | } 32 | 33 | // We recommend this pattern to be able to use async/await everywhere 34 | // and properly handle errors. 35 | main().catch((error) => { 36 | console.error(error); 37 | process.exitCode = 1; 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/create2/timelock.ts: -------------------------------------------------------------------------------- 1 | import { executeCreate2 } from "./helpers"; 2 | import hre from "hardhat"; 3 | 4 | async function main() { 5 | const constructorArgs: any[] = [ 6 | 60 * 60, 7 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", 8 | ["0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b"], 9 | ]; 10 | 11 | await executeCreate2( 12 | "MAHATimelockController", 13 | "MAHATimelockController", 14 | constructorArgs, 15 | hre.network.name, 16 | "0xe0bcdd4e23c1a527f2e76f1cf91d3065c17f0259fd17bdb4525ab0b04d735d91", 17 | "0x690005544ba364a53dcc9e8d81c9ce1e90018ab7" 18 | ); 19 | } 20 | 21 | // We recommend this pattern to be able to use async/await everywhere 22 | // and properly handle errors. 23 | main().catch((error) => { 24 | console.error(error); 25 | process.exitCode = 1; 26 | }); 27 | -------------------------------------------------------------------------------- /scripts/create2/xerc20-impl.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | import { executeCreate2 } from "./helpers"; 3 | 4 | async function main() { 5 | await executeCreate2( 6 | "XERC20-impl", 7 | "XERC20", 8 | [], 9 | hre.network.name, 10 | "0x45dd06119cc192324da27568c18ebf284036bfebf10402b1cd4e1b2eb63402d4", 11 | "0x69000b9e02fd541c6e1df00470e12e968d419051" 12 | ); 13 | } 14 | 15 | // We recommend this pattern to be able to use async/await everywhere 16 | // and properly handle errors. 17 | main().catch((error) => { 18 | console.error(error); 19 | process.exitCode = 1; 20 | }); 21 | -------------------------------------------------------------------------------- /scripts/create2/xerc20-zai-local.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { get } from "../guess/_helpers"; 3 | import { executeCreate2Proxy } from "./helpers"; 4 | import assert from "assert"; 5 | 6 | async function main() { 7 | assert(network.name === "mainnet", "not mainnet"); 8 | 9 | const implArgs = [ 10 | "xZAI Stablecoin", 11 | "xUSDz", 12 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", // admin 13 | ]; 14 | 15 | await executeCreate2Proxy( 16 | "xZAI-Stablecoin", 17 | "xZAI-Proxy", 18 | "XERC20", 19 | implArgs, 20 | get("XERC20-impl", "mainnet"), 21 | "mainnet", 22 | "0xfc44c6220e24c4d289f1c97b51df51573d769db1fa3fb2065f0ec3591eb962fd", 23 | "0x6900070de14fffaf3a129dc3880e0153444167fa" 24 | ); 25 | } 26 | 27 | // We recommend this pattern to be able to use async/await everywhere 28 | // and properly handle errors. 29 | main().catch((error) => { 30 | console.error(error); 31 | process.exitCode = 1; 32 | }); 33 | -------------------------------------------------------------------------------- /scripts/create2/xerc20-zai-remote.ts: -------------------------------------------------------------------------------- 1 | import { network } from "hardhat"; 2 | import { get } from "../guess/_helpers"; 3 | import { executeCreate2Proxy } from "./helpers"; 4 | import assert from "assert"; 5 | 6 | async function main() { 7 | assert(network.name !== "mainnet", "should not be mainnet"); 8 | 9 | const implArgs = [ 10 | "ZAI Stablecoin", 11 | "xUSDz", 12 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", // admin 13 | ]; 14 | 15 | await executeCreate2Proxy( 16 | "ZaiStablecoin", 17 | "xZAI-Proxy", 18 | "XERC20", 19 | implArgs, 20 | get("XERC20-impl", network.name), 21 | network.name, 22 | "0x2fcf32741f80f7e50bab7728ed54fd9f51edf766b3dda12113c84096ffc2fae8", 23 | "0x69000a259d21c1824c7ffe3fd1e19a557a81d87e" 24 | ); 25 | } 26 | 27 | // We recommend this pattern to be able to use async/await everywhere 28 | // and properly handle errors. 29 | main().catch((error) => { 30 | console.error(error); 31 | process.exitCode = 1; 32 | }); 33 | -------------------------------------------------------------------------------- /scripts/create2/zai.ts: -------------------------------------------------------------------------------- 1 | import hre, { ethers, network } from "hardhat"; 2 | import { buildBytecode } from "./create2"; 3 | import { waitForTx } from "../utils"; 4 | 5 | async function main() { 6 | const constructorArgs: any[] = ["0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"]; 7 | const salt = 8 | "0x7e5eb0064d6dcdd0dbd023d9b02d765c721ac4f0d8b25e904ca7b35dbf5e151d"; 9 | const target = "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0"; 10 | const deployer = await hre.ethers.getContractAt( 11 | "Deployer", 12 | "0x21F0F750E2d576AD5d01cFDDcF2095e8DA5b0fb0" 13 | ); 14 | 15 | const factory = await hre.ethers.getContractFactory("ZaiStablecoin"); 16 | 17 | const bytecode = buildBytecode( 18 | ["address"], 19 | constructorArgs, 20 | factory.bytecode 21 | ); 22 | 23 | await waitForTx( 24 | await deployer.deployWithAssert(bytecode, ethers.id(salt), target) 25 | ); 26 | 27 | if (network.name !== "hardhat") { 28 | await hre.deployments.save("ZaiStablecoin", { 29 | address: target, 30 | args: constructorArgs, 31 | abi: factory.interface.format(true), 32 | }); 33 | 34 | await hre.run("verify:verify", { 35 | address: target, 36 | contract: "contracts/core/ZaiStablecoin.sol:ZaiStablecoin", 37 | constructorArguments: constructorArgs, 38 | }); 39 | } 40 | } 41 | 42 | // We recommend this pattern to be able to use async/await everywhere 43 | // and properly handle errors. 44 | main().catch((error) => { 45 | console.error(error); 46 | process.exitCode = 1; 47 | }); 48 | -------------------------------------------------------------------------------- /scripts/governance/deploy-governance-uihelper.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | import { deployContract } from "../utils"; 3 | 4 | async function main() { 5 | const OmnichainStakingTokenD = await hre.deployments.get( 6 | "OmnichainStakingToken" 7 | ); 8 | 9 | // Deploy proxies 10 | await deployContract( 11 | hre, 12 | "GovernanceUiHelper", 13 | [OmnichainStakingTokenD.address], 14 | "GovernanceUiHelper" 15 | ); 16 | } 17 | 18 | main().catch((err) => { 19 | console.error(err); 20 | process.exitCode = 1; 21 | }); 22 | -------------------------------------------------------------------------------- /scripts/governance/snapshot-test.csv: -------------------------------------------------------------------------------- 1 | token,amount,start,end,owner,newowner 2 | 1,1,1669031039,1684972800,0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b, 3 | 2,1,1669031039,1684972800,0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b,0x77cd66d59ac48a0E7CE54fF16D9235a5fffF335E 4 | 3,1,1714743191,1840406400,0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b, 5 | -------------------------------------------------------------------------------- /scripts/guess/proxyAdmin.ts: -------------------------------------------------------------------------------- 1 | // import 2 | import { ethers } from "ethers"; 3 | import { getCreate2Address } from "../create2/create2"; 4 | 5 | // declare deployment parameters 6 | import contractArtifact from "../../artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json"; 7 | import { get } from "./_helpers"; 8 | 9 | const constructorTypes = contractArtifact.abi 10 | .find((v) => v.type === "constructor") 11 | ?.inputs.map((t) => t.type); 12 | 13 | const factoryAddress = get("Deployer", "arbitrum"); 14 | const constructorArgs: any[] = [get("MAHATimelockController", "arbitrum")]; 15 | 16 | console.log("constructor parameters", constructorTypes, constructorArgs); 17 | 18 | const job = () => { 19 | let i = 0; 20 | 21 | while (true) { 22 | const salt = ethers.id("" + i); 23 | // Calculate contract address 24 | const computedAddress = getCreate2Address({ 25 | salt: salt, 26 | 27 | factoryAddress, 28 | contractBytecode: contractArtifact.bytecode, 29 | constructorTypes: constructorTypes, 30 | constructorArgs: constructorArgs, 31 | }); 32 | 33 | if (computedAddress.startsWith("0x69000")) { 34 | console.log("found the right salt hash"); 35 | console.log("salt", salt, computedAddress); 36 | break; 37 | } 38 | 39 | if (i % 100000 == 0) console.log(i, "salt", salt, computedAddress); 40 | i++; 41 | } 42 | }; 43 | 44 | job(); 45 | -------------------------------------------------------------------------------- /scripts/guess/timelock.ts: -------------------------------------------------------------------------------- 1 | import implArtificat from "../../artifacts/contracts/governance/MAHATimelockController.sol/MAHATimelockController.json"; 2 | import { guess } from "./_helpers"; 3 | 4 | guess( 5 | implArtificat, 6 | [ 7 | 60 * 60, 8 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", 9 | ["0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b"], 10 | ], 11 | "mainnet" 12 | ); 13 | -------------------------------------------------------------------------------- /scripts/guess/xerc20-impl.ts: -------------------------------------------------------------------------------- 1 | import implArtificat from "../../artifacts/contracts/periphery/restaking/XERC20.sol/XERC20.json"; 2 | import { guess } from "./_helpers"; 3 | 4 | guess(implArtificat, [], "mainnet"); 5 | -------------------------------------------------------------------------------- /scripts/guess/xerc20-zai-local.ts: -------------------------------------------------------------------------------- 1 | import implArtificat from "../../artifacts/contracts/periphery/restaking/XERC20.sol/XERC20.json"; 2 | import { get, guessProxy } from "./_helpers"; 3 | 4 | guessProxy( 5 | implArtificat, 6 | get("XERC20-impl", "base"), 7 | "initialize", 8 | [ 9 | "xZAI Stablecoin", 10 | "xUSDz", 11 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", // admin 12 | ], 13 | "base" 14 | ); 15 | -------------------------------------------------------------------------------- /scripts/guess/xerc20-zai-remote.ts: -------------------------------------------------------------------------------- 1 | import implArtificat from "../../artifacts/contracts/periphery/restaking/XERC20.sol/XERC20.json"; 2 | import { get, guessProxy } from "./_helpers"; 3 | 4 | guessProxy( 5 | implArtificat, 6 | get("XERC20-impl", "base"), 7 | "initialize", 8 | [ 9 | "ZAI Stablecoin", 10 | "xUSDz", 11 | "0x1f09ec21d7fd0a21879b919bf0f9c46e6b85ca8b", // admin 12 | ], 13 | "base" 14 | ); 15 | -------------------------------------------------------------------------------- /scripts/guess/zai.ts: -------------------------------------------------------------------------------- 1 | // import 2 | import { ethers } from "ethers"; 3 | import { getCreate2Address } from "../create2/create2"; 4 | 5 | // declare deployment parameters 6 | import contractArtifact from "../../artifacts/contracts/core/ZaiStablecoin.sol/ZaiStablecoin.json"; 7 | 8 | const constructorTypes = contractArtifact.abi 9 | .find((v) => v.type === "constructor") 10 | ?.inputs.map((t) => t.type); 11 | 12 | const factoryAddress = "0x21F0F750E2d576AD5d01cFDDcF2095e8DA5b0fb0"; 13 | const constructorArgs: any[] = ["0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"]; 14 | 15 | console.log("constructor parameters", constructorTypes, constructorArgs); 16 | 17 | const job = () => { 18 | let i = 0; 19 | 20 | while (true) { 21 | const salt = ethers.id("" + i); 22 | // Calculate contract address 23 | const computedAddress = getCreate2Address({ 24 | salt: salt, 25 | 26 | factoryAddress, 27 | contractBytecode: contractArtifact.bytecode, 28 | constructorTypes: constructorTypes, 29 | constructorArgs: constructorArgs, 30 | }); 31 | 32 | if (computedAddress.startsWith("0x69000")) { 33 | console.log("found the right salt hash"); 34 | console.log("salt", salt, computedAddress); 35 | break; 36 | } 37 | 38 | if (i % 100000 == 0) console.log(i, "salt", salt, computedAddress); 39 | i++; 40 | } 41 | }; 42 | 43 | job(); 44 | -------------------------------------------------------------------------------- /scripts/helpers.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import fs from "fs"; 3 | import path from "path"; 4 | 5 | export function get(name: string, network: string): string { 6 | const data = fs.readFileSync( 7 | path.resolve(__dirname, `../deployments/${network}/${name}.json`) 8 | ); 9 | 10 | const res = JSON.parse(data.toString()).address as any as string; 11 | assert(res.length == 42, `invalid address for ${network}/${name}.json`); 12 | return res; 13 | } 14 | 15 | export function existsD(name: string, network: string): boolean { 16 | return fs.existsSync( 17 | path.resolve(__dirname, `../deployments/${network}/${name}.json`) 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /scripts/move-locks.ts: -------------------------------------------------------------------------------- 1 | import { keccak256 } from "ethers"; 2 | import { ethers, network, deployments } from "hardhat"; 3 | import { waitForTx } from "./utils"; 4 | 5 | async function main() { 6 | console.log(`Deploying to ${network.name}...`); 7 | 8 | const [deployer] = await ethers.getSigners(); 9 | console.log(`Deployer address is ${deployer.address}.`); 10 | // const deployer = await ethers.getSigner( 11 | // "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC" 12 | // ); 13 | 14 | const timelockD = await deployments.get("OmnichainStakingToken"); 15 | 16 | const staking = await ethers.getContractAt( 17 | "OmnichainStakingToken", 18 | timelockD.address 19 | ); 20 | 21 | await waitForTx( 22 | await staking.moveLockOwnership( 23 | "132", 24 | "0x7202136d70026DA33628dD3f3eFccb43F62a2469" 25 | ) 26 | ); 27 | } 28 | 29 | main().catch((error) => { 30 | console.error(error); 31 | process.exitCode = 1; 32 | }); 33 | -------------------------------------------------------------------------------- /scripts/odos/helpers/path.ts: -------------------------------------------------------------------------------- 1 | import { assembleTx, generateQuote } from "./odos"; 2 | 3 | export const getGelatoCode = async ( 4 | chainId: number, 5 | targetToken: string, 6 | contract: string, 7 | balances: string[], 8 | tokenAddresses: readonly `0x${string}`[] 9 | ) => { 10 | const hasBalance = 11 | balances.findIndex((v) => v !== "0" && v !== "" && !!v) >= 0; 12 | if (!hasBalance) throw new Error("no balance"); 13 | 14 | // get quote from odos 15 | const quote = await generateQuote({ 16 | chainId: chainId, 17 | inputTokens: tokenAddresses 18 | .map((t, i) => ({ 19 | tokenAddress: t, 20 | amount: balances[i].toString(), 21 | })) 22 | .filter((p) => p.tokenAddress.toLowerCase() != targetToken.toLowerCase()) 23 | .filter((p) => p.amount !== "0"), 24 | outputTokens: [ 25 | { 26 | tokenAddress: targetToken, 27 | proportion: 1, 28 | }, 29 | ], 30 | userAddr: contract, 31 | }); 32 | 33 | if (!quote) throw new Error("invalid quote from odos"); 34 | 35 | // prepare tx from odos 36 | const txData = await assembleTx(contract, quote); 37 | if (!txData) throw new Error("invalid assemble from odos"); 38 | 39 | console.log("data", txData.transaction.data); 40 | 41 | return txData.transaction; 42 | }; 43 | -------------------------------------------------------------------------------- /scripts/odos/prepare-tx-oft-l1-adapter.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/naming-convention */ 2 | import { ethers } from "ethers"; 3 | import { Contract } from "ethers"; 4 | import { getGelatoCode } from "./helpers/path"; 5 | import { get } from "../guess/_helpers"; 6 | 7 | const main = async () => { 8 | const l1ContractD = get("L1BridgeCollateralL0", "mainnet"); 9 | const tokenD = "0x73A15FeD60Bf67631dC6cd7Bc5B6e8da8190aCF5"; 10 | const susde = get("sUSDe", "mainnet"); 11 | 12 | const iface = new ethers.Interface([ 13 | "function balanceOf(address who) public view returns (uint256 bal)", 14 | "function processWithOdos(address token, bytes memory data) public", 15 | ]); 16 | 17 | const runner = new ethers.JsonRpcProvider("https://rpc.ankr.com/eth"); 18 | const token = new Contract(tokenD, iface, runner); 19 | 20 | const bal = await token.balanceOf(l1ContractD); 21 | 22 | try { 23 | const ret = await getGelatoCode(1, susde, l1ContractD, [bal], [tokenD]); 24 | console.log("odos data", ret); 25 | 26 | console.log("tx data", { 27 | to: l1ContractD, 28 | data: iface.encodeFunctionData("processWithOdos", [tokenD, ret.data]), 29 | }); 30 | } catch (error: any) { 31 | console.log(error); 32 | } 33 | }; 34 | 35 | main().catch((error) => { 36 | console.error(error); 37 | process.exitCode = 1; 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/odos/prepare-tx-susde-cron.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/naming-convention */ 2 | import { ethers } from "ethers"; 3 | import { Contract } from "ethers"; 4 | import { getGelatoCode } from "./helpers/path"; 5 | import { get } from "../guess/_helpers"; 6 | 7 | const main = async () => { 8 | const cron = get("sUSDeCollectorCron", "mainnet"); 9 | const zai = get("ZAI", "mainnet"); 10 | const susde = get("sUSDe", "mainnet") as `0x${string}`; 11 | 12 | const iface = new ethers.Interface([ 13 | "function balanceOf(address who) public view returns (uint256 bal)", 14 | "function execute(bytes memory data) public payable", 15 | ]); 16 | 17 | const runner = new ethers.JsonRpcProvider("https://rpc.ankr.com/eth"); 18 | const sUSDe = new Contract(susde, iface, runner); 19 | 20 | const bal = await sUSDe.balanceOf(cron); 21 | 22 | try { 23 | const ret = await getGelatoCode(1, zai, cron, [bal], [susde]); 24 | console.log("odos data", ret); 25 | 26 | console.log("tx data", { 27 | to: cron, 28 | data: iface.encodeFunctionData("execute", [ret.data]), 29 | }); 30 | } catch (error: any) { 31 | console.log(error); 32 | } 33 | }; 34 | 35 | main().catch((error) => { 36 | console.error(error); 37 | process.exitCode = 1; 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/prepare-timelock.ts: -------------------------------------------------------------------------------- 1 | import { Addressable, ContractTransaction } from "ethers"; 2 | import { HardhatRuntimeEnvironment } from "hardhat/types"; 3 | 4 | export const getTimelock = async ( 5 | hre: HardhatRuntimeEnvironment, 6 | address?: string | Addressable 7 | ) => { 8 | if (!address) 9 | address = (await hre.deployments.get("MAHATimelockController")).address; 10 | return await hre.ethers.getContractAt("MAHATimelockController", address); 11 | }; 12 | 13 | export const prepareTimelockData = async ( 14 | hre: HardhatRuntimeEnvironment, 15 | from: string | Addressable, 16 | txs: ContractTransaction[] = [], 17 | timelockAddr?: string | Addressable 18 | ) => { 19 | const timelock = await getTimelock(hre, timelockAddr); 20 | 21 | const salt = hre.ethers.id("salt"); 22 | const predecessor = hre.ethers.zeroPadValue("0x00", 32); 23 | console.log("using salt", salt); 24 | console.log("using predecessor", predecessor); 25 | 26 | const minDelay = await timelock.getMinDelay(); 27 | console.log("minDelay", minDelay); 28 | 29 | const schedule = await timelock.scheduleBatch.populateTransaction( 30 | txs.map((tx) => tx.to), 31 | txs.map(() => 0), 32 | txs.map((tx) => tx.data), 33 | predecessor, 34 | salt, 35 | minDelay 36 | ); 37 | const execute = await timelock.executeBatch.populateTransaction( 38 | txs.map((tx) => tx.to), 39 | txs.map(() => 0), 40 | txs.map((tx) => tx.data), 41 | predecessor, 42 | salt 43 | ); 44 | 45 | console.log(""); 46 | console.log("from", from); 47 | console.log("to", schedule.to); 48 | console.log("\nschedule tx"); 49 | console.log(schedule.data); 50 | console.log("\nexecute tx"); 51 | console.log(execute.data); 52 | console.log(""); 53 | 54 | return { schedule, execute }; 55 | }; 56 | -------------------------------------------------------------------------------- /scripts/prepareTimelockScript.ts: -------------------------------------------------------------------------------- 1 | import { keccak256 } from "ethers"; 2 | import { ethers, network, deployments } from "hardhat"; 3 | 4 | async function main() { 5 | console.log(`Deploying to ${network.name}...`); 6 | 7 | // const [deployer] = await ethers.getSigners(); 8 | const deployer = await ethers.getSigner( 9 | "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC" 10 | ); 11 | console.log(`Deployer address is ${deployer.address}.`); 12 | 13 | const timelockD = await deployments.get("MAHATimelockController"); 14 | 15 | const timelock = await ethers.getContractAt( 16 | "MAHATimelockController", 17 | timelockD.address 18 | ); 19 | 20 | const predecessor = 21 | "0x0000000000000000000000000000000000000000000000000000000000000000"; 22 | const salt = ethers.id("task1"); 23 | 24 | const contractD = await deployments.get("ProxyAdmin"); 25 | const contract = await ethers.getContractAt("ProxyAdmin", contractD.address); 26 | 27 | const data1 = await contract.transferOwnership.populateTransaction( 28 | "0x77cd66d59ac48a0E7CE54fF16D9235a5fffF335E" 29 | ); 30 | 31 | console.log(data1); 32 | 33 | const schedule = await timelock.schedule.populateTransaction( 34 | data1.to, 35 | 0, 36 | data1.data, 37 | predecessor, // bytes32 predecessor, 38 | salt, // bytes32 salt, 39 | await timelock.getMinDelay() 40 | ); 41 | console.log("schedule tx", schedule); 42 | 43 | const execute = await timelock.execute.populateTransaction( 44 | data1.to, 45 | 0, 46 | data1.data, 47 | predecessor, // bytes32 predecessor, 48 | salt // bytes32 salt, 49 | ); 50 | console.log("execute tx", execute); 51 | } 52 | 53 | main().catch((error) => { 54 | console.error(error); 55 | process.exitCode = 1; 56 | }); 57 | -------------------------------------------------------------------------------- /scripts/test-mint-redeem-susde.ts: -------------------------------------------------------------------------------- 1 | import { MaxUint256 } from "ethers"; 2 | import hre from "hardhat"; 3 | import { waitForTx } from "./utils"; 4 | 5 | async function main() { 6 | const { deployer } = await hre.getNamedAccounts(); 7 | 8 | const symbol = "sUSDe"; 9 | 10 | const usdcD = await hre.deployments.get(symbol); 11 | const zaiD = await hre.deployments.get("ZaiStablecoin"); 12 | const collateral = await hre.ethers.getContractAt( 13 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 14 | usdcD.address 15 | ); 16 | const zai = await hre.ethers.getContractAt( 17 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 18 | zaiD.address 19 | ); 20 | 21 | const psmD = await hre.deployments.get(`PegStabilityModule-${symbol}`); 22 | const psm = await hre.ethers.getContractAt( 23 | "PegStabilityModule", 24 | psmD.address 25 | ); 26 | 27 | console.log("giving approvals"); 28 | await waitForTx(await collateral.approve(psmD.address, MaxUint256)); 29 | await waitForTx(await zai.approve(psmD.address, MaxUint256)); 30 | 31 | console.log("testing psm mint"); 32 | await waitForTx(await psm.mint(deployer, 5n * 10n ** 18n)); 33 | 34 | console.log("testing psm redeem"); 35 | await waitForTx(await psm.redeem(deployer, 1n * 10n ** 18n)); 36 | } 37 | 38 | // We recommend this pattern to be able to use async/await everywhere 39 | // and properly handle errors. 40 | main().catch((error) => { 41 | console.error(error); 42 | process.exitCode = 1; 43 | }); 44 | -------------------------------------------------------------------------------- /scripts/test-mint-redeem-usdc.ts: -------------------------------------------------------------------------------- 1 | import { MaxUint256 } from "ethers"; 2 | import hre from "hardhat"; 3 | import { waitForTx } from "./utils"; 4 | 5 | async function main() { 6 | const { deployer } = await hre.getNamedAccounts(); 7 | 8 | const symbol = "USDC"; 9 | 10 | const usdcD = await hre.deployments.get(symbol); 11 | const zaiD = await hre.deployments.get("ZaiStablecoin"); 12 | const collateral = await hre.ethers.getContractAt( 13 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 14 | usdcD.address 15 | ); 16 | const zai = await hre.ethers.getContractAt( 17 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 18 | zaiD.address 19 | ); 20 | 21 | const psmD = await hre.deployments.get(`PegStabilityModule-${symbol}`); 22 | const psm = await hre.ethers.getContractAt( 23 | "PegStabilityModule", 24 | psmD.address 25 | ); 26 | 27 | console.log("giving approvals"); 28 | await waitForTx(await collateral.approve(psmD.address, MaxUint256)); 29 | await waitForTx(await zai.approve(psmD.address, MaxUint256)); 30 | 31 | console.log("testing psm mint", 50n * 10n ** 18n); 32 | await waitForTx(await psm.mint(deployer, 50n * 10n ** 18n)); 33 | 34 | console.log("testing psm redeem"); 35 | await waitForTx(await psm.redeem(deployer, 1n * 10n ** 18n)); 36 | } 37 | 38 | // We recommend this pattern to be able to use async/await everywhere 39 | // and properly handle errors. 40 | main().catch((error) => { 41 | console.error(error); 42 | process.exitCode = 1; 43 | }); 44 | -------------------------------------------------------------------------------- /scripts/test-mint-szai.ts: -------------------------------------------------------------------------------- 1 | import { MaxUint256 } from "ethers"; 2 | import hre from "hardhat"; 3 | import { waitForTx } from "./utils"; 4 | 5 | async function main() { 6 | const { deployer } = await hre.getNamedAccounts(); 7 | 8 | const zaiD = await hre.deployments.get("ZAI"); 9 | const szaiD = await hre.deployments.get("sZAI"); 10 | 11 | const zai = await hre.ethers.getContractAt( 12 | "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20", 13 | zaiD.address 14 | ); 15 | 16 | const szai = await hre.ethers.getContractAt("SafetyPool", szaiD.address); 17 | 18 | console.log("giving approvals"); 19 | await waitForTx(await zai.approve(szaiD.address, MaxUint256)); 20 | await waitForTx(await szai.mint(10n * 10n ** 18n, deployer)); 21 | } 22 | 23 | // We recommend this pattern to be able to use async/await everywhere 24 | // and properly handle errors. 25 | main().catch((error) => { 26 | console.error(error); 27 | process.exitCode = 1; 28 | }); 29 | -------------------------------------------------------------------------------- /scripts/timelock/upgrade-mahax.ts: -------------------------------------------------------------------------------- 1 | import hre, { ethers, deployments } from "hardhat"; 2 | import { deployContract } from "../utils"; 3 | import { ZeroAddress } from "ethers"; 4 | 5 | async function main() { 6 | console.log(`preparing timelock data`); 7 | 8 | const deployer = await ethers.getSigner( 9 | "0x6357EDbfE5aDA570005ceB8FAd3139eF5A8863CC" 10 | ); 11 | console.log(`Deployer address is ${deployer.address}.`); 12 | 13 | const newImpl = await deployContract( 14 | hre, 15 | "OmnichainStakingToken", 16 | [], 17 | "OmnichainStakingToken-v2" 18 | ); 19 | 20 | const staking = await ethers.getContractAt( 21 | "OmnichainStakingToken", 22 | newImpl.address 23 | ); 24 | 25 | const omnichainStakingToken = await deployments.get("OmnichainStakingToken"); 26 | const lockerToken = await deployments.get("LockerToken"); 27 | const wethD = await deployments.get("WETH"); 28 | 29 | const initData = await staking.initialize.populateTransaction( 30 | lockerToken.address, 31 | wethD.address, 32 | [], 33 | 1683216000, 34 | deployer.address, 35 | ZeroAddress 36 | ); 37 | 38 | const proxyAdminD = await deployments.get("ProxyAdmin"); 39 | const proxyAdmin = await ethers.getContractAt( 40 | "ProxyAdmin", 41 | proxyAdminD.address 42 | ); 43 | 44 | const upgradeTx = await proxyAdmin.upgradeAndCall.populateTransaction( 45 | omnichainStakingToken.address, 46 | newImpl.address, 47 | initData.data 48 | ); 49 | 50 | console.log("initData", initData); 51 | console.log("upgradeTx", upgradeTx); 52 | } 53 | 54 | main().catch((error) => { 55 | console.error(error); 56 | process.exitCode = 1; 57 | }); 58 | -------------------------------------------------------------------------------- /scripts/verify/save-tokens.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | 3 | import contractArtifact from "../../artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json"; 4 | 5 | async function main() { 6 | await hre.deployments.save("USDC", { 7 | address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", 8 | abi: contractArtifact.abi, 9 | }); 10 | } 11 | 12 | // We recommend this pattern to be able to use async/await everywhere 13 | // and properly handle errors. 14 | main().catch((error) => { 15 | console.error(error); 16 | process.exitCode = 1; 17 | }); 18 | -------------------------------------------------------------------------------- /scripts/verify/verify-timelock.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | 3 | import contractArtifact from "../../artifacts/contracts/core/ZaiStablecoin.sol/ZaiStablecoin.json"; 4 | 5 | async function main() { 6 | const constructorArguments = ["0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"]; 7 | 8 | const address = "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0"; 9 | 10 | hre.deployments.save("ZaiStablecoin", { 11 | address: address, 12 | args: constructorArguments, 13 | abi: contractArtifact.abi, 14 | }); 15 | 16 | hre.run("verify:verify", { 17 | address: address, 18 | constructorArguments, 19 | }); 20 | } 21 | 22 | // We recommend this pattern to be able to use async/await everywhere 23 | // and properly handle errors. 24 | main().catch((error) => { 25 | console.error(error); 26 | process.exitCode = 1; 27 | }); 28 | -------------------------------------------------------------------------------- /scripts/verify/verify-zai.ts: -------------------------------------------------------------------------------- 1 | import hre from "hardhat"; 2 | 3 | import contractArtifact from "../../artifacts/contracts/core/ZaiStablecoin.sol/ZaiStablecoin.json"; 4 | 5 | async function main() { 6 | const constructorArguments = ["0x1F09Ec21d7fd0A21879b919bf0f9C46e6b85CA8b"]; 7 | 8 | const address = "0x69000405f9dce69bd4cbf4f2865b79144a69bfe0"; 9 | 10 | hre.deployments.save("ZaiStablecoin", { 11 | address: address, 12 | args: constructorArguments, 13 | abi: contractArtifact.abi, 14 | }); 15 | 16 | hre.run("verify:verify", { 17 | address: address, 18 | constructorArguments, 19 | }); 20 | } 21 | 22 | // We recommend this pattern to be able to use async/await everywhere 23 | // and properly handle errors. 24 | main().catch((error) => { 25 | console.error(error); 26 | process.exitCode = 1; 27 | }); 28 | -------------------------------------------------------------------------------- /tasks/layerzero/print-ofts.ts: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Script to connect OFTs for the Zai and Maha tokens on the various networks. 4 | 5 | npx hardhat connect-oft --token zai --network arbitrum 6 | npx hardhat connect-oft --token zai --network base 7 | npx hardhat connect-oft --token zai --network blast 8 | npx hardhat connect-oft --token zai --network bsc 9 | npx hardhat connect-oft --token zai --network linea 10 | npx hardhat connect-oft --token zai --network optimism 11 | npx hardhat connect-oft --token zai --network xlayer 12 | npx hardhat connect-oft --token zai --network mainnet 13 | npx hardhat connect-oft --token zai --network scroll 14 | 15 | */ 16 | import { task } from "hardhat/config"; 17 | import { config } from "./config"; 18 | import { get } from "../../scripts/guess/_helpers"; 19 | 20 | task(`print-ofts`, `Prints all the OFTs`) 21 | .addParam("token", "either zai or maha") 22 | .setAction(async ({ token }) => { 23 | const networks = Object.keys(config); 24 | const contractNameToken = token === "zai" ? "ZaiStablecoin" : "MAHA"; 25 | 26 | for (let index = 0; index < networks.length; index++) { 27 | const network = networks[index]; 28 | const addr = get(contractNameToken, network); 29 | console.log(network, addr); 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /tasks/layerzero/skip-oft-tx.ts: -------------------------------------------------------------------------------- 1 | import { task } from "hardhat/config"; 2 | import { waitForTx } from "../../scripts/utils"; 3 | import { config } from "./config"; 4 | import { zeroPadValue } from "ethers"; 5 | 6 | task(`skip-oft-tx`, `Sets up the OFT with the right DVNs`) 7 | .addParam("targetnetwork", "The target network to send the OFT tokens to") 8 | .setAction(async ({ targetnetwork }, hre) => { 9 | const connections = Object.values(config); 10 | const connection = connections.find((c) => c.network === hre.network.name); 11 | if (!connection) throw new Error("cannot find connection"); 12 | 13 | const target = connections.find((c) => c.network === targetnetwork); 14 | if (!target) throw new Error("cannot find connection"); 15 | 16 | const [deployer] = await hre.ethers.getSigners(); 17 | 18 | const oftD = await hre.deployments.get(connection.contract); 19 | const oft = await hre.ethers.getContractAt("OFT", oftD.address); 20 | const endpoint = await hre.ethers.getContractAt( 21 | "IL0EndpointV2", 22 | await oft.endpoint() 23 | ); 24 | 25 | await waitForTx( 26 | await endpoint.skip( 27 | oft.target, // address _oapp, //the Oapp address 28 | target.eid, // uint32 _srcEid, //source chain endpoint id 29 | zeroPadValue(deployer.address, 32), // bytes32 _sender, //the byte32 format of sender address 30 | 3 // uint64 _nonce // the message nonce you wish to skip to 31 | ) 32 | ); 33 | }); 34 | -------------------------------------------------------------------------------- /tasks/layerzero/test-oft-adapter-multichain.ts: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Script to send a test OFT to a target network 4 | 5 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network arbitrum 6 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network base 7 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network blast 8 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network bsc 9 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network linea 10 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network optimism 11 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network xlayer 12 | npx hardhat test-oft-adapter --amt 1 --targetnetwork mainnet --token zai --network scroll 13 | 14 | */ 15 | import { task } from "hardhat/config"; 16 | import { config } from "./config"; 17 | 18 | task( 19 | `test-oft-adapter-multi`, 20 | `Tests the mainnet OFT adapter across mulitple chains` 21 | ) 22 | .addParam("token", "either zai or maha") 23 | .addParam("amt", "the amount of tokens") 24 | .setAction(async ({ token, amt }, hre) => { 25 | const networks = Object.keys(config).filter((n) => n !== hre.network.name); 26 | for (let index = 0; index < networks.length; index++) { 27 | const network = networks[index]; 28 | 29 | try { 30 | await hre.run("test-oft-adapter", { 31 | token, 32 | amt, 33 | targetnetwork: network, 34 | }); 35 | } catch (e) { 36 | console.log("error", e); 37 | console.log("send failed for network", network); 38 | } 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /tasks/layerzero/test-restake-l0.ts: -------------------------------------------------------------------------------- 1 | import { task } from "hardhat/config"; 2 | import { waitForTx } from "../../scripts/utils"; 3 | import { config } from "./config"; 4 | import assert from "assert"; 5 | import { MaxUint256 } from "ethers"; 6 | 7 | task(`test-restake-l0`).setAction(async (_, hre) => { 8 | const conifgLocal = config[hre.network.name]; 9 | assert(!!conifgLocal, `Config not found for ${hre.network.name}`); 10 | 11 | const contractD = await hre.deployments.get("L2DepositCollateralL0"); 12 | const usdcD = await hre.deployments.get("USDC"); 13 | 14 | const contract = await hre.ethers.getContractAt( 15 | "L2DepositCollateralL0", 16 | contractD.address 17 | ); 18 | const erc20 = await hre.ethers.getContractAt("MockERC20", usdcD.address); 19 | 20 | console.log("deposit contract is at", contract.target); 21 | await waitForTx(await erc20.approve(contract.target, MaxUint256)); 22 | await waitForTx(await contract.deposit(1e6)); 23 | }); 24 | -------------------------------------------------------------------------------- /tasks/layerzero/transfer-gov-ownership.ts: -------------------------------------------------------------------------------- 1 | // transfer the governance ownership to the timelock and checks if the timelock has proposer roles for the gov ownership 2 | -------------------------------------------------------------------------------- /tasks/misc/deploy-contract.ts: -------------------------------------------------------------------------------- 1 | import { task } from "hardhat/config"; 2 | import { deployContract } from "../../scripts/utils"; 3 | 4 | task(`deploy-contract`).setAction(async (_, hre) => { 5 | const contract = await deployContract( 6 | hre, 7 | "PegStabilityModuleYield", 8 | [], 9 | "PegStabilityModuleYield-Impl" 10 | ); 11 | console.log(contract.address); 12 | }); 13 | -------------------------------------------------------------------------------- /tasks/misc/notify-rewards.ts: -------------------------------------------------------------------------------- 1 | import { task } from "hardhat/config"; 2 | import { waitForTx } from "../../scripts/utils"; 3 | import { MaxUint256, parseEther } from "ethers"; 4 | 5 | task(`notify-rewards`).setAction(async (_, hre) => { 6 | const deployments = await hre.deployments.all(); 7 | const [deployer] = await hre.ethers.getSigners(); 8 | 9 | const mahaD = await hre.deployments.get("MAHA"); 10 | const maha = await hre.ethers.getContractAt("MAHA", mahaD.address); 11 | 12 | const rewardsD = await hre.deployments.get("StakingLPRewards-sUSDzUSDC"); 13 | const rewards = await hre.ethers.getContractAt( 14 | "StakingLPRewards", 15 | rewardsD.address 16 | ); 17 | 18 | const amount = parseEther("10"); 19 | 20 | await waitForTx(await maha.approve(rewardsD.address, MaxUint256)); 21 | await waitForTx(await rewards.notifyRewardAmount(maha.target, amount)); 22 | }); 23 | -------------------------------------------------------------------------------- /test/certora/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahaxyz/contracts/159435eb4810a0cb28da976bd0c2136c7655c218/test/certora/.gitkeep -------------------------------------------------------------------------------- /test/foundry/DDHubTest.fees.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "./base/BaseDDHubTest.sol"; 17 | 18 | contract DDHubTestFees is BaseDDHubTest { 19 | function setUp() public { 20 | _setUpHub(); 21 | _setupPool(); 22 | 23 | // fund metamorpho with 900 zai 24 | vm.prank(governance); 25 | plan.setTargetAssets(900 ether); 26 | vm.prank(executor); 27 | hub.exec(pool); 28 | } 29 | 30 | function test_setFeeCollector() public { 31 | vm.prank(governance); 32 | hub.setFeeCollector(address(0x2)); 33 | assertEq(hub.feeCollector(), address(0x2)); 34 | } 35 | 36 | function test_sweepFeesWithMetaMorpho() public { 37 | // go forward 100 days to accure some interest 38 | vm.warp(block.timestamp + 100 days); 39 | 40 | assertEq(zai.balanceOf(feeDestination), 0); 41 | 42 | hub.sweepFees(pool); 43 | 44 | // roughly 132 zai would be the interest accured 45 | assertGe(zai.balanceOf(feeDestination), 100 ether); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/foundry/DDHubTest.risk.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "./base/BaseDDHubTest.sol"; 17 | 18 | contract DDHubTestSimple is BaseDDHubTest { 19 | function setUp() public { 20 | _setUpHub(); 21 | _setupPool(); 22 | } 23 | 24 | function test_reduceDebtCeiling() public { 25 | IDDHub.PoolInfo memory poolInfo = hub.poolInfos(pool); 26 | assertEq(poolInfo.debtCeiling, 1000 ether); 27 | 28 | vm.prank(riskManager); 29 | hub.reduceDebtCeiling(pool, 300 ether); 30 | 31 | poolInfo = hub.poolInfos(pool); 32 | assertEq(poolInfo.debtCeiling, 700 ether); 33 | } 34 | 35 | function test_shutdownPool() public { 36 | IDDHub.PoolInfo memory poolInfo = hub.poolInfos(pool); 37 | assertEq(poolInfo.isLive, true); 38 | 39 | vm.prank(riskManager); 40 | hub.shutdownPool(pool); 41 | 42 | poolInfo = hub.poolInfos(pool); 43 | assertEq(poolInfo.isLive, false); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/foundry/DDHubTest.shutdown.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "./base/BaseDDHubTest.sol"; 17 | 18 | contract DDHubTestShutdown is BaseDDHubTest { 19 | function setUp() public { 20 | _setUpHub(); 21 | _setupPool(); 22 | 23 | // fund metamorpho with 1000 zai 24 | vm.prank(executor); 25 | hub.exec(pool); 26 | } 27 | 28 | function test_shutdownViaPlanDisabled() public { 29 | vm.prank(governance); 30 | plan.disable(); 31 | 32 | vm.expectEmit(address(hub)); 33 | emit DDEventsLib.BurnDebt(pool, 1000 ether - 1); 34 | 35 | vm.prank(executor); 36 | hub.exec(pool); 37 | } 38 | 39 | function test_shutdownViaShutdownPoolCall() public { 40 | vm.prank(riskManager); 41 | hub.shutdownPool(pool); 42 | 43 | vm.expectEmit(address(hub)); 44 | emit DDEventsLib.BurnDebt(pool, 1000 ether - 1); 45 | 46 | vm.prank(executor); 47 | hub.exec(pool); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/foundry/DDOperatorPlanTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "../../contracts/core/direct-deposit/plans/DDOperatorPlan.sol"; 17 | import {BaseZaiTest} from "./base/BaseZaiTest.sol"; 18 | 19 | contract DDOperatorPlanTest is BaseZaiTest { 20 | DDOperatorPlan private plan; 21 | 22 | function setUp() public { 23 | _setUpBase(); 24 | plan = new DDOperatorPlan(0, governance, 1000); 25 | 26 | assertEq(plan.active(), true); 27 | assertEq(plan.enabled(), 1); 28 | } 29 | 30 | function test_planDisable() public { 31 | assertEq(plan.active(), true); 32 | 33 | vm.prank(governance); 34 | plan.disable(); 35 | 36 | assertEq(plan.active(), false); 37 | assertEq(plan.enabled(), 0); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/foundry/ZaiStablecoinTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {BaseZaiTest} from "./base/BaseZaiTest.sol"; 17 | 18 | contract ZaiStablecoinTest is BaseZaiTest { 19 | function setUp() public { 20 | _setUpBase(); 21 | 22 | zai.grantManagerRole(whale); 23 | } 24 | 25 | function test_nameAndSymbol() public view { 26 | assertEq(zai.name(), "ZAI Stablecoin"); 27 | assertEq(zai.symbol(), "ZAI"); 28 | } 29 | 30 | function test_isManager() public view { 31 | assertEq(zai.isManager(governance), true); 32 | assertEq(zai.isManager(address(0x69)), false); 33 | } 34 | 35 | function test_revokeManager() public { 36 | assertEq(zai.isManager(governance), true); 37 | assertEq(zai.isManager(address(this)), true); 38 | 39 | zai.revokeManagerRole(address(this)); 40 | 41 | assertEq(zai.isManager(governance), true); 42 | assertEq(zai.isManager(address(this)), false); 43 | 44 | vm.expectRevert(); 45 | vm.prank(governance); 46 | zai.revokeManagerRole(governance); 47 | 48 | zai.revokeManagerRole(governance); 49 | 50 | assertEq(zai.isManager(governance), false); 51 | assertEq(zai.isManager(address(this)), false); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/foundry/base/BasePsmTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {PegStabilityModule} from "../../../contracts/core/psm/PegStabilityModule.sol"; 17 | import "./BaseZaiTest.sol"; 18 | 19 | contract BasePsmTest is BaseZaiTest { 20 | PegStabilityModule internal psmUSDC; 21 | PegStabilityModule internal psmDAI; 22 | 23 | function _setUpPSM() internal { 24 | _setUpBase(); 25 | 26 | psmUSDC = new PegStabilityModule(); 27 | psmUSDC.initialize( 28 | address(zai), // address _zai, 29 | address(usdc), // address _collateral, 30 | governance, // address _governance, 31 | 1e6, // uint256 _newRate, 32 | 100_000 * 1e6, // uint256 _supplyCap, 33 | 100_000 * 1e18, // uint256 _debtCap 34 | 100, // supplyFeeBps 1% 35 | 100, // redeemFeeBps 1% 36 | feeDestination 37 | ); 38 | 39 | psmDAI = new PegStabilityModule(); 40 | psmDAI.initialize( 41 | address(zai), // address _zai, 42 | address(dai), // address _collateral, 43 | governance, // address _governance, 44 | 1e18, // uint256 _newRate, 45 | 100_000 * 1e18, // uint256 _supplyCap, 46 | 100_000 * 1e18, // uint256 _debtCap 47 | 100, // supplyFeeBps 1% 48 | 100, // redeemFeeBps 1% 49 | feeDestination 50 | ); 51 | 52 | // give permissions 53 | zai.grantManagerRole(address(psmUSDC)); 54 | zai.grantManagerRole(address(psmDAI)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test/foundry/base/BasePsmYieldTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {PegStabilityModuleYield} from "../../../contracts/core/psm/PegStabilityModuleYield.sol"; 17 | import {BaseUsdzTest} from "./BaseUsdzTest.sol"; 18 | 19 | contract BasePsmYieldTest is BaseUsdzTest { 20 | PegStabilityModuleYield internal psmUSDe; 21 | 22 | function _setUpPSMYield() internal { 23 | _setUpBase(); 24 | 25 | psmUSDe = new PegStabilityModuleYield(); 26 | 27 | psmUSDe.initialize( 28 | address(usdz), 29 | address(sUsdc), 30 | governance, 31 | 100_000 * 1e6, // supplyCap 32 | 100_000 * 1e18, // debtCap 33 | 100, // supplyFeeBps 34 | 100, // redeemFeeBps 35 | feeDistributor // DistributorContract Address 36 | ); 37 | 38 | usdz.grantManagerRole(address(psmUSDe)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/foundry/base/BaseUsdzTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ZaiStablecoin} from "../../../contracts/core/ZaiStablecoin.sol"; 17 | import {Test, console} from "../../../lib/forge-std/src/Test.sol"; 18 | 19 | import {IERC20, MockERC20} from "../../../contracts/mocks/MockERC20.sol"; 20 | import {ERC4626Mock} from "../../../contracts/mocks/MockERC4626.sol"; 21 | 22 | abstract contract BaseUsdzTest is Test { 23 | event Transfer(address indexed from, address indexed to, uint256 value); 24 | 25 | ZaiStablecoin public usdz; 26 | MockERC20 public usdc; 27 | ERC4626Mock public sUsdc; 28 | 29 | address governance = makeAddr("governance"); 30 | address feeDistributor = makeAddr("feeDistributor"); 31 | 32 | function _setUpBase() internal { 33 | usdz = new ZaiStablecoin(address(this)); 34 | usdc = new MockERC20("USD Coin", "USDC", 6); 35 | sUsdc = new ERC4626Mock(address(usdc)); 36 | 37 | vm.label(address(usdz), "usdz"); 38 | vm.label(address(usdc), "usdc"); 39 | vm.label(address(sUsdc), "sUsdc"); 40 | 41 | usdz.grantManagerRole(address(this)); 42 | usdz.grantManagerRole(governance); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/foundry/base/BaseZaiTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {ZaiStablecoin} from "../../../contracts/core/ZaiStablecoin.sol"; 17 | import {Test, console} from "../../../lib/forge-std/src/Test.sol"; 18 | 19 | import {IERC20, MockERC20} from "../../../contracts/mocks/MockERC20.sol"; 20 | 21 | abstract contract BaseZaiTest is Test { 22 | event Transfer(address indexed from, address indexed to, uint256 value); 23 | 24 | ZaiStablecoin public zai; 25 | 26 | MockERC20 public usdc; 27 | MockERC20 public maha; 28 | MockERC20 public dai; 29 | MockERC20 public weth; 30 | 31 | address governance = makeAddr("governance"); 32 | address shark = makeAddr("shark"); 33 | address whale = makeAddr("whale"); 34 | address ant = makeAddr("ant"); 35 | address feeDestination = makeAddr("feeDestination"); 36 | 37 | function _setUpBase() internal { 38 | zai = new ZaiStablecoin(address(this)); 39 | 40 | usdc = new MockERC20("USD Coin", "USDC", 6); 41 | dai = new MockERC20("DAI", "DAI", 18); 42 | maha = new MockERC20("MahaDAO", "MAHA", 18); 43 | weth = new MockERC20("Wrapped Ether", "WETH", 18); 44 | 45 | vm.label(address(zai), "zai"); 46 | vm.label(address(usdc), "usdc"); 47 | vm.label(address(dai), "dai"); 48 | vm.label(address(weth), "weth"); 49 | 50 | zai.grantManagerRole(address(this)); 51 | zai.grantManagerRole(governance); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/foundry/governance/LockerTokenTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "../base/BaseGovernanceTest.sol"; 17 | 18 | contract LockerTokenTest is BaseGovernanceTest { 19 | function setUp() public { 20 | _setupLockers(); 21 | } 22 | 23 | function test_setFeeCollector() public { 24 | // todo 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/foundry/governance/MigrateTokenLocks.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {MigrateTokenLocks} from "../../../contracts/governance/locker/MigrateTokenLocks.sol"; 17 | import "../base/BaseGovernanceTest.sol"; 18 | 19 | contract MigrateTokenLocksTest is BaseGovernanceTest { 20 | MigrateTokenLocks migrator; 21 | 22 | function setUp() public { 23 | _setupGovernance(); 24 | } 25 | 26 | function test_setFeeCollector() public { 27 | // todo 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/foundry/governance/OmnichainStakingTokenTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import "../base/BaseZaiTest.sol"; 17 | 18 | contract OmnichainStakingTokenTest is BaseZaiTest { 19 | function setUp() public { 20 | _setUpBase(); 21 | } 22 | 23 | function test_setFeeCollector() public { 24 | // todo 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/foundry/periphery/oracles/MorphoFixedPriceOracleTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | // ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ 4 | // ████╗ ████║██╔══██╗██║ ██║██╔══██╗ 5 | // ██╔████╔██║███████║███████║███████║ 6 | // ██║╚██╔╝██║██╔══██║██╔══██║██╔══██║ 7 | // ██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██║ 8 | // ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 9 | 10 | // Website: https://maha.xyz 11 | // Discord: https://discord.gg/mahadao 12 | // Twitter: https://twitter.com/mahaxyz_ 13 | 14 | pragma solidity 0.8.21; 15 | 16 | import {MorphoFixedPriceOracle} from "../../../../contracts/periphery/oracles/MorphoFixedPriceOracle.sol"; 17 | import { 18 | AggregatorV3Interface, 19 | IERC4626, 20 | MorphoChainlinkOracleV2 21 | } from "../../../../lib/morpho-blue-oracles/src/morpho-chainlink/MorphoChainlinkOracleV2.sol"; 22 | import {BaseZaiTest, IERC20, console} from "../../base/BaseZaiTest.sol"; 23 | 24 | contract MorphoFixedPriceOracleTest is BaseZaiTest { 25 | string BASE_RPC_URL = vm.envString("BASE_RPC_URL"); 26 | 27 | function setUp() public { 28 | uint256 baseFork = vm.createFork(BASE_RPC_URL); 29 | vm.selectFork(baseFork); 30 | vm.rollFork(19_141_574); 31 | } 32 | 33 | function test_oracle_lp() public { 34 | MorphoFixedPriceOracle oracle = new MorphoFixedPriceOracle(2e24, 18); 35 | 36 | assertApproxEqAbs(oracle.getPriceFor(29_999_999_999_998_000), 60_000 ether, 1e10, "!oracle.getPriceFor"); 37 | assertEq(oracle.price() / 1e36, 2_000_000, "!morphoOracle.price"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "outDir": "dist", 8 | "noImplicitAny": false, 9 | "resolveJsonModule": true 10 | }, 11 | "include": ["./types", "./scripts", "./deploy", "./tasks"], 12 | "files": [ 13 | "./hardhat.config.ts", 14 | "node_modules/@nomiclabs/hardhat-etherscan/src/type-extensions.ts", 15 | "node_modules/hardhat-gas-reporter/src/type-extensions.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /web3-functions/fees-distribute-mainnet/index.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/naming-convention */ 2 | import { 3 | Web3Function, 4 | Web3FunctionContext, 5 | } from "@gelatonetwork/web3-functions-sdk"; 6 | import { ethers } from "ethers"; 7 | import { Contract } from "ethers"; 8 | import { getGelatoCode } from "../../scripts/odos/helpers/path"; 9 | 10 | Web3Function.onRun(async (context: Web3FunctionContext) => { 11 | const { userArgs } = context; 12 | const { contractAddress, susdeAddress, zaiAddress } = userArgs as { 13 | contractAddress: string; 14 | susdeAddress: `0x${string}`; 15 | zaiAddress: `0x${string}`; 16 | }; 17 | 18 | const iface = new ethers.Interface([ 19 | "function balanceOf(address who) public view returns (uint256 bal)", 20 | "function execute(bytes memory data) public payable", 21 | ]); 22 | 23 | const runner = new ethers.JsonRpcProvider("https://rpc.ankr.com/eth"); 24 | const sUSDe = new Contract(susdeAddress, iface, runner); 25 | 26 | const bal = await sUSDe.balanceOf(contractAddress); 27 | 28 | try { 29 | const ret = await getGelatoCode( 30 | 1, 31 | zaiAddress, 32 | contractAddress, 33 | [bal], 34 | [susdeAddress] 35 | ); 36 | 37 | return { 38 | canExec: true, 39 | callData: [ 40 | { 41 | to: contractAddress, 42 | data: iface.encodeFunctionData("execute", [ret.data]), 43 | }, 44 | ], 45 | }; 46 | } catch (error: any) { 47 | const message = (error.message as string) || ""; 48 | return { 49 | canExec: false, 50 | message, 51 | }; 52 | } 53 | }); 54 | -------------------------------------------------------------------------------- /web3-functions/fees-distribute-mainnet/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "web3FunctionVersion": "2.0.0", 3 | "runtime": "js-1.0", 4 | "memory": 128, 5 | "timeout": 30, 6 | "userArgs": { 7 | "contractAddress": "string", 8 | "susdeAddress": "string", 9 | "zaiAddress": "string" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /web3-functions/fees-distribute-mainnet/userArgs.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractAddress": "0x37FC7BaF265E749927F8D0Dec95AeEF1007e8574", 3 | "susdeAddress": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497", 4 | "zaiAddress": "0x69000dFD5025E82f48Eb28325A2B88a241182CEd" 5 | } 6 | --------------------------------------------------------------------------------