@centrifuge/sdk 0.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +149 -0
- package/dist/Account.d.ts +11 -0
- package/dist/Account.d.ts.map +1 -0
- package/dist/Account.js +46 -0
- package/dist/Account.js.map +1 -0
- package/dist/Centrifuge.d.ts +7117 -0
- package/dist/Centrifuge.d.ts.map +1 -0
- package/dist/Centrifuge.js +464 -0
- package/dist/Centrifuge.js.map +1 -0
- package/dist/Entity.d.ts +12 -0
- package/dist/Entity.d.ts.map +1 -0
- package/dist/Entity.js +16 -0
- package/dist/Entity.js.map +1 -0
- package/dist/Pool.d.ts +27 -0
- package/dist/Pool.d.ts.map +1 -0
- package/dist/Pool.js +73 -0
- package/dist/Pool.js.map +1 -0
- package/dist/PoolNetwork.d.ts +82 -0
- package/dist/PoolNetwork.d.ts.map +1 -0
- package/dist/PoolNetwork.js +235 -0
- package/dist/PoolNetwork.js.map +1 -0
- package/dist/Reports/Processor.d.ts +38 -0
- package/dist/Reports/Processor.d.ts.map +1 -0
- package/dist/Reports/Processor.js +167 -0
- package/dist/Reports/Processor.js.map +1 -0
- package/dist/Reports/index.d.ts +24 -0
- package/dist/Reports/index.d.ts.map +1 -0
- package/dist/Reports/index.js +68 -0
- package/dist/Reports/index.js.map +1 -0
- package/dist/Reports/types.d.ts +102 -0
- package/dist/Reports/types.d.ts.map +1 -0
- package/dist/Reports/types.js +2 -0
- package/dist/Reports/types.js.map +1 -0
- package/dist/Vault.d.ts +96 -0
- package/dist/Vault.d.ts.map +1 -0
- package/dist/Vault.js +330 -0
- package/dist/Vault.js.map +1 -0
- package/dist/abi/CentrifugeRouter.abi.json +43 -0
- package/dist/abi/Currency.abi.json +14 -0
- package/dist/abi/Gateway.abi.json +1 -0
- package/dist/abi/InvestmentManager.abi.json +4 -0
- package/dist/abi/LiquidityPool.abi.json +79 -0
- package/dist/abi/PoolManager.abi.json +55 -0
- package/dist/abi/RestrictionManager.abi.json +22 -0
- package/dist/abi/Router.abi.json +1 -0
- package/dist/abi/index.d.ts +11 -0
- package/dist/abi/index.d.ts.map +1 -0
- package/dist/abi/index.js +20 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/config/chains.d.ts +1575 -0
- package/dist/config/chains.d.ts.map +1 -0
- package/dist/config/chains.js +3 -0
- package/dist/config/chains.js.map +1 -0
- package/dist/config/lp.d.ts +17 -0
- package/dist/config/lp.d.ts.map +1 -0
- package/dist/config/lp.js +35 -0
- package/dist/config/lp.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/queries/poolFeeSnapshots.d.ts +48 -0
- package/dist/queries/poolFeeSnapshots.d.ts.map +1 -0
- package/dist/queries/poolFeeSnapshots.js +62 -0
- package/dist/queries/poolFeeSnapshots.js.map +1 -0
- package/dist/queries/poolSnapshots.d.ts +73 -0
- package/dist/queries/poolSnapshots.d.ts.map +1 -0
- package/dist/queries/poolSnapshots.js +106 -0
- package/dist/queries/poolSnapshots.js.map +1 -0
- package/dist/queries/trancheSnapshots.d.ts +70 -0
- package/dist/queries/trancheSnapshots.d.ts.map +1 -0
- package/dist/queries/trancheSnapshots.js +76 -0
- package/dist/queries/trancheSnapshots.js.map +1 -0
- package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts +3 -0
- package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts.map +1 -0
- package/dist/tests/mocks/mockPoolFeeSnapshot.js +68 -0
- package/dist/tests/mocks/mockPoolFeeSnapshot.js.map +1 -0
- package/dist/tests/mocks/mockPoolMetadata.d.ts +3 -0
- package/dist/tests/mocks/mockPoolMetadata.d.ts.map +1 -0
- package/dist/tests/mocks/mockPoolMetadata.js +118 -0
- package/dist/tests/mocks/mockPoolMetadata.js.map +1 -0
- package/dist/tests/mocks/mockPoolSnapshots.d.ts +3 -0
- package/dist/tests/mocks/mockPoolSnapshots.d.ts.map +1 -0
- package/dist/tests/mocks/mockPoolSnapshots.js +64 -0
- package/dist/tests/mocks/mockPoolSnapshots.js.map +1 -0
- package/dist/tests/mocks/mockTrancheSnapshots.d.ts +3 -0
- package/dist/tests/mocks/mockTrancheSnapshots.d.ts.map +1 -0
- package/dist/tests/mocks/mockTrancheSnapshots.js +112 -0
- package/dist/tests/mocks/mockTrancheSnapshots.js.map +1 -0
- package/dist/tests/setup.d.ts +16 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +41 -0
- package/dist/tests/setup.js.map +1 -0
- package/dist/tests/tenderly.d.ts +76 -0
- package/dist/tests/tenderly.d.ts.map +1 -0
- package/dist/tests/tenderly.js +219 -0
- package/dist/tests/tenderly.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/poolMetadata.d.ts +92 -0
- package/dist/types/poolMetadata.d.ts.map +1 -0
- package/dist/types/poolMetadata.js +2 -0
- package/dist/types/poolMetadata.js.map +1 -0
- package/dist/types/query.d.ts +11 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +2 -0
- package/dist/types/query.js.map +1 -0
- package/dist/types/transaction.d.ts +47 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/transaction.js +2 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/utils/BigInt.d.ts +80 -0
- package/dist/utils/BigInt.d.ts.map +1 -0
- package/dist/utils/BigInt.js +215 -0
- package/dist/utils/BigInt.js.map +1 -0
- package/dist/utils/date.d.ts +17 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +36 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/decimal.d.ts +6 -0
- package/dist/utils/decimal.d.ts.map +1 -0
- package/dist/utils/decimal.js +13 -0
- package/dist/utils/decimal.js.map +1 -0
- package/dist/utils/pinToApi.d.ts +2 -0
- package/dist/utils/pinToApi.d.ts.map +1 -0
- package/dist/utils/pinToApi.js +10 -0
- package/dist/utils/pinToApi.js.map +1 -0
- package/dist/utils/query.d.ts +2 -0
- package/dist/utils/query.d.ts.map +1 -0
- package/dist/utils/query.js +37 -0
- package/dist/utils/query.js.map +1 -0
- package/dist/utils/rx.d.ts +19 -0
- package/dist/utils/rx.d.ts.map +1 -0
- package/dist/utils/rx.js +45 -0
- package/dist/utils/rx.js.map +1 -0
- package/dist/utils/transaction.d.ts +14 -0
- package/dist/utils/transaction.d.ts.map +1 -0
- package/dist/utils/transaction.js +33 -0
- package/dist/utils/transaction.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Entity } from '../Entity.js';
|
|
2
|
+
import { poolSnapshotsPostProcess, poolSnapshotsQuery } from '../queries/poolSnapshots.js';
|
|
3
|
+
import { trancheSnapshotsPostProcess, trancheSnapshotsQuery, } from '../queries/trancheSnapshots.js';
|
|
4
|
+
import { combineLatest } from 'rxjs';
|
|
5
|
+
import { processor } from './Processor.js';
|
|
6
|
+
import { map } from 'rxjs';
|
|
7
|
+
import { poolFeeSnapshotQuery, poolFeeSnapshotsPostProcess, } from '../queries/poolFeeSnapshots.js';
|
|
8
|
+
export class Reports extends Entity {
|
|
9
|
+
pool;
|
|
10
|
+
constructor(centrifuge, pool) {
|
|
11
|
+
super(centrifuge, ['reports', pool.id]);
|
|
12
|
+
this.pool = pool;
|
|
13
|
+
}
|
|
14
|
+
balanceSheet(filter) {
|
|
15
|
+
return this._generateReport('balanceSheet', filter);
|
|
16
|
+
}
|
|
17
|
+
cashflow(filter) {
|
|
18
|
+
return this._generateReport('cashflow', filter);
|
|
19
|
+
}
|
|
20
|
+
profitAndLoss(filter) {
|
|
21
|
+
return this._generateReport('profitAndLoss', filter);
|
|
22
|
+
}
|
|
23
|
+
_generateReport(type, filter) {
|
|
24
|
+
return this._query([type, filter?.from, filter?.to, filter?.groupBy], () => {
|
|
25
|
+
const dateFilter = {
|
|
26
|
+
timestamp: {
|
|
27
|
+
greaterThan: filter?.from,
|
|
28
|
+
lessThanOrEqualTo: filter?.to && `${filter.to.split('T')[0]}T23:59:59.999Z`,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const metadata$ = this.pool.metadata();
|
|
32
|
+
const poolSnapshots$ = this.poolSnapshots({
|
|
33
|
+
...dateFilter,
|
|
34
|
+
poolId: { equalTo: this.pool.id },
|
|
35
|
+
});
|
|
36
|
+
const trancheSnapshots$ = this.trancheSnapshots({
|
|
37
|
+
...dateFilter,
|
|
38
|
+
tranche: { poolId: { equalTo: this.pool.id } },
|
|
39
|
+
});
|
|
40
|
+
const poolFeeSnapshots$ = this.poolFeeSnapshots({
|
|
41
|
+
...dateFilter,
|
|
42
|
+
poolFeeId: { includes: this.pool.id },
|
|
43
|
+
});
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'balanceSheet':
|
|
46
|
+
return combineLatest([poolSnapshots$, trancheSnapshots$]).pipe(map(([poolSnapshots, trancheSnapshots]) => processor.balanceSheet({ poolSnapshots, trancheSnapshots }, filter)));
|
|
47
|
+
case 'cashflow':
|
|
48
|
+
return combineLatest([poolSnapshots$, poolFeeSnapshots$, metadata$]).pipe(map(([poolSnapshots, poolFeeSnapshots, metadata]) => processor.cashflow({ poolSnapshots, poolFeeSnapshots, metadata }, filter)));
|
|
49
|
+
case 'profitAndLoss':
|
|
50
|
+
return combineLatest([poolSnapshots$, poolFeeSnapshots$, metadata$]).pipe(map(([poolSnapshots, poolFeeSnapshots, metadata]) => processor.profitAndLoss({ poolSnapshots, poolFeeSnapshots, metadata }, filter)));
|
|
51
|
+
default:
|
|
52
|
+
throw new Error(`Unsupported report type: ${type}`);
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
valueCacheTime: 120,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
poolFeeSnapshots(filter) {
|
|
59
|
+
return this._root._queryIndexer(poolFeeSnapshotQuery, { filter }, poolFeeSnapshotsPostProcess);
|
|
60
|
+
}
|
|
61
|
+
poolSnapshots(filter) {
|
|
62
|
+
return this._root._queryIndexer(poolSnapshotsQuery, { filter }, poolSnapshotsPostProcess);
|
|
63
|
+
}
|
|
64
|
+
trancheSnapshots(filter) {
|
|
65
|
+
return this._root._queryIndexer(trancheSnapshotsQuery, { filter }, trancheSnapshotsPostProcess);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Reports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAsB,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9G,OAAO,EAEL,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAG1B,OAAO,EAEL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,gCAAgC,CAAA;AAKvC,MAAM,OAAO,OAAQ,SAAQ,MAAM;IAGxB;IAFT,YACE,UAAsB,EACf,IAAU;QAEjB,KAAK,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QAFhC,SAAI,GAAJ,IAAI,CAAM;IAGnB,CAAC;IAED,YAAY,CAAC,MAAqB;QAChC,OAAO,IAAI,CAAC,eAAe,CAAqB,cAAc,EAAE,MAAM,CAAC,CAAA;IACzE,C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EAAE,EAAE,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAA;IAC3F,CAAC;IAED,gBAAgB,CAAC,MAA8B;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,EAAE,2BAA2B,CAAC,CAAA;IACjG,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { PoolFeeSnapshotsByDate } from '../queries/poolFeeSnapshots.js';
|
|
2
|
+
import { PoolSnapshot } from '../queries/poolSnapshots.js';
|
|
3
|
+
import { TrancheSnapshotsByDate } from '../queries/trancheSnapshots.js';
|
|
4
|
+
import { PoolMetadata } from '../types/poolMetadata.js';
|
|
5
|
+
import { Price } from '../utils/BigInt.js';
|
|
6
|
+
import { Currency } from '../utils/BigInt.js';
|
|
7
|
+
import { GroupBy } from '../utils/date.js';
|
|
8
|
+
export interface ReportFilter {
|
|
9
|
+
from?: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
groupBy?: GroupBy;
|
|
12
|
+
}
|
|
13
|
+
export type BalanceSheetReport = {
|
|
14
|
+
type: 'balanceSheet';
|
|
15
|
+
timestamp: string;
|
|
16
|
+
assetValuation: Currency;
|
|
17
|
+
onchainReserve: Currency;
|
|
18
|
+
offchainCash: Currency;
|
|
19
|
+
accruedFees: Currency;
|
|
20
|
+
netAssetValue: Currency;
|
|
21
|
+
tranches?: {
|
|
22
|
+
name: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
tokenId: string;
|
|
25
|
+
tokenSupply: Currency;
|
|
26
|
+
tokenPrice: Price | null;
|
|
27
|
+
trancheValue: Currency;
|
|
28
|
+
}[];
|
|
29
|
+
totalCapital?: Currency;
|
|
30
|
+
};
|
|
31
|
+
export type BalanceSheetData = {
|
|
32
|
+
poolSnapshots: PoolSnapshot[];
|
|
33
|
+
trancheSnapshots: TrancheSnapshotsByDate;
|
|
34
|
+
};
|
|
35
|
+
type CashflowReportBase = {
|
|
36
|
+
type: 'cashflow';
|
|
37
|
+
timestamp: string;
|
|
38
|
+
principalPayments: Currency;
|
|
39
|
+
interestPayments: Currency;
|
|
40
|
+
netCashflowAsset: Currency;
|
|
41
|
+
fees: {
|
|
42
|
+
name: string;
|
|
43
|
+
amount: Currency;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
feeId: string;
|
|
46
|
+
}[];
|
|
47
|
+
netCashflowAfterFees: Currency;
|
|
48
|
+
investments: Currency;
|
|
49
|
+
redemptions: Currency;
|
|
50
|
+
activitiesCashflow: Currency;
|
|
51
|
+
totalCashflow: Currency;
|
|
52
|
+
endCashBalance: {
|
|
53
|
+
balance: Currency;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type CashflowReportPublicCredit = CashflowReportBase & {
|
|
57
|
+
subtype: 'publicCredit';
|
|
58
|
+
realizedPL?: Currency;
|
|
59
|
+
assetPurchases?: Currency;
|
|
60
|
+
};
|
|
61
|
+
type CashflowReportPrivateCredit = CashflowReportBase & {
|
|
62
|
+
subtype: 'privateCredit';
|
|
63
|
+
assetFinancing?: Currency;
|
|
64
|
+
};
|
|
65
|
+
export type CashflowReport = CashflowReportPublicCredit | CashflowReportPrivateCredit;
|
|
66
|
+
export type CashflowData = {
|
|
67
|
+
poolSnapshots: PoolSnapshot[];
|
|
68
|
+
poolFeeSnapshots: PoolFeeSnapshotsByDate;
|
|
69
|
+
metadata: PoolMetadata | undefined;
|
|
70
|
+
};
|
|
71
|
+
export type ProfitAndLossReportBase = {
|
|
72
|
+
type: 'profitAndLoss';
|
|
73
|
+
timestamp: string;
|
|
74
|
+
profitAndLossFromAsset: Currency;
|
|
75
|
+
interestPayments: Currency;
|
|
76
|
+
otherPayments: Currency;
|
|
77
|
+
totalExpenses: Currency;
|
|
78
|
+
totalProfitAndLoss: Currency;
|
|
79
|
+
fees: {
|
|
80
|
+
name: string;
|
|
81
|
+
amount: Currency;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
feeId: string;
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
export type ProfitAndLossReportPublicCredit = ProfitAndLossReportBase & {
|
|
87
|
+
subtype: 'publicCredit';
|
|
88
|
+
totalIncome: Currency;
|
|
89
|
+
};
|
|
90
|
+
export type ProfitAndLossReportPrivateCredit = ProfitAndLossReportBase & {
|
|
91
|
+
subtype: 'privateCredit';
|
|
92
|
+
interestAccrued: Currency;
|
|
93
|
+
assetWriteOffs: Currency;
|
|
94
|
+
};
|
|
95
|
+
export type ProfitAndLossReport = ProfitAndLossReportPublicCredit | ProfitAndLossReportPrivateCredit;
|
|
96
|
+
export type ProfitAndLossData = {
|
|
97
|
+
poolSnapshots: PoolSnapshot[];
|
|
98
|
+
poolFeeSnapshots: PoolFeeSnapshotsByDate;
|
|
99
|
+
metadata: PoolMetadata | undefined;
|
|
100
|
+
};
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Reports/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,cAAc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;IAC9B,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,gBAAgB,EAAE,sBAAsB,CAAA;IACxC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;CACnC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Reports/types.ts"],"names":[],"mappings":""}
|
package/dist/Vault.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Decimal } from 'decimal.js-light';
|
|
2
|
+
import type { Centrifuge } from './Centrifuge.js';
|
|
3
|
+
import { Entity } from './Entity.js';
|
|
4
|
+
import type { Pool } from './Pool.js';
|
|
5
|
+
import { PoolNetwork } from './PoolNetwork.js';
|
|
6
|
+
import type { HexString } from './types/index.js';
|
|
7
|
+
import { Currency, DecimalWrapper, Token } from './utils/BigInt.js';
|
|
8
|
+
/**
|
|
9
|
+
* Query and interact with a vault, which is the main entry point for investing and redeeming funds.
|
|
10
|
+
* A vault is the combination of a network, a pool, a tranche and an investment currency.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Vault extends Entity {
|
|
13
|
+
network: PoolNetwork;
|
|
14
|
+
trancheId: string;
|
|
15
|
+
pool: Pool;
|
|
16
|
+
chainId: number;
|
|
17
|
+
/**
|
|
18
|
+
* The contract address of the investment currency.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_asset: HexString;
|
|
22
|
+
/**
|
|
23
|
+
* The contract address of the vault.
|
|
24
|
+
*/
|
|
25
|
+
address: HexString;
|
|
26
|
+
constructor(_root: Centrifuge, network: PoolNetwork, trancheId: string, asset: HexString, address: HexString);
|
|
27
|
+
/**
|
|
28
|
+
* Get the contract address of the restriction mananger.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
_restrictionManager(): import("./index.js").Query<`0x${string}`>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the details of the investment currency.
|
|
34
|
+
*/
|
|
35
|
+
investmentCurrency(): import("./index.js").Query<import("./config/lp.js").CurrencyMetadata>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the details of the share token.
|
|
38
|
+
*/
|
|
39
|
+
shareCurrency(): import("./index.js").Query<import("./config/lp.js").CurrencyMetadata>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the allowance of the investment currency for the CentrifugeRouter,
|
|
42
|
+
* which is the contract that moves funds into the vault on behalf of the investor.
|
|
43
|
+
* @param owner - The address of the owner
|
|
44
|
+
*/
|
|
45
|
+
allowance(owner: string): import("./index.js").Query<Currency>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the details of the investment of an investor in the vault and any pending investments or redemptions.
|
|
48
|
+
* @param investor - The address of the investor
|
|
49
|
+
*/
|
|
50
|
+
investment(investor: string): import("./index.js").Query<{
|
|
51
|
+
shareBalance: Token;
|
|
52
|
+
investmentCurrencyBalance: Currency;
|
|
53
|
+
investmentCurrencyAllowance: Currency;
|
|
54
|
+
isAllowedToInvest: boolean;
|
|
55
|
+
claimableInvestShares: Token;
|
|
56
|
+
claimableInvestCurrencyEquivalent: Currency;
|
|
57
|
+
claimableRedeemCurrency: Currency;
|
|
58
|
+
claimableRedeemSharesEquivalent: Token;
|
|
59
|
+
pendingInvestCurrency: Currency;
|
|
60
|
+
pendingRedeemShares: Token;
|
|
61
|
+
claimableCancelInvestCurrency: Currency;
|
|
62
|
+
claimableCancelRedeemShares: Token;
|
|
63
|
+
hasPendingCancelInvestRequest: boolean;
|
|
64
|
+
hasPendingCancelRedeemRequest: boolean;
|
|
65
|
+
investmentCurrency: import("./config/lp.js").CurrencyMetadata;
|
|
66
|
+
shareCurrency: import("./config/lp.js").CurrencyMetadata;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Place an order to invest funds in the vault. If an order exists, it will increase the amount.
|
|
70
|
+
* @param investAmount - The amount to invest in the vault
|
|
71
|
+
*/
|
|
72
|
+
increaseInvestOrder(investAmount: NumberInput): import("./index.js").Transaction;
|
|
73
|
+
/**
|
|
74
|
+
* Cancel an open investment order.
|
|
75
|
+
*/
|
|
76
|
+
cancelInvestOrder(): import("./index.js").Transaction;
|
|
77
|
+
/**
|
|
78
|
+
* Place an order to redeem funds from the vault. If an order exists, it will increase the amount.
|
|
79
|
+
* @param redeemAmount - The amount of shares to redeem
|
|
80
|
+
*/
|
|
81
|
+
increaseRedeemOrder(redeemAmount: NumberInput): import("./index.js").Transaction;
|
|
82
|
+
/**
|
|
83
|
+
* Cancel an open redemption order.
|
|
84
|
+
*/
|
|
85
|
+
cancelRedeemOrder(): import("./index.js").Transaction;
|
|
86
|
+
/**
|
|
87
|
+
* Claim any outstanding fund shares after an investment has gone through, or funds after an redemption has gone through.
|
|
88
|
+
* @param receiver - The address that should receive the funds. If not provided, the investor's address is used.
|
|
89
|
+
* @param controller - The address of the user that has invested. Allows someone else to claim on behalf of the user
|
|
90
|
+
* if the user has set the CentrifugeRouter as an operator on the vault. If not provided, the investor's address is used.
|
|
91
|
+
*/
|
|
92
|
+
claim(receiver?: string, controller?: string): import("./index.js").Transaction;
|
|
93
|
+
}
|
|
94
|
+
type NumberInput = number | bigint | DecimalWrapper | Decimal;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=Vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vault.d.ts","sourceRoot":"","sources":["../src/Vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAInE;;;GAGG;AACH,qBAAa,KAAM,SAAQ,MAAM;IActB,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,MAAM;IAd1B,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,MAAM,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAA;gBAEhB,KAAK,EAAE,UAAU,EACV,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,EACxB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,SAAS;IASpB;;;OAGG;IACH,mBAAmB;IAenB;;OAEG;IACH,kBAAkB;IAIlB;;OAEG;IACH,aAAa;IAIb;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM;IAwCvB;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;IA2G3B;;;OAGG;IACH,mBAAmB,CAAC,YAAY,EAAE,WAAW;IA8E7C;;OAEG;IACH,iBAAiB;IAoBjB;;;OAGG;IACH,mBAAmB,CAAC,YAAY,EAAE,WAAW;IAsB7C;;OAEG;IACH,iBAAiB;IAoBjB;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CA6B7C;AAED,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAA"}
|
package/dist/Vault.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { combineLatest, defer, map, switchMap } from 'rxjs';
|
|
2
|
+
import { encodeFunctionData, getContract } from 'viem';
|
|
3
|
+
import { Entity } from './Entity.js';
|
|
4
|
+
import { ABI } from './abi/index.js';
|
|
5
|
+
import { lpConfig } from './config/lp.js';
|
|
6
|
+
import { Currency, DecimalWrapper, Token } from './utils/BigInt.js';
|
|
7
|
+
import { repeatOnEvents } from './utils/rx.js';
|
|
8
|
+
import { doSignMessage, doTransaction, signPermit } from './utils/transaction.js';
|
|
9
|
+
/**
|
|
10
|
+
* Query and interact with a vault, which is the main entry point for investing and redeeming funds.
|
|
11
|
+
* A vault is the combination of a network, a pool, a tranche and an investment currency.
|
|
12
|
+
*/
|
|
13
|
+
export class Vault extends Entity {
|
|
14
|
+
network;
|
|
15
|
+
trancheId;
|
|
16
|
+
pool;
|
|
17
|
+
chainId;
|
|
18
|
+
/**
|
|
19
|
+
* The contract address of the investment currency.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
_asset;
|
|
23
|
+
/**
|
|
24
|
+
* The contract address of the vault.
|
|
25
|
+
*/
|
|
26
|
+
address;
|
|
27
|
+
constructor(_root, network, trancheId, asset, address) {
|
|
28
|
+
super(_root, ['vault', network.chainId, network.pool.id, trancheId, asset.toLowerCase()]);
|
|
29
|
+
this.network = network;
|
|
30
|
+
this.trancheId = trancheId;
|
|
31
|
+
this.chainId = network.chainId;
|
|
32
|
+
this.pool = network.pool;
|
|
33
|
+
this._asset = asset.toLowerCase();
|
|
34
|
+
this.address = address.toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the contract address of the restriction mananger.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
_restrictionManager() {
|
|
41
|
+
return this._query(['restrictionManager'], () => this.network._share(this.trancheId).pipe(switchMap((share) => this._root.getClient(this.chainId).readContract({
|
|
42
|
+
address: share,
|
|
43
|
+
abi: ABI.Currency,
|
|
44
|
+
functionName: 'hook',
|
|
45
|
+
}))));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the details of the investment currency.
|
|
49
|
+
*/
|
|
50
|
+
investmentCurrency() {
|
|
51
|
+
return this._root.currency(this._asset, this.chainId);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the details of the share token.
|
|
55
|
+
*/
|
|
56
|
+
shareCurrency() {
|
|
57
|
+
return this.network.shareCurrency(this.trancheId);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the allowance of the investment currency for the CentrifugeRouter,
|
|
61
|
+
* which is the contract that moves funds into the vault on behalf of the investor.
|
|
62
|
+
* @param owner - The address of the owner
|
|
63
|
+
*/
|
|
64
|
+
allowance(owner) {
|
|
65
|
+
const address = owner.toLowerCase();
|
|
66
|
+
return this._query(['allowance', address], () => this.investmentCurrency().pipe(switchMap((currency) => defer(() => this._root
|
|
67
|
+
.getClient(this.chainId)
|
|
68
|
+
.readContract({
|
|
69
|
+
address: this._asset,
|
|
70
|
+
abi: ABI.Currency,
|
|
71
|
+
functionName: 'allowance',
|
|
72
|
+
args: [address, lpConfig[this.chainId].centrifugeRouter],
|
|
73
|
+
})
|
|
74
|
+
.then((val) => new Currency(val, currency.decimals))).pipe(repeatOnEvents(this._root, {
|
|
75
|
+
address: this._asset,
|
|
76
|
+
abi: ABI.Currency,
|
|
77
|
+
eventName: ['Approval', 'Transfer'],
|
|
78
|
+
filter: (events) => {
|
|
79
|
+
return events.some((event) => {
|
|
80
|
+
return (event.args.owner?.toLowerCase() === address ||
|
|
81
|
+
event.args.spender?.toLowerCase() === this._asset ||
|
|
82
|
+
event.args.from?.toLowerCase() === address);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
}, this.chainId)))));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the details of the investment of an investor in the vault and any pending investments or redemptions.
|
|
89
|
+
* @param investor - The address of the investor
|
|
90
|
+
*/
|
|
91
|
+
investment(investor) {
|
|
92
|
+
const address = investor.toLowerCase();
|
|
93
|
+
return this._query(['investment', address], () => combineLatest([
|
|
94
|
+
this.investmentCurrency(),
|
|
95
|
+
this.shareCurrency(),
|
|
96
|
+
this.network._investmentManager(),
|
|
97
|
+
this._restrictionManager(),
|
|
98
|
+
]).pipe(switchMap(([investmentCurrency, shareCurrency, investmentManagerAddress, restrictionManagerAddress]) => combineLatest([
|
|
99
|
+
this._root.balance(investmentCurrency.address, address, this.chainId),
|
|
100
|
+
this._root.balance(shareCurrency.address, address, this.chainId),
|
|
101
|
+
this.allowance(address),
|
|
102
|
+
defer(async () => {
|
|
103
|
+
const client = this._root.getClient(this.chainId);
|
|
104
|
+
const vault = getContract({ address: this.address, abi: ABI.LiquidityPool, client });
|
|
105
|
+
const investmentManager = getContract({
|
|
106
|
+
address: investmentManagerAddress,
|
|
107
|
+
abi: ABI.InvestmentManager,
|
|
108
|
+
client,
|
|
109
|
+
});
|
|
110
|
+
const [isAllowedToInvest, maxDeposit, maxRedeem, investment] = await Promise.all([
|
|
111
|
+
vault.read.isPermissioned([address]),
|
|
112
|
+
vault.read.maxDeposit([address]),
|
|
113
|
+
vault.read.maxRedeem([address]),
|
|
114
|
+
investmentManager.read.investments([this.address, address]),
|
|
115
|
+
]);
|
|
116
|
+
const [maxMint, maxWithdraw, , , pendingInvest, pendingRedeem, claimableCancelInvestCurrency, claimableCancelRedeemShares, hasPendingCancelInvestRequest, hasPendingCancelRedeemRequest,] = investment;
|
|
117
|
+
return {
|
|
118
|
+
isAllowedToInvest,
|
|
119
|
+
claimableInvestShares: new Token(maxMint, shareCurrency.decimals),
|
|
120
|
+
claimableInvestCurrencyEquivalent: new Currency(maxDeposit, investmentCurrency.decimals),
|
|
121
|
+
claimableRedeemCurrency: new Currency(maxWithdraw, investmentCurrency.decimals),
|
|
122
|
+
claimableRedeemSharesEquivalent: new Token(maxRedeem, shareCurrency.decimals),
|
|
123
|
+
pendingInvestCurrency: new Currency(pendingInvest, investmentCurrency.decimals),
|
|
124
|
+
pendingRedeemShares: new Token(pendingRedeem, shareCurrency.decimals),
|
|
125
|
+
claimableCancelInvestCurrency: new Currency(claimableCancelInvestCurrency, investmentCurrency.decimals),
|
|
126
|
+
claimableCancelRedeemShares: new Token(claimableCancelRedeemShares, shareCurrency.decimals),
|
|
127
|
+
hasPendingCancelInvestRequest,
|
|
128
|
+
hasPendingCancelRedeemRequest,
|
|
129
|
+
investmentCurrency,
|
|
130
|
+
shareCurrency,
|
|
131
|
+
};
|
|
132
|
+
}).pipe(repeatOnEvents(this._root, {
|
|
133
|
+
address: [this.address, restrictionManagerAddress],
|
|
134
|
+
abi: [ABI.LiquidityPool, ABI.RestrictionManager],
|
|
135
|
+
eventName: [
|
|
136
|
+
'UpdateMember',
|
|
137
|
+
'CancelDepositClaim',
|
|
138
|
+
'CancelDepositClaimable',
|
|
139
|
+
'CancelDepositRequest',
|
|
140
|
+
'CancelRedeemClaim',
|
|
141
|
+
'CancelRedeemClaimable',
|
|
142
|
+
'CancelRedeemRequest',
|
|
143
|
+
'Deposit',
|
|
144
|
+
'DepositClaimable',
|
|
145
|
+
'DepositRequest',
|
|
146
|
+
'RedeemClaimable',
|
|
147
|
+
'RedeemRequest',
|
|
148
|
+
'Withdraw',
|
|
149
|
+
],
|
|
150
|
+
filter: (events) => events.some((event) => event.args.receiver?.toLowerCase() === address ||
|
|
151
|
+
event.args.controller?.toLowerCase() === address ||
|
|
152
|
+
event.args.sender?.toLowerCase() === address ||
|
|
153
|
+
event.args.owner?.toLowerCase() === address ||
|
|
154
|
+
// UpdateMember event
|
|
155
|
+
(event.args.user?.toLowerCase() === address &&
|
|
156
|
+
event.args.token?.toLowerCase() === shareCurrency.address)),
|
|
157
|
+
}, this.chainId)),
|
|
158
|
+
])), map(([currencyBalance, shareBalance, allowance, investment]) => ({
|
|
159
|
+
...investment,
|
|
160
|
+
shareBalance: new Token(shareBalance.toBigInt(), investment.shareCurrency.decimals),
|
|
161
|
+
investmentCurrencyBalance: currencyBalance,
|
|
162
|
+
investmentCurrencyAllowance: allowance,
|
|
163
|
+
}))));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Place an order to invest funds in the vault. If an order exists, it will increase the amount.
|
|
167
|
+
* @param investAmount - The amount to invest in the vault
|
|
168
|
+
*/
|
|
169
|
+
increaseInvestOrder(investAmount) {
|
|
170
|
+
const self = this;
|
|
171
|
+
return this._transactSequence(async function* ({ walletClient, publicClient, signer, signingAddress }) {
|
|
172
|
+
const { centrifugeRouter } = lpConfig[self.chainId];
|
|
173
|
+
const [estimate, investment] = await Promise.all([self.network._estimate(), self.investment(signingAddress)]);
|
|
174
|
+
const amount = toCurrency(investAmount, investment.investmentCurrency.decimals);
|
|
175
|
+
const { investmentCurrency, investmentCurrencyBalance, investmentCurrencyAllowance, isAllowedToInvest } = investment;
|
|
176
|
+
const supportsPermit = investmentCurrency.supportsPermit && 'send' in signer; // eth-permit uses the deprecated send method
|
|
177
|
+
const needsApproval = investmentCurrencyAllowance.lt(amount);
|
|
178
|
+
if (!isAllowedToInvest)
|
|
179
|
+
throw new Error('Not allowed to invest');
|
|
180
|
+
if (amount.gt(investmentCurrencyBalance))
|
|
181
|
+
throw new Error('Insufficient balance');
|
|
182
|
+
if (!amount.gt(0n))
|
|
183
|
+
throw new Error('Order amount must be greater than 0');
|
|
184
|
+
let permit = null;
|
|
185
|
+
if (needsApproval) {
|
|
186
|
+
if (supportsPermit) {
|
|
187
|
+
permit = yield* doSignMessage('Sign Permit', () => signPermit(walletClient, signer, self.chainId, signingAddress, investmentCurrency.address, centrifugeRouter, amount.toBigInt()));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
yield* doTransaction('Approve', publicClient, () => walletClient.writeContract({
|
|
191
|
+
address: investmentCurrency.address,
|
|
192
|
+
abi: ABI.Currency,
|
|
193
|
+
functionName: 'approve',
|
|
194
|
+
args: [centrifugeRouter, amount],
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const enableData = encodeFunctionData({
|
|
199
|
+
abi: ABI.CentrifugeRouter,
|
|
200
|
+
functionName: 'enableLockDepositRequest',
|
|
201
|
+
args: [self.address, amount],
|
|
202
|
+
});
|
|
203
|
+
const requestData = encodeFunctionData({
|
|
204
|
+
abi: ABI.CentrifugeRouter,
|
|
205
|
+
functionName: 'executeLockedDepositRequest',
|
|
206
|
+
args: [self.address, signingAddress, estimate],
|
|
207
|
+
});
|
|
208
|
+
const permitData = permit &&
|
|
209
|
+
encodeFunctionData({
|
|
210
|
+
abi: ABI.CentrifugeRouter,
|
|
211
|
+
functionName: 'permit',
|
|
212
|
+
args: [
|
|
213
|
+
investmentCurrency.address,
|
|
214
|
+
centrifugeRouter,
|
|
215
|
+
amount.toString(),
|
|
216
|
+
permit.deadline,
|
|
217
|
+
permit.v,
|
|
218
|
+
permit.r,
|
|
219
|
+
permit.s,
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
yield* doTransaction('Invest', publicClient, () => walletClient.writeContract({
|
|
223
|
+
address: centrifugeRouter,
|
|
224
|
+
abi: ABI.CentrifugeRouter,
|
|
225
|
+
functionName: 'multicall',
|
|
226
|
+
args: [[enableData, requestData, permitData].filter(Boolean)],
|
|
227
|
+
value: estimate,
|
|
228
|
+
}));
|
|
229
|
+
}, this.chainId);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Cancel an open investment order.
|
|
233
|
+
*/
|
|
234
|
+
cancelInvestOrder() {
|
|
235
|
+
const self = this;
|
|
236
|
+
return this._transactSequence(async function* ({ walletClient, signingAddress, publicClient }) {
|
|
237
|
+
const { centrifugeRouter } = lpConfig[self.chainId];
|
|
238
|
+
const [estimate, investment] = await Promise.all([self.network._estimate(), self.investment(signingAddress)]);
|
|
239
|
+
if (investment.pendingInvestCurrency.isZero())
|
|
240
|
+
throw new Error('No order to cancel');
|
|
241
|
+
yield* doTransaction('Cancel invest order', publicClient, () => walletClient.writeContract({
|
|
242
|
+
address: centrifugeRouter,
|
|
243
|
+
abi: ABI.CentrifugeRouter,
|
|
244
|
+
functionName: 'cancelDepositRequest',
|
|
245
|
+
args: [self.address, estimate],
|
|
246
|
+
value: estimate,
|
|
247
|
+
}));
|
|
248
|
+
}, this.chainId);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Place an order to redeem funds from the vault. If an order exists, it will increase the amount.
|
|
252
|
+
* @param redeemAmount - The amount of shares to redeem
|
|
253
|
+
*/
|
|
254
|
+
increaseRedeemOrder(redeemAmount) {
|
|
255
|
+
const self = this;
|
|
256
|
+
return this._transactSequence(async function* ({ walletClient, signingAddress, publicClient }) {
|
|
257
|
+
const { centrifugeRouter } = lpConfig[self.chainId];
|
|
258
|
+
const [estimate, investment] = await Promise.all([self.network._estimate(), self.investment(signingAddress)]);
|
|
259
|
+
const amount = toCurrency(redeemAmount, investment.shareCurrency.decimals);
|
|
260
|
+
if (amount.gt(investment.shareBalance))
|
|
261
|
+
throw new Error('Insufficient balance');
|
|
262
|
+
if (!amount.gt(0n))
|
|
263
|
+
throw new Error('Order amount must be greater than 0');
|
|
264
|
+
yield* doTransaction('Redeem', publicClient, () => walletClient.writeContract({
|
|
265
|
+
address: centrifugeRouter,
|
|
266
|
+
abi: ABI.CentrifugeRouter,
|
|
267
|
+
functionName: 'requestRedeem',
|
|
268
|
+
args: [self.address, amount.toBigInt(), signingAddress, signingAddress, estimate],
|
|
269
|
+
value: estimate,
|
|
270
|
+
}));
|
|
271
|
+
}, this.chainId);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Cancel an open redemption order.
|
|
275
|
+
*/
|
|
276
|
+
cancelRedeemOrder() {
|
|
277
|
+
const self = this;
|
|
278
|
+
return this._transactSequence(async function* ({ walletClient, signingAddress, publicClient }) {
|
|
279
|
+
const { centrifugeRouter } = lpConfig[self.chainId];
|
|
280
|
+
const [estimate, investment] = await Promise.all([self.network._estimate(), self.investment(signingAddress)]);
|
|
281
|
+
if (investment.pendingRedeemShares.isZero())
|
|
282
|
+
throw new Error('No order to cancel');
|
|
283
|
+
yield* doTransaction('Cancel redeem order', publicClient, () => walletClient.writeContract({
|
|
284
|
+
address: centrifugeRouter,
|
|
285
|
+
abi: ABI.CentrifugeRouter,
|
|
286
|
+
functionName: 'cancelRedeemRequest',
|
|
287
|
+
args: [self.address, estimate],
|
|
288
|
+
value: estimate,
|
|
289
|
+
}));
|
|
290
|
+
}, this.chainId);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Claim any outstanding fund shares after an investment has gone through, or funds after an redemption has gone through.
|
|
294
|
+
* @param receiver - The address that should receive the funds. If not provided, the investor's address is used.
|
|
295
|
+
* @param controller - The address of the user that has invested. Allows someone else to claim on behalf of the user
|
|
296
|
+
* if the user has set the CentrifugeRouter as an operator on the vault. If not provided, the investor's address is used.
|
|
297
|
+
*/
|
|
298
|
+
claim(receiver, controller) {
|
|
299
|
+
const self = this;
|
|
300
|
+
return this._transactSequence(async function* ({ walletClient, signingAddress, publicClient }) {
|
|
301
|
+
const { centrifugeRouter } = lpConfig[self.chainId];
|
|
302
|
+
const investment = await self.investment(signingAddress);
|
|
303
|
+
const receiverAddress = receiver || signingAddress;
|
|
304
|
+
const controllerAddress = controller || signingAddress;
|
|
305
|
+
const functionName = investment.claimableCancelInvestCurrency.gt(0n)
|
|
306
|
+
? 'claimCancelDepositRequest'
|
|
307
|
+
: investment.claimableCancelRedeemShares.gt(0n)
|
|
308
|
+
? 'claimCancelRedeemRequest'
|
|
309
|
+
: investment.claimableInvestShares.gt(0n)
|
|
310
|
+
? 'claimDeposit'
|
|
311
|
+
: investment.claimableRedeemCurrency.gt(0n)
|
|
312
|
+
? 'claimRedeem'
|
|
313
|
+
: '';
|
|
314
|
+
if (!functionName)
|
|
315
|
+
throw new Error('No claimable funds');
|
|
316
|
+
yield* doTransaction('Claim', publicClient, () => walletClient.writeContract({
|
|
317
|
+
address: centrifugeRouter,
|
|
318
|
+
abi: ABI.CentrifugeRouter,
|
|
319
|
+
functionName,
|
|
320
|
+
args: [self.address, receiverAddress, controllerAddress],
|
|
321
|
+
}));
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function toCurrency(val, decimals) {
|
|
326
|
+
return typeof val === 'number'
|
|
327
|
+
? Currency.fromFloat(val, decimals)
|
|
328
|
+
: new Currency(val instanceof DecimalWrapper ? val.to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