Merge pull request #308 from blockworks-foundation/lou/position-funding

Add position funding to the perp positions table
This commit is contained in:
saml33 2023-11-07 13:50:12 +11:00 committed by GitHub
commit 74bfcf627f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 5 deletions

View File

@ -151,6 +151,7 @@ const PerpPositions = () => {
</Th>
<Th className="text-right">{t('trade:unrealized-pnl')}</Th>
<Th className="text-right">ROE</Th>
<Th className="text-right">{t('funding')}</Th>
{!isUnownedAccount ? (
<Th>
{openPerpPositions?.length > 1 ? (
@ -192,6 +193,8 @@ const PerpPositions = () => {
position.cumulativePnlOverPositionLifetimeUi(market)
const unrealizedPnl = position.getUnRealizedPnlUi(market)
const realizedPnl = position.getRealizedPnlUi()
const positionFunding =
position.getCumulativeFundingUi(market)
const roe =
(unrealizedPnl / (Math.abs(basePosition) * avgEntryPrice)) *
100
@ -320,6 +323,19 @@ const PerpPositions = () => {
<FormatNumericValue value={roe} decimals={2} />%
</span>
</Td>
<Td className="text-right font-mono">
<span
className={
positionFunding >= 0 ? 'text-th-up' : 'text-th-down'
}
>
<FormatNumericValue
value={positionFunding}
decimals={2}
isUsd
/>
</span>
</Td>
{!isUnownedAccount ? (
<Td>
<div className="flex items-center justify-end space-x-4">
@ -450,6 +466,7 @@ const PerpPositions = () => {
group,
mangoAccount,
)
const positionFunding = position.getCumulativeFundingUi(market)
const unsettledPnl = position.getUnsettledPnlUi(market)
const notional = Math.abs(floorBasePosition) * market._uiPrice
return (
@ -661,6 +678,24 @@ const PerpPositions = () => {
<FormatNumericValue value={roe} decimals={2} />%
</p>
</div>
<div className="col-span-1">
<p className="text-xs text-th-fgd-3">
{t('funding')}
</p>
<p
className={`font-mono ${
positionFunding >= 0
? 'text-th-up'
: 'text-th-down'
}`}
>
<FormatNumericValue
value={positionFunding}
decimals={2}
isUsd
/>
</p>
</div>
<div className="col-span-2 mt-3 flex space-x-3">
<Button
className="w-full text-xs sm:text-sm"

View File

@ -23,7 +23,7 @@
"dependencies": {
"@blockworks-foundation/mango-feeds": "0.1.7",
"@blockworks-foundation/mango-mints-redemption": "^0.0.10",
"@blockworks-foundation/mango-v4": "^0.19.41",
"@blockworks-foundation/mango-v4": "0.19.43",
"@blockworks-foundation/mango-v4-settings": "0.2.16",
"@blockworks-foundation/mangolana": "0.0.1-beta.15",
"@headlessui/react": "1.6.6",

View File

@ -50,10 +50,10 @@
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"
"@blockworks-foundation/mango-v4@^0.19.41":
version "0.19.41"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.19.41.tgz#d4f88aebe5509cacf5569e6b3b7665bc9053c33f"
integrity sha512-q3rXSgql8lcYtCbtvIb5VPHjkcQUEbnmMQ4p6D81X+wVE3sBKNOpXiq2uQNEVJRBsWKzz/Ea1W9jM6siq7bpWA==
"@blockworks-foundation/mango-v4@0.19.43":
version "0.19.43"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.19.43.tgz#82c2df9c63204e31c19473672329cba43ea40fbc"
integrity sha512-son/flq/mvngtBppKbxXfNIq/Z4L7mp6zOP5k8cD11rVlZ3wmb3jfBkKqocgL3IqnRIWj3cL9R6dM37tqaFZzw==
dependencies:
"@blockworks-foundation/mango-v4-settings" "^0.2.16"
"@coral-xyz/anchor" "^0.28.1-beta.2"