|
| 1 | +name: Dispense Predictoor USDC Rewards |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * 1" |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + amt_of_tokens: |
| 13 | + description: "Amount of tokens to distribute" |
| 14 | + required: true |
| 15 | + default: "1" |
| 16 | + |
| 17 | +jobs: |
| 18 | + dispense-predictoor-usdc: |
| 19 | + env: |
| 20 | + BINANCE_API_URL: ${{secrets.BINANCE_API_URL}} |
| 21 | + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 22 | + permissions: |
| 23 | + contents: "read" |
| 24 | + id-token: "write" |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + python-version: [3.8] |
| 29 | + #needs: run-tests |
| 30 | + steps: |
| 31 | + - id: df-py |
| 32 | + uses: pozetroninc/github-action-get-latest-release@master |
| 33 | + with: |
| 34 | + owner: oceanprotocol |
| 35 | + repo: df-py |
| 36 | + excludes: prerelease, draft |
| 37 | + |
| 38 | + - name: Set branch to checkout |
| 39 | + id: set_branch |
| 40 | + run: echo "BRANCH=${{ github.event_name == 'schedule' && steps.df-py.outputs.release || github.ref }}" >> $GITHUB_ENV |
| 41 | + |
| 42 | + - uses: actions/checkout@v3 |
| 43 | + with: |
| 44 | + ref: ${{ env.BRANCH }} |
| 45 | + |
| 46 | + - name: Set up Python {{ matrix.python-version }} |
| 47 | + uses: actions/setup-python@v2 |
| 48 | + with: |
| 49 | + python-version: ${{ matrix.python-version }} |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + working-directory: ${{ github.workspace }} |
| 53 | + run: | |
| 54 | + python -m pip install --upgrade pip |
| 55 | + pip install -r requirements.txt --quiet |
| 56 | +
|
| 57 | + - name: Set up Openzeppelin |
| 58 | + run: npm install @openzeppelin/contracts |
| 59 | + |
| 60 | + - name: Set env variables |
| 61 | + run: | |
| 62 | + echo "DFTOOL_KEY=${{ secrets.DF_SAPPHIRE_ROSE_REWARDS_PK }}" >> $GITHUB_ENV |
| 63 | + echo "ADDRESS_FILE=.github/workflows/data/address.json" >> $GITHUB_ENV |
| 64 | + echo "WEB3_INFURA_PROJECT_ID=${{ secrets.WEB3_INFURA_PROJECT_ID }}" >> $GITHUB_ENV |
| 65 | + echo "SECRET_SEED=${{ secrets.SECRET_SEED }}" >> $GITHUB_ENV |
| 66 | + echo "date=$(date -d "last-thursday - 1 week" '+%Y-%m-%d')" >> $GITHUB_ENV |
| 67 | + echo "now=$(date -d "last-thursday" '+%Y-%m-%d')" >> $GITHUB_ENV |
| 68 | + echo "CSV_DIR=/tmp/csv" >> $GITHUB_ENV |
| 69 | + echo "RETRY_TIMES=5" >> $GITHUB_ENV |
| 70 | + echo "POLYGON_RPC_URL=https://polygon-mainnet.infura.io/v3/" >> $GITHUB_ENV |
| 71 | + echo "MUMBAI_RPC_URL=https://polygon-mumbai.infura.io/v3/" >> $GITHUB_ENV |
| 72 | + echo "MAINNET_RPC_URL=https://mainnet.infura.io/v3/" >> $GITHUB_ENV |
| 73 | + echo "SAPPHIRE_MAINNET_RPC_URL=https://sapphire.oasis.io/" >> $GITHUB_ENV |
| 74 | + echo "GOERLI_RPC_URL=https://rpc.ankr.com/eth_goerli" >> $GITHUB_ENV |
| 75 | + echo "INFURA_NETWORKS=polygon,mumbai,mainnet" >> $GITHUB_ENV |
| 76 | +
|
| 77 | + - name: Make dftool executable |
| 78 | + run: chmod +x dftool |
| 79 | + |
| 80 | + - name: Run dftool predictoor_data |
| 81 | + run: | |
| 82 | + ./dftool predictoor_data $date $now $CSV_DIR 23294 --RETRIES $RETRY_TIMES |
| 83 | +
|
| 84 | + - name: Run dftool calc rewards for predictoor_rose |
| 85 | + run: | |
| 86 | + ./dftool calc predictoor_rose $CSV_DIR 500 |
| 87 | +
|
| 88 | + - name: Upload artifacts |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: CSV Files |
| 92 | + retention-days: 5 |
| 93 | + path: /tmp/csv |
| 94 | + |
| 95 | + - name: Distribute Predictoor rewards |
| 96 | + env: |
| 97 | + USE_MULTISIG: false |
| 98 | + if: github.event_name == 'schedule' |
| 99 | + run: | |
| 100 | + ./dftool dispense_active $CSV_DIR 23294 --DFREWARDS_ADDR="0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0" --TOKEN_ADDR="0x2c2E3812742Ab2DA53a728A09F5DE670Aba584b6" --PREDICTOOR_ROSE True |
| 101 | +
|
| 102 | + - name: Rename folder to round number |
| 103 | + run: | |
| 104 | + bash ./scripts/workflow_rename_folder.sh $now -USDC |
| 105 | +
|
| 106 | + - id: "auth" |
| 107 | + uses: "google-github-actions/auth@v1" |
| 108 | + with: |
| 109 | + credentials_json: "${{ secrets.GC_SECRET }}" |
| 110 | + |
| 111 | + - name: Set upload destination |
| 112 | + run: | |
| 113 | + if [[ "${{ github.event_name }}" == "schedule" ]]; then |
| 114 | + echo "DESTINATION=df-historical-data" >> $GITHUB_ENV |
| 115 | + else |
| 116 | + echo "DESTINATION=df-historical-data-test" >> $GITHUB_ENV |
| 117 | + fi |
| 118 | +
|
| 119 | + - name: Remove predictoor_data.csv |
| 120 | + run: rm /tmp/csv/${{ env.DFWEEK }}/predictoor_data.csv |
| 121 | + |
| 122 | + - id: "upload-folder" |
| 123 | + uses: "google-github-actions/upload-cloud-storage@v1" |
| 124 | + with: |
| 125 | + path: "/tmp/csv/${{ env.DFWEEK }}/" |
| 126 | + destination: "${{ env.DESTINATION }}" |
0 commit comments