Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce IVersionable interface #12

Merged
merged 11 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
SOLIDITY_VERSION = 0.8.16
OPTIMIZER_ENABLED = true
OPTIMIZER_RUNS = 1000
GAS_REPORTER_ENABLED = false
HARDHAT_MNEMONIC = test test test test test test test test test test test junk
GANACHE_RPC = http://127.0.0.1:7545
GANACHE_MNEMONIC = test test test test test test test test test test test junk
CW_TESTNET_RPC =
CW_TESTNET_PK =
CW_TESTNET_MNEMONIC =
CW_MAINNET_RPC =
CW_MAINNET_PK =
CW_MAINNET_MNEMONIC =
SOLIDITY_VERSION = 0.8.16
OPTIMIZER_ENABLED = true
OPTIMIZER_RUNS = 1000
GAS_REPORTER_ENABLED = false
CONTRACT_SIZER_ENABLED = false
HARDHAT_MNEMONIC = test test test test test test test test test test test junk
GANACHE_RPC = http://127.0.0.1:7545
GANACHE_MNEMONIC = test test test test test test test test test test test junk
CW_TESTNET_RPC =
CW_TESTNET_PK =
CW_TESTNET_MNEMONIC =
CW_MAINNET_RPC =
CW_MAINNET_PK =
CW_MAINNET_MNEMONIC =
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
![example branch parameter](https://github.com/cloudwalk/brlc-yield-streamer/actions/workflows/build.yml/badge.svg?branch=main)
![example branch parameter](https://github.com/cloudwalk/brlc-yield-streamer/actions/workflows/test.yml/badge.svg?branch=main)

This repository contains Yield Streamer smart contracts.</br>
This repository contains YieldStreamer smart contracts.

## Project Setup
1. Clone the repo.
2. Create the `.env` file based on the `.env.example` one:
* Windows:
* Windows:
```sh
copy .env.example .env
```
* MacOS/Linux:
* MacOS/Linux:
```sh
cp .env.example .env
```
3. Update settings in the newly created `.env` file if needed (e.g. another solidity version, number of optimization runs, private keys (PK) for networks, network RPC URLs, etc.).

3. Optionally update the settings in the newly created `.env` file (e.g., Solidity version, number of optimization runs, network RPC URLs, private keys (PK) for networks, etc.).

## Build and test

Expand All @@ -37,10 +36,6 @@ npx hardhat compile
npx hardhat test
```

## Networks and deployments

Information about deployments across all the networks can be found [here](./docs/deployed-contracts.json).

## Licensing

This project is released under the MIT License, see [LICENSE](./LICENSE).
3 changes: 2 additions & 1 deletion contracts/BalanceTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/O

import { IBalanceTracker } from "./interfaces/IBalanceTracker.sol";
import { IERC20Hook } from "./interfaces/IERC20Hook.sol";
import { Versionable } from "./base/Versionable.sol";

/**
* @title BalanceTracker contract
* @author CloudWalk Inc.
* @notice The contract that keeps track of the token balance for each account on a daily basis
*/
contract BalanceTracker is OwnableUpgradeable, IBalanceTracker, IERC20Hook {
contract BalanceTracker is OwnableUpgradeable, IBalanceTracker, IERC20Hook, Versionable {
/// @notice The time shift of a day in seconds
uint256 public constant NEGATIVE_TIME_SHIFT = 3 hours;

Expand Down
4 changes: 3 additions & 1 deletion contracts/YieldStreamer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IBalanceTracker } from "./interfaces/IBalanceTracker.sol";
import { PausableExtUpgradeable } from "./base/PausableExtUpgradeable.sol";
import { BlocklistableUpgradeable } from "./base/BlocklistableUpgradeable.sol";
import { RescuableUpgradeable } from "./base/RescuableUpgradeable.sol";
import { Versionable } from "./base/Versionable.sol";

/**
* @title YieldStreamer contract
Expand All @@ -22,7 +23,8 @@ contract YieldStreamer is
BlocklistableUpgradeable,
RescuableUpgradeable,
IBalanceTracker,
IYieldStreamer
IYieldStreamer,
Versionable
{
/// @notice The factor that is used together with yield rate values
/// @dev e.g. 0.1% rate should be represented as 0.001*RATE_FACTOR
Expand Down
21 changes: 21 additions & 0 deletions contracts/base/Versionable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../interfaces/IVersionable.sol";

/**
* @title Versionable contract
* @author CloudWalk Inc. (See https://cloudwalk.io)
* @dev Defines the contract version.
*/
abstract contract Versionable is IVersionable {
// ------------------ Pure functions -------------------------- //

/**
* @inheritdoc IVersionable
*/
function $__VERSION() external pure returns (Version memory) {
return Version(1, 0, 0);
}
}
24 changes: 24 additions & 0 deletions contracts/interfaces/IVersionable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
* @title IVersionable interface
* @author CloudWalk Inc. (See https://cloudwalk.io)
* @dev Defines the function of getting the contract version.
*/
interface IVersionable {
/**
* @dev The struct for the contract version.
*/
struct Version {
uint16 major; // -- The major version of contract
uint16 minor; // -- The minor version of contract
uint16 patch; // -- The patch version of contract
}

/**
* @dev Returns the version of the contract.
*/
function $__VERSION() external pure returns (Version memory);
}
22 changes: 0 additions & 22 deletions docs/deployed-contracts.json

This file was deleted.

3 changes: 3 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const config: HardhatUserConfig = {
},
gasReporter: {
enabled: process.env.GAS_REPORTER_ENABLED === "true"
},
contractSizer: {
runOnCompile: process.env.CONTRACT_SIZER_ENABLED === "true"
}
};

Expand Down
Loading
Loading