Skip to content

Commit

Permalink
Merge branch 'develop' into feat-liquidity-lockup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight authored Sep 18, 2024
2 parents 42c38c3 + 90454aa commit e559999
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 426 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ jobs:
restore-keys: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Yarn Install
run: yarn install --immutable
- name: Build Packages
run: yarn build:packages
- name: Build Web
run: yarn env && yarn build:web
# a poor mans extension of cloudflare/pages-action@1 https://github.com/cloudflare/pages-action/blob/main/src/index.ts
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@
"@shapeshiftoss/caip": "workspace:^",
"@shapeshiftoss/chain-adapters": "workspace:^",
"@shapeshiftoss/errors": "workspace:^",
"@shapeshiftoss/hdwallet-coinbase": "1.55.2",
"@shapeshiftoss/hdwallet-core": "1.55.2",
"@shapeshiftoss/hdwallet-keepkey": "1.55.2",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.55.2",
"@shapeshiftoss/hdwallet-keplr": "1.55.2",
"@shapeshiftoss/hdwallet-ledger": "1.55.2",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.55.2",
"@shapeshiftoss/hdwallet-metamask": "1.55.2",
"@shapeshiftoss/hdwallet-native": "1.55.2",
"@shapeshiftoss/hdwallet-native-vault": "1.55.2",
"@shapeshiftoss/hdwallet-shapeshift-multichain": "1.55.2",
"@shapeshiftoss/hdwallet-walletconnectv2": "1.55.2",
"@shapeshiftoss/hdwallet-xdefi": "1.55.2",
"@shapeshiftoss/hdwallet-coinbase": "1.55.4",
"@shapeshiftoss/hdwallet-core": "1.55.4",
"@shapeshiftoss/hdwallet-keepkey": "1.55.4",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.55.4",
"@shapeshiftoss/hdwallet-keplr": "1.55.4",
"@shapeshiftoss/hdwallet-ledger": "1.55.4",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.55.4",
"@shapeshiftoss/hdwallet-metamask": "1.55.4",
"@shapeshiftoss/hdwallet-native": "1.55.4",
"@shapeshiftoss/hdwallet-native-vault": "1.55.4",
"@shapeshiftoss/hdwallet-shapeshift-multichain": "1.55.4",
"@shapeshiftoss/hdwallet-walletconnectv2": "1.55.4",
"@shapeshiftoss/hdwallet-xdefi": "1.55.4",
"@shapeshiftoss/swapper": "workspace:^",
"@shapeshiftoss/types": "workspace:^",
"@shapeshiftoss/unchained-client": "workspace:^",
Expand Down Expand Up @@ -136,7 +136,7 @@
"chakra-ui-steps": "^1.7.3",
"crypto-browserify": "^3.12.0",
"dayjs": "^1.11.3",
"dompurify": "^2.3.8",
"dompurify": "^2.5.4",
"embla-carousel-auto-height": "^7.0.9",
"embla-carousel-autoplay": "^7.0.5",
"embla-carousel-react": "^7.0.5",
Expand Down Expand Up @@ -309,6 +309,7 @@
"react-dom@^18.2.0": "patch:react-dom@npm%3A18.2.0#./.yarn/patches/react-dom-npm-18.2.0-dd675bca1c.patch",
"react-dev-utils/fork-ts-checker-webpack-plugin": "^6.5.3",
"react-scripts/webpack": "5.94.0",
"react-scripts/workbox-webpack-plugin": "^7.1.0",
"p-queue": "^6.6.2",
"web3": "4.2.1-dev.a0d6730.0",
"@wherever/react-notification-feed/wagmi": "^0.10.12",
Expand Down
15 changes: 8 additions & 7 deletions src/pages/Lending/AvailablePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,20 @@ export const AvailablePools = () => {
[history, path],
)
const headerComponent = useMemo(() => <LendingHeader />, [])
const { data: lendingSupportedAssets } = useLendingSupportedAssets({
type: 'collateral',
statusFilter: 'All',
})
const { isLoading: isLendingSupportedAssetsLoading, data: lendingSupportedAssets } =
useLendingSupportedAssets({
type: 'collateral',
statusFilter: 'All',
})

const lendingRows = useMemo(() => {
if (!lendingSupportedAssets)
if (isLendingSupportedAssetsLoading)
return new Array(2).fill(null).map((_, i) => <Skeleton key={i} height={16} />)

return lendingSupportedAssets.map(asset => (
return (lendingSupportedAssets ?? []).map(asset => (
<LendingPoolButton key={asset.assetId} asset={asset} onPoolClick={handlePoolClick} />
))
}, [handlePoolClick, lendingSupportedAssets])
}, [handlePoolClick, isLendingSupportedAssetsLoading, lendingSupportedAssets])

return (
<Main headerComponent={headerComponent} isSubPage>
Expand Down
1 change: 0 additions & 1 deletion src/pages/Lending/YourLoans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export const YourLoans = () => {

const { data: lendingSupportedAssets } = useLendingSupportedAssets({
type: 'collateral',
hasLoanCollateral: false,
})

const history = useHistory()
Expand Down
1 change: 0 additions & 1 deletion src/pages/Lending/hooks/useAllLendingPositionsData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type UseAllLendingPositionsDataProps = {
export const useAllLendingPositionsData = ({ assetId }: UseAllLendingPositionsDataProps = {}) => {
const { data: lendingSupportedAssets } = useLendingSupportedAssets({
type: 'collateral',
hasLoanCollateral: false,
})

const accountIds = useAppSelector(selectWalletAccountIds)
Expand Down
32 changes: 27 additions & 5 deletions src/pages/Lending/hooks/useLendingSupportedAssets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { useSelector } from 'react-redux'
import { useIsSnapInstalled } from 'hooks/useIsSnapInstalled/useIsSnapInstalled'
import { useWallet } from 'hooks/useWallet/useWallet'
import { walletSupportsChain } from 'hooks/useWalletSupportsChain/useWalletSupportsChain'
import { bnOrZero } from 'lib/bignumber/bignumber'
import { isSome } from 'lib/utils'
import { thorchainBlockTimeMs } from 'lib/utils/thorchain/constants'
import {
selectAccountIdsByChainId,
selectAssetById,
Expand All @@ -25,14 +25,14 @@ import { store, useAppSelector } from 'state/store'

const queryKey = ['lendingSupportedAssets']

const lendingThorRegex = /^LENDING-THOR-(\w+)$/

export const useLendingSupportedAssets = ({
type,
statusFilter = 'Available',
hasLoanCollateral = true,
}: {
type: 'collateral' | 'borrow'
statusFilter?: ThornodePoolStatuses | 'All'
hasLoanCollateral?: boolean
}) => {
const wallet = useWallet().state.wallet
const { isSnapInstalled } = useIsSnapInstalled()
Expand All @@ -48,6 +48,11 @@ export const useLendingSupportedAssets = ({
: undefined,
})

const { data: mimir } = useQuery({
...reactQueries.thornode.mimir(),
staleTime: thorchainBlockTimeMs,
})

const accountIdsByChainId = useAppSelector(selectAccountIdsByChainId)
const walletSupportChains = useMemo(
() =>
Expand All @@ -68,9 +73,26 @@ export const useLendingSupportedAssets = ({
const selectSupportedAssets = useCallback(
(data: ThornodePoolResponse[] | undefined) => {
if (!data) return []
if (!mimir) return []

const pools = (availablePools ?? []).filter(pool => {
if (type === 'borrow') return true
if (type === 'collateral') return !hasLoanCollateral || bnOrZero(pool.loan_collateral).gt(0)
if (type === 'collateral') {
const mimirLendingEnabledPools = Object.keys(mimir)
.filter(key => lendingThorRegex.test(key))
.map(key => {
const match = key.match(lendingThorRegex)?.[1]
if (!match) return undefined

// i.e LENDING-THOR-BTC, LENDING-THOR-ETH
// No token pools support, so that works, and lending's pretty much going hasta la vista
// so we don't need to worry about this not generalizing to assets
return `${match}.${match}`
})
.filter(Boolean)

return mimirLendingEnabledPools.includes(pool.asset)
}
return false
})

Expand Down Expand Up @@ -103,7 +125,7 @@ export const useLendingSupportedAssets = ({
}
return supportedAssets
},
[availablePools, hasLoanCollateral, type, wallet, walletChainIds, walletSupportChains],
[availablePools, mimir, type, wallet, walletChainIds, walletSupportChains],
)

const lendingSupportedAssetsQuery = useQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RFOX/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Widget: React.FC = () => {
<Tabs variant='unstyled' index={stepIndex} isLazy>
<TabPanels>
<TabPanel px={0} py={0}>
<Stake headerComponent={TabHeader} />
<Stake headerComponent={TabHeader} setStepIndex={setStepIndex} />
</TabPanel>
<TabPanel px={0} py={0}>
<Unstake headerComponent={TabHeader} />
Expand Down
Loading

0 comments on commit e559999

Please sign in to comment.