Skip to content

Commit

Permalink
feat: renamed debt, debtcoupon, bonding
Browse files Browse the repository at this point in the history
  • Loading branch information
bojan07 committed Oct 17, 2023
1 parent ad9dd55 commit 5198378
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 190 deletions.
10 changes: 5 additions & 5 deletions packages/dapp/components/lib/contracts-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function ensureERC1155Allowance(logName: string, contract: Contract
// const toEtherNum = (n: BigNumber) => +n.toString() / 1e18;
// const toNum = (n: BigNumber) => +n.toString();

// export async function logBondingUbqInfo(contracts: Contracts) {
// export async function logStakingUbqInfo(contracts: Contracts) {
// const reserves = await contracts.ugovUadPair.getReserves();
// const ubqReserve = +reserves.reserve0.toString();
// const uadReserve = +reserves.reserve1.toString();
Expand All @@ -58,7 +58,7 @@ export async function ensureERC1155Allowance(logName: string, contract: Contract
// const actualUbqPerBlock = toEtherNum(ubqPerBlock.mul(ubqMultiplier).div(`${1e18}`));
// console.log("Actual UBQ per block", actualUbqPerBlock);
// console.log("Extra UBQ per block to treasury", actualUbqPerBlock / ugovDivider);
// const blockCountInAWeek = toNum(await contracts.bonding.blockCountInAWeek());
// const blockCountInAWeek = toNum(await contracts.staking.blockCountInAWeek());
// console.log("Block count in a week", blockCountInAWeek);

// const ubqPerWeek = actualUbqPerBlock * blockCountInAWeek;
Expand All @@ -67,7 +67,7 @@ export async function ensureERC1155Allowance(logName: string, contract: Contract

// const DAYS_IN_A_YEAR = 365.2422;
// const totalShares = toEtherNum(await contracts.masterChef.totalShares());
// console.log("Total Bonding Shares", totalShares);
// console.log("Total Staking Shares", totalShares);
// const usdPerWeek = ubqPerWeek * ubqPrice;
// const usdPerDay = usdPerWeek / 7;
// const usdPerYear = usdPerDay * DAYS_IN_A_YEAR;
Expand All @@ -77,11 +77,11 @@ export async function ensureERC1155Allowance(logName: string, contract: Contract
// const usdAsLp = 0.7460387929;
// const bigNumberOneUsdAsLp = ethers.utils.parseEther(usdAsLp.toString());

// const bondingDiscountMultiplier = await contracts.bonding.bondingDiscountMultiplier();
// const stakingDiscountMultiplier = await contracts.staking.stakingDiscountMultiplier();
// const sharesResults = await Promise.all(
// [1, 50, 100, 208].map(async (i) => {
// const weeks = BigNumber.from(i.toString());
// const shares = toEtherNum(await contracts.ubiquityFormulas.durationMultiply(bigNumberOneUsdAsLp, weeks, bondingDiscountMultiplier));
// const shares = toEtherNum(await contracts.ubiquityFormulas.durationMultiply(bigNumberOneUsdAsLp, weeks, stakingDiscountMultiplier));
// return [i, shares];
// })
// );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDebtCouponManagerContract, getUbiquityManagerContract } from "@/components/utils/contracts";
import { getCreditNftManagerContract, getUbiquityManagerContract } from "@/components/utils/contracts";
import { useMemo } from "react";
import useDeployedAddress from "../use-deployed-address";
import useWeb3Provider from "../use-web-3-provider";
Expand All @@ -7,13 +7,13 @@ export type DeployedContracts = ReturnType<typeof useDeployedContracts> | null;
const useDeployedContracts = () => {
const provider = useWeb3Provider();
// cspell: disable-next-line
const [addr1, addr2] = useDeployedAddress("UbiquityAlgorithmicDollarManager", "DebtCouponManager");
const [addr1, addr2] = useDeployedAddress("UbiquityAlgorithmicDollarManager", "CreditNftManager");
return useMemo(
() =>
addr1 && addr2 && provider
? {
manager: getUbiquityManagerContract(addr1, provider),
debtCouponManager: getDebtCouponManagerContract(addr2, provider),
creditNftManager: getCreditNftManagerContract(addr2, provider),
}
: null,
[addr1, addr2, provider]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
getStakingShareContract,
getBondingV2Contract,
getDebtCouponContract,
getStakingV2Contract,
getCreditNftContract,
getDollarMintCalculatorContract,
getERC20Contract,
getICouponsForDollarsCalculatorContract,
getINftsForDollarsCalculatorContract,
getIMetaPoolContract,
getIUARForDollarsCalculatorContract,
getMasterChefV2Contract,
Expand Down Expand Up @@ -88,13 +88,13 @@ async function connectManagerContracts(manager: ManagerFacet, provider: NonNulla
governanceToken: getGovernanceContract(governanceToken, provider),
_3crvToken: getERC20Contract(_3crvToken, provider),
stakingToken: getStakingShareContract(stakingToken, provider),
creditNft: getDebtCouponContract(creditNft, provider),
staking: getBondingV2Contract(staking, provider),
creditNft: getCreditNftContract(creditNft, provider),
staking: getStakingV2Contract(staking, provider),
masterChef: getMasterChefV2Contract(masterChef, provider),
sushiSwapPool: sushiSwapPoolContract,
governanceMarket: governanceMarket,
ubiquityFormulas: getUbiquityFormulasContract(ubiquityFormulas, provider),
creditNftCalculator: getICouponsForDollarsCalculatorContract(creditNftCalculator, provider),
creditNftCalculator: getINftsForDollarsCalculatorContract(creditNftCalculator, provider),
creditCalculator: getIUARForDollarsCalculatorContract(creditCalculator, provider),
};
}
Expand Down
22 changes: 11 additions & 11 deletions packages/dapp/components/monitor/token-monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import useEffectAsync from "../lib/hooks/use-effect-async";

type State = null | TokenMonitorProps;
type TokenMonitorProps = {
debtCouponAddress: string;
debtCouponManagerAddress: string;
totalOutstandingDebt: number;
creditNftAddress: string;
creditNftManagerAddress: string;
totalOutstandingCredit: number;
totalRedeemable: number;
};

Expand All @@ -24,15 +24,15 @@ const TokenMonitorContainer = () => {
const contracts = await protocolContracts;
if (contracts && contracts.creditNftManagerFacet) {
if (creditNft && dollarToken) {
const [totalOutstandingDebt, totalRedeemable] = await Promise.all([
creditNft.getTotalOutstandingDebt(),
const [totalOutstandingCredit, totalRedeemable] = await Promise.all([
creditNft.getTotalOutstandingCredit(),
dollarToken.balanceOf(contracts.creditNftManagerFacet.address),
]);

setTokenMonitorProps({
debtCouponAddress: creditNft.address,
debtCouponManagerAddress: contracts.creditNftManagerFacet.address,
totalOutstandingDebt: +formatEther(totalOutstandingDebt),
creditNftAddress: creditNft.address,
creditNftManagerAddress: contracts.creditNftManagerFacet.address,
totalOutstandingCredit: +formatEther(totalOutstandingCredit),
totalRedeemable: +formatEther(totalRedeemable),
});
}
Expand All @@ -47,12 +47,12 @@ const TokenMonitor = (props: TokenMonitorProps) => {
<div className="panel">
<h2>Credit Monitor</h2>
<div>
<Balance title="Total Outstanding" unit="uCR-NFT" balance={props.totalOutstandingDebt} />
{/* <Address title="Debt Coupon Manager" address={props.debtCouponManagerAddress} /> */}
<Balance title="Total Outstanding" unit="uCR-NFT" balance={props.totalOutstandingCredit} />
{/* <Address title="Credit Nft Manager" address={props.creditNftManagerAddress} /> */}
</div>
<div>
<Balance title="Total Redeemable" unit="uCR-NFT" balance={props.totalRedeemable} />
{/* <Address title="Debt Coupon" address={props.debtCouponAddress} /> */}
{/* <Address title="Credit Nft" address={props.creditNftAddress} /> */}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const UcrNftGenerator = () => {
const protocolContracts = useProtocolContracts();

const [inputVal, setInputVal] = useState("");
const [expectedDebtCoupon, setExpectedDebtCoupon] = useState<BigNumber | null>(null);
const [expectedCreditNft, setExpectedCreditNft] = useState<BigNumber | null>(null);

if (!walletAddress || !signer) {
return <span>Connect wallet</span>;
Expand All @@ -30,7 +30,7 @@ const UcrNftGenerator = () => {
return <span>· · ·</span>;
}

const depositDollarForDebtCoupons = async (amount: BigNumber) => {
const depositDollarForCreditNfts = async (amount: BigNumber) => {
const contracts = await protocolContracts;
if (contracts.dollarToken && contracts.creditNftManagerFacet) {
// cspell: disable-next-line
Expand All @@ -46,7 +46,7 @@ const UcrNftGenerator = () => {
// cspell: disable-next-line
doTransaction("Burning uAD...", async () => {
setInputVal("");
await depositDollarForDebtCoupons(amount);
await depositDollarForCreditNfts(amount);
});
}
};
Expand All @@ -56,8 +56,8 @@ const UcrNftGenerator = () => {
setInputVal(val);
const amount = extractValidAmount(val);
if (amount && contracts.creditNftRedemptionCalculatorFacet) {
setExpectedDebtCoupon(null);
setExpectedDebtCoupon(await contracts.creditNftRedemptionCalculatorFacet.connect(signer).getCreditNftAmount(amount));
setExpectedCreditNft(null);
setExpectedCreditNft(await contracts.creditNftRedemptionCalculatorFacet.connect(signer).getCreditNftAmount(amount));
}
};

Expand All @@ -76,7 +76,7 @@ const UcrNftGenerator = () => {
{/* cspell: disable-next-line */}
Redeem uAD for uCR-NFT
</Button>
{expectedDebtCoupon && inputVal && <p>expected uCR-NFT {formatEther(expectedDebtCoupon)}</p>}
{expectedCreditNft && inputVal && <p>expected uCR-NFT {formatEther(expectedCreditNft)}</p>}
</div>
);
};
Expand Down
Loading

0 comments on commit 5198378

Please sign in to comment.