Skip to content

Commit

Permalink
Merge pull request #434 from teller-protocol/zk-cra/market-handler
Browse files Browse the repository at this point in the history
market handler merge into cra
  • Loading branch information
elclandestin0 authored Jul 29, 2021
2 parents 04087de + ce38b12 commit b395cd6
Show file tree
Hide file tree
Showing 202 changed files with 190,131 additions and 4,871 deletions.
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ALCHEMY_ROPSTEN_KEY=add-your-alchemy-key-here
ALCHEMY_KOVAN_KEY=add-your-alchemy-key-here

# Matic key used to deploy smart contracts
# Key should be the full URL
MATIC_MAINNET_KEY=add-your-matic-vigil-key-here
MATIC_MUMBAI_KEY=add-your-matic-vigil-key-here

Expand All @@ -25,7 +26,7 @@ INFURA_KEY=add-your-infura-key-here
ETHERSCAN_API_KEY=add-your-etherscan-api-key-here

# CoinMarketCap API key used for gas reporting
CMC_KEY=add-your-alchemy-key-here
CMC_KEY=add-your-coinmarketcap-key-here

# Gas price (in Gwei) used to deploy smart contract.
# Note: Check current gas price in the Ethereum network before deploying.
Expand Down
7 changes: 6 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"parserOptions": {
"project": "tsconfig.json"
},
"ignorePatterns": ["artifacts/**", "cache/**", "docs/**", "types/**"],
"plugins": ["prettier", "simple-import-sort", "@typescript-eslint"],
"rules": {
"@typescript-eslint/no-empty-interface": "off",
Expand All @@ -18,17 +19,21 @@
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/require-array-sort-compare": "off",
"arrow-parens": "error",
"no-extra-semi": "error",
"no-unused-vars": "off",
"no-useless-return": "off",
"no-void": "off",
"prefer-arrow-callback": "error",
"prettier/prettier": "error",
"semi": ["error", "never"],
"no-extra-semi": "error",
"simple-import-sort/imports": "error"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [pull_request]

jobs:
test:
name: Build Project
name: Build Project - Mainnet
runs-on: ubuntu-latest
environment: testing-keys
env:
Expand All @@ -28,9 +28,9 @@ jobs:
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
- name: Install dependencies - Mainnet
run: |
yarn --network-concurrency 1
- name: Compiling and Executing Tests
- name: Compiling and Executing Tests - Mainnet
run: |
yarn test mainnet
36 changes: 36 additions & 0 deletions .github/workflows/run-ci-polygon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Compile & Run Smart Contract Unit Tests

on: [pull_request]

jobs:
test:
name: Build Project - Polygon
runs-on: ubuntu-latest
environment: testing-keys
env:
MNEMONIC_KEY: ${{ secrets.MNEMONIC_KEY }}
ALCHEMY_MAINNET_KEY: ${{ secrets.ALCHEMY_MAINNET_KEY }}
ALCHEMY_RINKEBY_KEY: ${{ secrets.ALCHEMY_RINKEBY_KEY }}
ALCHEMY_ROPSTEN_KEY: ${{ secrets.ALCHEMY_ROPSTEN_KEY }}
ALCHEMY_KOVAN_KEY: ${{ secrets.ALCHEMY_KOVAN_KEY }}
MATIC_MAINNET_KEY: ${{ secrets.MATIC_MAINNET_KEY }}
MATIC_MUMBAI_KEY: ${{ secrets.MATIC_MUMBAI_KEY }}
INFURA_KEY: ${{ secrets.INFURA_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
CMC_KEY: ${{ secrets.CMC_KEY }}
GAS_PRICE_GWEI_KEY: 20
GAS_WEI_KEY: 2500000
ADDRESS_COUNT_KEY: 20
DEFAULT_ADDRESS_INDEX_KEY: 0
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies - Polygon
run: |
yarn --network-concurrency 1
- name: Compiling and Executing Tests - Polygon
run: |
yarn test polygon
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"files": "*.sol",
"options": {
"compiler": "0.8.0",
"tabWidth": 4,
"singleQuote": false,
"explicitTypes": "always",
Expand All @@ -19,7 +20,6 @@
{
"files": "*.ts",
"options": {
"printWidth": 80
}
}
]
Expand Down
15 changes: 8 additions & 7 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"func-visibility": ["warn", { "ignoreConstructors": true }],
"check-send-result": "warn",
"reentrancy": "warn",
"quotes": "error",
"compiler-version": "off",
"contract-name-camelcase": "off",
"no-empty-blocks": "off",
"func-name-mixedcase": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"max-line-length": ["warn", 120],
"no-empty-blocks": "off",
"no-inline-assembly": "off",
"prettier/prettier": "warn",
"quotes": "error",
"reentrancy": "warn",
"var-name-mixedcase": "off"
},
"plugins": ["prettier"]
}
}
121 changes: 94 additions & 27 deletions config/asset-settings.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,120 @@
import { AssetSettings } from '../types/custom/config-types'
import { AssetType } from '../utils/consts'

const mainnetAssetSettings: AssetSettings = {
DAI: [
{ key: 'cToken', value: 'CDAI', type: AssetType.Address },
{ key: 'aToken', value: 'ADAI', type: AssetType.Address },
{ key: 'yVault', value: 'YDAI', type: AssetType.Address },
{ key: 'pPool', value: 'PCDAI', type: AssetType.Address },
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Address }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Address }],
}

export const assetSettings: Record<string, AssetSettings> = {
kovan: {
DAI: [
{ key: 'cToken', value: 'CDAI', type: AssetType.Address },
{ key: 'cToken', value: 'CDAI', type: AssetType.Token },
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 100000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Address }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Address }],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Token }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Token }],
},
rinkeby: {
DAI: [
{ key: 'cToken', value: 'CDAI', type: AssetType.Address },
{ key: 'pPool', value: 'PCDAI', type: AssetType.Address },
{ key: 'cToken', value: 'CDAI', type: AssetType.Token },
{
key: 'pPool',
value: '0x4706856FA8Bb747D50b4EF8547FE51Ab5Edc4Ac2',
type: AssetType.Address,
},
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 100000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Address }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Address }],
USDC: [
{ key: 'cToken', value: 'CUSDC', type: AssetType.Token },
{
key: 'pPool',
value: '0xde5275536231eCa2Dd506B9ccD73C028e16a9a32',
type: AssetType.Address,
},
],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Token }],
},
ropsten: {
DAI: [
{ key: 'cToken', value: 'CDAI', type: AssetType.Address },
{ key: 'cToken', value: 'CDAI', type: AssetType.Token },
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 100000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Address }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Address }],
USDC: [{ key: 'cToken', value: 'CUSDC', type: AssetType.Token }],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Token }],
},
mainnet: {
DAI: [
{ key: 'cToken', value: 'CDAI', type: AssetType.Token },
{ key: 'aToken', value: 'ADAI', type: AssetType.Token },
{ key: 'yVault', value: 'YDAI', type: AssetType.Token },
{
key: 'pPool',
value: '0xEBfb47A7ad0FD6e57323C8A42B2E5A6a4F68fc1a',
type: AssetType.Address,
},
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDT: [
{ key: 'cToken', value: 'CUSDT', type: AssetType.Token },
{ key: 'aToken', value: 'AUSDT', type: AssetType.Token },
{ key: 'yVault', value: 'YUSDT', type: AssetType.Token },
{
key: 'pPool',
value: '0x481f1BA81f7C01400831DfF18215961C3530D118',
type: AssetType.Address,
},
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [
{ key: 'cToken', value: 'CUSDC', type: AssetType.Token },
{
key: 'pPool',
value: '0xde9ec95d7708b8319ccca4b8bc92c0a3b70bf416',
type: AssetType.Address,
},
],
WETH: [{ key: 'cToken', value: 'CETH', type: AssetType.Token }],
},
polygon: {
DAI: [
{ key: 'aToken', value: 'ADAI', type: AssetType.Token },
{
key: 'pPool',
value: '0xFECFa775643eb8C0F755491Ba4569e501764DA51',
type: AssetType.Address,
},
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDT: [
{ key: 'aToken', value: 'AUSDT', type: AssetType.Token },
{
key: 'pPool',
value: '0x887E17D791Dcb44BfdDa3023D26F7a04Ca9C7EF4',
type: AssetType.Address,
},
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'aToken', value: 'AUSDC', type: AssetType.Token }],
WETH: [{ key: 'aToken', value: 'AETH', type: AssetType.Token }],
},
polygon_mumbai: {
DAI: [
{ key: 'aToken', value: 'ADAI', type: AssetType.Token },
{ key: 'MaxLoanAmount', value: 25000, type: AssetType.Amount },
{ key: 'MaxTVL', value: 10000000, type: AssetType.Amount },
{ key: 'MaxDebtRatio', value: 5000, type: AssetType.Uint },
],
USDC: [{ key: 'aToken', value: 'AUSDC', type: AssetType.Token }],
WETH: [{ key: 'aToken', value: 'AETH', type: AssetType.Token }],
},
hardhat: mainnetAssetSettings,
localhost: mainnetAssetSettings,
mainnet: mainnetAssetSettings,
}
2 changes: 2 additions & 0 deletions config/atms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ export const atms: Record<string, ATMs> = {
hardhat: mainnetATMs,
localhost: mainnetATMs,
mainnet: mainnetATMs,
polygon: mainnetATMs,
polygon_mumbai: mainnetATMs,
}
65 changes: 63 additions & 2 deletions config/chainlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,44 @@ const mainnetChainlink: Chainlink = {
},
}

const polygonChainlink: Chainlink = {
MATIC_ETH: {
baseTokenName: 'MATIC',
quoteTokenName: 'ETH',
address: '0x327e23A4855b6F663a28c5161541d69Af8973302',
},
USDC_ETH: {
baseTokenName: 'USDC',
quoteTokenName: 'ETH',
address: '0xefb7e6be8356cCc6827799B6A7348eE674A80EaE',
},
USDT_ETH: {
baseTokenName: 'USDT',
quoteTokenName: 'ETH',
address: '0xf9d5AAC6E5572AEFa6bd64108ff86a222F69B64d',
},
DAI_ETH: {
baseTokenName: 'DAI',
quoteTokenName: 'ETH',
address: '0xFC539A559e170f848323e19dfD66007520510085',
},
LINK_ETH: {
baseTokenName: 'LINK',
quoteTokenName: 'ETH',
address: '0xb77fa460604b9C6435A235D057F7D319AC83cb53',
},
AAVE_ETH: {
baseTokenName: 'AAVE',
quoteTokenName: 'ETH',
address: '0xbE23a3AA13038CfC28aFd0ECe4FdE379fE7fBfc4',
},
SUSHI_USDC: {
baseTokenName: 'SUSHI',
quoteTokenName: 'USDC',
address: '0x49B0c695039243BBfEb8EcD054EB70061fd54aa0',
},
}

export const chainlink: Record<string, Chainlink> = {
kovan: {
ETH_USDC: {
Expand Down Expand Up @@ -121,7 +159,30 @@ export const chainlink: Record<string, Chainlink> = {
address: '0xD4d78d8e18d4717F5eE8801335eE5b5B97a4b824',
},
},
hardhat: mainnetChainlink,
localhost: mainnetChainlink,
polygon: polygonChainlink,
polygon_mumbai: {
USDC_MATIC: {
baseTokenName: 'MATIC',
quoteTokenName: 'USDC',
address: '0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada', // MATIC-USD
},
DAI_MATIC: {
baseTokenName: 'MATIC',
quoteTokenName: 'DAI',
address: '0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada', // MATIC-USD
},
USDC_ETH: {
baseTokenName: 'ETH',
quoteTokenName: 'USDC',
address: '0x0715A7794a1dc8e42615F059dD6e406A6594651A', // ETH-USD
},
DAI_ETH: {
baseTokenName: 'ETH',
quoteTokenName: 'DAI',
address: '0x0715A7794a1dc8e42615F059dD6e406A6594651A', // ETH-USD
},
},
hardhat: polygonChainlink,
localhost: polygonChainlink,
mainnet: mainnetChainlink,
}
Loading

0 comments on commit b395cd6

Please sign in to comment.