1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

move all pool copy into content data file

This commit is contained in:
Matthias Kretschmann 2020-10-14 19:08:46 +02:00
parent abc70b9cae
commit 287eea3c94
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 112 additions and 25 deletions

26
content/price.json Normal file
View File

@ -0,0 +1,26 @@
{
"pool": {
"tooltips": {
"price": "Explain how this price is determined...",
"liquidity": "Explain what this represents, advantage of providing liquidity..."
},
"add": {
"title": "Add Liquidity",
"output": {
"titleIn": "You will receive",
"titleOut": "You will earn"
},
"action": "Supply"
},
"remove": {
"title": "Remove Liquidity",
"simple": "Set the amount of your pool shares to spend. You will get the equivalent value in OCEAN, limited to maximum amount for pool protection.",
"advanced": "Set the amount of your pool shares to spend. You will get OCEAN and Datatokens equivalent to your pool share, without any limit.",
"output": {
"titleIn": "You will spend",
"titleOut": "You will receive"
},
"action": "Remove"
}
}
}

View File

@ -11,6 +11,29 @@ import PriceUnit from '../../../atoms/Price/PriceUnit'
import Actions from './Actions' import Actions from './Actions'
import Tooltip from '../../../atoms/Tooltip' import Tooltip from '../../../atoms/Tooltip'
import { ReactComponent as Caret } from '../../../../images/caret.svg' import { ReactComponent as Caret } from '../../../../images/caret.svg'
import { graphql, useStaticQuery } from 'gatsby'
const contentQuery = graphql`
query PoolAddQuery {
content: allFile(filter: { relativePath: { eq: "price.json" } }) {
edges {
node {
childContentJson {
pool {
add {
output {
titleIn
titleOut
}
action
}
}
}
}
}
}
}
`
export default function Add({ export default function Add({
setShowAdd, setShowAdd,
@ -29,6 +52,9 @@ export default function Add({
dtSymbol: string dtSymbol: string
dtAddress: string dtAddress: string
}): ReactElement { }): ReactElement {
const data = useStaticQuery(contentQuery)
const content = data.content.edges[0].node.childContentJson.pool.add
const { ocean, accountId, balance } = useOcean() const { ocean, accountId, balance } = useOcean()
const [amount, setAmount] = useState('') const [amount, setAmount] = useState('')
const [txId, setTxId] = useState<string>('') const [txId, setTxId] = useState<string>('')
@ -93,7 +119,7 @@ export default function Add({
return ( return (
<> <>
<Header title="Add Liquidity" backAction={() => setShowAdd(false)} /> <Header title={content.title} backAction={() => setShowAdd(false)} />
<div className={styles.addInput}> <div className={styles.addInput}>
<div className={styles.userLiquidity}> <div className={styles.userLiquidity}>
@ -138,12 +164,12 @@ export default function Add({
<div className={styles.output}> <div className={styles.output}>
<div> <div>
<p>You will receive</p> <p>{content.output.titleIn}</p>
<Token symbol="pool shares" balance={newPoolTokens} /> <Token symbol="pool shares" balance={newPoolTokens} />
<Token symbol="% of pool" balance={newPoolShare} /> <Token symbol="% of pool" balance={newPoolShare} />
</div> </div>
<div> <div>
<p>You will earn</p> <p>{content.output.titleOut}</p>
<Token symbol="% swap fee" balance={swapFee} /> <Token symbol="% swap fee" balance={swapFee} />
</div> </div>
</div> </div>
@ -151,7 +177,7 @@ export default function Add({
<Actions <Actions
isLoading={isLoading} isLoading={isLoading}
loaderMessage="Adding Liquidity..." loaderMessage="Adding Liquidity..."
actionName="Supply" actionName={content.action}
action={handleAddLiquidity} action={handleAddLiquidity}
txId={txId} txId={txId}
/> />

View File

@ -15,13 +15,31 @@ import Token from './Token'
import FormHelp from '../../../atoms/Input/Help' import FormHelp from '../../../atoms/Input/Help'
import Button from '../../../atoms/Button' import Button from '../../../atoms/Button'
import { getMaxValuesRemove } from './utils' import { getMaxValuesRemove } from './utils'
import { graphql, useStaticQuery } from 'gatsby'
const help = { const contentQuery = graphql`
simple: query PoolRemoveQuery {
'You will get the equivalent value in OCEAN, limited to 60% of the total liquidity.', content: allFile(filter: { relativePath: { eq: "price.json" } }) {
advanced: edges {
'You will get OCEAN and Datatokens equivalent to your pool share, without any limit.' node {
} childContentJson {
pool {
remove {
simple
advanced
output {
titleIn
titleOut
}
action
}
}
}
}
}
}
}
`
export default function Remove({ export default function Remove({
setShowRemove, setShowRemove,
@ -34,6 +52,9 @@ export default function Remove({
poolTokens: string poolTokens: string
dtSymbol: string dtSymbol: string
}): ReactElement { }): ReactElement {
const data = useStaticQuery(contentQuery)
const content = data.content.edges[0].node.childContentJson.pool.remove
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const [amountPercent, setAmountPercent] = useState('0') const [amountPercent, setAmountPercent] = useState('0')
const [amountMaxPercent, setAmountMaxPercent] = useState('100') const [amountMaxPercent, setAmountMaxPercent] = useState('100')
@ -114,10 +135,7 @@ export default function Remove({
return ( return (
<div className={styles.remove}> <div className={styles.remove}>
<Header <Header title={content.title} backAction={() => setShowRemove(false)} />
title="Remove Liquidity"
backAction={() => setShowRemove(false)}
/>
<form className={styles.removeInput}> <form className={styles.removeInput}>
<div className={styles.range}> <div className={styles.range}>
@ -139,9 +157,7 @@ export default function Remove({
</div> </div>
<FormHelp> <FormHelp>
{`Set the amount of your pool shares to spend. ${ {isAdvanced === true ? content.advanced : content.simple}
isAdvanced === true ? help.advanced : help.simple
}`}
</FormHelp> </FormHelp>
<Button style="text" size="small" onClick={handleAdvancedButton}> <Button style="text" size="small" onClick={handleAdvancedButton}>
{isAdvanced === true ? 'Simple' : 'Advanced'} {isAdvanced === true ? 'Simple' : 'Advanced'}
@ -151,11 +167,11 @@ export default function Remove({
<div className={styles.output}> <div className={styles.output}>
<div> <div>
<p>You will spend</p> <p>{content.output.titleIn}</p>
<Token symbol="pool shares" balance={amountPoolShares} noIcon /> <Token symbol="pool shares" balance={amountPoolShares} noIcon />
</div> </div>
<div> <div>
<p>You will receive</p> <p>{content.output.titleOut}</p>
<Token symbol="OCEAN" balance={amountOcean} /> <Token symbol="OCEAN" balance={amountOcean} />
{isAdvanced === true && ( {isAdvanced === true && (
<Token symbol={dtSymbol} balance={amountDatatoken} /> <Token symbol={dtSymbol} balance={amountDatatoken} />
@ -166,7 +182,7 @@ export default function Remove({
<Actions <Actions
isLoading={isLoading} isLoading={isLoading}
loaderMessage="Removing Liquidity..." loaderMessage="Removing Liquidity..."
actionName="Remove" actionName={content.action}
action={handleRemoveLiquidity} action={handleRemoveLiquidity}
txId={txId} txId={txId}
/> />

View File

@ -13,17 +13,36 @@ import Conversion from '../../../atoms/Price/Conversion'
import EtherscanLink from '../../../atoms/EtherscanLink' import EtherscanLink from '../../../atoms/EtherscanLink'
import Token from './Token' import Token from './Token'
import TokenList from './TokenList' import TokenList from './TokenList'
import { graphql, useStaticQuery } from 'gatsby'
export interface Balance { export interface Balance {
ocean: number ocean: number
datatoken: number datatoken: number
} }
/* const contentQuery = graphql`
TODO: create tooltip copy query PoolQuery {
*/ content: allFile(filter: { relativePath: { eq: "price.json" } }) {
edges {
node {
childContentJson {
pool {
tooltips {
price
liquidity
}
}
}
}
}
}
}
`
export default function Pool({ ddo }: { ddo: DDO }): ReactElement { export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
const data = useStaticQuery(contentQuery)
const content = data.content.edges[0].node.childContentJson.pool
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const { price } = useMetadata(ddo) const { price } = useMetadata(ddo)
@ -137,7 +156,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
<PriceUnit price="1" symbol={dtSymbol} /> ={' '} <PriceUnit price="1" symbol={dtSymbol} /> ={' '}
<PriceUnit price={`${price.value}`} /> <PriceUnit price={`${price.value}`} />
<Conversion price={`${price.value}`} /> <Conversion price={`${price.value}`} />
<Tooltip content="Explain how this price is determined..." /> <Tooltip content={content.tooltips.price} />
<div className={styles.dataTokenLinks}> <div className={styles.dataTokenLinks}>
<EtherscanLink <EtherscanLink
network="rinkeby" network="rinkeby"
@ -155,7 +174,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
title={ title={
<> <>
Your Liquidity Your Liquidity
<Tooltip content="Explain what this represents, advantage of providing liquidity..." /> <Tooltip content={content.tooltips.liquidity} />
</> </>
} }
ocean={`${userLiquidity.ocean}`} ocean={`${userLiquidity.ocean}`}