-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add orders report * Clean up * [bot] New pkg version: 0.0.0-alpha.6 * Fix tests * Add asset time series report * Fix error handling in balance sheet report * Add missing fields to tokenPrice report * Add name to assetList report * Add trancheId to investorList * Add fromAsset and toAsset in AssetTransaction report * Fix failing test --------- Co-authored-by: GitHub Actions <actions@github.com>
- Loading branch information
1 parent
1e4b291
commit da1e121
Showing
13 changed files
with
503 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Currency, Price } from '../utils/BigInt.js' | ||
|
||
export type EpochFilter = Partial<Record<keyof SubqueryEpochs['epoches']['nodes'][0], any>> | ||
|
||
export type Epoch = { | ||
epochId: string | ||
closedAt: string | ||
paidFees: Currency | ||
tokenPrice: Price | ||
sumOutstandingInvestOrders: Currency | ||
sumFulfilledInvestOrders: Currency | ||
sumOutstandingRedeemOrders: Currency | ||
sumFulfilledRedeemOrders: Currency | ||
netAssetValue: Currency | ||
} | ||
|
||
type SubqueryEpochs = { | ||
epoches: { | ||
nodes: { | ||
id: string | ||
sumPoolFeesPaidAmount: string | ||
closedAt: string | ||
epochStates: { | ||
nodes: { | ||
tokenPrice: string | ||
sumOutstandingInvestOrders: string | ||
sumFulfilledInvestOrders: string | ||
sumOutstandingRedeemOrders: string | ||
sumFulfilledRedeemOrders: string | ||
}[] | ||
} | ||
pool: { | ||
currency: { | ||
decimals: number | ||
} | ||
} | ||
poolSnapshots: { | ||
nodes: { | ||
netAssetValue: string | ||
}[] | ||
} | ||
}[] | ||
} | ||
} | ||
|
||
export const epochsPostProcess = (data: SubqueryEpochs): Epoch[] => { | ||
return data.epoches.nodes.map((order) => { | ||
const index = order.epochStates.nodes.length > 1 ? order.epochStates.nodes.length - 1 : 0 | ||
const epochStates = order.epochStates.nodes[index] | ||
const currencyDecimals = order.pool.currency.decimals | ||
return { | ||
epochId: order.id, | ||
closedAt: order.closedAt, | ||
paidFees: new Currency(order.sumPoolFeesPaidAmount, currencyDecimals), | ||
tokenPrice: new Price(epochStates?.tokenPrice ?? '0'), | ||
sumOutstandingInvestOrders: new Currency(epochStates?.sumOutstandingInvestOrders ?? '0', currencyDecimals), | ||
sumFulfilledInvestOrders: new Currency(epochStates?.sumFulfilledInvestOrders ?? '0', currencyDecimals), | ||
sumOutstandingRedeemOrders: new Currency(epochStates?.sumOutstandingRedeemOrders ?? '0', currencyDecimals), | ||
sumFulfilledRedeemOrders: new Currency(epochStates?.sumFulfilledRedeemOrders ?? '0', currencyDecimals), | ||
netAssetValue: new Currency(order.poolSnapshots.nodes[index]?.netAssetValue ?? '0', currencyDecimals), | ||
} satisfies Epoch | ||
}) | ||
} | ||
|
||
export const epochsQuery = ` | ||
query($filter: EpochFilter) { | ||
epoches(filter: $filter) { | ||
nodes { | ||
poolId | ||
id | ||
sumPoolFeesPaidAmount | ||
closedAt | ||
epochStates { | ||
nodes { | ||
tokenPrice | ||
sumOutstandingInvestOrders | ||
sumFulfilledInvestOrders | ||
sumOutstandingRedeemOrders | ||
sumFulfilledRedeemOrders | ||
} | ||
} | ||
pool { | ||
currency { | ||
decimals | ||
} | ||
} | ||
poolSnapshots { | ||
nodes { | ||
netAssetValue | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.