Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
bpierre committed Apr 11, 2024
2 parents f8aca43 + 7edba5d commit 0bfedc1
Show file tree
Hide file tree
Showing 22 changed files with 1,301 additions and 366 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: test contracts
name: Contracts Tests

# This workflow:
# - Runs the Foundry tests
# - Checks for console imports in the contracts
# - Runs the Hardhat tests
# - Generates a coverage report (currently disabled)

defaults:
run:
Expand Down Expand Up @@ -45,43 +51,8 @@ jobs:
forge test -vvv
id: test

deploy:
if: false
name: Deploy contracts to Liquity v2 Testnet
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: 8

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'

- name: Install dependencies
run: pnpm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run deployment tool
run: ./deploy liquity-testnet --verify
env:
DEPLOYER: ${{ secrets.DEPLOYER }}

console-logs:
name: Check we didn’t forget to remove console imports
name: Console imports check
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -129,6 +100,7 @@ jobs:
run: pnpm test

coverage:
if: false
name: Coverage
runs-on: ubuntu-latest
continue-on-error: true
Expand Down Expand Up @@ -215,4 +187,3 @@ jobs:
base-path: ./contracts/
path-to-lcov: ./contracts/lcov_merged.info
debug: true

101 changes: 101 additions & 0 deletions .github/workflows/testnet-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Testnet Deployment

# This workflow:
# - Deploys the contracts to the Liquity v2 Testnet (currently disabled)
# - Deploys the app to Vercel (only for the main branch, not PRs)

on:
push:
branches: [main]
paths:
- ".github/workflows/deploy-testnet.yml"
- "contracts/**"
- "frontend/**"
pull_request:
paths:
- ".github/workflows/deploy-testnet.yml"
- "contracts/**"

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy-contracts:
name: Deploy contracts
if: false # Disable contracts deployment for now
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: 8

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'

- name: Install dependencies
run: pnpm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run deployment tool
working-directory: ./contracts
run: ./deploy liquity-testnet --verify
env:
DEPLOYER: ${{ secrets.DEPLOYER }}

- name: Upload deployment context
uses: actions/upload-artifact@v4
with:
name: deployment-context
path: ./contracts/deployment-context-latest.json

deploy-app:
name: Deploy app
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: 8

- name: Install Vercel CLI
run: pnpm install --global vercel@canary

- name: Download deployment context
if: false # Disable contracts deployment for now
uses: actions/download-artifact@v4
with:
name: deployment-context

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

- name: Build Project Artifacts
run: |
test -f ./deployment-context-latest.json && cat ./deployment-context-latest.json | pn tsx contracts/utils/deployment-artifacts-to-next-env.ts > ./frontend/.env.local
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
25 changes: 0 additions & 25 deletions .github/workflows/vercel-deployment-main.yml

This file was deleted.

3 changes: 2 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ cache_hardhat
coverage/
coverage.json
mochaOutput.json
testMatrix.json
testMatrix.json
/deployment-context-latest.json
1 change: 1 addition & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"tsx": "^4.7.1",
"typechain": "^8.1.0",
"typescript": ">=4.5.0",
"zod": "^3.22.4",
"zx": "^7.2.3"
}
}
36 changes: 19 additions & 17 deletions contracts/src/Interfaces/ISortedTroves.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,46 @@
pragma solidity 0.8.18;

import "./ITroveManager.sol";
import {BatchId, BATCH_ID_ZERO} from "../Types/BatchId.sol";

// TODO
//type Id is uint256;
//type Value is uint256;


// Common interface for the SortedTroves Doubly Linked List.
interface ISortedTroves {
function borrowerOperationsAddress() external view returns (address);
function troveManager() external view returns (ITroveManager);
// -- Mutating functions (permissioned) --

function setParams(uint256 _size, address _TroveManagerAddress, address _borrowerOperationsAddress) external;
function setAddresses(address _troveManagerAddress, address _borrowerOperationsAddress) external;

function insert(uint256 _id, uint256 _value, uint256 _prevId, uint256 _nextId) external;
function insert(uint256 _id, uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external;
function insertIntoBatch(uint256 _troveId, BatchId _batchId, uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external;

function remove(uint256 _id) external;
function removeFromBatch(uint256 _id) external;

function reInsert(uint256 _id, uint256 _newValue, uint256 _prevId, uint256 _nextId) external;
function reInsert(uint256 _id, uint256 _newAnnualInterestRate, uint256 _prevId, uint256 _nextId) external;
function reInsertBatch(BatchId _id, uint256 _newAnnualInterestRate, uint256 _prevId, uint256 _nextId) external;

function contains(uint256 _id) external view returns (bool);
// -- View functions --

function isFull() external view returns (bool);
function contains(uint256 _id) external view returns (bool);
function isBatchedNode(uint256 _id) external view returns (bool);

function isEmpty() external view returns (bool);

function getSize() external view returns (uint256);

function getMaxSize() external view returns (uint256);

function getFirst() external view returns (uint256);

function getLast() external view returns (uint256);

function getNext(uint256 _id) external view returns (uint256);

function getPrev(uint256 _id) external view returns (uint256);

function validInsertPosition(uint256 _value, uint256 _prevId, uint256 _nextId) external view returns (bool);
function validInsertPosition(uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external view returns (bool);
function findInsertPosition(uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external view returns (uint256, uint256);

function findInsertPosition(uint256 _value, uint256 _prevId, uint256 _nextId) external view returns (uint256, uint256);
// Public state variable getters
function borrowerOperationsAddress() external view returns (address);
function troveManager() external view returns (ITroveManager);
function size() external view returns (uint256);
function nodes(uint256 _id) external view returns (uint256 nextId, uint256 prevId, BatchId batchId, bool exists);
function batches(BatchId _id) external view returns (uint256 head, uint256 tail);
}
Loading

0 comments on commit 0bfedc1

Please sign in to comment.