mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
output liquidity provider fee for given pool
This commit is contained in:
parent
0c3afad2cd
commit
711dd38a9f
@ -16,17 +16,18 @@ export default function Add({
|
|||||||
setShowAdd,
|
setShowAdd,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
totalPoolTokens,
|
totalPoolTokens,
|
||||||
totalBalance
|
totalBalance,
|
||||||
|
liquidityProviderFee
|
||||||
}: {
|
}: {
|
||||||
setShowAdd: (show: boolean) => void
|
setShowAdd: (show: boolean) => void
|
||||||
poolAddress: string
|
poolAddress: string
|
||||||
totalPoolTokens: string
|
totalPoolTokens: string
|
||||||
totalBalance: Balance
|
totalBalance: Balance
|
||||||
|
liquidityProviderFee: string
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { debug } = useUserPreferences()
|
const { debug } = useUserPreferences()
|
||||||
const { ocean, accountId, balance } = useOcean()
|
const { ocean, accountId, balance } = useOcean()
|
||||||
const [amount, setAmount] = useState('')
|
const [amount, setAmount] = useState('')
|
||||||
const [swapFee, setSwapFee] = useState<string>()
|
|
||||||
const [txId, setTxId] = useState<string>('')
|
const [txId, setTxId] = useState<string>('')
|
||||||
const [isLoading, setIsLoading] = useState<boolean>()
|
const [isLoading, setIsLoading] = useState<boolean>()
|
||||||
|
|
||||||
@ -38,14 +39,6 @@ export default function Add({
|
|||||||
totalBalance &&
|
totalBalance &&
|
||||||
((Number(newPoolTokens) / Number(totalPoolTokens)) * 100).toFixed(2)
|
((Number(newPoolTokens) / Number(totalPoolTokens)) * 100).toFixed(2)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
async function getFee() {
|
|
||||||
const swapFee = await ocean.pool.getSwapFee(accountId, poolAddress)
|
|
||||||
setSwapFee(swapFee)
|
|
||||||
}
|
|
||||||
getFee()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
async function handleAddLiquidity() {
|
async function handleAddLiquidity() {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
|
|
||||||
@ -96,7 +89,7 @@ export default function Add({
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>You will earn</p>
|
<p>You will earn</p>
|
||||||
<Token symbol="%" balance={swapFee} />
|
<Token symbol="%" balance={liquidityProviderFee} />
|
||||||
of each pool transaction
|
of each pool transaction
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,6 +33,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
const [totalBalance, setTotalBalance] = useState<Balance>()
|
const [totalBalance, setTotalBalance] = useState<Balance>()
|
||||||
const [dtSymbol, setDtSymbol] = useState<string>()
|
const [dtSymbol, setDtSymbol] = useState<string>()
|
||||||
const [userBalance, setUserBalance] = useState<Balance>()
|
const [userBalance, setUserBalance] = useState<Balance>()
|
||||||
|
const [liquidityProviderFee, setLiquidityProviderFee] = useState<string>()
|
||||||
|
|
||||||
const [showAdd, setShowAdd] = useState(false)
|
const [showAdd, setShowAdd] = useState(false)
|
||||||
const [showRemove, setShowRemove] = useState(false)
|
const [showRemove, setShowRemove] = useState(false)
|
||||||
@ -103,6 +104,13 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setUserBalance(userBalance)
|
setUserBalance(userBalance)
|
||||||
|
|
||||||
|
// Get liquidity provider fee
|
||||||
|
const liquidityProviderFee = await ocean.pool.getSwapFee(
|
||||||
|
accountId,
|
||||||
|
price.address
|
||||||
|
)
|
||||||
|
setLiquidityProviderFee(liquidityProviderFee)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message)
|
console.error(error.message)
|
||||||
} finally {
|
} finally {
|
||||||
@ -122,6 +130,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
poolAddress={price.address}
|
poolAddress={price.address}
|
||||||
totalPoolTokens={totalPoolTokens}
|
totalPoolTokens={totalPoolTokens}
|
||||||
totalBalance={totalBalance}
|
totalBalance={totalBalance}
|
||||||
|
liquidityProviderFee={liquidityProviderFee}
|
||||||
/>
|
/>
|
||||||
) : showRemove ? (
|
) : showRemove ? (
|
||||||
<Remove
|
<Remove
|
||||||
@ -168,6 +177,10 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
{debug === true && (
|
{debug === true && (
|
||||||
<Token symbol="BPT" balance={totalPoolTokens} />
|
<Token symbol="BPT" balance={totalPoolTokens} />
|
||||||
)}
|
)}
|
||||||
|
<Token
|
||||||
|
symbol="% liquidity provider fee"
|
||||||
|
balance={liquidityProviderFee}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user