Skip to content

Commit

Permalink
Feature branch: runtime upgrade 1038 (#1953)
Browse files Browse the repository at this point in the history
* Oracle Feeders (#1880)

* Pool fees (#1903)

* Add pool fee tab and table with drawers for edit and charging fees

* Add UI of form to charge fees

* Update links

* Add successful submit state to charge order

* Fetch pool fee data from onchain

* Update styles of Drawer header

* Enable setting pool fee charge

* Fix update order

* Remove logs

* Add functionality for edit fees drawer

* Update metadata when editing pool fees

* Query proposed changes

* Fix metadata update when item is not being removed

* Clean up

* Hide edit fee structure button for non admins

* Remove unused var

* Update styles

* Support LP in holders & investor tx reporting (#1912)

* Update

* Fix

* wip

* Fix address format

* Improve

* Naming

* Add investor tx type filter

* Disable oracles (#1916)

---------

Co-authored-by: Jeroen <[email protected]>
Co-authored-by: Onno Visser <[email protected]>

* fix types

* Add pool fees to create pool form (#1920)

* Add pool fees to create pool form

* Add create fees to create pool

* Add treasury account

* Update formik to resolve type errors

* Align all columns to the left

* Add fees tab to issuer pool

* Fix gray background to full width

* Add pool analysis section to Create Pool form (#1939)

* Pool fees follow up (#1933)

* Fix button spacing in holdings

* Update font color of tertiary button

* Use tertiary buttons for poolfees table

* Show actions only to allowed viewers

* Handle cancel better on update fee charge

* Update label

* Add pool type input to create pool

* Add validation for new input

* Set correct default fees based on poolType

* Add ~ to pending fees

* Add pending fees for fixed fees

* Fix tilde logic

* Fix balance types

* Account for epoch time if limit is amountPerSecond

* Use last nav for pending fee calculation

* Clean up naming

* Remove ~ and add pending fees to fixed fee calc

* Fix input jumping

* Fix multiply by zero on first epoch where previous nav is 0

* Remove logs

* Add type decorations for nav runtime api

* Fix PoolNav types

* Fetch nav value from runtime instead of chain storage

* Fix decimal error in fees

* force workflows on this branch (revert this before merging)

* Revert workflow updates

* Add regex for PRs in pinning

* Temp fix for asset page

* Add back oracle price form that got lost in merge conflict

* Pool type follow up (#1963)

* Fix typo in tooltip

* Place pool type next to pool name

* Swaps: Fulfill orders with market prices (#1966)

* remove old oracle stuff

* Fix asset value and nav calc (#1967)

* Fix bug in create pool form

* fix demo pod url

* Parse hex to BN to fix demo pools

* Fix breaking change since rt upgrade 1041 (#1979)

* Remove deprecated orderBook.tradingPair query (#1981)

* Pool fees feedback (#1975)

* Add copy to clipboard to receiving address in table

* Add total pending fees to page summary

* Show action column only to receiving address and pool admins

* Use maxPayable as amount for non fixed charges

* Add fee position column and numbered fees

* Fix disabled dropdown label

* Rename protocol fees

* Add tooltip to fee type label

* Add fee position to metadata and update label of fixed fee input

* Ajust edit fees drawer

* Rename title in charge fees drawer

* Remove log

* Add * to required fields in create pool form

* Update centrifuge-app/src/pages/IssuerCreatePool/PoolFeeInput.tsx

* Fix fixed pending fees

* Prettier

* Fix reserve in chart

---------

Co-authored-by: JP <[email protected]>

* feat: add pool fees RtApi v1 & add Loans RtApi v2 & cleanup RPCs (#1954)

* feat: add pool fees runtime api

* fix: remove non-existent RPCs

* feat: LoansApi v2

* fix runtime api

* Fix typing

* Fee reporting (#1994)

* Set up fee tx reporting

* Use fee id

* Setup

* Naming

* Update centrifuge-app/src/components/Report/FeeTransactions.tsx

Co-authored-by: Sophia <[email protected]>

---------

Co-authored-by: Sophia <[email protected]>

* Fix portfolio runtime call (#2018)

* Add pool fees to pool detail page (#2015)

* Upgrade packages in Centrifuge JS + Bump version (#2019)

* Upgrade polkadot packages

* Bump version

* Upgrade deps in cent-app

* Fix pool fees

---------

Co-authored-by: Onno Visser <[email protected]>
Co-authored-by: Jeroen <[email protected]>
Co-authored-by: Onno Visser <[email protected]>
Co-authored-by: Guillermo Perez <[email protected]>
Co-authored-by: JP <[email protected]>
Co-authored-by: William Freudenberger <[email protected]>
  • Loading branch information
7 people authored Mar 18, 2024
1 parent 0eac4cc commit 0b7bf89
Show file tree
Hide file tree
Showing 74 changed files with 3,375 additions and 1,604 deletions.
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 @@ -13,35 +13,15 @@ type IssuerSectionProps = {

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 / deploy-development / webapp / 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 / deploy-ff-prod / webapp / 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 ReportDetails({ metadata }: IssuerSectionProps) {
)
)
}

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 @@ -272,7 +272,7 @@ function AssetMetadataField({ loan, name, attribute }: { loan: Row; name: string
)
}

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

0 comments on commit 0b7bf89

Please sign in to comment.