Skip to content
Open
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
Binary file added .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"lib/contracts": {
"rev": "72073d0e2cabf7966b493fc77291e4891c5402d7"
},
"lib/forge-std": {
"rev": "f73c73d2018eb6a111f35e4dae7b4f27401e9421"
},
"lib/hebeswap-contract": {
"rev": "fb606bdcf5ddaee985039605bcd847918a66c3a7"
},
"lib/openzeppelin-contracts": {
"rev": "0457042d93d9dfd760dbaa06a4d2f1216fdbe297"
},
"lib/solmate": {
"rev": "3998897acb502fa7b480f505138a6ae1842e8d10"
}
}
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ libs = ['node_modules', 'lib']
remappings = [
'@chainlink/contracts/=node_modules/@chainlink/contracts'
]
via_ir = true
optimizer = true
optimizer_runs = 200

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Binary file added lib/.DS_Store
Binary file not shown.
10 changes: 10 additions & 0 deletions scripts/DeploymentParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ contract DeploymentParameters {
uint256 public RESERVE_COIN_INITIAL_PRICE;
uint256 public TX_LIMIT;

string public NAME_SC = "StableCoin";
string public SYMBOL_SC = "SC";
string public NAME_RC = "ReserveCoin";
string public SYMBOL_RC = "RC";

address constant CHAINLINK_SEPOLIA_INVERTED_ORACLE_ADDRESS = 0xB9C050Fd340aD5ED3093F31aAFAcC3D779f405f4;
address constant HEBESWAP_ORACLE_INVERTED_ADDRESS_MORDOR = 0xb0d99da21Bb4fa877e3D1DCA89E6657c5e840Eb2;
address constant HEBESWAP_ORACLE_INVERTED_ADDRESS_MAINNET = 0x2fd961e20896e121EC7D499cC4F38462e286994A;
Expand All @@ -50,6 +55,7 @@ contract DeploymentParameters {
)
internal
returns (
string memory, string memory, string memory, string memory,
address, address,
uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256
)
Expand Down Expand Up @@ -102,6 +108,10 @@ contract DeploymentParameters {
}

return (
NAME_SC,
SYMBOL_SC,
NAME_RC,
SYMBOL_RC,
oracleAddress,
treasuryAddress,
SCALING_FACTOR,
Expand Down
8 changes: 8 additions & 0 deletions scripts/deployDjedContract.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ contract DeployDjed is Script, DeploymentParameters {

vm.startBroadcast(senderPrivateKey);
(
string memory nameSC,
string memory symbolSC,
string memory nameRC,
string memory symbolRC,
address oracleAddress,
address treasuryAddress,
uint256 SCALING_FACTOR,
Expand All @@ -27,6 +31,10 @@ contract DeployDjed is Script, DeploymentParameters {
) = getConfigFromNetwork(network, version);

Djed djed = new Djed{value: INITIAL_BALANCE}(
nameSC,
symbolSC,
nameRC,
symbolRC,
oracleAddress,
SCALING_FACTOR,
treasuryAddress,
Expand Down
8 changes: 8 additions & 0 deletions scripts/deployDjedShuContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ contract DeployDjedShu is Script, DeploymentParameters {

vm.startBroadcast(senderPrivateKey);
(
string memory nameSC,
string memory symbolSC,
string memory nameRC,
string memory symbolRC,
address oracleAddress,
address treasuryAddress,
uint256 SCALING_FACTOR,
Expand All @@ -27,6 +31,10 @@ contract DeployDjedShu is Script, DeploymentParameters {
) = getConfigFromNetwork(network, version);

DjedShu djedShu = new DjedShu{value: INITIAL_BALANCE}(
nameSC,
symbolSC,
nameRC,
symbolRC,
oracleAddress,
SCALING_FACTOR,
treasuryAddress,
Expand Down
Binary file added src/.DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions src/Djed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ contract Djed is ReentrancyGuard {
event SoldBothCoins(address indexed seller, address indexed receiver, uint256 amountSC, uint256 amountRC, uint256 amountBC);

constructor(
string memory nameSC, string memory symbolSC,
string memory nameRC, string memory symbolRC,
address oracleAddress, uint256 _scalingFactor,
address _treasury, uint256 _initialTreasuryFee, uint256 _treasuryRevenueTarget,
uint256 _reserveRatioMin, uint256 _reserveRatioMax,
uint256 _fee, uint256 _thresholdSupplySC, uint256 _rcMinPrice, uint256 _rcInitialPrice, uint256 _txLimit
) payable {
stableCoin = new Coin("StableCoin", "SC");
reserveCoin = new Coin("ReserveCoin", "RC");
stableCoin = new Coin(nameSC, symbolSC);
reserveCoin = new Coin(nameRC, symbolRC);
scDecimalScalingFactor = 10**stableCoin.decimals();
rcDecimalScalingFactor = 10**reserveCoin.decimals();
scalingFactor = _scalingFactor;
Expand Down
6 changes: 4 additions & 2 deletions src/DjedShu.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ contract DjedShu is ReentrancyGuard {
event SoldBothCoins(address indexed seller, address indexed receiver, uint256 amountSC, uint256 amountRC, uint256 amountBC);

constructor(
string memory nameSC, string memory symbolSC,
string memory nameRC, string memory symbolRC,
address oracleAddress, uint256 _scalingFactor,
address _treasury, uint256 _initialTreasuryFee, uint256 _treasuryRevenueTarget,
uint256 _reserveRatioMin, uint256 _reserveRatioMax,
uint256 _fee, uint256 _thresholdSupplySC, uint256 _rcMinPrice, uint256 _rcInitialPrice, uint256 _txLimit
) payable {
stableCoin = new Coin("StableCoin", "SC");
reserveCoin = new Coin("ReserveCoin", "RC");
stableCoin = new Coin(nameSC, symbolSC);
reserveCoin = new Coin(nameRC, symbolRC);
scDecimalScalingFactor = 10**stableCoin.decimals();
rcDecimalScalingFactor = 10**reserveCoin.decimals();
scalingFactor = _scalingFactor;
Expand Down
4 changes: 4 additions & 0 deletions src/test/Djed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ contract DjedTest is CTest, Utilities {
function setUp() public {
oracle = new MockOracle(ORACLE_EXCHANGE_RATE);
djed = (new Djed){value: INITIAL_BALANCE}(
NAME_SC,
SYMBOL_SC,
NAME_RC,
SYMBOL_RC,
address(oracle),
SCALING_FACTOR,
TREASURY,
Expand Down
4 changes: 4 additions & 0 deletions src/test/Fee.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ contract FeeTest is CTest, Utilities {

oracle = new MockOracle(ORACLE_EXCHANGE_RATE);
djed = (new Djed){value: INITIAL_BALANCE}(
NAME_SC,
SYMBOL_SC,
NAME_RC,
SYMBOL_RC,
address(oracle),
SCALING_FACTOR,
TREASURY,
Expand Down
4 changes: 4 additions & 0 deletions src/test/TransactionLimit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ contract TransactionLimitTest is CTest, Utilities {

oracle = new MockOracle(ORACLE_EXCHANGE_RATE);
djed = (new Djed){value: INITIAL_BALANCE}(
NAME_SC,
SYMBOL_SC,
NAME_RC,
SYMBOL_RC,
address(oracle),
SCALING_FACTOR,
TREASURY,
Expand Down
5 changes: 5 additions & 0 deletions src/test/Utilities.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ contract Utilities {
uint256 THRESHOLD_NUMBER_SC = 1e6;
uint256 TX_LIMIT = 200e6; // 200 SC

string constant NAME_SC = "StableCoin";
string constant SYMBOL_SC = "SC";
string constant NAME_RC = "ReserveCoin";
string constant SYMBOL_RC = "RC";

uint64 constant ORACLE_EXCHANGE_RATE = 1e18 / 2; // 1 USD = 0.5 ADA (ADA per USD)

address constant TREASURY = 0x078D888E40faAe0f32594342c85940AF3949E666;
Expand Down