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

docs: Add docs generation #43

Merged
merged 44 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
486a30f
add docs generation
onnovisser Jan 13, 2025
e8ba866
[bot] New pkg version: 0.0.0-alpha.6
actions-user Jan 13, 2025
6ca9ccf
Test docs automation
sophialittlejohn Jan 13, 2025
eadf434
Force yarn@stable in workflow
sophialittlejohn Jan 13, 2025
4a05f36
Try setting stable version manually
sophialittlejohn Jan 13, 2025
d825475
Update order
sophialittlejohn Jan 13, 2025
07bed06
Install deps before gen:docs
sophialittlejohn Jan 13, 2025
2f5fb40
Add user to github
sophialittlejohn Jan 13, 2025
ef531bd
Convert script to cjs file
sophialittlejohn Jan 13, 2025
095efe0
Update clone url
sophialittlejohn Jan 13, 2025
5b6fde1
Add org name
sophialittlejohn Jan 13, 2025
c313385
Remove docs
sophialittlejohn Jan 14, 2025
1c2f461
Checkout branch later
sophialittlejohn Jan 14, 2025
20104b1
Update docs
actions-user Jan 14, 2025
20f6f74
Login to github
sophialittlejohn Jan 14, 2025
60a8a25
Update docs
actions-user Jan 14, 2025
fef7676
Use PAT token to allow pushing to repo
sophialittlejohn Jan 14, 2025
d97b7f1
Use auth url
sophialittlejohn Jan 14, 2025
20843ed
oauth for authorization
sophialittlejohn Jan 14, 2025
c380e23
Update docs
actions-user Jan 14, 2025
8477ffd
Regular auth?
sophialittlejohn Jan 14, 2025
53d1140
Fix naming
sophialittlejohn Jan 14, 2025
f6a84e5
Update docs
actions-user Jan 14, 2025
06481dd
Exclude readme and improve copy
sophialittlejohn Jan 14, 2025
2da740f
[ci:bot] Update docs
actions-user Jan 14, 2025
5924ed5
Unique branch names and earlier auth
sophialittlejohn Jan 14, 2025
e6c77e4
[ci:bot] Update docs
actions-user Jan 14, 2025
212732e
Fix branch name
sophialittlejohn Jan 14, 2025
da56da0
[ci:bot] Update docs
actions-user Jan 14, 2025
f4a0555
Exclude readme in typedoc generation
sophialittlejohn Jan 14, 2025
7cb1f39
[ci:bot] Update docs
actions-user Jan 14, 2025
862f7f1
Exclude _globals.md
sophialittlejohn Jan 14, 2025
95301cd
[ci:bot] Update docs
actions-user Jan 14, 2025
ae12cdc
Fix typo
sophialittlejohn Jan 14, 2025
34d731a
[ci:bot] Update docs
actions-user Jan 14, 2025
79d4569
Add note in readme and switch trigger branch to main
sophialittlejohn Jan 14, 2025
63f931b
Exclude docs from test coverage
sophialittlejohn Jan 15, 2025
25fd692
Improve script to handle updating index.html.md and deleting old files
sophialittlejohn Jan 15, 2025
e8e313e
Update target for testing
sophialittlejohn Jan 15, 2025
45d9bb1
[ci:bot] Update docs
actions-user Jan 15, 2025
216f00e
Test deployment without pushing docs/ folder
sophialittlejohn Jan 15, 2025
89e29cf
Move diff check into script
sophialittlejohn Jan 15, 2025
10098ef
Merge branch 'main' of github.com:centrifuge/centrifuge-sdk into gene…
sophialittlejohn Jan 27, 2025
c3c67a4
Disable workflow
sophialittlejohn Jan 27, 2025
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
Prev Previous commit
Next Next commit
Update docs
  • Loading branch information
actions-user committed Jan 14, 2025
commit 60a8a256651ed019f6b13926502d056b8076179f
192 changes: 192 additions & 0 deletions docs/_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@

## Centrifuge SDK [![Codecov](https://codecov.io/gh/centrifuge/sdk/graph/badge.svg?token=Q2yU8QfefP)](https://codecov.io/gh/centrifuge/sdk) [![Build CI status](https://github.com/centrifuge/sdk/actions/workflows/build-test-report.yml/badge.svg)](https://github.com/centrifuge/sdk/actions/workflows/build-test-report.yml) [![Latest Release](https://img.shields.io/github/v/release/centrifuge/sdk?sort=semver)](https://github.com/centrifuge/sdk/releases/latest)

The Centrifuge SDK is a JavaScript client for interacting with the [Centrifuge](https://centrifuge.io) ecosystem. It provides a comprehensive, fully typed library to integrate investments and redemptions, generate financial reports, manage pools, and much more.

### Installation

Centrifuge SDK uses [Viem](https://viem.sh/) under the hood. It's necessary to install it alongside the SDK.

```bash
npm install --save @centrifuge/sdk viem
## or
yarn install @centrifuge/sdk viem
```

### Init and config

Create an instance and pass optional configuration

```js
import Centrifuge from '@centrifuge/sdk'

const centrifuge = new Centrifuge()
```

The following config options can be passed on initialization of the SDK:

- `environment: 'mainnet' | 'demo' | 'dev'`
- Optional
- Default value: `mainnet`
- `rpcUrls: Record<number, string>`
- Optional
- A object mapping chain ids to RPC URLs

### Queries

Queries return Promise-like [Observables](https://rxjs.dev/guide/observable). They can be either awaited to get a single value, or subscribed to to get fresh data whenever on-chain data changes.

```js
try {
const pool = await centrifuge.pools()
} catch (error) {
console.error(error)
}
```

```js
const subscription = centrifuge.pools().subscribe(
(pool) => console.log(pool),
(error) => console.error(error)
)
subscription.unsubscribe()
```

The returned results are either immutable values, or entities that can be further queried.

### Transactions

To perform transactions, you need to set a signer on the `centrifuge` instance.

```js
centrifuge.setSigner(signer)
```

`signer` can be a [EIP1193](https://eips.ethereum.org/EIPS/eip-1193)-compatible provider or a Viem [LocalAccount](https://viem.sh/docs/accounts/local).

With this you can call transaction methods. Similar to queries they can be awaited to get their final result, or subscribed to get get status updates.

```js
const pool = await centrifuge.pool('1')
try {
const status = await pool.closeEpoch()
console.log(status)
} catch (error) {
console.error(error)
}
```

```js
const pool = await centrifuge.pool('1')
const subscription = pool.closeEpoch().subscribe(
(status) => console.log(pool),
(error) => console.error(error),
() => console.log('complete')
)
```

### Investments

Investments for a pool are done via [ERC-7540 Tokenized Vaults](https://eips.ethereum.org/EIPS/eip-7540). Vaults can be deployed for a tranche on any supported network, for any supported currency

Retrieve a vault by querying it from the pool:

```js
const pool = await centrifuge.pool('1')
const vault = await pool.vault(1, '0xabc...', '0xdef...') // Chain ID, tranche ID, investment currency address
```

Query the state of an investment on the vault for an investor:

```js
const investment = await vault.investment('0x123...')
// Will return an object containing:
// isAllowedToInvest - Whether an investor is allowed to invest in the tranche
// investmentCurrency - The ERC20 token that is used to invest in the vault
// investmentCurrencyBalance - The balance of the investor of the investment currency
// investmentCurrencyAllowance - The allowance of the vault
// shareCurrency - The ERC20 token that is issued to investors to account for their share in the tranche
// shareBalance - The number of shares the investor has in the tranche
// claimableInvestShares - The number of shares an investor can claim after their invest order has been processed (partially or not)
// claimableInvestCurrencyEquivalent - The equivalent value of the claimable shares denominated in the invest currency
// claimableRedeemCurrency - The amout of money an investor can claim after their redeem order has been processed (partially or not)
// claimableRedeemSharesEquivalent - The amount of shares that have been redeemed for which the investor can claim money
// pendingInvestCurrency - The amount of money that the investor wants to invest in the tranche that has not been processed yet
// pendingRedeemShares - The amount of shares that the investor wants to redeem from the tranche that has not been processed yet
// claimableCancelInvestCurrency - The amount of money an investor can claim after an invest order cancellation has been processed
// claimableCancelRedeemShares - The amount of shares an investor can claim after a redeem order cancellation has been processed
// hasPendingCancelInvestRequest - Whether the investor has an invest order that is in the process of being cancelled
// hasPendingCancelRedeemRequest - Whether the investor has a redeem order that is in the process of being cancelled
```

Invest in a vault:

```js
const result = await vault.increaseInvestOrder(1000)
console.log(result.hash)
```

Once an order has been processed, `claimableInvestShares` will positive and shares can be claimed with:

```js
const result = await vault.claim()
```

### Reports

Reports are generated from data from the Centrifuge API and are combined with pool metadata to provide a comprehensive view of the pool's financials.

Available reports are:

- `balanceSheet`
- `profitAndLoss`
- `cashflow`

```ts
const pool = await centrifuge.pool('<pool-id>')
const balanceSheetReport = await pool.reports.balanceSheet()
```

#### Report Filtering

Reports can be filtered using the `ReportFilter` type.

```ts
type GroupBy = 'day' | 'month' | 'quarter' | 'year'

const balanceSheetReport = await pool.reports.balanceSheet({
from: '2024-01-01',
to: '2024-01-31',
groupBy: 'month',
})
```

### Developer Docs

#### Dev server

```bash
yarn dev
```

#### Build

```bash
yarn build
```

#### Test

```bash
yarn test
yarn test:single <path-to-file>
yarn test:simple:single <path-to-file> ## without setup file, faster and without tenderly setup
```

#### PR Naming Convention

PR naming should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.

#### Semantic Versioning

PRs should be marked with the appropriate type: `major`, `minor`, `patch`, `no-release`.
68 changes: 68 additions & 0 deletions docs/_globals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

## @centrifuge/sdk

### References

#### default

Renames and re-exports [Centrifuge](#class-centrifuge)

### Classes

- [Centrifuge](#class-centrifuge)
- [Currency](#class-currency)
- [~~Perquintill~~](#class-perquintill)
- [Pool](#class-pool)
- [PoolNetwork](#class-poolnetwork)
- [Price](#class-price)
- [~~Rate~~](#class-rate)
- [Reports](#class-reports)
- [Vault](#class-vault)

### Interfaces

- [ReportFilter](#interfaces-reportfilter)

### Typees

- [AssetListReport](#type-assetlistreport)
- [AssetListReportBase](#type-assetlistreportbase)
- [AssetListReportFilter](#type-assetlistreportfilter)
- [AssetListReportPrivateCredit](#type-assetlistreportprivatecredit)
- [AssetListReportPublicCredit](#type-assetlistreportpubliccredit)
- [AssetTransactionReport](#type-assettransactionreport)
- [AssetTransactionReportFilter](#type-assettransactionreportfilter)
- [BalanceSheetReport](#type-balancesheetreport)
- [CashflowReport](#type-cashflowreport)
- [CashflowReportBase](#type-cashflowreportbase)
- [CashflowReportPrivateCredit](#type-cashflowreportprivatecredit)
- [CashflowReportPublicCredit](#type-cashflowreportpubliccredit)
- [Client](#type-client)
- [Config](#type-config)
- [CurrencyMetadata](#type-currencymetadata)
- [EIP1193ProviderLike](#type-eip1193providerlike)
- [FeeTransactionReport](#type-feetransactionreport)
- [FeeTransactionReportFilter](#type-feetransactionreportfilter)
- [GroupBy](#type-groupby)
- [HexString](#type-hexstring)
- [InvestorListReport](#type-investorlistreport)
- [InvestorListReportFilter](#type-investorlistreportfilter)
- [InvestorTransactionsReport](#type-investortransactionsreport)
- [InvestorTransactionsReportFilter](#type-investortransactionsreportfilter)
- [OperationConfirmedStatus](#type-operationconfirmedstatus)
- [OperationPendingStatus](#type-operationpendingstatus)
- [OperationSignedMessageStatus](#type-operationsignedmessagestatus)
- [OperationSigningMessageStatus](#type-operationsigningmessagestatus)
- [OperationSigningStatus](#type-operationsigningstatus)
- [OperationStatus](#type-operationstatus)
- [OperationStatusType](#type-operationstatustype)
- [OperationSwitchChainStatus](#type-operationswitchchainstatus)
- [ProfitAndLossReport](#type-profitandlossreport)
- [ProfitAndLossReportBase](#type-profitandlossreportbase)
- [ProfitAndLossReportPrivateCredit](#type-profitandlossreportprivatecredit)
- [ProfitAndLossReportPublicCredit](#type-profitandlossreportpubliccredit)
- [Query](#type-query)
- [Signer](#type-signer)
- [TokenPriceReport](#type-tokenpricereport)
- [TokenPriceReportFilter](#type-tokenpricereportfilter)
- [Transaction](#type-transaction)
Loading
Loading