Skip to content

Commit

Permalink
fixed bugs and created ci/cd pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
yogesh0509 committed Sep 16, 2024
1 parent 5f73eee commit dc153ce
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
# run: npm run test

- name: Prepare production build
run: npm run build:milkomeda-c1-testnet
run: npm run build
9 changes: 7 additions & 2 deletions .github/workflows/codepreview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Create preview environment

on:
pull_request:
branches: [main, milkomeda-c1-testnet]
branches: [main]
push:
branches: [main, milkomeda-c1-testnet]
branches: [main]

concurrency:
# The preview script can't handle concurrent deploys
Expand Down Expand Up @@ -55,6 +55,11 @@ jobs:
if: ${{ (github.head_ref || github.ref_name) == 'main' }}
run: CI=false npm run build:milkomeda-c1

# CI=false disables reporting warnings as errors
- name: Prepare build (main)
if: ${{ (github.head_ref || github.ref_name) == 'main' }}
run: CI=false npm run build:shu-mordor

- name: Create SSH key
run: |
mkdir -p ~/.ssh/
Expand Down
2 changes: 1 addition & 1 deletion env/milkomeda-testnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REACT_APP_CHAIN_ID=200101
REACT_APP_DJED_ADDRESS=0xc4C0669Ea7BFF70A6cFa5905A0Ba487fC181Dc37
REACT_APP_FEE_UI=0
REACT_APP_UI=0x0232556C83791b8291E9b23BfEa7d67405Bd9839
REACT_APP_MILKOMEDA_C1_EXPLORER=https://explorer-devnet-cardano-evm.c1.milkomeda.com/
REACT_APP_EXPLORER=https://explorer-devnet-cardano-evm.c1.milkomeda.com/
REACT_APP_BC=Milkomeda
REACT_APP_PROTOCOL_CHAIN_DESCRIPTION=Milkomeda is the EVM-compatible chain of the Cardano ecosystem. Its native currency is mADA, a bridged version of Cardano`s ADA
REACT_APP_CHAIN_COIN=mADA
Expand Down
2 changes: 1 addition & 1 deletion env/milkomeda.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REACT_APP_CHAIN_ID=2001
REACT_APP_DJED_ADDRESS=0x67A30B399F5Ed499C1a6Bc0358FA6e42Ea4BCe76
REACT_APP_FEE_UI=0.01
REACT_APP_UI=0x6AfD84920971Ba96118a302deaA6d11e7ce18b03
REACT_APP_MILKOMEDA_C1_EXPLORER=https://explorer-mainnet-cardano-evm.c1.milkomeda.com/
REACT_APP_EXPLORER=https://explorer-mainnet-cardano-evm.c1.milkomeda.com/
REACT_APP_BC=Milkomeda
REACT_APP_PROTOCOL_CHAIN_DESCRIPTION=Milkomeda is the EVM-compatible chain of the Cardano ecosystem. Its native currency is mADA, a bridged version of Cardano`s ADA
REACT_APP_CHAIN_COIN=mADA
Expand Down
8 changes: 4 additions & 4 deletions env/shu-mordor.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
###############
REACT_APP_BLOCKCHAIN_URI=https://rpc.mordor.etccooperative.org
REACT_APP_CHAIN_ID=63
REACT_APP_DJED_ADDRESS=0x7535E14d98c8a8744DcFe216Aa0af3b95c76a5E3
REACT_APP_DJED_SHU_ADDRESS=0x7535E14d98c8a8744DcFe216Aa0af3b95c76a5E3
REACT_APP_DJED_ADDRESS=0x1F09D7d259073414a81E5663C74a76182B05852D
REACT_APP_DJED_SHU_ADDRESS=0x1F09D7d259073414a81E5663C74a76182B05852D
REACT_APP_FEE_UI=0
REACT_APP_UI=0x0232556C83791b8291E9b23BfEa7d67405Bd9839
REACT_APP_EXPLORER=https://etc-mordor.blockscout.com/
Expand All @@ -16,8 +16,8 @@ REACT_APP_SC_SYMBOL=ECSD
REACT_APP_RC_NAME=Ethereum Classic Reserve Surplus Share
REACT_APP_RC_SYMBOL=ECRS
REACT_APP_LIMIT_PER_TXN=10000
REACT_APP_EVM_RESERVECOIN_ADDRESS=0x81D6C9F0dd8823Ae664B9E43e25Bf3e6A79dC351
REACT_APP_EVM_STABLECOIN_ADDRESS=0x4746e9c3cB00f70Af6e25a699AE3490e43207Fd9
REACT_APP_EVM_RESERVECOIN_ADDRESS=0x851D24a058fED2b0458c875BFb512BAc04dDeE09
REACT_APP_EVM_STABLECOIN_ADDRESS=0x6b7ff59Ddb17610146c2666Dd6eB402b3BC5C59D

# Color Theme
REACT_APP_GRADIENT_THEME='gradient-theme-7'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"scripts": {
"start": "craco start",
"build": "craco build",
"build:milkomeda-testnet": "npx -y env-cmd -f ./env/milkomeda-testnet.env npm run build",
"build:milkomeda-c1-testnet": "npx -y env-cmd -f ./env/milkomeda-testnet.env npm run build",
"build:sepolia": "npx -y env-cmd -f ./env/sepolia.env npm run build",
"build:milkomeda": "npx -y env-cmd -f ./env/milkomeda.env npm run build",
"build:milkomeda-c1": "npx -y env-cmd -f ./env/milkomeda.env npm run build",
"build:mordor": "npx -y env-cmd -f ./env/mordor.env npm run build",
"build:ethereum-classic": "npx -y env-cmd -f ./env/ethereum-classic.env npm run build",
"build:shu-mordor": "npx -y env-cmd -f ./env/shu-mordor.env npm run build",
Expand Down
6 changes: 4 additions & 2 deletions src/components/molecules/CoinCard/CoinCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const CoinCard = ({
coinIcon,
coinName,
priceAmount,
minPriceAmount,
maxPriceAmount,
sellPriceAmount,
circulatingAmount,
tokenName,
Expand Down Expand Up @@ -38,14 +40,14 @@ const CoinCard = ({
<div className="PriceInfo">
<span>Current Minimum Price</span>
<h3>
{priceAmount} {CHAIN_COIN}
{minPriceAmount} {CHAIN_COIN}
</h3>
</div>

<div className="PriceInfo">
<span>Current Maximum Price</span>
<h3>
{priceAmount} {CHAIN_COIN}
{maxPriceAmount} {CHAIN_COIN}
</h3>
</div>
</>
Expand Down
8 changes: 6 additions & 2 deletions src/components/molecules/ReservesCard/ReservesCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const ReservesCard = ({
reserveRatio,
reserveRatioMin,
reserveRatioMax,
showCurrentReserveRatio
showCurrentReserveRatio,
isShu
}) => (
<div className="ReservesCard">
<CoinIndicator coinIcon={coinIcon} coinName={coinName} />
Expand All @@ -30,7 +31,10 @@ const ReservesCard = ({
<NumberItem amount={reserveRatioMin} label="Minimum Reserve Ratio" />
<NumberItem amount={reserveRatioMax} label="Maximum Reserve Ratio" />
{showCurrentReserveRatio && (
<NumberItem amount={reserveRatio} label="Current Reserve Ratio" />
<NumberItem
amount={isShu ? `[${reserveRatio[0]} -- ${reserveRatio[1]}]` : reserveRatio}
label="Current Reserve Ratio"
/>
)}
</div>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/routes/protocol.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export default function Protocol() {
</a>
. Here you can interact with a{" "}
<a
href={`${process.env.REACT_APP_MILKOMEDA_C1_EXPLORER}/address/${process.env.REACT_APP_DJED_ADDRESS}`}
href={`${process.env.REACT_APP_EXPLORER}/address/${
isShu
? process.env.REACT_APP_DJED_SHU_ADDRESS
: process.env.REACT_APP_DJED_ADDRESS
}`}
target="_blank"
rel="noreferrer"
>
Expand Down Expand Up @@ -116,6 +120,7 @@ export default function Protocol() {
reserveRatioMin={systemParams?.reserveRatioMin}
reserveRatioMax={systemParams?.reserveRatioMax}
showCurrentReserveRatio={Number(coinsDetails?.unscaledNumberSc) > 0}
isShu={isShu}
/>
</div>
</div>
Expand Down
25 changes: 12 additions & 13 deletions src/utils/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export const getShuCoinDetails = async (
scDecimals,
rcDecimals
) => {
console.log(await web3Promise(djed, "rcBuyingPrice", 0));
const [
[scaledNumberSc, unscaledNumberSc],
[scaledMinPriceSc, unscaledMinPriceSc],
Expand All @@ -183,10 +182,10 @@ export const getShuCoinDetails = async (
let scaledSellPriceRc = emptyValue;
let unscaledSellPriceRc = emptyValue;
let percentReserveRatio = emptyValue;
const scaledScExchangeRate = scaledPromise(
(unscaledMinPriceSc + unscaledMaxPriceSc) / 2,
BC_DECIMALS
);
const scaledScExchangeRate = (
(parseFloat(scaledMinPriceSc) + parseFloat(scaledMaxPriceSc)) /
2
).toString();

//Check total stablecoin supply
if (!BigNumber.from(unscaledNumberRc).isZero()) {
Expand All @@ -197,10 +196,10 @@ export const getShuCoinDetails = async (
}
//Check total reservecoin supply
if (!BigNumber.from(unscaledNumberSc).isZero()) {
percentReserveRatio = await percentScaledPromise(
web3Promise(djed, "ratio"),
SCALING_DECIMALS
);
percentReserveRatio = [
await percentScaledPromise(web3Promise(djed, "ratioMin"), SCALING_DECIMALS),
await percentScaledPromise(web3Promise(djed, "ratioMax"), SCALING_DECIMALS)
];
}
return {
scaledNumberSc,
Expand Down Expand Up @@ -668,16 +667,16 @@ const calculateFuturePrice = async ({
web3Promise(djedContract, "R", 0)
]);

const price = readPriceMethod === "readData" ? scTargetPrice : scTargetPrice[0];

const futureScSupply = BigNumber.from(scSupply).add(BigNumber.from(amountSC));
const futureRatio = BigNumber.from(ratio).add(BigNumber.from(amountBC));

if (futureScSupply.isZero()) {
return scTargetPrice;
return price;
} else {
const futurePrice = futureRatio.mul(scDecimalScalingFactor).div(futureScSupply);
return BigNumber.from(scTargetPrice).lt(futurePrice)
? scTargetPrice
: futurePrice.toString();
return BigNumber.from(price).lt(futurePrice) ? price : futurePrice.toString();
}
} catch (error) {
console.log("calculateFuturePrice error", error);
Expand Down

0 comments on commit dc153ce

Please sign in to comment.