From e93efb9226f3380b258947778f70fe7110bd2f0f Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Mon, 12 Apr 2021 16:18:42 +0530 Subject: [PATCH 1/3] Add polygon deposit and exit manager --- contracts/{ => mainnet}/common/basic.sol | 0 contracts/{ => mainnet}/common/interfaces.sol | 0 contracts/{ => mainnet}/common/math.sol | 0 contracts/{ => mainnet}/common/stores.sol | 0 .../{ => mainnet}/connectors/1inch/events.sol | 0 .../connectors/1inch/helpers.sol | 0 .../connectors/1inch/interface.sol | 0 .../{ => mainnet}/connectors/1inch/main.sol | 0 .../connectors/1proto/events.sol | 0 .../connectors/1proto/helpers.sol | 0 .../connectors/1proto/interface.sol | 0 .../{ => mainnet}/connectors/1proto/main.sol | 0 .../{ => mainnet}/connectors/COMP/events.sol | 0 .../{ => mainnet}/connectors/COMP/helpers.sol | 0 .../connectors/COMP/interface.sol | 0 .../{ => mainnet}/connectors/COMP/main.sol | 0 .../connectors/aave/v1/events.sol | 0 .../connectors/aave/v1/helpers.sol | 0 .../connectors/aave/v1/interface.sol | 0 .../{ => mainnet}/connectors/aave/v1/main.sol | 0 .../connectors/aave/v2/events.sol | 0 .../connectors/aave/v2/helpers.sol | 0 .../connectors/aave/v2/interface.sol | 0 .../{ => mainnet}/connectors/aave/v2/main.sol | 0 .../connectors/authority/events.sol | 0 .../connectors/authority/helpers.sol | 0 .../connectors/authority/interface.sol | 0 .../connectors/authority/main.sol | 0 .../{ => mainnet}/connectors/basic/events.sol | 0 .../{ => mainnet}/connectors/basic/main.sol | 0 .../{ => mainnet}/connectors/chi/events.sol | 0 .../{ => mainnet}/connectors/chi/helpers.sol | 0 .../connectors/chi/interface.sol | 0 .../{ => mainnet}/connectors/chi/main.sol | 0 .../connectors/compound/events.sol | 0 .../connectors/compound/helpers.sol | 0 .../connectors/compound/interface.sol | 0 .../connectors/compound/main.sol | 0 .../{ => mainnet}/connectors/dydx/events.sol | 0 .../{ => mainnet}/connectors/dydx/helpers.sol | 0 .../connectors/dydx/interface.sol | 0 .../{ => mainnet}/connectors/dydx/main.sol | 0 .../{ => mainnet}/connectors/fee/main.sol | 0 .../connectors/gelato/events.sol | 0 .../connectors/gelato/interface.sol | 0 .../{ => mainnet}/connectors/gelato/main.sol | 0 .../connectors/instapool/events.sol | 0 .../connectors/instapool/helpers.sol | 0 .../connectors/instapool/interface.sol | 0 .../connectors/instapool/main.sol | 0 .../{ => mainnet}/connectors/kyber/events.sol | 0 .../connectors/kyber/helpers.sol | 0 .../connectors/kyber/interface.sol | 0 .../{ => mainnet}/connectors/kyber/main.sol | 0 .../connectors/makerdao/events.sol | 0 .../connectors/makerdao/helpers.sol | 0 .../connectors/makerdao/interface.sol | 0 .../connectors/makerdao/main.sol | 0 .../{ => mainnet}/connectors/oasis/events.sol | 0 .../connectors/oasis/interface.sol | 0 .../{ => mainnet}/connectors/oasis/main.sol | 0 .../connectors/polygon-bridge/events.sol | 12 +++++ .../connectors/polygon-bridge/helpers.sol | 17 ++++++ .../connectors/polygon-bridge/interface.sol | 11 ++++ .../connectors/polygon-bridge/main.sol | 53 +++++++++++++++++++ .../connectors/reflexer/events.sol | 0 .../connectors/reflexer/helpers.sol | 0 .../connectors/reflexer/interface.sol | 0 .../connectors/reflexer/main.sol | 0 .../connectors/uniswap/events.sol | 0 .../connectors/uniswap/helpers.sol | 0 .../connectors/uniswap/interface.sol | 0 .../{ => mainnet}/connectors/uniswap/main.sol | 0 .../{ => mainnet}/connectors_old/1inch.sol | 0 .../{ => mainnet}/connectors_old/COMP.sol | 0 .../{ => mainnet}/connectors_old/aave.sol | 0 .../{ => mainnet}/connectors_old/aave_v2.sol | 0 .../connectors_old/authority.sol | 0 .../{ => mainnet}/connectors_old/basic.sol | 0 .../{ => mainnet}/connectors_old/chi.sol | 0 .../{ => mainnet}/connectors_old/compound.sol | 0 .../{ => mainnet}/connectors_old/cream.sol | 0 .../{ => mainnet}/connectors_old/curve.sol | 0 .../connectors_old/curve_3pool.sol | 0 .../connectors_old/curve_gauge.sol | 0 .../connectors_old/curve_vesting.sol | 0 .../connectors_old/curvesbtc.sol | 0 .../{ => mainnet}/connectors_old/curvey.sol | 0 .../{ => mainnet}/connectors_old/dydx.sol | 0 .../connectors_old/dydxFlash.sol | 0 .../{ => mainnet}/connectors_old/fee.sol | 0 .../{ => mainnet}/connectors_old/gelato.sol | 0 .../connectors_old/instapool.sol | 0 .../{ => mainnet}/connectors_old/kyber.sol | 0 .../{ => mainnet}/connectors_old/makerdao.sol | 0 .../{ => mainnet}/connectors_old/mock.sol | 0 .../{ => mainnet}/connectors_old/oasis.sol | 0 .../{ => mainnet}/connectors_old/staking.sol | 0 .../{ => mainnet}/connectors_old/swerve.sol | 0 .../{ => mainnet}/connectors_old/uniswap.sol | 0 contracts/{ => mainnet}/mapping/1inch.sol | 0 contracts/{ => mainnet}/mapping/compound.sol | 0 .../mapping/curve_gauge_mapping.sol | 0 .../{ => mainnet}/mapping/instapoolFee.sol | 0 contracts/{ => mainnet}/mapping/reflexer.sol | 0 contracts/{ => mainnet}/mapping/staking.sol | 0 contracts/{ => mainnet}/static/basic.sol | 0 contracts/{ => mainnet}/static/maker.sol | 0 108 files changed, 93 insertions(+) rename contracts/{ => mainnet}/common/basic.sol (100%) rename contracts/{ => mainnet}/common/interfaces.sol (100%) rename contracts/{ => mainnet}/common/math.sol (100%) rename contracts/{ => mainnet}/common/stores.sol (100%) rename contracts/{ => mainnet}/connectors/1inch/events.sol (100%) rename contracts/{ => mainnet}/connectors/1inch/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/1inch/interface.sol (100%) rename contracts/{ => mainnet}/connectors/1inch/main.sol (100%) rename contracts/{ => mainnet}/connectors/1proto/events.sol (100%) rename contracts/{ => mainnet}/connectors/1proto/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/1proto/interface.sol (100%) rename contracts/{ => mainnet}/connectors/1proto/main.sol (100%) rename contracts/{ => mainnet}/connectors/COMP/events.sol (100%) rename contracts/{ => mainnet}/connectors/COMP/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/COMP/interface.sol (100%) rename contracts/{ => mainnet}/connectors/COMP/main.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v1/events.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v1/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v1/interface.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v1/main.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v2/events.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v2/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v2/interface.sol (100%) rename contracts/{ => mainnet}/connectors/aave/v2/main.sol (100%) rename contracts/{ => mainnet}/connectors/authority/events.sol (100%) rename contracts/{ => mainnet}/connectors/authority/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/authority/interface.sol (100%) rename contracts/{ => mainnet}/connectors/authority/main.sol (100%) rename contracts/{ => mainnet}/connectors/basic/events.sol (100%) rename contracts/{ => mainnet}/connectors/basic/main.sol (100%) rename contracts/{ => mainnet}/connectors/chi/events.sol (100%) rename contracts/{ => mainnet}/connectors/chi/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/chi/interface.sol (100%) rename contracts/{ => mainnet}/connectors/chi/main.sol (100%) rename contracts/{ => mainnet}/connectors/compound/events.sol (100%) rename contracts/{ => mainnet}/connectors/compound/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/compound/interface.sol (100%) rename contracts/{ => mainnet}/connectors/compound/main.sol (100%) rename contracts/{ => mainnet}/connectors/dydx/events.sol (100%) rename contracts/{ => mainnet}/connectors/dydx/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/dydx/interface.sol (100%) rename contracts/{ => mainnet}/connectors/dydx/main.sol (100%) rename contracts/{ => mainnet}/connectors/fee/main.sol (100%) rename contracts/{ => mainnet}/connectors/gelato/events.sol (100%) rename contracts/{ => mainnet}/connectors/gelato/interface.sol (100%) rename contracts/{ => mainnet}/connectors/gelato/main.sol (100%) rename contracts/{ => mainnet}/connectors/instapool/events.sol (100%) rename contracts/{ => mainnet}/connectors/instapool/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/instapool/interface.sol (100%) rename contracts/{ => mainnet}/connectors/instapool/main.sol (100%) rename contracts/{ => mainnet}/connectors/kyber/events.sol (100%) rename contracts/{ => mainnet}/connectors/kyber/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/kyber/interface.sol (100%) rename contracts/{ => mainnet}/connectors/kyber/main.sol (100%) rename contracts/{ => mainnet}/connectors/makerdao/events.sol (100%) rename contracts/{ => mainnet}/connectors/makerdao/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/makerdao/interface.sol (100%) rename contracts/{ => mainnet}/connectors/makerdao/main.sol (100%) rename contracts/{ => mainnet}/connectors/oasis/events.sol (100%) rename contracts/{ => mainnet}/connectors/oasis/interface.sol (100%) rename contracts/{ => mainnet}/connectors/oasis/main.sol (100%) create mode 100644 contracts/mainnet/connectors/polygon-bridge/events.sol create mode 100644 contracts/mainnet/connectors/polygon-bridge/helpers.sol create mode 100644 contracts/mainnet/connectors/polygon-bridge/interface.sol create mode 100644 contracts/mainnet/connectors/polygon-bridge/main.sol rename contracts/{ => mainnet}/connectors/reflexer/events.sol (100%) rename contracts/{ => mainnet}/connectors/reflexer/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/reflexer/interface.sol (100%) rename contracts/{ => mainnet}/connectors/reflexer/main.sol (100%) rename contracts/{ => mainnet}/connectors/uniswap/events.sol (100%) rename contracts/{ => mainnet}/connectors/uniswap/helpers.sol (100%) rename contracts/{ => mainnet}/connectors/uniswap/interface.sol (100%) rename contracts/{ => mainnet}/connectors/uniswap/main.sol (100%) rename contracts/{ => mainnet}/connectors_old/1inch.sol (100%) rename contracts/{ => mainnet}/connectors_old/COMP.sol (100%) rename contracts/{ => mainnet}/connectors_old/aave.sol (100%) rename contracts/{ => mainnet}/connectors_old/aave_v2.sol (100%) rename contracts/{ => mainnet}/connectors_old/authority.sol (100%) rename contracts/{ => mainnet}/connectors_old/basic.sol (100%) rename contracts/{ => mainnet}/connectors_old/chi.sol (100%) rename contracts/{ => mainnet}/connectors_old/compound.sol (100%) rename contracts/{ => mainnet}/connectors_old/cream.sol (100%) rename contracts/{ => mainnet}/connectors_old/curve.sol (100%) rename contracts/{ => mainnet}/connectors_old/curve_3pool.sol (100%) rename contracts/{ => mainnet}/connectors_old/curve_gauge.sol (100%) rename contracts/{ => mainnet}/connectors_old/curve_vesting.sol (100%) rename contracts/{ => mainnet}/connectors_old/curvesbtc.sol (100%) rename contracts/{ => mainnet}/connectors_old/curvey.sol (100%) rename contracts/{ => mainnet}/connectors_old/dydx.sol (100%) rename contracts/{ => mainnet}/connectors_old/dydxFlash.sol (100%) rename contracts/{ => mainnet}/connectors_old/fee.sol (100%) rename contracts/{ => mainnet}/connectors_old/gelato.sol (100%) rename contracts/{ => mainnet}/connectors_old/instapool.sol (100%) rename contracts/{ => mainnet}/connectors_old/kyber.sol (100%) rename contracts/{ => mainnet}/connectors_old/makerdao.sol (100%) rename contracts/{ => mainnet}/connectors_old/mock.sol (100%) rename contracts/{ => mainnet}/connectors_old/oasis.sol (100%) rename contracts/{ => mainnet}/connectors_old/staking.sol (100%) rename contracts/{ => mainnet}/connectors_old/swerve.sol (100%) rename contracts/{ => mainnet}/connectors_old/uniswap.sol (100%) rename contracts/{ => mainnet}/mapping/1inch.sol (100%) rename contracts/{ => mainnet}/mapping/compound.sol (100%) rename contracts/{ => mainnet}/mapping/curve_gauge_mapping.sol (100%) rename contracts/{ => mainnet}/mapping/instapoolFee.sol (100%) rename contracts/{ => mainnet}/mapping/reflexer.sol (100%) rename contracts/{ => mainnet}/mapping/staking.sol (100%) rename contracts/{ => mainnet}/static/basic.sol (100%) rename contracts/{ => mainnet}/static/maker.sol (100%) diff --git a/contracts/common/basic.sol b/contracts/mainnet/common/basic.sol similarity index 100% rename from contracts/common/basic.sol rename to contracts/mainnet/common/basic.sol diff --git a/contracts/common/interfaces.sol b/contracts/mainnet/common/interfaces.sol similarity index 100% rename from contracts/common/interfaces.sol rename to contracts/mainnet/common/interfaces.sol diff --git a/contracts/common/math.sol b/contracts/mainnet/common/math.sol similarity index 100% rename from contracts/common/math.sol rename to contracts/mainnet/common/math.sol diff --git a/contracts/common/stores.sol b/contracts/mainnet/common/stores.sol similarity index 100% rename from contracts/common/stores.sol rename to contracts/mainnet/common/stores.sol diff --git a/contracts/connectors/1inch/events.sol b/contracts/mainnet/connectors/1inch/events.sol similarity index 100% rename from contracts/connectors/1inch/events.sol rename to contracts/mainnet/connectors/1inch/events.sol diff --git a/contracts/connectors/1inch/helpers.sol b/contracts/mainnet/connectors/1inch/helpers.sol similarity index 100% rename from contracts/connectors/1inch/helpers.sol rename to contracts/mainnet/connectors/1inch/helpers.sol diff --git a/contracts/connectors/1inch/interface.sol b/contracts/mainnet/connectors/1inch/interface.sol similarity index 100% rename from contracts/connectors/1inch/interface.sol rename to contracts/mainnet/connectors/1inch/interface.sol diff --git a/contracts/connectors/1inch/main.sol b/contracts/mainnet/connectors/1inch/main.sol similarity index 100% rename from contracts/connectors/1inch/main.sol rename to contracts/mainnet/connectors/1inch/main.sol diff --git a/contracts/connectors/1proto/events.sol b/contracts/mainnet/connectors/1proto/events.sol similarity index 100% rename from contracts/connectors/1proto/events.sol rename to contracts/mainnet/connectors/1proto/events.sol diff --git a/contracts/connectors/1proto/helpers.sol b/contracts/mainnet/connectors/1proto/helpers.sol similarity index 100% rename from contracts/connectors/1proto/helpers.sol rename to contracts/mainnet/connectors/1proto/helpers.sol diff --git a/contracts/connectors/1proto/interface.sol b/contracts/mainnet/connectors/1proto/interface.sol similarity index 100% rename from contracts/connectors/1proto/interface.sol rename to contracts/mainnet/connectors/1proto/interface.sol diff --git a/contracts/connectors/1proto/main.sol b/contracts/mainnet/connectors/1proto/main.sol similarity index 100% rename from contracts/connectors/1proto/main.sol rename to contracts/mainnet/connectors/1proto/main.sol diff --git a/contracts/connectors/COMP/events.sol b/contracts/mainnet/connectors/COMP/events.sol similarity index 100% rename from contracts/connectors/COMP/events.sol rename to contracts/mainnet/connectors/COMP/events.sol diff --git a/contracts/connectors/COMP/helpers.sol b/contracts/mainnet/connectors/COMP/helpers.sol similarity index 100% rename from contracts/connectors/COMP/helpers.sol rename to contracts/mainnet/connectors/COMP/helpers.sol diff --git a/contracts/connectors/COMP/interface.sol b/contracts/mainnet/connectors/COMP/interface.sol similarity index 100% rename from contracts/connectors/COMP/interface.sol rename to contracts/mainnet/connectors/COMP/interface.sol diff --git a/contracts/connectors/COMP/main.sol b/contracts/mainnet/connectors/COMP/main.sol similarity index 100% rename from contracts/connectors/COMP/main.sol rename to contracts/mainnet/connectors/COMP/main.sol diff --git a/contracts/connectors/aave/v1/events.sol b/contracts/mainnet/connectors/aave/v1/events.sol similarity index 100% rename from contracts/connectors/aave/v1/events.sol rename to contracts/mainnet/connectors/aave/v1/events.sol diff --git a/contracts/connectors/aave/v1/helpers.sol b/contracts/mainnet/connectors/aave/v1/helpers.sol similarity index 100% rename from contracts/connectors/aave/v1/helpers.sol rename to contracts/mainnet/connectors/aave/v1/helpers.sol diff --git a/contracts/connectors/aave/v1/interface.sol b/contracts/mainnet/connectors/aave/v1/interface.sol similarity index 100% rename from contracts/connectors/aave/v1/interface.sol rename to contracts/mainnet/connectors/aave/v1/interface.sol diff --git a/contracts/connectors/aave/v1/main.sol b/contracts/mainnet/connectors/aave/v1/main.sol similarity index 100% rename from contracts/connectors/aave/v1/main.sol rename to contracts/mainnet/connectors/aave/v1/main.sol diff --git a/contracts/connectors/aave/v2/events.sol b/contracts/mainnet/connectors/aave/v2/events.sol similarity index 100% rename from contracts/connectors/aave/v2/events.sol rename to contracts/mainnet/connectors/aave/v2/events.sol diff --git a/contracts/connectors/aave/v2/helpers.sol b/contracts/mainnet/connectors/aave/v2/helpers.sol similarity index 100% rename from contracts/connectors/aave/v2/helpers.sol rename to contracts/mainnet/connectors/aave/v2/helpers.sol diff --git a/contracts/connectors/aave/v2/interface.sol b/contracts/mainnet/connectors/aave/v2/interface.sol similarity index 100% rename from contracts/connectors/aave/v2/interface.sol rename to contracts/mainnet/connectors/aave/v2/interface.sol diff --git a/contracts/connectors/aave/v2/main.sol b/contracts/mainnet/connectors/aave/v2/main.sol similarity index 100% rename from contracts/connectors/aave/v2/main.sol rename to contracts/mainnet/connectors/aave/v2/main.sol diff --git a/contracts/connectors/authority/events.sol b/contracts/mainnet/connectors/authority/events.sol similarity index 100% rename from contracts/connectors/authority/events.sol rename to contracts/mainnet/connectors/authority/events.sol diff --git a/contracts/connectors/authority/helpers.sol b/contracts/mainnet/connectors/authority/helpers.sol similarity index 100% rename from contracts/connectors/authority/helpers.sol rename to contracts/mainnet/connectors/authority/helpers.sol diff --git a/contracts/connectors/authority/interface.sol b/contracts/mainnet/connectors/authority/interface.sol similarity index 100% rename from contracts/connectors/authority/interface.sol rename to contracts/mainnet/connectors/authority/interface.sol diff --git a/contracts/connectors/authority/main.sol b/contracts/mainnet/connectors/authority/main.sol similarity index 100% rename from contracts/connectors/authority/main.sol rename to contracts/mainnet/connectors/authority/main.sol diff --git a/contracts/connectors/basic/events.sol b/contracts/mainnet/connectors/basic/events.sol similarity index 100% rename from contracts/connectors/basic/events.sol rename to contracts/mainnet/connectors/basic/events.sol diff --git a/contracts/connectors/basic/main.sol b/contracts/mainnet/connectors/basic/main.sol similarity index 100% rename from contracts/connectors/basic/main.sol rename to contracts/mainnet/connectors/basic/main.sol diff --git a/contracts/connectors/chi/events.sol b/contracts/mainnet/connectors/chi/events.sol similarity index 100% rename from contracts/connectors/chi/events.sol rename to contracts/mainnet/connectors/chi/events.sol diff --git a/contracts/connectors/chi/helpers.sol b/contracts/mainnet/connectors/chi/helpers.sol similarity index 100% rename from contracts/connectors/chi/helpers.sol rename to contracts/mainnet/connectors/chi/helpers.sol diff --git a/contracts/connectors/chi/interface.sol b/contracts/mainnet/connectors/chi/interface.sol similarity index 100% rename from contracts/connectors/chi/interface.sol rename to contracts/mainnet/connectors/chi/interface.sol diff --git a/contracts/connectors/chi/main.sol b/contracts/mainnet/connectors/chi/main.sol similarity index 100% rename from contracts/connectors/chi/main.sol rename to contracts/mainnet/connectors/chi/main.sol diff --git a/contracts/connectors/compound/events.sol b/contracts/mainnet/connectors/compound/events.sol similarity index 100% rename from contracts/connectors/compound/events.sol rename to contracts/mainnet/connectors/compound/events.sol diff --git a/contracts/connectors/compound/helpers.sol b/contracts/mainnet/connectors/compound/helpers.sol similarity index 100% rename from contracts/connectors/compound/helpers.sol rename to contracts/mainnet/connectors/compound/helpers.sol diff --git a/contracts/connectors/compound/interface.sol b/contracts/mainnet/connectors/compound/interface.sol similarity index 100% rename from contracts/connectors/compound/interface.sol rename to contracts/mainnet/connectors/compound/interface.sol diff --git a/contracts/connectors/compound/main.sol b/contracts/mainnet/connectors/compound/main.sol similarity index 100% rename from contracts/connectors/compound/main.sol rename to contracts/mainnet/connectors/compound/main.sol diff --git a/contracts/connectors/dydx/events.sol b/contracts/mainnet/connectors/dydx/events.sol similarity index 100% rename from contracts/connectors/dydx/events.sol rename to contracts/mainnet/connectors/dydx/events.sol diff --git a/contracts/connectors/dydx/helpers.sol b/contracts/mainnet/connectors/dydx/helpers.sol similarity index 100% rename from contracts/connectors/dydx/helpers.sol rename to contracts/mainnet/connectors/dydx/helpers.sol diff --git a/contracts/connectors/dydx/interface.sol b/contracts/mainnet/connectors/dydx/interface.sol similarity index 100% rename from contracts/connectors/dydx/interface.sol rename to contracts/mainnet/connectors/dydx/interface.sol diff --git a/contracts/connectors/dydx/main.sol b/contracts/mainnet/connectors/dydx/main.sol similarity index 100% rename from contracts/connectors/dydx/main.sol rename to contracts/mainnet/connectors/dydx/main.sol diff --git a/contracts/connectors/fee/main.sol b/contracts/mainnet/connectors/fee/main.sol similarity index 100% rename from contracts/connectors/fee/main.sol rename to contracts/mainnet/connectors/fee/main.sol diff --git a/contracts/connectors/gelato/events.sol b/contracts/mainnet/connectors/gelato/events.sol similarity index 100% rename from contracts/connectors/gelato/events.sol rename to contracts/mainnet/connectors/gelato/events.sol diff --git a/contracts/connectors/gelato/interface.sol b/contracts/mainnet/connectors/gelato/interface.sol similarity index 100% rename from contracts/connectors/gelato/interface.sol rename to contracts/mainnet/connectors/gelato/interface.sol diff --git a/contracts/connectors/gelato/main.sol b/contracts/mainnet/connectors/gelato/main.sol similarity index 100% rename from contracts/connectors/gelato/main.sol rename to contracts/mainnet/connectors/gelato/main.sol diff --git a/contracts/connectors/instapool/events.sol b/contracts/mainnet/connectors/instapool/events.sol similarity index 100% rename from contracts/connectors/instapool/events.sol rename to contracts/mainnet/connectors/instapool/events.sol diff --git a/contracts/connectors/instapool/helpers.sol b/contracts/mainnet/connectors/instapool/helpers.sol similarity index 100% rename from contracts/connectors/instapool/helpers.sol rename to contracts/mainnet/connectors/instapool/helpers.sol diff --git a/contracts/connectors/instapool/interface.sol b/contracts/mainnet/connectors/instapool/interface.sol similarity index 100% rename from contracts/connectors/instapool/interface.sol rename to contracts/mainnet/connectors/instapool/interface.sol diff --git a/contracts/connectors/instapool/main.sol b/contracts/mainnet/connectors/instapool/main.sol similarity index 100% rename from contracts/connectors/instapool/main.sol rename to contracts/mainnet/connectors/instapool/main.sol diff --git a/contracts/connectors/kyber/events.sol b/contracts/mainnet/connectors/kyber/events.sol similarity index 100% rename from contracts/connectors/kyber/events.sol rename to contracts/mainnet/connectors/kyber/events.sol diff --git a/contracts/connectors/kyber/helpers.sol b/contracts/mainnet/connectors/kyber/helpers.sol similarity index 100% rename from contracts/connectors/kyber/helpers.sol rename to contracts/mainnet/connectors/kyber/helpers.sol diff --git a/contracts/connectors/kyber/interface.sol b/contracts/mainnet/connectors/kyber/interface.sol similarity index 100% rename from contracts/connectors/kyber/interface.sol rename to contracts/mainnet/connectors/kyber/interface.sol diff --git a/contracts/connectors/kyber/main.sol b/contracts/mainnet/connectors/kyber/main.sol similarity index 100% rename from contracts/connectors/kyber/main.sol rename to contracts/mainnet/connectors/kyber/main.sol diff --git a/contracts/connectors/makerdao/events.sol b/contracts/mainnet/connectors/makerdao/events.sol similarity index 100% rename from contracts/connectors/makerdao/events.sol rename to contracts/mainnet/connectors/makerdao/events.sol diff --git a/contracts/connectors/makerdao/helpers.sol b/contracts/mainnet/connectors/makerdao/helpers.sol similarity index 100% rename from contracts/connectors/makerdao/helpers.sol rename to contracts/mainnet/connectors/makerdao/helpers.sol diff --git a/contracts/connectors/makerdao/interface.sol b/contracts/mainnet/connectors/makerdao/interface.sol similarity index 100% rename from contracts/connectors/makerdao/interface.sol rename to contracts/mainnet/connectors/makerdao/interface.sol diff --git a/contracts/connectors/makerdao/main.sol b/contracts/mainnet/connectors/makerdao/main.sol similarity index 100% rename from contracts/connectors/makerdao/main.sol rename to contracts/mainnet/connectors/makerdao/main.sol diff --git a/contracts/connectors/oasis/events.sol b/contracts/mainnet/connectors/oasis/events.sol similarity index 100% rename from contracts/connectors/oasis/events.sol rename to contracts/mainnet/connectors/oasis/events.sol diff --git a/contracts/connectors/oasis/interface.sol b/contracts/mainnet/connectors/oasis/interface.sol similarity index 100% rename from contracts/connectors/oasis/interface.sol rename to contracts/mainnet/connectors/oasis/interface.sol diff --git a/contracts/connectors/oasis/main.sol b/contracts/mainnet/connectors/oasis/main.sol similarity index 100% rename from contracts/connectors/oasis/main.sol rename to contracts/mainnet/connectors/oasis/main.sol diff --git a/contracts/mainnet/connectors/polygon-bridge/events.sol b/contracts/mainnet/connectors/polygon-bridge/events.sol new file mode 100644 index 00000000..e0b1b46e --- /dev/null +++ b/contracts/mainnet/connectors/polygon-bridge/events.sol @@ -0,0 +1,12 @@ +pragma solidity ^0.7.0; + +contract Events { + event LogDeposit( + address targetDsa, + address token, + uint256 amt, + uint256 getId, + uint256 setId + ); + event LogWithdraw(bytes proof); +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/polygon-bridge/helpers.sol b/contracts/mainnet/connectors/polygon-bridge/helpers.sol new file mode 100644 index 00000000..82cd0f9b --- /dev/null +++ b/contracts/mainnet/connectors/polygon-bridge/helpers.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.7.0; + +import { DSMath } from "../../common/math.sol"; +import { Basic } from "../../common/basic.sol"; +import { RootChainManagerInterface } from "./interface.sol"; + +abstract contract Helpers is DSMath, Basic { + /** + * Polygon POS Bridge ERC20 Predicate + */ + address internal constant erc20Predicate = 0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf; + + /** + * Polygon POS Bridge Manager + */ + RootChainManagerInterface internal constant migrator = RootChainManagerInterface(0xA0c68C638235ee32657e8f720a23ceC1bFc77C77); +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/polygon-bridge/interface.sol b/contracts/mainnet/connectors/polygon-bridge/interface.sol new file mode 100644 index 00000000..6043e9a7 --- /dev/null +++ b/contracts/mainnet/connectors/polygon-bridge/interface.sol @@ -0,0 +1,11 @@ +pragma solidity ^0.7.0; + +interface RootChainManagerInterface { + function depositEtherFor(address user) external payable; + function depositFor( + address user, + address rootToken, + bytes calldata depositData + ) external; + function exit(bytes calldata inputData) external; +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/polygon-bridge/main.sol b/contracts/mainnet/connectors/polygon-bridge/main.sol new file mode 100644 index 00000000..a188be8d --- /dev/null +++ b/contracts/mainnet/connectors/polygon-bridge/main.sol @@ -0,0 +1,53 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "../../common/interfaces.sol"; +import { Stores } from "../../common/stores.sol"; +import { Helpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract PolygonBridgeResolver is Events, Helpers { + function deposit( + address targetDsa, + address token, + uint256 amt, + uint256 getId, + uint256 setId + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + uint _amt = getUint(getId, amt); + + if (token == ethAddr) { + _amt = _amt == uint(-1) ? address(this).balance : _amt; + migrator.depositEtherFor{value: _amt}(targetDsa); + } else { + TokenInterface _token = TokenInterface(token); + _amt = _amt == uint(-1) ? _token.balanceOf(address(this)) : _amt; + _token.approve(erc20Predicate, _amt); + migrator.depositFor(targetDsa, token, abi.encode(_amt)); + } + + setUint(setId, _amt); + + _eventName = "LogDeposit(address,address,uint256,uint256,uint256)"; + _eventParam = abi.encode(targetDsa, token, _amt, getId, setId); + } + + /** + * @dev Withdraw assets from Polygon. + * @notice Complete withdraw by submitting burn tx hash. + * @param proof The proof generated from burn tx. + */ + function withdraw( + bytes calldata proof + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + require(proof.length > 0, "invalid-proof"); + + migrator.exit(proof); + + _eventName = "LogWithdraw(bytes)"; + _eventParam = abi.encode(proof); + } +} + +contract ConnectPolygonBridge is PolygonBridgeResolver { + string public constant name = "COMP-v1"; +} \ No newline at end of file diff --git a/contracts/connectors/reflexer/events.sol b/contracts/mainnet/connectors/reflexer/events.sol similarity index 100% rename from contracts/connectors/reflexer/events.sol rename to contracts/mainnet/connectors/reflexer/events.sol diff --git a/contracts/connectors/reflexer/helpers.sol b/contracts/mainnet/connectors/reflexer/helpers.sol similarity index 100% rename from contracts/connectors/reflexer/helpers.sol rename to contracts/mainnet/connectors/reflexer/helpers.sol diff --git a/contracts/connectors/reflexer/interface.sol b/contracts/mainnet/connectors/reflexer/interface.sol similarity index 100% rename from contracts/connectors/reflexer/interface.sol rename to contracts/mainnet/connectors/reflexer/interface.sol diff --git a/contracts/connectors/reflexer/main.sol b/contracts/mainnet/connectors/reflexer/main.sol similarity index 100% rename from contracts/connectors/reflexer/main.sol rename to contracts/mainnet/connectors/reflexer/main.sol diff --git a/contracts/connectors/uniswap/events.sol b/contracts/mainnet/connectors/uniswap/events.sol similarity index 100% rename from contracts/connectors/uniswap/events.sol rename to contracts/mainnet/connectors/uniswap/events.sol diff --git a/contracts/connectors/uniswap/helpers.sol b/contracts/mainnet/connectors/uniswap/helpers.sol similarity index 100% rename from contracts/connectors/uniswap/helpers.sol rename to contracts/mainnet/connectors/uniswap/helpers.sol diff --git a/contracts/connectors/uniswap/interface.sol b/contracts/mainnet/connectors/uniswap/interface.sol similarity index 100% rename from contracts/connectors/uniswap/interface.sol rename to contracts/mainnet/connectors/uniswap/interface.sol diff --git a/contracts/connectors/uniswap/main.sol b/contracts/mainnet/connectors/uniswap/main.sol similarity index 100% rename from contracts/connectors/uniswap/main.sol rename to contracts/mainnet/connectors/uniswap/main.sol diff --git a/contracts/connectors_old/1inch.sol b/contracts/mainnet/connectors_old/1inch.sol similarity index 100% rename from contracts/connectors_old/1inch.sol rename to contracts/mainnet/connectors_old/1inch.sol diff --git a/contracts/connectors_old/COMP.sol b/contracts/mainnet/connectors_old/COMP.sol similarity index 100% rename from contracts/connectors_old/COMP.sol rename to contracts/mainnet/connectors_old/COMP.sol diff --git a/contracts/connectors_old/aave.sol b/contracts/mainnet/connectors_old/aave.sol similarity index 100% rename from contracts/connectors_old/aave.sol rename to contracts/mainnet/connectors_old/aave.sol diff --git a/contracts/connectors_old/aave_v2.sol b/contracts/mainnet/connectors_old/aave_v2.sol similarity index 100% rename from contracts/connectors_old/aave_v2.sol rename to contracts/mainnet/connectors_old/aave_v2.sol diff --git a/contracts/connectors_old/authority.sol b/contracts/mainnet/connectors_old/authority.sol similarity index 100% rename from contracts/connectors_old/authority.sol rename to contracts/mainnet/connectors_old/authority.sol diff --git a/contracts/connectors_old/basic.sol b/contracts/mainnet/connectors_old/basic.sol similarity index 100% rename from contracts/connectors_old/basic.sol rename to contracts/mainnet/connectors_old/basic.sol diff --git a/contracts/connectors_old/chi.sol b/contracts/mainnet/connectors_old/chi.sol similarity index 100% rename from contracts/connectors_old/chi.sol rename to contracts/mainnet/connectors_old/chi.sol diff --git a/contracts/connectors_old/compound.sol b/contracts/mainnet/connectors_old/compound.sol similarity index 100% rename from contracts/connectors_old/compound.sol rename to contracts/mainnet/connectors_old/compound.sol diff --git a/contracts/connectors_old/cream.sol b/contracts/mainnet/connectors_old/cream.sol similarity index 100% rename from contracts/connectors_old/cream.sol rename to contracts/mainnet/connectors_old/cream.sol diff --git a/contracts/connectors_old/curve.sol b/contracts/mainnet/connectors_old/curve.sol similarity index 100% rename from contracts/connectors_old/curve.sol rename to contracts/mainnet/connectors_old/curve.sol diff --git a/contracts/connectors_old/curve_3pool.sol b/contracts/mainnet/connectors_old/curve_3pool.sol similarity index 100% rename from contracts/connectors_old/curve_3pool.sol rename to contracts/mainnet/connectors_old/curve_3pool.sol diff --git a/contracts/connectors_old/curve_gauge.sol b/contracts/mainnet/connectors_old/curve_gauge.sol similarity index 100% rename from contracts/connectors_old/curve_gauge.sol rename to contracts/mainnet/connectors_old/curve_gauge.sol diff --git a/contracts/connectors_old/curve_vesting.sol b/contracts/mainnet/connectors_old/curve_vesting.sol similarity index 100% rename from contracts/connectors_old/curve_vesting.sol rename to contracts/mainnet/connectors_old/curve_vesting.sol diff --git a/contracts/connectors_old/curvesbtc.sol b/contracts/mainnet/connectors_old/curvesbtc.sol similarity index 100% rename from contracts/connectors_old/curvesbtc.sol rename to contracts/mainnet/connectors_old/curvesbtc.sol diff --git a/contracts/connectors_old/curvey.sol b/contracts/mainnet/connectors_old/curvey.sol similarity index 100% rename from contracts/connectors_old/curvey.sol rename to contracts/mainnet/connectors_old/curvey.sol diff --git a/contracts/connectors_old/dydx.sol b/contracts/mainnet/connectors_old/dydx.sol similarity index 100% rename from contracts/connectors_old/dydx.sol rename to contracts/mainnet/connectors_old/dydx.sol diff --git a/contracts/connectors_old/dydxFlash.sol b/contracts/mainnet/connectors_old/dydxFlash.sol similarity index 100% rename from contracts/connectors_old/dydxFlash.sol rename to contracts/mainnet/connectors_old/dydxFlash.sol diff --git a/contracts/connectors_old/fee.sol b/contracts/mainnet/connectors_old/fee.sol similarity index 100% rename from contracts/connectors_old/fee.sol rename to contracts/mainnet/connectors_old/fee.sol diff --git a/contracts/connectors_old/gelato.sol b/contracts/mainnet/connectors_old/gelato.sol similarity index 100% rename from contracts/connectors_old/gelato.sol rename to contracts/mainnet/connectors_old/gelato.sol diff --git a/contracts/connectors_old/instapool.sol b/contracts/mainnet/connectors_old/instapool.sol similarity index 100% rename from contracts/connectors_old/instapool.sol rename to contracts/mainnet/connectors_old/instapool.sol diff --git a/contracts/connectors_old/kyber.sol b/contracts/mainnet/connectors_old/kyber.sol similarity index 100% rename from contracts/connectors_old/kyber.sol rename to contracts/mainnet/connectors_old/kyber.sol diff --git a/contracts/connectors_old/makerdao.sol b/contracts/mainnet/connectors_old/makerdao.sol similarity index 100% rename from contracts/connectors_old/makerdao.sol rename to contracts/mainnet/connectors_old/makerdao.sol diff --git a/contracts/connectors_old/mock.sol b/contracts/mainnet/connectors_old/mock.sol similarity index 100% rename from contracts/connectors_old/mock.sol rename to contracts/mainnet/connectors_old/mock.sol diff --git a/contracts/connectors_old/oasis.sol b/contracts/mainnet/connectors_old/oasis.sol similarity index 100% rename from contracts/connectors_old/oasis.sol rename to contracts/mainnet/connectors_old/oasis.sol diff --git a/contracts/connectors_old/staking.sol b/contracts/mainnet/connectors_old/staking.sol similarity index 100% rename from contracts/connectors_old/staking.sol rename to contracts/mainnet/connectors_old/staking.sol diff --git a/contracts/connectors_old/swerve.sol b/contracts/mainnet/connectors_old/swerve.sol similarity index 100% rename from contracts/connectors_old/swerve.sol rename to contracts/mainnet/connectors_old/swerve.sol diff --git a/contracts/connectors_old/uniswap.sol b/contracts/mainnet/connectors_old/uniswap.sol similarity index 100% rename from contracts/connectors_old/uniswap.sol rename to contracts/mainnet/connectors_old/uniswap.sol diff --git a/contracts/mapping/1inch.sol b/contracts/mainnet/mapping/1inch.sol similarity index 100% rename from contracts/mapping/1inch.sol rename to contracts/mainnet/mapping/1inch.sol diff --git a/contracts/mapping/compound.sol b/contracts/mainnet/mapping/compound.sol similarity index 100% rename from contracts/mapping/compound.sol rename to contracts/mainnet/mapping/compound.sol diff --git a/contracts/mapping/curve_gauge_mapping.sol b/contracts/mainnet/mapping/curve_gauge_mapping.sol similarity index 100% rename from contracts/mapping/curve_gauge_mapping.sol rename to contracts/mainnet/mapping/curve_gauge_mapping.sol diff --git a/contracts/mapping/instapoolFee.sol b/contracts/mainnet/mapping/instapoolFee.sol similarity index 100% rename from contracts/mapping/instapoolFee.sol rename to contracts/mainnet/mapping/instapoolFee.sol diff --git a/contracts/mapping/reflexer.sol b/contracts/mainnet/mapping/reflexer.sol similarity index 100% rename from contracts/mapping/reflexer.sol rename to contracts/mainnet/mapping/reflexer.sol diff --git a/contracts/mapping/staking.sol b/contracts/mainnet/mapping/staking.sol similarity index 100% rename from contracts/mapping/staking.sol rename to contracts/mainnet/mapping/staking.sol diff --git a/contracts/static/basic.sol b/contracts/mainnet/static/basic.sol similarity index 100% rename from contracts/static/basic.sol rename to contracts/mainnet/static/basic.sol diff --git a/contracts/static/maker.sol b/contracts/mainnet/static/maker.sol similarity index 100% rename from contracts/static/maker.sol rename to contracts/mainnet/static/maker.sol From 1d55aa7615df24823873be8f320bab782469ac71 Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Mon, 12 Apr 2021 16:42:03 +0530 Subject: [PATCH 2/3] Add polygon -> mainnet withdraw contracts --- .../connectors/polygon-bridge/main.sol | 9 ++++ contracts/polygon/common/basic.sol | 45 +++++++++++++++++ contracts/polygon/common/interfaces.sol | 27 ++++++++++ contracts/polygon/common/math.sol | 50 +++++++++++++++++++ contracts/polygon/common/stores.sol | 37 ++++++++++++++ .../connectors/mainnet-bridge/events.sol | 10 ++++ .../connectors/mainnet-bridge/main.sol | 41 +++++++++++++++ 7 files changed, 219 insertions(+) create mode 100644 contracts/polygon/common/basic.sol create mode 100644 contracts/polygon/common/interfaces.sol create mode 100644 contracts/polygon/common/math.sol create mode 100644 contracts/polygon/common/stores.sol create mode 100644 contracts/polygon/connectors/mainnet-bridge/events.sol create mode 100644 contracts/polygon/connectors/mainnet-bridge/main.sol diff --git a/contracts/mainnet/connectors/polygon-bridge/main.sol b/contracts/mainnet/connectors/polygon-bridge/main.sol index a188be8d..2acb29e0 100644 --- a/contracts/mainnet/connectors/polygon-bridge/main.sol +++ b/contracts/mainnet/connectors/polygon-bridge/main.sol @@ -6,6 +6,15 @@ import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; abstract contract PolygonBridgeResolver is Events, Helpers { + /** + * @dev Deposit assets to the bridge. + * @notice Deposit assets to the bridge. + * @param targetDsa The address to receive the token on Polygon + * @param token The address of the token to deposit. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) + * @param amt The amount of tokens to deposit. (For max: `uint256(-1)`) + * @param getId ID to retrieve amt. + * @param setId ID stores the amount of tokens deposit. + */ function deposit( address targetDsa, address token, diff --git a/contracts/polygon/common/basic.sol b/contracts/polygon/common/basic.sol new file mode 100644 index 00000000..fea2b1ec --- /dev/null +++ b/contracts/polygon/common/basic.sol @@ -0,0 +1,45 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "./interfaces.sol"; +import { Stores } from "./stores.sol"; +import { DSMath } from "./math.sol"; + +abstract contract Basic is DSMath, Stores { + + function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) { + amt = (_amt / 10 ** (18 - _dec)); + } + + function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) { + amt = mul(_amt, 10 ** (18 - _dec)); + } + + function getTokenBal(TokenInterface token) internal view returns(uint _amt) { + _amt = address(token) == maticAddr ? address(this).balance : token.balanceOf(address(this)); + } + + function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) { + buyDec = address(buyAddr) == maticAddr ? 18 : buyAddr.decimals(); + sellDec = address(sellAddr) == maticAddr ? 18 : sellAddr.decimals(); + } + + function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) { + return abi.encode(eventName, eventParam); + } + + function changeMaticAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){ + _buy = buy == maticAddr ? TokenInterface(wmaticAddr) : TokenInterface(buy); + _sell = sell == maticAddr ? TokenInterface(wmaticAddr) : TokenInterface(sell); + } + + function convertMaticToWmatic(bool isMatic, TokenInterface token, uint amount) internal { + if(isMatic) token.deposit{value: amount}(); + } + + function convertWmaticToMatic(bool isMatic, TokenInterface token, uint amount) internal { + if(isMatic) { + token.approve(address(token), amount); + token.withdraw(amount); + } + } +} diff --git a/contracts/polygon/common/interfaces.sol b/contracts/polygon/common/interfaces.sol new file mode 100644 index 00000000..24a4eb47 --- /dev/null +++ b/contracts/polygon/common/interfaces.sol @@ -0,0 +1,27 @@ +pragma solidity ^0.7.0; + +interface TokenInterface { + function approve(address, uint256) external; + function transfer(address, uint) external; + function transferFrom(address, address, uint) external; + function deposit() external payable; + function withdraw(uint) external; + function balanceOf(address) external view returns (uint); + function decimals() external view returns (uint); +} + +interface MemoryInterface { + function getUint(uint id) external returns (uint num); + function setUint(uint id, uint val) external; +} + +interface InstaMapping { + function cTokenMapping(address) external view returns (address); + function gemJoinMapping(bytes32) external view returns (address); +} + +interface AccountInterface { + function enable(address) external; + function disable(address) external; + function isAuth(address) external view returns (bool); +} diff --git a/contracts/polygon/common/math.sol b/contracts/polygon/common/math.sol new file mode 100644 index 00000000..f6e2e6cd --- /dev/null +++ b/contracts/polygon/common/math.sol @@ -0,0 +1,50 @@ +pragma solidity ^0.7.0; + +import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; + +contract DSMath { + uint constant WAD = 10 ** 18; + uint constant RAY = 10 ** 27; + + function add(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.add(x, y); + } + + function sub(uint x, uint y) internal virtual pure returns (uint z) { + z = SafeMath.sub(x, y); + } + + function mul(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.mul(x, y); + } + + function div(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.div(x, y); + } + + function wmul(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD; + } + + function wdiv(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y; + } + + function rdiv(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y; + } + + function rmul(uint x, uint y) internal pure returns (uint z) { + z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY; + } + + function toInt(uint x) internal pure returns (int y) { + y = int(x); + require(y >= 0, "int-overflow"); + } + + function toRad(uint wad) internal pure returns (uint rad) { + rad = mul(wad, 10 ** 27); + } + +} diff --git a/contracts/polygon/common/stores.sol b/contracts/polygon/common/stores.sol new file mode 100644 index 00000000..3afef234 --- /dev/null +++ b/contracts/polygon/common/stores.sol @@ -0,0 +1,37 @@ +pragma solidity ^0.7.0; + +import { MemoryInterface, InstaMapping } from "./interfaces.sol"; + + +abstract contract Stores { + + /** + * @dev Return ethereum address + */ + address constant internal maticAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + + /** + * @dev Return Wrapped ETH address + */ + address constant internal wmaticAddr = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; + + /** + * @dev Return memory variable address + */ + MemoryInterface constant internal instaMemory = MemoryInterface(0x6C7256cf7C003dD85683339F75DdE9971f98f2FD); + + /** + * @dev Get Uint value from InstaMemory Contract. + */ + function getUint(uint getId, uint val) internal returns (uint returnVal) { + returnVal = getId == 0 ? val : instaMemory.getUint(getId); + } + + /** + * @dev Set Uint value in InstaMemory Contract. + */ + function setUint(uint setId, uint val) virtual internal { + if (setId != 0) instaMemory.setUint(setId, val); + } + +} diff --git a/contracts/polygon/connectors/mainnet-bridge/events.sol b/contracts/polygon/connectors/mainnet-bridge/events.sol new file mode 100644 index 00000000..0212e59d --- /dev/null +++ b/contracts/polygon/connectors/mainnet-bridge/events.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.7.0; + +contract Events { + event LogWithdraw( + address token, + uint256 amt, + uint256 getId, + uint256 setId + ); +} \ No newline at end of file diff --git a/contracts/polygon/connectors/mainnet-bridge/main.sol b/contracts/polygon/connectors/mainnet-bridge/main.sol new file mode 100644 index 00000000..030fa679 --- /dev/null +++ b/contracts/polygon/connectors/mainnet-bridge/main.sol @@ -0,0 +1,41 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "../../common/interfaces.sol"; +import { Stores } from "../../common/stores.sol"; +import { Events } from "./events.sol"; + +abstract contract MainnetBridgeResolver is Stores, Events { + /** + * @dev Withdraw assets to mainnet. + * @notice Withdraw assets to mainnet by burning the tokens. + * @param token The address of the token to withdraw. (For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) + * @param amt The amount of tokens to withdraw. (For max: `uint256(-1)`) + * @param getId ID to retrieve amt. + * @param setId ID stores the amount of tokens withdrawn. + */ + function withdraw( + address token, + uint256 amt, + uint256 getId, + uint256 setId + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + uint _amt = getUint(getId, amt); + + if (token == maticAddr) { + _amt = _amt == uint(-1) ? address(this).balance : _amt; + TokenInterface(address(0)).withdraw(_amt); + } else { + TokenInterface _token = TokenInterface(token); + _amt = _amt == uint(-1) ? _token.balanceOf(address(this)) : _amt; + _token.withdraw(_amt); + if (token == wmaticAddr) { + TokenInterface(address(0)).withdraw(_amt); + } + } + + setUint(setId, _amt); + + _eventName = "LogWithdraw(address,address,uint256,uint256,uint256)"; + _eventParam = abi.encode(token, _amt, getId, setId); + } +} \ No newline at end of file From d6a51b836a7cb564a534bb76a2d4922d4702c823 Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Tue, 13 Apr 2021 01:49:35 +0530 Subject: [PATCH 3/3] removed withdraw from Polygon as you need EOA --- .../connectors/polygon-bridge/main.sol | 16 -------- .../connectors/mainnet-bridge/events.sol | 10 ----- .../connectors/mainnet-bridge/main.sol | 41 ------------------- 3 files changed, 67 deletions(-) delete mode 100644 contracts/polygon/connectors/mainnet-bridge/events.sol delete mode 100644 contracts/polygon/connectors/mainnet-bridge/main.sol diff --git a/contracts/mainnet/connectors/polygon-bridge/main.sol b/contracts/mainnet/connectors/polygon-bridge/main.sol index 2acb29e0..def0211e 100644 --- a/contracts/mainnet/connectors/polygon-bridge/main.sol +++ b/contracts/mainnet/connectors/polygon-bridge/main.sol @@ -39,22 +39,6 @@ abstract contract PolygonBridgeResolver is Events, Helpers { _eventName = "LogDeposit(address,address,uint256,uint256,uint256)"; _eventParam = abi.encode(targetDsa, token, _amt, getId, setId); } - - /** - * @dev Withdraw assets from Polygon. - * @notice Complete withdraw by submitting burn tx hash. - * @param proof The proof generated from burn tx. - */ - function withdraw( - bytes calldata proof - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - require(proof.length > 0, "invalid-proof"); - - migrator.exit(proof); - - _eventName = "LogWithdraw(bytes)"; - _eventParam = abi.encode(proof); - } } contract ConnectPolygonBridge is PolygonBridgeResolver { diff --git a/contracts/polygon/connectors/mainnet-bridge/events.sol b/contracts/polygon/connectors/mainnet-bridge/events.sol deleted file mode 100644 index 0212e59d..00000000 --- a/contracts/polygon/connectors/mainnet-bridge/events.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma solidity ^0.7.0; - -contract Events { - event LogWithdraw( - address token, - uint256 amt, - uint256 getId, - uint256 setId - ); -} \ No newline at end of file diff --git a/contracts/polygon/connectors/mainnet-bridge/main.sol b/contracts/polygon/connectors/mainnet-bridge/main.sol deleted file mode 100644 index 030fa679..00000000 --- a/contracts/polygon/connectors/mainnet-bridge/main.sol +++ /dev/null @@ -1,41 +0,0 @@ -pragma solidity ^0.7.0; - -import { TokenInterface } from "../../common/interfaces.sol"; -import { Stores } from "../../common/stores.sol"; -import { Events } from "./events.sol"; - -abstract contract MainnetBridgeResolver is Stores, Events { - /** - * @dev Withdraw assets to mainnet. - * @notice Withdraw assets to mainnet by burning the tokens. - * @param token The address of the token to withdraw. (For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) - * @param amt The amount of tokens to withdraw. (For max: `uint256(-1)`) - * @param getId ID to retrieve amt. - * @param setId ID stores the amount of tokens withdrawn. - */ - function withdraw( - address token, - uint256 amt, - uint256 getId, - uint256 setId - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - uint _amt = getUint(getId, amt); - - if (token == maticAddr) { - _amt = _amt == uint(-1) ? address(this).balance : _amt; - TokenInterface(address(0)).withdraw(_amt); - } else { - TokenInterface _token = TokenInterface(token); - _amt = _amt == uint(-1) ? _token.balanceOf(address(this)) : _amt; - _token.withdraw(_amt); - if (token == wmaticAddr) { - TokenInterface(address(0)).withdraw(_amt); - } - } - - setUint(setId, _amt); - - _eventName = "LogWithdraw(address,address,uint256,uint256,uint256)"; - _eventParam = abi.encode(token, _amt, getId, setId); - } -} \ No newline at end of file