Skip to content

Commit 3a290c2

Browse files
committed
Merge branch 'main' into rs-index-wallet-balances
2 parents f3896d4 + 49d5bd3 commit 3a290c2

10 files changed

+247
-94
lines changed

.prettierrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": { "parser": "json" }
9+
}
10+
]
11+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"pub": "subql publish",
99
"codegen": "subql codegen",
1010
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
11-
"dev": "network=local && subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
11+
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
1212
"prepack": "rm -rf dist && npm run build",
1313
"test": "jest",
1414
"subql": "subql codegen --help",

project.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,26 @@ const project: CosmosProject = {
9696
// },
9797
// },
9898
// },
99-
{
100-
handler: "handleIbcSendPacketEvent",
101-
kind: CosmosHandlerKind.Event,
102-
filter: {
103-
type: "send_packet",
104-
messageFilter: {
105-
type: "/ibc.applications.transfer.v1.MsgTransfer",
106-
},
107-
},
108-
},
109-
{
110-
handler: "handleIbcReceivePacketEvent",
111-
kind: CosmosHandlerKind.Event,
112-
filter: {
113-
type: "recv_packet",
114-
messageFilter: {
115-
type: "/ibc.core.channel.v1.MsgRecvPacket",
116-
},
117-
},
118-
},
99+
// {
100+
// handler: "handleIbcSendPacketEvent",
101+
// kind: CosmosHandlerKind.Event,
102+
// filter: {
103+
// type: "send_packet",
104+
// messageFilter: {
105+
// type: "/ibc.applications.transfer.v1.MsgTransfer",
106+
// },
107+
// },
108+
// },
109+
// {
110+
// handler: "handleIbcReceivePacketEvent",
111+
// kind: CosmosHandlerKind.Event,
112+
// filter: {
113+
// type: "recv_packet",
114+
// messageFilter: {
115+
// type: "/ibc.core.channel.v1.MsgRecvPacket",
116+
// },
117+
// },
118+
// },
119119
{
120120
handler: "handleStateChangeEvent",
121121
kind: CosmosHandlerKind.Event,

schema.graphql

+7
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,10 @@ type VaultStatesDaily @entity {
303303
liquidated: BigInt!
304304
liquidatedClosed: BigInt!
305305
}
306+
307+
type Balances @entity {
308+
id: ID!
309+
address: String @index
310+
balance: BigInt
311+
denom: String @index
312+
}

src/mappings/events/boardAux.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BoardAux } from "../../types";
1+
import { BoardAux } from '../../types';
22

33
export const boardAuxEventKit = (block: any, data: any, module: string, path: string) => {
44
async function saveBoardAux(payload: any): Promise<Promise<any>[]> {
@@ -8,7 +8,7 @@ export const boardAuxEventKit = (block: any, data: any, module: string, path: st
88
block.block.header.time as any,
99
payload.allegedName,
1010
payload.displayInfo.assetKind,
11-
payload.displayInfo.decimalPlaces ?? 0
11+
payload.displayInfo.decimalPlaces ?? 0,
1212
).save();
1313

1414
return [boardAux];

src/mappings/events/priceFeed.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { OraclePrice, OraclePriceDaily } from "../../types";
2-
import { dateToDayKey } from "../utils";
1+
import { OraclePrice, OraclePriceDaily } from '../../types';
2+
import { dateToDayKey } from '../utils';
33

44
export const priceFeedEventKit = (block: any, data: any, module: string, path: string) => {
55
async function savePriceFeed(payload: any): Promise<Promise<any>[]> {
@@ -22,7 +22,7 @@ export const priceFeedEventKit = (block: any, data: any, module: string, path: s
2222
BigInt(payload.amountIn.__value),
2323
BigInt(payload.amountOut.__value),
2424
typeInName,
25-
typeOutName
25+
typeOutName,
2626
).save();
2727

2828
return [oraclePrice, oraclePriceDaily];
@@ -49,15 +49,10 @@ export const priceFeedEventKit = (block: any, data: any, module: string, path: s
4949
}
5050

5151
async function getOraclePriceDaily(feedName: string, dateKey: number): Promise<OraclePriceDaily> {
52-
const id = feedName + ":" + dateKey.toString();
52+
const id = feedName + ':' + dateKey.toString();
5353
let state = await OraclePriceDaily.get(id);
5454
if (!state) {
55-
state = new OraclePriceDaily(
56-
id,
57-
dateKey,
58-
BigInt(data.blockHeight),
59-
new Date(block.block.header.time as any)
60-
);
55+
state = new OraclePriceDaily(id, dateKey, BigInt(data.blockHeight), new Date(block.block.header.time as any));
6156
}
6257
return state;
6358
}

src/mappings/events/psm.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { PsmGovernance, PsmMetrics, PsmMetricsDaily } from "../../types";
2-
import { dateToDayKey } from "../utils";
1+
import { PsmGovernance, PsmMetrics, PsmMetricsDaily } from '../../types';
2+
import { dateToDayKey } from '../utils';
33

44
export const psmEventKit = (block: any, data: any, module: string, path: string) => {
55
async function savePsmMetrics(payload: any): Promise<Promise<any>[]> {
@@ -8,13 +8,13 @@ export const psmEventKit = (block: any, data: any, module: string, path: string)
88
path,
99
BigInt(data.blockHeight),
1010
block.block.header.time as any,
11-
path.split(".")[3],
12-
path.split(".")[3],
11+
path.split('.')[3],
12+
path.split('.')[3],
1313
BigInt(payload.anchorPoolBalance.__value),
1414
BigInt(payload.feePoolBalance.__value),
1515
BigInt(payload.mintedPoolBalance.__value),
1616
BigInt(payload.totalAnchorProvided.__value),
17-
BigInt(payload.totalMintedProvided.__value)
17+
BigInt(payload.totalMintedProvided.__value),
1818
).save();
1919

2020
return [psmMetric, psmMetricDaily];
@@ -25,7 +25,7 @@ export const psmEventKit = (block: any, data: any, module: string, path: string)
2525

2626
let state = await getPsmMetricDaily(dateKey);
2727

28-
state.denom = path.split(".")[3];
28+
state.denom = path.split('.')[3];
2929

3030
state.anchorPoolBalanceLast = BigInt(payload.anchorPoolBalance.__value);
3131
state.feePoolBalanceLast = BigInt(payload.feePoolBalance.__value);
@@ -39,10 +39,16 @@ export const psmEventKit = (block: any, data: any, module: string, path: string)
3939
}
4040

4141
async function getPsmMetricDaily(dateKey: number): Promise<PsmMetricsDaily> {
42-
const id = path + ":" + dateKey.toString();
42+
const id = path + ':' + dateKey.toString();
4343
let state = await PsmMetricsDaily.get(id);
4444
if (!state) {
45-
state = new PsmMetricsDaily(id, path, dateKey, BigInt(data.blockHeight), new Date(block.block.header.time as any));
45+
state = new PsmMetricsDaily(
46+
id,
47+
path,
48+
dateKey,
49+
BigInt(data.blockHeight),
50+
new Date(block.block.header.time as any),
51+
);
4652
}
4753
return state;
4854
}
@@ -52,13 +58,13 @@ export const psmEventKit = (block: any, data: any, module: string, path: string)
5258
path,
5359
BigInt(data.blockHeight),
5460
block.block.header.time as any,
55-
path.split(".")[3],
56-
path.split(".")[3],
61+
path.split('.')[3],
62+
path.split('.')[3],
5763
BigInt(payload.current.MintLimit.value.__value),
5864
BigInt(payload.current.GiveMintedFee?.value?.denominator?.__value ?? 0),
5965
BigInt(payload.current.GiveMintedFee?.value?.numerator?.__value ?? 0),
6066
BigInt(payload.current.WantMintedFee?.value?.denominator?.__value ?? 0),
61-
BigInt(payload.current.WantMintedFee?.value?.numerator?.__value ?? 0)
67+
BigInt(payload.current.WantMintedFee?.value?.numerator?.__value ?? 0),
6268
).save();
6369
return [psmGovernance];
6470
}

src/mappings/events/reserves.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { promises } from "dns";
2-
import { ReserveAllocationMetrics, ReserveAllocationMetricsDaily, ReserveMetrics } from "../../types";
3-
import { dateToDayKey, extractBrand } from "../utils";
1+
import { promises } from 'dns';
2+
import { ReserveAllocationMetrics, ReserveAllocationMetricsDaily, ReserveMetrics } from '../../types';
3+
import { dateToDayKey, extractBrand } from '../utils';
44

55
export const reservesEventKit = (block: any, data: any, module: string, path: string) => {
66
async function saveReserveMetrics(payload: any): Promise<Promise<any>[]> {
@@ -11,7 +11,7 @@ export const reservesEventKit = (block: any, data: any, module: string, path: st
1111
block.block.header.time as any,
1212
BigInt(payload.shortfallBalance.__value),
1313
BigInt(payload.totalFeeBurned.__value),
14-
BigInt(payload.totalFeeMinted.__value)
14+
BigInt(payload.totalFeeMinted.__value),
1515
);
1616
promises.push(reserveMetric.save());
1717

@@ -30,7 +30,7 @@ export const reservesEventKit = (block: any, data: any, module: string, path: st
3030
brand,
3131
key,
3232
BigInt(allocation.__value),
33-
reserveMetric.id
33+
reserveMetric.id,
3434
);
3535

3636
promises.push(reserveAllocationMetric.save());
@@ -40,7 +40,12 @@ export const reservesEventKit = (block: any, data: any, module: string, path: st
4040
return promises;
4141
}
4242

43-
async function saveReserveAllocationMetricDaily(brand: string, payload: any, allocation: any, key: string): Promise<any> {
43+
async function saveReserveAllocationMetricDaily(
44+
brand: string,
45+
payload: any,
46+
allocation: any,
47+
key: string,
48+
): Promise<any> {
4449
const dateKey = dateToDayKey(block.block.header.time);
4550

4651
let state = await getReserveAllocationMetricDaily(brand, dateKey);
@@ -54,17 +59,17 @@ export const reservesEventKit = (block: any, data: any, module: string, path: st
5459

5560
async function getReserveAllocationMetricDaily(
5661
brand: string,
57-
dateKey: number
62+
dateKey: number,
5863
): Promise<ReserveAllocationMetricsDaily> {
59-
const id = brand + ":" + dateKey.toString();
64+
const id = brand + ':' + dateKey.toString();
6065
let state = await ReserveAllocationMetricsDaily.get(id);
6166
if (!state) {
6267
state = new ReserveAllocationMetricsDaily(
6368
id,
6469
brand,
6570
dateKey,
6671
BigInt(data.blockHeight),
67-
new Date(block.block.header.time as any)
72+
new Date(block.block.header.time as any),
6873
);
6974
}
7075
return state;

0 commit comments

Comments
 (0)