-
Notifications
You must be signed in to change notification settings - Fork 50
[Deposit] Update UI to show pending assets #1505
Conversation
into issue-1496/ui-pending-assets
Still WIP - currently it fails to get data of liquidity providers
Note: address$ causes the race condition. Also instead of subscribing selectedPoolAsset$, just use oRouteAsset (which is available asap)
as suggested by @thatStrangeGuyThorchain
})) | ||
A.map((provider): LiquidityProvider => { | ||
const pendingRuneAmount = baseAmount(provider.pending_rune, THORCHAIN_DECIMAL) | ||
const pendingAssetAmount = baseAmount(provider.pending_asset, assetDecimal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just realized that such transformation to the BaseAmount
is a little bit incorrect... assetDecimal
is not always the same as selectedPoolAsset
's decimal in general.
for the future i believe we need to pass pending amounts as strings directly and transform to the BaseAmount
only "on demand" (at the view level when we know assets' decimals...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be done with another PR - see #1512
@@ -84,16 +84,19 @@ export type GetLiquidityProvidersParams = { | |||
} | |||
|
|||
export type GetLiquidityProviderParams = GetLiquidityProvidersParams & { | |||
runeAddress: O.Option<Address> | |||
assetAddress: O.Option<Address> | |||
runeAddress: Address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would keep runeAddress: O.Option<Address>
:
assetAddress
is always required for bothsym
/asym
providersruneAddress
is optional to detect if we want to getsym
/asym
provider.
i know we now "ignore" all asym-related stuff but if this is a brand-new stuff we should be "aimed" to the future stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be done with another PR - see #1512
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runeAddress is optional to detect if we want to get sym/asym provider.
That's not correct, but as follow: "if member is assym - they will only have either rune_address or asset_address in their member details." (see https://thorchain.slack.com/archives/C012CLYR1DG/p1612347969232600?thread_ts=1612288793.231200&cid=C012CLYR1DG). We will check always both addresses then.
Check for pending asset is for sym. deposit needed only. If an asym. deposit might fail, there won't be a pending asset.
const [liquidityProvider] = useObservableState<LiquidityProviderRD>(() => { | ||
return Rx.combineLatest([ | ||
network$, | ||
// We should look for THORChain's wallet at the response of liqudity_providers endpoint | ||
address$, | ||
addressByChain$(THORChain), | ||
assetWithDecimalLD | ||
]).pipe( | ||
RxOp.switchMap(([network, oAssetAddress, oRuneAddress, assetWithDecimalRD]) => { | ||
return FP.pipe( | ||
sequenceTOption(oRuneAddress, oAssetAddress, RD.toOption(assetWithDecimalRD)), | ||
O.fold( | ||
(): LiquidityProviderLD => Rx.of(RD.initial), | ||
([runeAddress, assetAddress, assetWithDecimal]) => | ||
getLiquidityProvider({ assetWithDecimal, network, runeAddress, assetAddress }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would move this data getter directly inside of SymDepositView
. with optional runeAddress
at the getLiquidityProvider
we can easily split this logic between 2 views without passing-down liquidityProvider
through few levels:
SymDepositView
:getLiquidityProvider({ assetWithDecimal: ..., network: ..., runeAddress: O.some(Address), assetAddress: Address })
AsymDepositView
:getLiquidityProvider({ assetWithDecimal: ..., network: ..., runeAddress: O.none, assetAddress: Address })
what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be done with another PR - see #1512
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to skip this for same reason mentioned in #1505 (comment)
part 2 will be following tomorrow
Merging now to have it in next release... All open suggestion will be done with another PR - see #1512 |
Peek.2021-06-07.18-38.mp4
Closes #1496