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

wip on sflr #99

Merged
merged 6 commits into from
Sep 19, 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
3 changes: 2 additions & 1 deletion .github/workflows/manual-sol-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
type: choice
options:
- ownable-oracle-vault
- flare-ftso-oracle-price-vault
- sceptre-staked-flare-price-vault
- implementations

receipt-vault-asset:
Expand Down Expand Up @@ -84,6 +84,7 @@ jobs:
RECEIPT_VAULT_SYMBOL: ${{ inputs.receipt-vault-symbol || '' }}
OWNER_ADDRESS: ${{ inputs.owner || '' }}
CLONE_FACTORY : ${{ vars[env.clone_factory_name] || '' }}
SCEPTRE_STAKED_FLR_ADDRESS: ${{ vars.SCEPTRE_STAKED_FLR_ADDRESS || '' }}
ERC20_PRICE_ORACLE_VAULT_IMPLEMENTATION: ${{ vars[env.erc20_price_oracle_vault_implementation_name] || '' }}
DEPLOY_BROADCAST: '1'
DEPLOYMENT_KEY: ${{ secrets.CI_PRIVATE_KEY }}
Expand Down
12 changes: 0 additions & 12 deletions contracts/concrete/oracle/FlareFTSOOracle.sol

This file was deleted.

30 changes: 30 additions & 0 deletions contracts/concrete/oracle/FtsoCurrentPriceUsdOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.25;

import {IPriceOracleV1} from "../../interface/IPriceOracleV1.sol";
import {LibFtsoCurrentPriceUsd} from "rain.flare/lib/price/LibFtsoCurrentPriceUsd.sol";
import {LibIntOrAString, IntOrAString} from "rain.intorastring/lib/LibIntOrAString.sol";

struct FtsoCurrentPriceUsdOracleConfig {
string symbol;
uint256 staleAfter;
}

contract FtsoCurrentPriceUsdOracle is IPriceOracleV1 {
event Construction(address sender, FtsoCurrentPriceUsdOracleConfig config);

IntOrAString public immutable iSymbol;
uint256 public immutable iStaleAfter;

constructor(FtsoCurrentPriceUsdOracleConfig memory config) {
iSymbol = LibIntOrAString.fromString2(config.symbol);
iStaleAfter = config.staleAfter;

emit Construction(msg.sender, config);
}

/// @inheritdoc IPriceOracleV1
function price() external view override returns (uint256) {
return LibFtsoCurrentPriceUsd.ftsoCurrentPriceUsd(LibIntOrAString.toString(iSymbol), iStaleAfter);
}
}
18 changes: 18 additions & 0 deletions contracts/concrete/oracle/SceptreStakedFlrOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.25;

import {IPriceOracleV1} from "../../interface/IPriceOracleV1.sol";
import {IStakedFlr} from "rain.flare/interface/IStakedFlr.sol";

contract SceptreStakedFlrOracle is IPriceOracleV1 {
IStakedFlr public immutable iStakedFlr;

constructor(IStakedFlr stakedFlr) {
iStakedFlr = stakedFlr;
}

/// @inheritdoc IPriceOracleV1
function price() external view override returns (uint256) {
return iStakedFlr.getSharesByPooledFlr(1e18);
}
}
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ fuzz.runs = 2056

remappings = [
"rain.factory/=lib/rain.factory/src/",
"rain.intorastring/=lib/rain.interpreter/lib/rain.intorastring/src/",
"forge-std/=lib/rain.interpreter/lib/forge-std/src/",
"rain.flare/=lib/rain.flare/src/",
]
34 changes: 27 additions & 7 deletions script/Deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import {
} from "contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {VaultConfig} from "contracts/abstract/ReceiptVault.sol";
import {ICloneableFactoryV2} from "rain.factory/interface/ICloneableFactoryV2.sol";
import {FlareFTSOOracle} from "contracts/concrete/oracle/FlareFTSOOracle.sol";
import {
FtsoCurrentPriceUsdOracle,
FtsoCurrentPriceUsdOracleConfig
} from "contracts/concrete/oracle/FtsoCurrentPriceUsdOracle.sol";
import {
OffchainAssetReceiptVault,
ReceiptVaultConstructionConfig
} from "contracts/concrete/vault/OffchainAssetReceiptVault.sol";
import {Receipt as ReceiptContract} from "contracts/concrete/receipt/Receipt.sol";
import {SceptreStakedFlrOracle} from "contracts/concrete/oracle/SceptreStakedFlrOracle.sol";
import {TwoPriceOracle, TwoPriceOracleConfig} from "contracts/concrete/oracle/TwoPriceOracle.sol";
import {IStakedFlr} from "rain.flare/interface/IStakedFlr.sol";

bytes32 constant DEPLOYMENT_SUITE_IMPLEMENTATIONS = keccak256("implementations");
bytes32 constant DEPLOYMENT_SUITE_OWNABLE_ORACLE_VAULT = keccak256("ownable-oracle-vault");
bytes32 constant DEPLOYMENT_SUITE_FLARE_FTSO_ORACLE_PRICE_VAULT = keccak256("flare-ftso-oracle-price-vault");
bytes32 constant DEPLOYMENT_SUITE_STAKED_FLR_PRICE_VAULT = keccak256("sceptre-staked-flare-price-vault");

/// @title Deploy
/// This is intended to be run on every commit by CI to a testnet such as mumbai,
Expand All @@ -39,15 +45,29 @@ contract Deploy is Script {
vm.stopBroadcast();
}

function deployFlareFTSOOraclePriceVault(uint256 deploymentKey) internal {
function deployStakedFlrPriceVault(uint256 deploymentKey) internal {
vm.startBroadcast(deploymentKey);
address flareFTSOOracle = address(
new FtsoCurrentPriceUsdOracle(
FtsoCurrentPriceUsdOracleConfig({
symbol: "FLR",
// 30 mins.
staleAfter: 1800
})
)
);
address stakedFlr = vm.envAddress("SCEPTRE_STAKED_FLR_ADDRESS");
address stakedFlrOracle = address(new SceptreStakedFlrOracle(IStakedFlr(stakedFlr)));
address twoPriceOracle =
address(new TwoPriceOracle(TwoPriceOracleConfig({base: flareFTSOOracle, quote: stakedFlrOracle})));

ICloneableFactoryV2(vm.envAddress("CLONE_FACTORY")).clone(
vm.envAddress("ERC20_PRICE_ORACLE_VAULT_IMPLEMENTATION"),
abi.encode(
ERC20PriceOracleVaultConfig({
priceOracle: address(new FlareFTSOOracle()),
priceOracle: twoPriceOracle,
vaultConfig: VaultConfig({
asset: vm.envAddress("RECEIPT_VAULT_ASSET"),
asset: stakedFlr,
name: vm.envString("RECEIPT_VAULT_NAME"),
symbol: vm.envString("RECEIPT_VAULT_SYMBOL")
})
Expand Down Expand Up @@ -90,8 +110,8 @@ contract Deploy is Script {

if (suite == DEPLOYMENT_SUITE_IMPLEMENTATIONS) {
deployImplementations(deployerPrivateKey);
} else if (suite == DEPLOYMENT_SUITE_FLARE_FTSO_ORACLE_PRICE_VAULT) {
deployFlareFTSOOraclePriceVault(deployerPrivateKey);
} else if (suite == DEPLOYMENT_SUITE_STAKED_FLR_PRICE_VAULT) {
deployStakedFlrPriceVault(deployerPrivateKey);
} else {
revert("Unknown deployment suite");
}
Expand Down
2 changes: 1 addition & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"detectors_to_exclude": "solc-version,block-timestamp,unused-imports,different-pragma-directives-are-used",
"detectors_to_exclude": "solc-version,block-timestamp,unused-imports,different-pragma-directives-are-used,assembly-usage",
"filter_paths": "lib/openzeppelin-contracts,lib/rain.tier.interface,test/,node_modules"
}
2 changes: 1 addition & 1 deletion test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {LibERC20PriceOracleReceiptVaultCreator} from "../lib/LibERC20PriceOracleReceiptVaultCreator.sol";
import {Receipt as ReceiptContract} from "contracts/concrete/receipt/Receipt.sol";
import {TwoPriceOracle, TwoPriceOracleConfig} from "contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle, TwoPriceOracleConfig} from "contracts/concrete/oracle/TwoPriceOracle.sol";
import {
ChainlinkFeedPriceOracle,
ChainlinkFeedPriceOracleConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity =0.8.25;

import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity =0.8.25;

import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ERC20PriceOracleReceiptVaultConfig
} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";

contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceiptVaultTest {
/// Test ERC20PriceOracleReceiptVault is constracted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity =0.8.25;
import {MinShareRatio, ZeroAssetsAmount, ZeroReceiver} from "../../../../../contracts/abstract/ReceiptVault.sol";
import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity =0.8.25;
import {MinShareRatio, ZeroAssetsAmount, ZeroReceiver} from "../../../../../contracts/abstract/ReceiptVault.sol";
import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity =0.8.25;
import {MinShareRatio, ZeroAssetsAmount, ZeroReceiver} from "../../../../../contracts/abstract/ReceiptVault.sol";
import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity =0.8.25;

import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity =0.8.25;

import {ERC20PriceOracleReceiptVault} from "../../../../../contracts/concrete/vault/ERC20PriceOracleReceiptVault.sol";
import {ERC20PriceOracleReceiptVaultTest, Vm} from "test/foundry/abstract/ERC20PriceOracleReceiptVaultTest.sol";
import {TwoPriceOracle} from "../../../../../contracts/oracle/price/TwoPriceOracle.sol";
import {TwoPriceOracle} from "../../../../../contracts/concrete/oracle/TwoPriceOracle.sol";
import {
LibFixedPointDecimalArithmeticOpenZeppelin,
Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "contracts/concrete/vault/OffchainAssetReceiptVault.sol";
import {StringsUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/utils/StringsUpgradeable.sol";
import {TestErc20} from "contracts/test/TestErc20.sol";
import {ReadWriteTier} from "contracts/test/ReadWriteTier.sol";
import {ReadWriteTier} from "../../../concrete/ReadWriteTier.sol";

contract RolesTest is OffchainAssetReceiptVaultTest {
/// Test to checks Admin roles granted
Expand Down
Loading