Skip to content

Commit

Permalink
Merge pull request #871 from TempleDAO/nexus-post
Browse files Browse the repository at this point in the history
Nexus post changes
  • Loading branch information
princetonbishop authored Nov 21, 2023
2 parents 25352d3 + cfe7f87 commit d389945
Show file tree
Hide file tree
Showing 73 changed files with 44,157 additions and 38,537 deletions.
132 changes: 113 additions & 19 deletions .github/workflows/protocol-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,149 @@ on:
paths:
- 'protocol/**'

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

jobs:
e2eTest:
hardhatTests:
name: Hardhat Tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 18

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: protocol/yarn.lock

- run: yarn install
- name: Install yarn project
run: yarn install
working-directory: protocol

- run: yarn compile
- name: Hardhat Compile
run: yarn compile
working-directory: protocol

- run: yarn test
- name: Hardhat Test
run: yarn test
working-directory: protocol
env:
TESTS_MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}

fuzzTest:
foundryTests:
name: Foundry Tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 18

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v3
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: protocol/yarn.lock

- run: yarn install
- name: Install yarn project
run: yarn install
working-directory: protocol

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.0.10
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
version: nightly
# version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
cache: true

- run: forge --version
- name: Show the Foundry CI config
run: forge config
env:
FOUNDRY_PROFILE: ci

- name: Show the Foundry version
run: forge --version
working-directory: protocol

- name: Run tests
run: FOUNDRY_PROFILE=ci forge test --gas-report
- name: Foundry tests
run: forge test --gas-report
working-directory: protocol
env:
FOUNDRY_PROFILE: ci
MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}

slither:
name: Slither
runs-on: ${{ matrix.os }}
permissions:
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 18

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: protocol/yarn.lock

- name: Install yarn project
run: yarn install
working-directory: protocol

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
# version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
cache: false

- name: install slither
run: cd protocol && pip install -r slither.requirements.txt

# Can't output to SARIF for private repos without paying for Advanced Security
- name: run slither
run: cd protocol && yarn slither-check
42 changes: 0 additions & 42 deletions .github/workflows/slither.yaml

This file was deleted.

1 change: 1 addition & 0 deletions protocol/contracts/common/CommonEventsAndErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ library CommonEventsAndErrors {
error ExpectedNonZero();
error Unimplemented();
event TokenRecovered(address indexed to, address indexed token, uint256 amount);
error AccountBlacklisted(address account);
}
90 changes: 90 additions & 0 deletions protocol/contracts/interfaces/nexus/IBaseSacrifice.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pragma solidity 0.8.19;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (interfaces/nexus/IBaseSacrifice.sol)


import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface ISacrifice {
event TokenSacrificed(address indexed fromAccount, address indexed token, uint256 amount);
event PartnerZeroSacrificed(address indexed to, uint256 relicId, uint256 enclaveId);
event OriginTimeSet(uint64 originTime);
event RelicMintCapSet(uint256 cap);

error FutureOriginTime(uint64 originTime);
error MintCapExceeded(uint256 newTotal);

/*
* @notice Get amount of tokens to mint a Relic
* @return Relic price
*/
function getPrice() external view returns (uint256);

/*
* @notice Set origin time.
* Origin time is the start of the linear ascending price to params.priceMaxPeriod
* @param _originTime Origin time
*/
function setOriginTime(uint64 _originTime) external;

/*
* @notice Sacrifice tokens to mint a Relic
* Caller must approve contract to spend tokens.
* @param enclaveId Enclave ID
* @param to Destination address
*/
function sacrifice(uint256 enclaveId, address to) external returns (uint256 relicId);
}

interface IPartnerSacrifice is ISacrifice {
/*
* @notice Get mint cap for partner
* @return Mint Cap
*/
function mintCap() external view returns (uint256);

/*
* @notice Get total Relics minted by partner
* @return Total minted Relics
*/
function totalMinted() external view returns (uint256);

/*
* @notice set mint cap for partner
* @param cap Cap to set
*/
function setMintCap(uint256 cap) external;
}

interface IBaseSacrifice is ISacrifice {

event CustomPriceSet(uint256 price);
event PriceParamsSet(PriceParam params);
event TokenRecipientSet(address recipient);

struct PriceParam {
uint64 priceMaxPeriod;
uint128 minimumPrice;
uint128 maximumPrice;
}

/*
* @notice Set price parameters.
* @param _priceParams Price parameters to set
*/
function setPriceParams(PriceParam calldata _priceParams) external;

/*
* @notice Set custom price
* owner can reset price with 0 _price value. Custom price can be set anytime during or after params.priceMaxPeriod on
* a flash sale or at a discounted price.
* @param _price Custom price
*/
function setCustomPrice(uint256 _price) external;

/*
* @notice Sacrifice Token address
* @return Sacrifice Token address
*/
function sacrificeToken() external view returns (IERC20);
}
Loading

0 comments on commit d389945

Please sign in to comment.