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
27 changes: 18 additions & 9 deletions env/sepolia.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
###############
REACT_APP_BLOCKCHAIN_URI=https://ethereum-sepolia.publicnode.com/
REACT_APP_CHAIN_ID=11155111
REACT_APP_DJED_ADDRESS=0x624FcD0a1F9B5820c950FefD48087531d38387f4
REACT_APP_DJED_ADDRESS=0xcAefe832436445eE3798F63658925b264F92A598
REACT_APP_DJED_SHU_ADDRESS=0xcAefe832436445eE3798F63658925b264F92A598
REACT_APP_FEE_UI=0
REACT_APP_UI=0x0232556C83791b8291E9b23BfEa7d67405Bd9839
REACT_APP_EXPLORER=https://sepolia.etherscan.io/
REACT_APP_BC=Sepolia
REACT_APP_PROTOCOL_CHAIN_DESCRIPTION=Sepolia was initially launched as a proof-of-authority testnet in October 2021 by Ethereum core developers.
REACT_APP_PROTOCOL_CHAIN_DESCRIPTION=Sepolia was initially launched as a proof-of-authority testnet in October 2021 by Ethereum core developers
REACT_APP_CHAIN_COIN=ETH
REACT_APP_SC_NAME=Sepolia Djed Osiris Dollar
REACT_APP_SC_SYMBOL=SOD
REACT_APP_RC_NAME=Sepolia Djed Osiris Reservecoin
REACT_APP_RC_SYMBOL=SOR
REACT_APP_SC_NAME=Sepolia Djed Tefnut Dollar
REACT_APP_SC_SYMBOL=STD
REACT_APP_RC_NAME=Sepolia Djed Tefnut Reservecoin
REACT_APP_RC_SYMBOL=STR
REACT_APP_LIMIT_PER_TXN=10000
REACT_APP_EVM_RESERVECOIN_ADDRESS=0xc61ac381F4F585fd194D3C5cE20B76826b960e5E
REACT_APP_EVM_STABLECOIN_ADDRESS=0x6b930182787F346F18666D167e8d32166dC5eFBD
REACT_APP_EVM_RESERVECOIN_ADDRESS=0x8F4577F6DdfA503ED2112cAdf6629C4ea4524a48
REACT_APP_EVM_STABLECOIN_ADDRESS=0x0B3861ec4a3afef02345F5d0CB058D061017ECD8

REACT_APP_LOGO_PATH=Logo_symbol.png
# Color Theme
REACT_APP_GRADIENT_THEME='gradient-theme-7'
REACT_APP_COLOR_THEME='green-dark'

REACT_APP_TERMS_OF_USE=terms-of-use-default
REACT_APP_LOGO_PATH=Logo_symbol.png

# Tefnut version flag (simplified Djed with no reserve ratio limits)
REACT_APP_SHU_VERSION=true
1 change: 1 addition & 0 deletions src/artifacts/DjedTefnut.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/molecules/CoinCard/CoinCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const CoinCard = ({
) : isShu ? (
<>
<div className="PriceInfo">
<span>Current Minimum Price</span>
<span>Sell Price (Min)</span>
<h3>
{minPriceAmount} {CHAIN_COIN}
</h3>
</div>

<div className="PriceInfo">
<span>Current Maximum Price</span>
<span>Buy Price (Max)</span>
<h3>
{maxPriceAmount} {CHAIN_COIN}
</h3>
Expand Down
4 changes: 0 additions & 4 deletions src/components/molecules/ReservesCard/ReservesCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const ReservesCard = ({
priceAmount,
equivalence,
reserveRatio,
reserveRatioMin,
reserveRatioMax,
showCurrentReserveRatio,
isShu
}) => (
Expand All @@ -28,8 +26,6 @@ const ReservesCard = ({
<p>≈ {equivalence}</p>
</div>
<div className="ReservesRatio">
<NumberItem amount={reserveRatioMin} label="Minimum Reserve Ratio" />
<NumberItem amount={reserveRatioMax} label="Maximum Reserve Ratio" />
{showCurrentReserveRatio && (
<NumberItem
amount={isShu ? `[${reserveRatio[0]} -- ${reserveRatio[1]}]` : reserveRatio}
Expand Down
69 changes: 2 additions & 67 deletions src/context/AppProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ import {
getSystemParams,
getAccountDetails,
getCoinBudgets,
calculateIsRatioBelowMax,
calculateIsRatioAboveMin,
calculateFutureScPrice,
getDjedShuContract,
getShuOracleContract,
getShuCoinDetails,
calculateFutureMinScPrice,
calculateFutureMaxScPrice
getShuCoinDetails
} from "../utils/ethereum";
import useInterval from "../utils/hooks/useInterval";
import {
ACCOUNT_DETAILS_REQUEST_INTERVAL,
COIN_DETAILS_REQUEST_INTERVAL
} from "../utils/constants";
import { BigNumber } from "ethers";

import {
flintWalletConnector,
Expand Down Expand Up @@ -261,60 +255,6 @@ export const AppProvider = ({ children }) => {
isWalletConnected && isVisible ? COIN_DETAILS_REQUEST_INTERVAL : null
);

const isRatioBelowMax = ({ scPrice, reserveBc }) => {
const scDecimals = BigNumber.from(decimals.scDecimals);
const totalScSupply = BigNumber.from(coinsDetails?.unscaledNumberSc);
const reserveRatioMax = BigNumber.from(systemParams?.reserveRatioMaxUnscaled);
const scDecimalScalingFactor = BigNumber.from(10).pow(scDecimals);
const thresholdSupplySC = BigNumber.from(systemParams.thresholdSupplySC);
return calculateIsRatioBelowMax({
scPrice,
reserveBc,
totalScSupply,
reserveRatioMax,
scDecimalScalingFactor,
thresholdSupplySC
});
};

const isRatioAboveMin = ({ scPrice, totalScSupply, reserveBc }) => {
const scDecimals = BigNumber.from(decimals.scDecimals);
const reserveRatioMin = BigNumber.from(systemParams?.reserveRatioMinUnscaled);
const scDecimalScalingFactor = BigNumber.from(10).pow(scDecimals);

return calculateIsRatioAboveMin({
scPrice,
reserveBc,
totalScSupply,
reserveRatioMin,
scDecimalScalingFactor
});
};

/**
* This function should prepare parameters for calculating future stableCoin price
* @param {string} amountBC The unscaled amount of BC (e.g. for 1BC, value should be 1 * 10^BC_DECIMALS)
* @param {string} amountSC The unscaled amount of StableCoin (e.g. for 1SC, value should be 1 * 10^SC_DECIMALS)
* @returns future stablecoin price as result of calculateFutureScPrice function
*/
const getFuturePrice = async ({ amountBC, amountSC, method }) => {
return method({
amountBC,
amountSC,
djedContract,
oracleContract,
stableCoinContract: coinContracts.stableCoin,
scDecimalScalingFactor: BigNumber.from(10).pow(decimals.scDecimals)
});
};

const getFutureScPrice = async (params) =>
getFuturePrice({ ...params, method: calculateFutureScPrice });
const getFutureMinScPrice = async (params) =>
getFuturePrice({ ...params, method: calculateFutureMinScPrice });
const getFutureMaxScPrice = async (params) =>
getFuturePrice({ ...params, method: calculateFutureMaxScPrice });

if (isLoading) {
return <FullPageSpinner />;
} else {
Expand Down Expand Up @@ -356,12 +296,7 @@ export const AppProvider = ({ children }) => {
redirectToNufi,
activeConnector,
account,
signer,
isRatioBelowMax,
isRatioAboveMin,
getFutureScPrice,
getFutureMinScPrice,
getFutureMaxScPrice
signer
}}
>
{children}
Expand Down
26 changes: 10 additions & 16 deletions src/routes/protocol.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "../utils/helpers";

export default function Protocol() {
const { coinsDetails, isShu, systemParams } = useAppProvider();
const { coinsDetails, isShu } = useAppProvider();

const scFloat = parseFloat(coinsDetails?.scaledNumberSc.replaceAll(",", ""));
const scConverted = getScAdaEquivalent(coinsDetails, scFloat);
Expand All @@ -31,13 +31,13 @@ export default function Protocol() {
<div className="ProtocolSection">
<div className="Left">
<h1>
<strong>Djed on {process.env.REACT_APP_BC}</strong>
<strong>Djed Tefnut on {process.env.REACT_APP_BC}</strong>
</h1>
<div className="DescriptionContainer">
<p>
Djed is a formally verified crypto-backed autonomous stablecoin protocol. It
has been researched since Q2 2020, its whitepaper has been released in
August 2021, and it has multiple{" "}
Djed Tefnut is a simplified version of the Djed protocol - a formally verified
crypto-backed autonomous stablecoin protocol. It has been researched since Q2 2020,
its whitepaper has been released in August 2021, and it has multiple{" "}
<a href="https://github.com/DjedAlliance" target="_blank" rel="noreferrer">
implementations
</a>{" "}
Expand All @@ -49,7 +49,11 @@ export default function Protocol() {
>
deployments
</a>
. Here you can interact with a{" "}
. Djed Tefnut simplifies the original Djed by removing minimum and maximum
reserve ratio restrictions, allowing unrestricted minting and redemption at any time.
</p>
<p>
Here you can interact with a{" "}
<a
href={`${process.env.REACT_APP_EXPLORER}/address/${
isShu
Expand All @@ -61,14 +65,6 @@ export default function Protocol() {
>
deployment
</a>{" "}
that uses{" "}
<a
href="https://github.com/DjedAlliance/Djed-Solidity/commits/Belus"
target="_blank"
rel="noreferrer"
>
these smart contracts
</a>{" "}
on {process.env.REACT_APP_BC}.
</p>
<p>
Expand Down Expand Up @@ -117,8 +113,6 @@ export default function Protocol() {
coinIcon="/coin-icon-three.png"
coinName="Reserves"
reserveRatio={coinsDetails?.percentReserveRatio}
reserveRatioMin={systemParams?.reserveRatioMin}
reserveRatioMax={systemParams?.reserveRatioMax}
showCurrentReserveRatio={Number(coinsDetails?.unscaledNumberSc) > 0}
isShu={isShu}
/>
Expand Down
63 changes: 6 additions & 57 deletions src/routes/reservecoin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ import {
checkSellableRc,
verifyTx,
BC_DECIMALS,
calculateTxFees,
isTxLimitReached,
DJED_ADDRESS,
FEE_UI_UNSCALED,
UI
} from "../utils/ethereum";
import { BigNumber, ethers } from "ethers";
import { ethers } from "ethers";
import {
ConnectWSCButton,
TransactionConfigWSCProvider,
Expand All @@ -56,13 +55,7 @@ export default function ReserveCoin() {
account,
signer,
systemParams,
isRatioBelowMax,
isRatioAboveMin,
isShu,
coinContracts,
getFutureScPrice,
getFutureMinScPrice,
getFutureMaxScPrice
coinContracts
} = useAppProvider();
const { isWSCConnected } = useWSCProvider();
const { setOpen } = useWSCModal();
Expand Down Expand Up @@ -97,23 +90,6 @@ export default function ReserveCoin() {
amountScaled
);

const futureSCPrice = isShu
? await getFutureMinScPrice({
amountBC: data.totalUnscaled,
amountSC: 0
})
: await getFutureScPrice({
amountBC: data.totalUnscaled,
amountSC: 0
});

const { f } = calculateTxFees(data.totalUnscaled, systemParams?.feeUnscaled, 0);
const isRatioBelowMaximum = isRatioBelowMax({
scPrice: BigNumber.from(futureSCPrice),
reserveBc: BigNumber.from(coinsDetails?.unscaledReserveBc).add(
BigNumber.from(data.totalUnscaled).add(f)
)
});
const bcUsdEquivalent = calculateBcUsdEquivalent(
coinsDetails,
parseFloat(data.totalScaled.replaceAll(",", ""))
Expand All @@ -138,8 +114,6 @@ export default function ReserveCoin() {
)
) {
setBuyValidity(TRANSACTION_VALIDITY.INSUFFICIENT_BC);
} else if (!isRatioBelowMaximum) {
setBuyValidity(TRANSACTION_VALIDITY.RESERVE_RATIO_HIGH);
} else {
checkBuyableRc(
djedContract,
Expand Down Expand Up @@ -171,23 +145,6 @@ export default function ReserveCoin() {
coinsDetails,
parseFloat(data.amountScaled.replaceAll(",", ""))
).replaceAll(",", "");
const futureSCPrice = isShu
? await getFutureMaxScPrice({
amountBC: data.totalUnscaled,
amountSC: 0
})
: await getFutureScPrice({
amountBC: data.totalUnscaled,
amountSC: 0
});
const { f } = calculateTxFees(data.totalUnscaled, systemParams?.feeUnscaled, 0);
const isRatioAboveMinimum = isRatioAboveMin({
totalScSupply: BigNumber.from(coinsDetails?.unscaledNumberSc),
scPrice: BigNumber.from(futureSCPrice),
reserveBc: BigNumber.from(coinsDetails?.unscaledReserveBc).sub(
BigNumber.from(data.totalUnscaled).sub(f)
)
});

setTradeData(data);
if (!isWalletConnected) {
Expand All @@ -208,8 +165,6 @@ export default function ReserveCoin() {
)
) {
setSellValidity(TRANSACTION_VALIDITY.INSUFFICIENT_RC);
} else if (!isRatioAboveMinimum) {
setSellValidity(TRANSACTION_VALIDITY.RESERVE_RATIO_LOW);
} else {
checkSellableRc(
djedContract,
Expand Down Expand Up @@ -322,7 +277,7 @@ export default function ReserveCoin() {
<div className="DescriptionContainer">
<p>
A ReserveCoin represents a portion of the surplus of the underlying reserves
of {process.env.REACT_APP_CHAIN_COIN} in the Djed protocol. As such,
of {process.env.REACT_APP_CHAIN_COIN} in the Djed Tefnut protocol. As such,
ReserveCoins have a leveraged volatile price that increases when the price
of {process.env.REACT_APP_CHAIN_COIN} increases and decreases when the price
of {process.env.REACT_APP_CHAIN_COIN} decreases. Furthermore, ReserveCoin
Expand All @@ -331,15 +286,9 @@ export default function ReserveCoin() {
surplus.
</p>
<p>
You are allowed to buy ReserveCoins, as long as the reserve ratio remains
below the maximum of {systemParams?.reserveRatioMax}. This prevents
excessive dilution of previous ReserveCoin holders. This restriction only
applies when the StableCoin supply is above 500000.
</p>
<p>
You are allowed to sell ReserveCoins, as long as the reserve ratio remains
above the minimum of {systemParams?.reserveRatioMin}. This aims to ensure
that all StableCoins remain sufficiently backed.
You are always allowed to buy and sell ReserveCoins. Djed Tefnut has no minimum
or maximum reserve ratio restrictions, allowing unrestricted minting and
redemption of ReserveCoins at any time.
</p>
<p>
There is a limit of {process.env.REACT_APP_LIMIT_PER_TXN} USD worth of{" "}
Expand Down
Loading