Skip to content

Commit

Permalink
refactor: bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
malijss committed Jun 8, 2022
1 parent f854f92 commit 388e67a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 539 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function SwapPage({ onSwitch }: { onSwitch: any }) {
const debouncedAmountIn = useDebounce(amountIn, 500)
const deiCurrency = DEI_TOKEN
const bdeiCurrency = BDEI_TOKEN
const deiCurrencyBalance = useCurrencyBalance(account ?? undefined, deiCurrency)
const bDeiCurrencyBalance = useCurrencyBalance(account ?? undefined, bdeiCurrency)
const { amountOut } = useSwapAmountsOut(debouncedAmountIn, deiCurrency)

// Amount typed in either fields
Expand All @@ -71,9 +71,9 @@ export default function SwapPage({ onSwitch }: { onSwitch: any }) {
}, [amountOut, deiCurrency])

const insufficientBalance = useMemo(() => {
if (!deiAmount) return false
return deiCurrencyBalance?.lessThan(deiAmount)
}, [deiCurrencyBalance, deiAmount])
if (!bdeiAmount) return false
return bDeiCurrencyBalance?.lessThan(bdeiAmount)
}, [bDeiCurrencyBalance, bdeiAmount])

const {
state: redeemCallbackState,
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function SwapPage({ onSwitch }: { onSwitch: any }) {
return null
}
if (insufficientBalance) {
return <RedeemButton disabled>Insufficient {deiCurrency?.symbol} Balance</RedeemButton>
return <RedeemButton disabled>Insufficient {bdeiCurrency?.symbol} Balance</RedeemButton>
}
if (awaitingRedeemConfirmation) {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useSwapCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function useSwapCallback(

const methodName = 'swap'

const subtractSlippage = toBN(toHex(bdeiAmount.quotient))
const subtractSlippage = toBN(toHex(deiAmount.quotient))
.multipliedBy((100 - Number(slippage)) / 100)
.toFixed(0, 1)

Expand Down Expand Up @@ -79,8 +79,8 @@ export default function useSwapCallback(
return {
state: RedeemCallbackState.VALID,
error: null,
callback: async function onRedeem(): Promise<string> {
console.log('onRedeem callback')
callback: async function onSwap(): Promise<string> {
console.log('onSwap callback')
const call = constructCall()
const { address, calldata, value } = call

Expand Down
7 changes: 4 additions & 3 deletions src/pages/deibonds/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState } from 'react'
import styled from 'styled-components'

import Hero, { HeroSubtext } from 'components/Hero'
import Disclaimer from 'components/Disclaimer'
import { Navigation, NavigationTypes } from 'components/StableCoin'
import Mint from './mint'
import Swap from './swap'
import Redeem from './redeem'
import Mint from 'components/App/Bonds/mint'
import Redeem from 'components/App/Bonds/redeem'
import Swap from 'components/App/Bonds/swap'

const Container = styled.div`
display: flex;
Expand Down
329 changes: 0 additions & 329 deletions src/pages/deibonds/index2.tsx

This file was deleted.

Loading

1 comment on commit 388e67a

@vercel
Copy link

@vercel vercel bot commented on 388e67a Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.