@evergonlabs/tmi-protocol-indexer 0.1.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/README.md +34 -0
- package/dist/ponder.schema.d.ts +997 -0
- package/dist/ponder.schema.js +121 -0
- package/dist/src/db/fractions.schema.d.ts +1640 -0
- package/dist/src/db/fractions.schema.js +258 -0
- package/package.json +66 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { onchainTable, primaryKey, index, relations, onchainEnum } from "ponder";
|
|
2
|
+
export var FractionSaleStatusEnum;
|
|
3
|
+
(function (FractionSaleStatusEnum) {
|
|
4
|
+
FractionSaleStatusEnum["CREATED"] = "created";
|
|
5
|
+
FractionSaleStatusEnum["APPROVED"] = "approved";
|
|
6
|
+
FractionSaleStatusEnum["REJECTED"] = "rejected";
|
|
7
|
+
FractionSaleStatusEnum["FINALIZED"] = "finalized";
|
|
8
|
+
FractionSaleStatusEnum["REFUNDED"] = "refunded";
|
|
9
|
+
})(FractionSaleStatusEnum || (FractionSaleStatusEnum = {}));
|
|
10
|
+
export var FractionSaleEventEnum;
|
|
11
|
+
(function (FractionSaleEventEnum) {
|
|
12
|
+
FractionSaleEventEnum["CREATED"] = "created";
|
|
13
|
+
FractionSaleEventEnum["STATUS_UPDATE"] = "status_update";
|
|
14
|
+
FractionSaleEventEnum["PURCHASE"] = "purchase";
|
|
15
|
+
FractionSaleEventEnum["CLAIM"] = "claim";
|
|
16
|
+
FractionSaleEventEnum["WITHDRAW"] = "withdraw";
|
|
17
|
+
FractionSaleEventEnum["WITHDRAW_NON_WRAPPED"] = "withdraw_non_wrapped";
|
|
18
|
+
FractionSaleEventEnum["REFUND"] = "refund";
|
|
19
|
+
})(FractionSaleEventEnum || (FractionSaleEventEnum = {}));
|
|
20
|
+
export const fractionStatusType = onchainEnum("fraction_status_type", [
|
|
21
|
+
FractionSaleStatusEnum.CREATED,
|
|
22
|
+
FractionSaleStatusEnum.APPROVED,
|
|
23
|
+
FractionSaleStatusEnum.REJECTED,
|
|
24
|
+
FractionSaleStatusEnum.FINALIZED,
|
|
25
|
+
FractionSaleStatusEnum.REFUNDED,
|
|
26
|
+
]);
|
|
27
|
+
export const fractionEventType = onchainEnum("fraction_event_type", [
|
|
28
|
+
FractionSaleEventEnum.CREATED,
|
|
29
|
+
FractionSaleEventEnum.STATUS_UPDATE,
|
|
30
|
+
FractionSaleEventEnum.PURCHASE,
|
|
31
|
+
FractionSaleEventEnum.CLAIM,
|
|
32
|
+
FractionSaleEventEnum.WITHDRAW,
|
|
33
|
+
FractionSaleEventEnum.REFUND,
|
|
34
|
+
]);
|
|
35
|
+
export const asset = onchainTable("asset", (t) => ({
|
|
36
|
+
chainId: t.integer("chain_id").notNull(),
|
|
37
|
+
address: t.hex("address").notNull(),
|
|
38
|
+
type: t.varchar("type").notNull(),
|
|
39
|
+
name: t.varchar("name").notNull(),
|
|
40
|
+
symbol: t.varchar("symbol").notNull(),
|
|
41
|
+
tokenId: t.bigint("token_id"), // tokenId has ERC_721 and ERC_1155 asset type
|
|
42
|
+
decimals: t.integer("decimals").default(0),
|
|
43
|
+
burnable: t.boolean("burnable").default(false),
|
|
44
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
45
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
46
|
+
}), (table) => ({
|
|
47
|
+
pk: primaryKey({
|
|
48
|
+
columns: [table.chainId, table.address],
|
|
49
|
+
}),
|
|
50
|
+
typeIdx: index().on(table.type),
|
|
51
|
+
addressIdx: index().on(table.address),
|
|
52
|
+
chainIdIdx: index().on(table.chainId),
|
|
53
|
+
}));
|
|
54
|
+
export const fractionsSaleActivity = onchainTable("fractions_sale_activity", (t) => ({
|
|
55
|
+
chainId: t.integer("chain_id").notNull(),
|
|
56
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
57
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
58
|
+
from: t.hex("from").notNull(),
|
|
59
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
60
|
+
metadata: t.json("metadata").$type().notNull(),
|
|
61
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
62
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
63
|
+
}), (table) => ({
|
|
64
|
+
pk: primaryKey({
|
|
65
|
+
columns: [table.chainId, table.transactionHash],
|
|
66
|
+
}),
|
|
67
|
+
fromIdx: index().on(table.from),
|
|
68
|
+
chainIdIdx: index().on(table.chainId),
|
|
69
|
+
}));
|
|
70
|
+
export const fractionsSaleActivityRelations = relations(fractionsSaleActivity, ({ one }) => ({
|
|
71
|
+
fractionsMarket: one(fractionsMarket, {
|
|
72
|
+
fields: [fractionsSaleActivity.chainId, fractionsSaleActivity.diamondAddress],
|
|
73
|
+
references: [fractionsMarket.chainId, fractionsMarket.contractAddress],
|
|
74
|
+
}),
|
|
75
|
+
fractionSale: one(fractionsSale, {
|
|
76
|
+
fields: [fractionsSaleActivity.chainId, fractionsSaleActivity.diamondAddress, fractionsSaleActivity.saleId],
|
|
77
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
78
|
+
}),
|
|
79
|
+
}));
|
|
80
|
+
export const fractionsAssetsRelations = relations(asset, ({ many }) => ({
|
|
81
|
+
asBurnable: many(fractionsMarket, { relationName: "burnAsset" }),
|
|
82
|
+
asFractions: many(fractionsSale, { relationName: "fractionsAsset" }),
|
|
83
|
+
asWrappedAsset: many(fractionsWrappedAsset),
|
|
84
|
+
asFundingAsset: many(fractionsFundingAsset),
|
|
85
|
+
}));
|
|
86
|
+
export const fractionsMarket = onchainTable("fractions_market", (t) => ({
|
|
87
|
+
contractAddress: t.hex("contract_address").notNull(),
|
|
88
|
+
template: t.varchar("template").notNull(),
|
|
89
|
+
wrapperAddress: t.hex("wrapper_address").notNull(),
|
|
90
|
+
adminAddress: t.hex("admin").notNull(),
|
|
91
|
+
chainId: t.integer("chain_id").notNull(),
|
|
92
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
93
|
+
burnAssetAddress: t.hex("burn_asset_address"),
|
|
94
|
+
feesBps: t.integer("fees_bps").default(0),
|
|
95
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
96
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
97
|
+
}), (table) => ({
|
|
98
|
+
pk: primaryKey({
|
|
99
|
+
columns: [table.chainId, table.contractAddress],
|
|
100
|
+
}),
|
|
101
|
+
adminAddressIdx: index().on(table.adminAddress),
|
|
102
|
+
contractAddressIdx: index().on(table.contractAddress),
|
|
103
|
+
chainIdIdx: index().on(table.chainId),
|
|
104
|
+
}));
|
|
105
|
+
export const fractionsMarketRelations = relations(fractionsMarket, ({ many, one }) => ({
|
|
106
|
+
fractionsSales: many(fractionsSale),
|
|
107
|
+
activities: many(fractionsSaleActivity),
|
|
108
|
+
burnAsset: one(asset, {
|
|
109
|
+
fields: [fractionsMarket.chainId, fractionsMarket.burnAssetAddress],
|
|
110
|
+
references: [asset.chainId, asset.address],
|
|
111
|
+
}),
|
|
112
|
+
}));
|
|
113
|
+
export const fractionsSale = onchainTable("fractions_sale", (t) => ({
|
|
114
|
+
chainId: t.integer("chain_id").notNull(),
|
|
115
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
116
|
+
nftId: t.bigint("nft_id").notNull(),
|
|
117
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
118
|
+
creator: t.hex("address").notNull(),
|
|
119
|
+
status: t.varchar("status").notNull().default("created"),
|
|
120
|
+
fractionPrice: t.bigint("fraction_price").notNull().default(0n),
|
|
121
|
+
softCap: t.bigint("soft_cap"),
|
|
122
|
+
hardCap: t.bigint("hard_cap"),
|
|
123
|
+
softCapPerAccount: t.bigint("soft_cap_per_account"),
|
|
124
|
+
hardCapPerAccount: t.bigint("hard_cap_per_account"),
|
|
125
|
+
cliffDate: t.timestamp("cliff_date"),
|
|
126
|
+
totalVestingPeriod: t.bigint("total_vesting_period"),
|
|
127
|
+
portionPeriod: t.bigint("portion_period"),
|
|
128
|
+
startDate: t.timestamp("start_date"),
|
|
129
|
+
endDate: t.timestamp("end_date"),
|
|
130
|
+
fractionsCreated: t.bigint("fractions_created").notNull().default(0n),
|
|
131
|
+
fractionsAddress: t.hex("fractions_addres").notNull(),
|
|
132
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
133
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
134
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
135
|
+
}), (table) => ({
|
|
136
|
+
pk: primaryKey({
|
|
137
|
+
columns: [table.chainId, table.diamondAddress, table.saleId],
|
|
138
|
+
}),
|
|
139
|
+
diamondAddressIdx: index().on(table.diamondAddress),
|
|
140
|
+
creatorIdx: index().on(table.creator),
|
|
141
|
+
}));
|
|
142
|
+
export const fractionsSaleRelations = relations(fractionsSale, ({ one, many }) => ({
|
|
143
|
+
fractionsMarket: one(fractionsMarket, {
|
|
144
|
+
fields: [fractionsSale.chainId, fractionsSale.diamondAddress],
|
|
145
|
+
references: [fractionsMarket.chainId, fractionsMarket.contractAddress],
|
|
146
|
+
}),
|
|
147
|
+
fractionsAsset: one(asset, {
|
|
148
|
+
fields: [fractionsSale.chainId, fractionsSale.fractionsAddress],
|
|
149
|
+
references: [asset.chainId, asset.address],
|
|
150
|
+
}),
|
|
151
|
+
wrappedAssets: many(fractionsWrappedAsset),
|
|
152
|
+
fundingAssets: many(fractionsFundingAsset),
|
|
153
|
+
activities: many(fractionsSaleActivity),
|
|
154
|
+
purchases: many(fractionsPurchase),
|
|
155
|
+
claims: many(fractionsClaim),
|
|
156
|
+
withdrawals: many(fractionsWithdrawal),
|
|
157
|
+
}));
|
|
158
|
+
export const fractionsWrappedAsset = onchainTable("fractions_wrapped_asset", (t) => ({
|
|
159
|
+
chainId: t.integer("chain_id").notNull(),
|
|
160
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
161
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
162
|
+
tokenAddress: t.hex("token_address").notNull(),
|
|
163
|
+
wrappedAmount: t.bigint("wrapped_amount").notNull(),
|
|
164
|
+
}), (table) => ({
|
|
165
|
+
pk: primaryKey({ columns: [table.chainId, table.saleId, table.diamondAddress, table.tokenAddress] }),
|
|
166
|
+
}));
|
|
167
|
+
export const wrappedAssetsRelations = relations(fractionsWrappedAsset, ({ one }) => ({
|
|
168
|
+
asset: one(asset, {
|
|
169
|
+
fields: [fractionsWrappedAsset.chainId, fractionsWrappedAsset.tokenAddress],
|
|
170
|
+
references: [asset.chainId, asset.address],
|
|
171
|
+
}),
|
|
172
|
+
fractionSale: one(fractionsSale, {
|
|
173
|
+
fields: [fractionsWrappedAsset.chainId, fractionsWrappedAsset.diamondAddress, fractionsWrappedAsset.saleId],
|
|
174
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
175
|
+
}),
|
|
176
|
+
}));
|
|
177
|
+
export const fractionsFundingAsset = onchainTable("fractions_funding_asset", (t) => ({
|
|
178
|
+
chainId: t.integer("chain_id").notNull(),
|
|
179
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
180
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
181
|
+
tokenAddress: t.hex("token_address").notNull(),
|
|
182
|
+
amountPerPacket: t.bigint("amount_per_packet").notNull(),
|
|
183
|
+
}), (table) => ({ pk: primaryKey({ columns: [table.chainId, table.saleId, table.diamondAddress, table.tokenAddress] }) }));
|
|
184
|
+
export const fundingAssetsRelations = relations(fractionsFundingAsset, ({ one }) => ({
|
|
185
|
+
asset: one(asset, {
|
|
186
|
+
fields: [fractionsFundingAsset.chainId, fractionsFundingAsset.tokenAddress],
|
|
187
|
+
references: [asset.chainId, asset.address],
|
|
188
|
+
}),
|
|
189
|
+
fractionSale: one(fractionsSale, {
|
|
190
|
+
fields: [fractionsFundingAsset.chainId, fractionsFundingAsset.diamondAddress, fractionsFundingAsset.saleId],
|
|
191
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
192
|
+
}),
|
|
193
|
+
}));
|
|
194
|
+
export const fractionsPurchase = onchainTable("fractions_purchase", (t) => ({
|
|
195
|
+
chainId: t.integer("chain_id").notNull(),
|
|
196
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
197
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
198
|
+
buyerAddress: t.hex("buyer_address").notNull(),
|
|
199
|
+
amountOfFractions: t.bigint("amount_of_fractions").notNull(),
|
|
200
|
+
priceId: t.bigint("price_id").notNull(),
|
|
201
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
202
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
203
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
204
|
+
}), (table) => ({
|
|
205
|
+
pk: primaryKey({
|
|
206
|
+
columns: [table.chainId, table.transactionHash],
|
|
207
|
+
}),
|
|
208
|
+
diamondAddressIdx: index().on(table.diamondAddress),
|
|
209
|
+
buyerAddressIdx: index().on(table.buyerAddress),
|
|
210
|
+
}));
|
|
211
|
+
export const fractionsPurchaseRelations = relations(fractionsPurchase, ({ one }) => ({
|
|
212
|
+
fractionSale: one(fractionsSale, {
|
|
213
|
+
fields: [fractionsPurchase.chainId, fractionsPurchase.diamondAddress, fractionsPurchase.saleId],
|
|
214
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
215
|
+
}),
|
|
216
|
+
}));
|
|
217
|
+
export const fractionsClaim = onchainTable("fractions_claim", (t) => ({
|
|
218
|
+
chainId: t.integer("chain_id").notNull(),
|
|
219
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
220
|
+
receiver: t.hex("receiver").notNull(),
|
|
221
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
222
|
+
semiFungibleBurntId: t.bigint("semi_fungible_burnt_id").notNull(),
|
|
223
|
+
amountOfFractionsBurnt: t.bigint("amount_of_fractions_burnt").notNull(),
|
|
224
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
225
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
226
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
227
|
+
}), (table) => ({
|
|
228
|
+
pk: primaryKey({
|
|
229
|
+
columns: [table.chainId, table.diamondAddress, table.receiver, table.saleId, table.semiFungibleBurntId],
|
|
230
|
+
}),
|
|
231
|
+
diamondAddressIdx: index().on(table.diamondAddress),
|
|
232
|
+
}));
|
|
233
|
+
export const fractionsClaimRelations = relations(fractionsClaim, ({ one }) => ({
|
|
234
|
+
fractionSale: one(fractionsSale, {
|
|
235
|
+
fields: [fractionsClaim.chainId, fractionsClaim.diamondAddress, fractionsClaim.saleId],
|
|
236
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
237
|
+
}),
|
|
238
|
+
}));
|
|
239
|
+
export const fractionsWithdrawal = onchainTable("fractions_withdrawal", (t) => ({
|
|
240
|
+
chainId: t.integer("chain_id").notNull(),
|
|
241
|
+
diamondAddress: t.hex("diamond_address").notNull(),
|
|
242
|
+
saleId: t.bigint("sale_id").notNull(),
|
|
243
|
+
amount: t.bigint("amount").notNull(),
|
|
244
|
+
transactionHash: t.hex("tx_hash").notNull(),
|
|
245
|
+
createdAt: t.timestamp("created_at").notNull(),
|
|
246
|
+
updatedAt: t.timestamp("updated_at").notNull(),
|
|
247
|
+
}), (table) => ({
|
|
248
|
+
pk: primaryKey({
|
|
249
|
+
columns: [table.chainId, table.transactionHash],
|
|
250
|
+
}),
|
|
251
|
+
diamondAddressIdx: index().on(table.diamondAddress),
|
|
252
|
+
}));
|
|
253
|
+
export const fractionsWithdrawalRelations = relations(fractionsWithdrawal, ({ one }) => ({
|
|
254
|
+
fractionSale: one(fractionsSale, {
|
|
255
|
+
fields: [fractionsWithdrawal.chainId, fractionsWithdrawal.diamondAddress, fractionsWithdrawal.saleId],
|
|
256
|
+
references: [fractionsSale.chainId, fractionsSale.diamondAddress, fractionsSale.saleId],
|
|
257
|
+
}),
|
|
258
|
+
}));
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@evergonlabs/tmi-protocol-indexer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./schema": {
|
|
8
|
+
"import": "./dist/ponder.schema.js",
|
|
9
|
+
"types": "./dist/ponder.schema.d.js",
|
|
10
|
+
"default": "./dist/ponder.schema.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@evergonlabs/tmi-contracts-fractions-sdk": "1.1.0",
|
|
18
|
+
"@evergonlabs/tmi-contracts-staking-sdk": "^0.1.0",
|
|
19
|
+
"@evergonlabs/tmi-evm-contracts": "0.3.4",
|
|
20
|
+
"drizzle-orm": "0.41.0",
|
|
21
|
+
"hono": "^4.6.19",
|
|
22
|
+
"kysely": "^0.26.3",
|
|
23
|
+
"ponder": "^0.11.4",
|
|
24
|
+
"type-fest": "^4.33.0",
|
|
25
|
+
"zod": "^3.24.1",
|
|
26
|
+
"@evergonlabs/tmi-protocol-fractions-sdk": "0.2.0",
|
|
27
|
+
"@evergonlabs/tmi-protocol-types": "0.2.0",
|
|
28
|
+
"@evergonlabs/tmi-protocol-utils": "0.2.0",
|
|
29
|
+
"@evergonlabs/tmi-protocol-staking-sdk": "0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@evergonlabs/tmi-eslint-config": "^0.1.3",
|
|
33
|
+
"@evergonlabs/tmi-typescript-config": "^0.2.0",
|
|
34
|
+
"@topcli/prompts": "^2.1.0",
|
|
35
|
+
"abitype": "^1.0.8",
|
|
36
|
+
"eslint": "^9.21.0",
|
|
37
|
+
"jiti": "^2.4.2",
|
|
38
|
+
"kleur": "^4.1.5",
|
|
39
|
+
"npm-run-all": "^4.1.5",
|
|
40
|
+
"rimraf": "^6.0.1",
|
|
41
|
+
"typescript": "5.7.3",
|
|
42
|
+
"viem": "^2.22.22",
|
|
43
|
+
"@evergonlabs/internal": "0.0.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"viem": "^2.0.0"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsc -p tsconfig.build.json",
|
|
57
|
+
"check-types": "tsc --noEmit",
|
|
58
|
+
"clean": "rimraf ./generated",
|
|
59
|
+
"codegen": "ponder codegen",
|
|
60
|
+
"db": "ponder db",
|
|
61
|
+
"lint": "eslint .",
|
|
62
|
+
"serve": "ponder serve",
|
|
63
|
+
"start": "ponder start --schema=${DATABASE_SCHEMA} --views-schema=v2 -- --network=prod",
|
|
64
|
+
"start:dev": "ponder dev -v -- --network=dev --schema=v01"
|
|
65
|
+
}
|
|
66
|
+
}
|