Skip to content

Commit ba1fe86

Browse files
authored
RWA CLI, coins (#11336)
* RWA CLI * afiUSD
1 parent 648a76f commit ba1fe86

File tree

5 files changed

+104
-6
lines changed

5 files changed

+104
-6
lines changed

coins/src/adapters/yield/misc4626/tokens.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"wstETH_WETH_x12_AAVEV3": "0xa260b049ddD6567E739139404C7554435c456d9E",
9999
"wstrBTC": "0xA3Ca88cfb7bBe9CfBd47df053ffA2130C7E6f770",
100100
"gtusdcf": "0xc582F04d8a82795aa2Ff9c8bb4c1c889fe7b754e",
101-
"yPrism": "0xdd5eff0756db08bad0ff16b66f88f506e7318894"
101+
"yPrism": "0xdd5eff0756db08bad0ff16b66f88f506e7318894",
102+
"afiUSD": "0x0b4c655bc989baafe728f8270ff988a7c2b40fd1"
102103
},
103104
"arbitrum": {
104105
"voltGNS": "0x39ff5098081fbe1ab241c31fe0a9974fe9891d04",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { runInPromisePool } from "@defillama/sdk/build/generalUtil";
2-
import atvl from './atvl';
3-
import { getCurrentUnixTimestamp, getTimestampAtStartOfDay } from "../utils/date";
4-
import { fetchTimestampsPG, initPG } from "./db";
2+
import atvl from '../atvl';
3+
import { getCurrentUnixTimestamp, getTimestampAtStartOfDay } from "../../utils/date";
4+
import { fetchTimestampsPG, initPG } from "../db";
55

66
const start = 1735690215; // 1 Jan 2025
77
const end = getCurrentUnixTimestamp()
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { initPG, fetchMetadataPG, DAILY_RWA_DATA, HOURLY_RWA_DATA } from "../db";
2+
3+
async function main() {
4+
console.log('Finding RWA IDs with activeMcapData = false...');
5+
6+
await initPG();
7+
8+
// Fetch all metadata
9+
const metadata = await fetchMetadataPG();
10+
console.log(`Fetched metadata for ${metadata.length} RWA assets`);
11+
12+
// Find IDs where activeMcapData is false
13+
const idsToReset: string[] = [];
14+
metadata.forEach((m: any) => {
15+
if (m.data && m.data.activeMcapData === false) {
16+
idsToReset.push(m.id);
17+
}
18+
});
19+
20+
console.log(`Found ${idsToReset.length} IDs with activeMcapData = false:`);
21+
console.log(idsToReset);
22+
23+
if (idsToReset.length === 0) {
24+
console.log('No IDs to reset. Exiting.');
25+
process.exit();
26+
}
27+
28+
// Update DAILY_RWA_DATA for all found IDs
29+
console.log('\nUpdating DAILY_RWA_DATA...');
30+
const [dailyAffectedRows] = await DAILY_RWA_DATA.update(
31+
{
32+
activemcap: JSON.stringify({}),
33+
aggregatedactivemcap: 0,
34+
updated_at: new Date(),
35+
},
36+
{
37+
where: {
38+
id: idsToReset,
39+
},
40+
}
41+
);
42+
43+
console.log(`Updated ${dailyAffectedRows} record(s) in DAILY_RWA_DATA`);
44+
45+
// Update HOURLY_RWA_DATA for all found IDs
46+
console.log('\nUpdating HOURLY_RWA_DATA...');
47+
const [hourlyAffectedRows] = await HOURLY_RWA_DATA.update(
48+
{
49+
activemcap: JSON.stringify({}),
50+
aggregatedactivemcap: 0,
51+
updated_at: new Date(),
52+
},
53+
{
54+
where: {
55+
id: idsToReset,
56+
},
57+
}
58+
);
59+
60+
console.log(`Updated ${hourlyAffectedRows} record(s) in HOURLY_RWA_DATA`);
61+
62+
console.log(`\nCompleted! Reset activemcap and aggregatedactivemcap for ${idsToReset.length} IDs across all timestamps.`);
63+
}
64+
65+
main().catch((e) => {
66+
console.error(`Error resetting activeMcap:`, e);
67+
}); // ts-node defi/src/rwa/resetActiveMcap.ts

defi/src/rwa/cli/resetId.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { initPG, DAILY_RWA_DATA } from "../db";
2+
3+
const id = '202'
4+
5+
async function main() {
6+
console.log(`Resetting defiactivetvl and aggregatedactivemcap for id: ${id}`);
7+
8+
await initPG();
9+
10+
const [affectedRows] = await DAILY_RWA_DATA.update(
11+
{
12+
defiactivetvl: JSON.stringify({}),
13+
aggregatedefiactivetvl: 0,
14+
updated_at: new Date(),
15+
},
16+
{
17+
where: {
18+
id: id,
19+
},
20+
}
21+
);
22+
23+
console.log(`Updated ${affectedRows} record(s) for id: ${id}`);
24+
process.exit();
25+
}
26+
27+
main().catch((e) => {
28+
console.error(`Error resetting`, e);
29+
process.exit(1);
30+
}); // ts-node defi/src/rwa/resetId.ts

defi/src/rwa/db.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getCurrentUnixTimestamp, getTimestampAtStartOfDay, secondsInDay } from
22
import { DataTypes, Model, Op, QueryTypes, Sequelize } from 'sequelize'
33

44
class META_RWA_DATA extends Model { }
5-
class DAILY_RWA_DATA extends Model { }
6-
class HOURLY_RWA_DATA extends Model { }
5+
export class DAILY_RWA_DATA extends Model { }
6+
export class HOURLY_RWA_DATA extends Model { }
77
class BACKUP_RWA_DATA extends Model { }
88

99
let pgConnection: any;

0 commit comments

Comments
 (0)