Skip to content

Commit

Permalink
fixed logo
Browse files Browse the repository at this point in the history
  • Loading branch information
hckrg committed Jul 17, 2023
1 parent 9d9e67f commit a0730d1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
window.Buffer = Buffer;
</script>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Basket Protocol</title>
</head>
<body>
<div id="root"></div>
Expand Down
Binary file added public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

11 changes: 10 additions & 1 deletion src/components/IssueModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getIssueCode } from "../cadence/transactions/IssueBasket"
import * as fcl from '@onflow/fcl'
import { singerAuth, userSign } from "../utils/authz"
import { subscribeTxStatus } from "../utils/subscribeTxStatus"
import classNames from "classnames"

export type IssueTokenModalProps = {
onClose: () => void,
Expand All @@ -21,16 +22,21 @@ function IssueTokenModal({ onClose, basketDetails, type}: IssueTokenModalProps)
const msg = type == "issue" ? "Buy": "Redeem"
const [value, setValue] = useState(0)
const [totalFlow, setTotalFlow] = useState("0")
const [disable, setDisable] = useState(true)

const udTokenAmount = basketDetails?.underlyingTokens.map(u => (Number(u.amount)*value).toFixed(2))
const udTokenAddress = basketDetails?.underlyingTokens.map(u => u.tokenIdentifier)
const slippage = 10 // 5%
const adminAuth = singerAuth(admin, adminKey)

const calculateFlow = async() => {
setDisable(true)
if (udTokenAddress && udTokenAmount){
const data = await getAmountsIn(udTokenAmount, udTokenAddress)
const totalAmount = (data.map((d: any) => Number(d)).reduce((x: any, y: any) => x + y, 0) * (100 + slippage)) / 100
if (totalAmount && totalAmount > 0 && value > 0) {
setDisable(false)
}
setTotalFlow(totalAmount.toFixed(2))
}
}
Expand Down Expand Up @@ -99,7 +105,10 @@ function IssueTokenModal({ onClose, basketDetails, type}: IssueTokenModalProps)
<p>{totalFlow ?? 0} FLOW</p>
</div>
</div>
<button onClick={handleIssue} className="bg-custom-500 text-white-100 font-bold py-2 my-2 px-6 rounded-lg cursor-pointer w-full">{msg}</button>
<button disabled={disable} onClick={handleIssue} className={
classNames("bg-custom-500 text-white-100 font-bold py-2 my-2 px-6 rounded-lg cursor-pointer w-5/6", {
"bg-gray-400": disable
})}>{msg}</button>
</div>
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/components/RedeemModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useRecoilValue } from "recoil"
import { userAtom } from "../App"
import { subscribeTxStatus } from "../utils/subscribeTxStatus"
import { getBasketBalance } from "../cadence/scripts/getFlowBalance"
import classNames from "classnames"

export type IssueTokenModalProps = {
onClose: () => void,
Expand All @@ -25,6 +26,8 @@ function RedeemTokenModal({ onClose, basketDetails}: IssueTokenModalProps) {
const [value, setValue] = useState(0)
const [totalFlow, setTotalFlow] = useState("0")
const [amountOut, setAmountOut] = useState<string[]>([])
const [disable, setDisable] = useState(true)

const user = useRecoilValue(userAtom)
const [tokenBal, setTokenBal] = useState<string>();
const udTokenAmount = basketDetails?.underlyingTokens.map(u => (Number(u.amount)*value).toFixed(2))
Expand All @@ -33,9 +36,13 @@ function RedeemTokenModal({ onClose, basketDetails}: IssueTokenModalProps) {
const adminAuth = singerAuth(admin, adminKey)

const calculateFlow = async() => {
setDisable(true)
if (udTokenAddress && udTokenAmount){
const data = await getAmountsOut(udTokenAmount, udTokenAddress)
const totalAmount = (data.map((d: any) => Number(d)).reduce((x: any, y: any) => x + y, 0) * (100 - slippage)) / 100
if (totalAmount && totalAmount > 0 && value > 0) {
setDisable(false)
}
setTotalFlow(totalAmount.toFixed(2))
setAmountOut(data.map((d: any) => Number(d)* (100 - slippage) / 100).map((p: any) => p.toFixed(2)))
}
Expand Down Expand Up @@ -109,7 +116,10 @@ function RedeemTokenModal({ onClose, basketDetails}: IssueTokenModalProps) {
<p>{totalFlow ?? 0} FLOW</p>
</div>
</div>
<button onClick={handleIssue} className="bg-custom-500 text-white-100 font-bold py-2 my-2 px-6 rounded-lg cursor-pointer w-5/6">Redeem</button>
<button disabled={disable} onClick={handleIssue}
className={classNames("bg-custom-500 text-white-100 font-bold py-2 my-2 px-6 rounded-lg cursor-pointer w-5/6", {
"bg-gray-400": disable
})}>Redeem</button>
</div>
</div>
)
Expand Down

0 comments on commit a0730d1

Please sign in to comment.