Skip to content

Commit

Permalink
Add Polygon-zkevm (#46)
Browse files Browse the repository at this point in the history
* Prepare new CelerChainPath.json

* Add scripts for polygon-evm

* Add compensate_set_price_ratio

* Add swap of zkevm

* Add abi

* Add contract address

* Fix export

* Add zkevm-main check

* Fix config

* Fix abi of factory

* Add abi

* Add reinitialize

* Fix config

* Add handle script for refunded tokens

* Update format

---------

Co-authored-by: icodezjb <[email protected]>
Co-authored-by: AAweidai <[email protected]>
  • Loading branch information
3 people authored Jul 20, 2023
1 parent 3c29c0a commit 48e3f2a
Show file tree
Hide file tree
Showing 22 changed files with 12,580 additions and 36 deletions.
2 changes: 2 additions & 0 deletions ethereum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ brownie networks modify polygon-test host=https://matic-mumbai.chainstacklabs.co

~~~shell
brownie networks add Arbitrum arbitrum-test host=https://rinkeby.arbitrum.io/rpc name=Testnet chainid=421611

brownie networks add Polygon zkevm-main host="https://zkevm-rpc.com" name="zkevm-main" chainid=1101
~~~

65 changes: 65 additions & 0 deletions ethereum/brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,10 @@ networks:
chainid: 324
pair: ETHUSD
address: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"
zkevm:
chainid: 1011
pair: ETHUSD
address: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"
multichain:
chainid: 1
fast_router: "0x1633D66Ca91cE4D81F63Ea047B7B19Beb92dF7f3"
Expand Down Expand Up @@ -978,6 +982,10 @@ networks:
chainid: 324
pair: ETHUSD
address: "0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e"
zkevm:
chainid: 1011
pair: ETHUSD
address: "0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e"
multichain:
chainid: 56
fast_router: "0x400b971099e0ebfda2c03a3063739cb5398734a6"
Expand Down Expand Up @@ -1132,6 +1140,11 @@ networks:
chainid: 324
pair: ETHUSD
address: "0x976B3D034E162d8bD72D6b9C989d545b839003b0"

zkevm:
chainid: 1011
pair: ETHUSD
address: "0x976B3D034E162d8bD72D6b9C989d545b839003b0"
multichain:
chainid: 43114
fast_router: "0x1633D66Ca91cE4D81F63Ea047B7B19Beb92dF7f3"
Expand Down Expand Up @@ -1279,6 +1292,10 @@ networks:
chainid: 324
pair: ETHUSD
address: "0xF9680D99D6C9589e2a93a78A04A279e509205945"
zkevm:
chainid: 1011
pair: ETHUSD
address: "0xF9680D99D6C9589e2a93a78A04A279e509205945"
multichain:
chainid: 137
fast_router: "0x1633D66Ca91cE4D81F63Ea047B7B19Beb92dF7f3"
Expand Down Expand Up @@ -1406,6 +1423,10 @@ networks:
chainid: 324
pair: ETHUSD
address: "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612"
zkevm:
chainid: 1011
pair: ETHUSD
address: "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612"
multichain:
chainid: 42161
fast_router: "0x1633D66Ca91cE4D81F63Ea047B7B19Beb92dF7f3"
Expand Down Expand Up @@ -1512,6 +1533,10 @@ networks:
chainid: 324
pair: ETHUSD
address: "0x13e3Ee699D1909E989722E753853AE30b17e08c5"
zkevm:
chainid: 1011
pair: ETHUSD
address: "0x13e3Ee699D1909E989722E753853AE30b17e08c5"
multichain:
chainid: 10
fast_router: "0x1633D66Ca91cE4D81F63Ea047B7B19Beb92dF7f3"
Expand Down Expand Up @@ -1599,6 +1624,46 @@ networks:
weth:
address: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91"
decimal: 18
zkevm-main:
chainid: 1101
token:
weth:
address: "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9"
decimal: 18
swap:
IQuickSwapRouter:
name: QuickSwapV3
router: "0xF6Ad3CcF71Abb3E12beCf6b3D2a74C963859ADCd"
token_list: ""
quoter: "0x55BeE1bD3Eb9986f6d2d963278de09eE92a3eF1D"
factory: "0x4B9f4d2435Ef65559567e5DbFC1BbB37abC43B57"
ISwapRouter:
name: PancakeSwapV3
router: "0x1b81D678ffb9C0263b24A97847620C99d213eB14"
token_list: ""
quoter: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997"
factory: "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865"
bridges:
celer:
chainid: 1101
message_bus: "0x9Bb46D5100d2Db4608112026951c9C965b233f4D"
token:
weth:
address: "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9"
decimal: 18

gas:
base_gas: 700000
dst_chainid:
- 1 # mainnet
- 10 # optimism-main
- 56 # bsc-main
- 137 # polygon-main
- 324 # zksync2-main
- 1101 # zkevm-main
- 42161 # arbitrum-main
- 43114 # avax-main

wallets:
from_key: ${PRIVATE_KEY}
from_mnemonic: ${MNEMONIC}
135 changes: 135 additions & 0 deletions ethereum/contracts/Interfaces/IQuickFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/**
* @title The interface for the Algebra Factory
* @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
* https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
*/
interface IQuickFactory {
/**
* @notice Emitted when the owner of the factory is changed
* @param newOwner The owner after the owner was changed
*/
event Owner(address indexed newOwner);

/**
* @notice Emitted when the vault address is changed
* @param newVaultAddress The vault address after the address was changed
*/
event VaultAddress(address indexed newVaultAddress);

/**
* @notice Emitted when a pool is created
* @param token0 The first token of the pool by address sort order
* @param token1 The second token of the pool by address sort order
* @param pool The address of the created pool
*/
event Pool(address indexed token0, address indexed token1, address pool);

/**
* @notice Emitted when the farming address is changed
* @param newFarmingAddress The farming address after the address was changed
*/
event FarmingAddress(address indexed newFarmingAddress);

event FeeConfiguration(
uint16 alpha1,
uint16 alpha2,
uint32 beta1,
uint32 beta2,
uint16 gamma1,
uint16 gamma2,
uint32 volumeBeta,
uint16 volumeGamma,
uint16 baseFee
);

/**
* @notice Returns the current owner of the factory
* @dev Can be changed by the current owner via setOwner
* @return The address of the factory owner
*/
function owner() external view returns (address);

/**
* @notice Returns the current poolDeployerAddress
* @return The address of the poolDeployer
*/
function poolDeployer() external view returns (address);

/**
* @dev Is retrieved from the pools to restrict calling
* certain functions not by a tokenomics contract
* @return The tokenomics contract address
*/
function farmingAddress() external view returns (address);

function vaultAddress() external view returns (address);

/**
* @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
* @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
* @param tokenA The contract address of either token0 or token1
* @param tokenB The contract address of the other token
* @return pool The pool address
*/
function poolByPair(address tokenA, address tokenB) external view returns (address pool);

/**
* @notice Creates a pool for the given two tokens and fee
* @param tokenA One of the two tokens in the desired pool
* @param tokenB The other of the two tokens in the desired pool
* @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
* from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
* are invalid.
* @return pool The address of the newly created pool
*/
function createPool(address tokenA, address tokenB) external returns (address pool);

/**
* @notice Updates the owner of the factory
* @dev Must be called by the current owner
* @param _owner The new owner of the factory
*/
function setOwner(address _owner) external;

/**
* @dev updates tokenomics address on the factory
* @param _farmingAddress The new tokenomics contract address
*/
function setFarmingAddress(address _farmingAddress) external;

/**
* @dev updates vault address on the factory
* @param _vaultAddress The new vault contract address
*/
function setVaultAddress(address _vaultAddress) external;

/**
* @notice Changes initial fee configuration for new pools
* @dev changes coefficients for sigmoids: α / (1 + e^( (β-x) / γ))
* alpha1 + alpha2 + baseFee (max possible fee) must be <= type(uint16).max
* gammas must be > 0
* @param alpha1 max value of the first sigmoid
* @param alpha2 max value of the second sigmoid
* @param beta1 shift along the x-axis for the first sigmoid
* @param beta2 shift along the x-axis for the second sigmoid
* @param gamma1 horizontal stretch factor for the first sigmoid
* @param gamma2 horizontal stretch factor for the second sigmoid
* @param volumeBeta shift along the x-axis for the outer volume-sigmoid
* @param volumeGamma horizontal stretch factor the outer volume-sigmoid
* @param baseFee minimum possible fee
*/
function setBaseFeeConfiguration(
uint16 alpha1,
uint16 alpha2,
uint32 beta1,
uint32 beta2,
uint16 gamma1,
uint16 gamma2,
uint32 volumeBeta,
uint16 volumeGamma,
uint16 baseFee
) external;
}
Loading

0 comments on commit 48e3f2a

Please sign in to comment.