Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature branch: runtime upgrade 1038 #1953

Merged
merged 39 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fb6570d
Oracle Feeders (#1880)
onnovisser Jan 31, 2024
0760a49
Pool fees (#1903)
sophialittlejohn Jan 31, 2024
f4aff09
Merge branch 'main' into runtime-upgrade-1038
onnovisser Feb 1, 2024
d29f625
fix types
onnovisser Feb 1, 2024
79da971
Add pool fees to create pool form (#1920)
sophialittlejohn Feb 5, 2024
2597c3f
Merge branch 'main' into runtime-upgrade-1038
onnovisser Feb 7, 2024
3ef8453
Add pool analysis section to Create Pool form (#1939)
onnovisser Feb 7, 2024
cd843f5
Pool fees follow up (#1933)
sophialittlejohn Feb 12, 2024
785c491
force workflows on this branch (revert this before merging)
gpmayorga Feb 13, 2024
54b2b69
Merge branch 'main' of github.com:centrifuge/apps into runtime-upgrad…
sophialittlejohn Feb 13, 2024
03a2917
Revert workflow updates
sophialittlejohn Feb 13, 2024
1899b0d
Add regex for PRs in pinning
sophialittlejohn Feb 13, 2024
3c639e0
Temp fix for asset page
sophialittlejohn Feb 13, 2024
b241843
Add back oracle price form that got lost in merge conflict
sophialittlejohn Feb 13, 2024
cb07b57
Pool type follow up (#1963)
sophialittlejohn Feb 15, 2024
f4dd072
Merge branch 'main' of github.com:centrifuge/apps into runtime-upgrad…
sophialittlejohn Feb 15, 2024
fff8eb9
Swaps: Fulfill orders with market prices (#1966)
onnovisser Feb 16, 2024
ec2ee59
remove old oracle stuff
onnovisser Feb 16, 2024
9ffacba
Fix asset value and nav calc (#1967)
sophialittlejohn Feb 16, 2024
3529682
Fix bug in create pool form
sophialittlejohn Feb 21, 2024
e518891
fix demo pod url
gpmayorga Feb 22, 2024
3be1570
Parse hex to BN to fix demo pools
sophialittlejohn Feb 22, 2024
23dd660
Fix breaking change since rt upgrade 1041 (#1979)
sophialittlejohn Feb 23, 2024
3868795
Remove deprecated orderBook.tradingPair query (#1981)
sophialittlejohn Feb 26, 2024
1bd4d79
Merge branch 'main' of github.com:centrifuge/apps into runtime-upgrad…
sophialittlejohn Feb 26, 2024
e49bf01
Merge branch 'runtime-upgrade-1038' of github.com:centrifuge/apps int…
sophialittlejohn Feb 26, 2024
a3d9cba
Pool fees feedback (#1975)
sophialittlejohn Feb 27, 2024
9ffce20
feat: add pool fees RtApi v1 & add Loans RtApi v2 & cleanup RPCs (#1954)
wischli Mar 7, 2024
cc1d424
fix runtime api
onnovisser Mar 7, 2024
a91efaa
Merge branch 'main' of github.com:centrifuge/apps into runtime-upgrad…
sophialittlejohn Mar 8, 2024
d55ebbb
Merge branch 'runtime-upgrade-1038' of github.com:centrifuge/apps int…
sophialittlejohn Mar 8, 2024
0855100
Fix typing
sophialittlejohn Mar 8, 2024
a4c090c
Fee reporting (#1994)
hieronx Mar 14, 2024
097ab3f
Fix portfolio runtime call (#2018)
onnovisser Mar 14, 2024
5a66588
Add pool fees to pool detail page (#2015)
sophialittlejohn Mar 15, 2024
94ce0dc
Upgrade packages in Centrifuge JS + Bump version (#2019)
sophialittlejohn Mar 15, 2024
76d0557
Merge branch 'main' of github.com:centrifuge/apps into runtime-upgrad…
sophialittlejohn Mar 15, 2024
8dc0423
Fix pool fees
sophialittlejohn Mar 15, 2024
87ca95f
Merge branch 'main' into runtime-upgrade-1038
sophialittlejohn Mar 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions .github/workflows/centrifuge-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ on:
# Fancy concurrency group string to allow for multi-staging deployments
concurrency:
group: 'centrifuge-app-${{ inputs.deploy_env || github.event.inputs.deploy_env }}@${{ github.event.name }}${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
cancel-in-progress: true
env:
artifact_name: "webpack${{ inputs.deploy_env && format('-{0}', inputs.deploy_env) }}"
jobs:
jobs:
build-app:
runs-on: ubuntu-latest
defaults:
Expand All @@ -39,23 +39,23 @@ jobs:
with:
node-version: '16'
cache: yarn

- name: set PR function values
if: github.event_name == 'pull_request'
shell: bash
env:
PINNING_URL: https:\/\/${{ vars.GCLOUD_REGION }}-${{ vars.GCP_DEV_PROJ }}.cloudfunctions.net\/pinning-api-pr${{ github.event.number }}
ONBOARDING_URL: https:\/\/${{ vars.GCLOUD_REGION }}-${{ vars.GCP_DEV_PROJ }}.cloudfunctions.net\/onboarding-api-pr${{ github.event.number }}
# Ex:
# Ex:
# sed -i .bak -e '/^REACT_APP_ONBOARDING_API_URL=/s/=.*/=https:\/\/europe-central2-peak-vista.cloudfunctions.net\/onboarding-api-pr1144/' $PWD/.env-config/.env.development
run: |
sed -i -e '/^REACT_APP_PINNING_API_URL=/s/=.*/=${{ env.PINNING_URL }}/' $PWD/.env-config/.env.${{ steps.prepare.outputs.env_name }}
sed -i -e '/^REACT_APP_ONBOARDING_API_URL=/s/=.*/=${{ env.ONBOARDING_URL }}/' $PWD/.env-config/.env.${{ steps.prepare.outputs.env_name }}
cat .env-config/.env.${{ steps.prepare.outputs.env_name }} | grep API

- name: Install Dependencies
# env:
# NODE_ENV: production
# NODE_ENV: production
run: yarn install --immutable
- name: Lint
run: yarn lint
Expand All @@ -64,16 +64,16 @@ jobs:
shell: bash
env:
# https://github.com/actions/runner-images/issues/70#issuecomment-1191708172
NODE_OPTIONS: "--max_old_space_size=4096"
NODE_OPTIONS: '--max_old_space_size=4096'
run: |
yarn build:fabric
yarn build:centjs
yarn build:centReact
cat .env-config/.env.${{ steps.prepare.outputs.env_name }}
yarn build:app --mode ${{ steps.prepare.outputs.env_name }}

- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #@3.1.2
with:
with:
name: ${{ env.artifact_name }}
path: ./centrifuge-app/build
if-no-files-found: error
Expand All @@ -89,16 +89,15 @@ jobs:
outputs:
front_url: ${{ steps.prepare.outputs.front_url }}
gh_env: ${{ steps.prepare.outputs.gh_env }}


deploy-app:
concurrency:
# Do not sync the same bucket in parallel
# Do not sync the same bucket in parallel
group: deploy-${{ needs.build-app.outputs.front_url }}-${{ github.event.name }}
cancel-in-progress: true
cancel-in-progress: true
permissions:
contents: 'read'
id-token: 'write'
id-token: 'write'
runs-on: ubuntu-latest
needs: build-app
environment: ${{ needs.build-app.outputs.gh_env }}
Expand All @@ -107,7 +106,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
path: apps

- name: deploy to GCS
id: gcsdeploy
uses: ./apps/.github/actions/deploy-gcs
Expand Down Expand Up @@ -155,5 +154,3 @@ jobs:
# with:
# target: https://${{ needs.deploy-app.outputs.bucket_url }}
# allow_issue_writing: false # Remove this to activate creating issues with the report


11 changes: 5 additions & 6 deletions .github/workflows/fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
branches:
- main
paths:
- 'fabric/**'
- 'fabric/**'
- '.github/workflows/fabric.yml'
pull_request:
paths:
- '.github/workflows/fabric.yml'
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
cancel-in-progress: true
jobs:
build-fabric:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,13 +44,12 @@ jobs:
retention-days: 1
path: ./fabric/storybook-static


deploy-storybook: # to google storage
# if: github.ref == 'refs/heads/main'
needs: build-fabric
permissions:
contents: 'read'
id-token: 'write'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -66,5 +65,5 @@ jobs:
bucket_url: 'fabric-storybook.k-f.dev'
GWIP: ${{ secrets.GWIP }}
GSA: ${{ secrets.GSA }}
# ToDo: send notification when deployed?

# ToDo: send notification when deployed?
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.altair
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kova
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
REACT_APP_TREASURY=kAJkmGxAd6iqX9JjWTdhXgCf2PL1TAphTRYrmEqzBrYhwbXAn
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.catalyst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kova
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=4bo2vNkwZtr2PuqppWwqya6dPC8MzxqZ4kgnAoTZyKo9Kxq8
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
REACT_APP_TREASURY=kAJkmGxAd6iqX9JjWTdhXgCf2PL1TAphTRYrmEqzBrYhwbXAn
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kova
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALwmJutBq95s41U9fWnoApCUgvPqPGTh1GSmFnQh5f9fWo93
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
REACT_APP_TREASURY=kAJkmGxAd6iqX9JjWTdhXgCf2PL1TAphTRYrmEqzBrYhwbXAn
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kAJ27w29x7gHM75xajP2yXVLjVBaKmmUTxHwgRuCoAcWaoEiz
REACT_APP_TREASURY=kAJkmGxAd6iqX9JjWTdhXgCf2PL1TAphTRYrmEqzBrYhwbXAn
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kova
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
REACT_APP_TREASURY=kAJkmGxAd6iqX9JjWTdhXgCf2PL1TAphTRYrmEqzBrYhwbXAn
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-main
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/prod/gn
REACT_APP_TREASURY=4dpEcgqJRyJK3J8Es6v8ZfVntV7c64Ysgcjd4hYwyGoFPWbg
2 changes: 1 addition & 1 deletion centrifuge-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@subwallet/wallet-connect": "^0.2.6",
"@web3modal/standalone": "^2.4.2",
"bn.js": "^5.2.1",
"formik": "^2.2.9",
"formik": "^2.4.5",
"merkletreejs": "^0.3.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
5 changes: 5 additions & 0 deletions centrifuge-app/src/components/DebugFlags/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type Key =
| 'showTestNets'
| 'showSwaps'
| 'showPrime'
| 'showOracle'
| 'poolCreationType'
| 'podAdminSeed'
| 'holdersReport'
Expand Down Expand Up @@ -136,6 +137,10 @@ export const flagsConfig: Record<Key, DebugFlagConfig> = {
default: false,
type: 'checkbox',
},
showOracle: {
default: false,
type: 'checkbox',
},
showTestNets: {
alwaysShow: true,
default: isTestEnv,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import { CurrencyBalance, CurrencyMetadata, Pool } from '@centrifuge/centrifuge-js'
import { CurrencyBalance, Pool } from '@centrifuge/centrifuge-js'
import {
useCentrifuge,
useCentrifugeApi,
useCentrifugeConsts,
useCentrifugeQuery,
useEvmNativeBalance,
useEvmNativeCurrency,
useEvmProvider,
useWallet,
} from '@centrifuge/centrifuge-react'
import { TransactionRequest } from '@ethersproject/providers'
import BN from 'bn.js'
import Decimal from 'decimal.js-light'
import * as React from 'react'
import { map } from 'rxjs'
import { Dec } from '../../utils/Decimal'
import { useEvmTransaction } from '../../utils/tinlake/useEvmTransaction'
import { useAddress } from '../../utils/useAddress'
import { useLiquidityPoolInvestment, useLiquidityPools, useLPEvents } from '../../utils/useLiquidityPools'
import { useLPEvents, useLiquidityPoolInvestment, useLiquidityPools } from '../../utils/useLiquidityPools'
import { usePendingCollect, usePool, usePoolMetadata } from '../../utils/usePools'
import { useDebugFlags } from '../DebugFlags'
import { InvestRedeemContext } from './InvestRedeemProvider'
import { InvestRedeemAction, InvestRedeemActions, InvestRedeemProviderProps as Props, InvestRedeemState } from './types'
import { InvestRedeemAction, InvestRedeemActions, InvestRedeemState, InvestRedeemProviderProps as Props } from './types'

export function InvestRedeemLiquidityPoolsProvider({ poolId, trancheId, children }: Props) {
const centAddress = useAddress('substrate')
Expand Down Expand Up @@ -72,8 +68,7 @@ export function InvestRedeemLiquidityPoolsProvider({ poolId, trancheId, children

const collectType = currencyToCollect.gt(0) ? 'redeem' : investToCollect.gt(0) ? 'invest' : null

const assetPairMinOrder = useAssetPair(pool.currency, lpInvest?.currency)
const minOrder = max(assetPairMinOrder?.toDecimal() ?? Dec(0), consts.orderBook.minFulfillment.toDecimal())
const minOrder = consts.orderBook.minFulfillment.toDecimal()

const invest = useEvmTransaction('Invest', (cent) => cent.liquidityPools.increaseInvestOrder)
const decreaseInvest = useEvmTransaction('Invest', (cent) => cent.liquidityPools.decreaseInvestOrder)
Expand Down Expand Up @@ -257,22 +252,3 @@ export function InvestRedeemLiquidityPoolsProvider({ poolId, trancheId, children

return <InvestRedeemContext.Provider value={{ state, actions, hooks }}>{children}</InvestRedeemContext.Provider>
}

function useAssetPair(currency: CurrencyMetadata, otherCurrency?: CurrencyMetadata) {
const api = useCentrifugeApi()
const [data] = useCentrifugeQuery(
['assetPair', currency.key, otherCurrency?.key],
() =>
api.query.orderBook.tradingPair(currency.key, otherCurrency!.key).pipe(
map((minOrderData) => {
return new CurrencyBalance(minOrderData.toPrimitive() as string, otherCurrency!.decimals)
})
),
{ enabled: !!otherCurrency }
)
return data
}

function max(...nums: Decimal[]) {
return nums.reduce((a, b) => (a.greaterThan(b) ? b : a))
}
25 changes: 2 additions & 23 deletions centrifuge-app/src/components/IssuerSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,16 @@
}

export function IssuerSection({ metadata }: IssuerSectionProps) {
const cent = useCentrifuge()

Check warning on line 15 in centrifuge-app/src/components/IssuerSection.tsx

View workflow job for this annotation

GitHub Actions / build-app

'cent' is assigned a value but never used

Check warning on line 15 in centrifuge-app/src/components/IssuerSection.tsx

View workflow job for this annotation

GitHub Actions / app-demo / build-app

'cent' is assigned a value but never used

const report = metadata?.pool?.reports?.[0]

return (
<Card p={3} backgroundColor="backgroundAccentSecondary">
<Grid columns={[1, 2]} equalColumns gap={9} rowGap={3}>
{report && (
<Stack gap={2}>
<Text variant="heading2">Pool analysis</Text>
<Shelf gap={1}>
{report.author.avatar?.uri && (
<Box
as="img"
height={40}
borderRadius={30}
src={cent.metadata.parseMetadataUrl(report.author.avatar.uri)}
alt=""
/>
)}
<Text variant="body2">
Reviewer: {report.author.name}
<br />
{report.author.title}
</Text>
</Shelf>
<div>
<AnchorButton href={report.uri} target="_blank" variant="inverted" icon={IconExternalLink}>
View full report
</AnchorButton>
</div>
<ReportDetails metadata={metadata} />
</Stack>
)}
<Stack gap={2}>
Expand Down Expand Up @@ -84,7 +64,6 @@
)
)
}

export function IssuerDetails({ metadata }: IssuerSectionProps) {
const cent = useCentrifuge()
const [isDialogOpen, setIsDialogOpen] = React.useState(false)
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/LoanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

return aId.localeCompare(bId)
})
}, [loans])

Check warning on line 87 in centrifuge-app/src/components/LoanList.tsx

View workflow job for this annotation

GitHub Actions / build-app

React Hook React.useMemo has a missing dependency: 'isTinlakePool'. Either include it or remove the dependency array

Check warning on line 87 in centrifuge-app/src/components/LoanList.tsx

View workflow job for this annotation

GitHub Actions / app-demo / build-app

React Hook React.useMemo has a missing dependency: 'isTinlakePool'. Either include it or remove the dependency array
const filters = useFilters({
data: loansWithLabelStatus,
})
Expand Down Expand Up @@ -272,7 +272,7 @@
)
}

function AssetName({ loan }: { loan: Row }) {
export function AssetName({ loan }: { loan: Pick<Row, 'id' | 'poolId' | 'asset' | 'pricing'> }) {
const isTinlakePool = loan.poolId.startsWith('0x')
const nft = useCentNFT(loan.asset.collectionId, loan.asset.nftId, false, isTinlakePool)
const { data: metadata, isLoading } = useMetadata(nft?.metadataUri, nftMetadataSchema)
Expand Down
10 changes: 9 additions & 1 deletion centrifuge-app/src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IconGlobe,
IconInvestments,
IconNft,
IconPools,
IconSwitch,
IconWallet,
Menu as Panel,
Expand All @@ -27,7 +28,7 @@ export function Menu() {
const pools = usePoolsThatAnyConnectedAddressHasPermissionsFor() || []
const isLarge = useIsAboveBreakpoint('L')
const address = useAddress('substrate')
const { showSwaps, showPrime } = useDebugFlags()
const { showSwaps, showPrime, showOracle } = useDebugFlags()
const transactions = useTransactionsByAddress(address)

return (
Expand Down Expand Up @@ -106,6 +107,13 @@ export function Menu() {
</PageLink>
)}

{showOracle && (
<PageLink to="/nav-management" stacked={!isLarge}>
<IconPools />
NAV management
</PageLink>
)}

{config.network !== 'centrifuge' && (
<PageLink to="/nfts" stacked={!isLarge}>
<IconNft />
Expand Down
Loading
Loading