diff --git a/packages/stats-worker/src/BonderStats.ts b/packages/stats-worker/src/BonderStats.ts index 0603795c4..40207bff2 100644 --- a/packages/stats-worker/src/BonderStats.ts +++ b/packages/stats-worker/src/BonderStats.ts @@ -189,6 +189,7 @@ class BonderStats { dbData.optimismFeesAmount, dbData.novaFeesAmount, dbData.baseFeesAmount, + dbData.lineaFeesAmount, dbData.ethereumFeesAmount, dbData.totalFeesAmount, startDate @@ -275,6 +276,7 @@ class BonderStats { Number(dbData.optimismTxFees || 0) + Number(dbData.novaTxFees || 0) + Number(dbData.baseTxFees || 0) + + Number(dbData.lineaTxFees || 0) + Number(dbData.ethereumTxFees || 0)) * ethPrice console.log(dbData.totalFees) @@ -288,6 +290,7 @@ class BonderStats { dbData.optimismTxFees, dbData.novaTxFees, dbData.baseTxFees, + dbData.lineaTxFees, dbData.ethereumTxFees, dbData.totalFees, dbData.ethPrice, @@ -656,7 +659,11 @@ class BonderStats { dbData.baseBlockNumber, dbData.baseCanonicalAmount, dbData.baseHTokenAmount, - dbData.baseNativeAmount + dbData.baseNativeAmount, + dbData.lineaBlockNumber, + dbData.lineaCanonicalAmount, + dbData.lineaHTokenAmount, + dbData.lineaNativeAmount ) console.log( day, @@ -1205,6 +1212,8 @@ class BonderStats { (dbData.novaHTokenAmount || 0) + (dbData.baseCanonicalAmount || 0) + (dbData.baseHTokenAmount || 0) + + (dbData.lineaCanonicalAmount || 0) + + (dbData.lineaHTokenAmount || 0) + dbData.ethereumCanonicalAmount + (dbData.stakedAmount - dbData.unstakedAmount) - dbData.initialCanonicalAmount - @@ -1229,12 +1238,16 @@ class BonderStats { let nativeTokenDebt = dbData.polygonNativeAmount * dbData.maticPriceUsd + dbData.gnosisNativeAmount * dbData.xdaiPriceUsd + - (dbData.ethereumNativeAmount + + ( + dbData.ethereumNativeAmount + dbData.optimismNativeAmount + dbData.arbitrumNativeAmount + dbData.arbitrumAliasAmount + dbData.arbitrumMessengerWrapperAmount + - (dbData.novaNativeAmount || 0) * (dbData.baseNativeAmount || 0)) * + (dbData.novaNativeAmount || 0) + + (dbData.baseNativeAmount || 0) + + (dbData.lineaNativeAmount || 0) + ) * dbData.ethPriceUsd if (token === 'ETH') { @@ -1242,13 +1255,16 @@ class BonderStats { (dbData.polygonNativeAmount * dbData.maticPriceUsd) / dbData.ethPriceUsd + (dbData.gnosisNativeAmount * dbData.xdaiPriceUsd) / dbData.ethPriceUsd + - (dbData.ethereumNativeAmount + + ( + dbData.ethereumNativeAmount + dbData.optimismNativeAmount + dbData.arbitrumNativeAmount + dbData.arbitrumAliasAmount + dbData.arbitrumMessengerWrapperAmount + (dbData.novaNativeAmount || 0) + - (dbData.baseNativeAmount || 0)) + (dbData.baseNativeAmount || 0) + + (dbData.lineaNativeAmount || 0) + ) } nativeTokenDebt = nativeStartingTokenAmount - nativeTokenDebt diff --git a/packages/stats-worker/src/Db.ts b/packages/stats-worker/src/Db.ts index cf613c081..97f2cde96 100644 --- a/packages/stats-worker/src/Db.ts +++ b/packages/stats-worker/src/Db.ts @@ -112,6 +112,10 @@ class Db { base_canonical_amount NUMERIC, base_hToken_amount NUMERIC, base_native_amount NUMERIC + linea_block_number INTEGER, + linea_canonical_amount NUMERIC, + linea_hToken_amount NUMERIC, + linea_native_amount NUMERIC )`) if (argv.resetBonderFeesDb) { this.db.run(`DROP TABLE IF EXISTS bonder_fees`) @@ -126,6 +130,7 @@ class Db { optimism_fees_amount NUMERIC NOT NULL, nova_fees_amount NUMERIC NOT NULL, base_fees_amount NUMERIC NOT NULL, + linea_fees_amount NUMERIC NOT NULL, ethereum_fees_amount NUMERIC NOT NULL, total_fees_amount NUMERIC NOT NULL, timestamp INTEGER NOT NULL @@ -142,6 +147,8 @@ class Db { arbitrum_tx_fees NUMERIC NOT NULL, optimism_tx_fees NUMERIC NOT NULL, nova_tx_fees NUMERIC NOT NULL, + base_tx_fees NUMERIC NOT NULL, + linea_tx_fees NUMERIC NOT NULL, ethereum_tx_fees NUMERIC NOT NULL, total_tx_fees NUMERIC NOT NULL, eth_price_usd NUMERIC NOT NULL, @@ -269,6 +276,20 @@ class Db { 'ALTER TABLE bonder_balances ADD COLUMN base_native_amount NUMERIC;' ) } + this.migrations[21] = () => { + this.db.run( + 'ALTER TABLE bonder_balances ADD COLUMN linea_block_number INTEGER;' + ) + this.db.run( + 'ALTER TABLE bonder_balances ADD COLUMN linea_canonical_amount NUMERIC;' + ) + this.db.run( + 'ALTER TABLE bonder_balances ADD COLUMN linea_hToken_amount NUMERIC;' + ) + this.db.run( + 'ALTER TABLE bonder_balances ADD COLUMN linea_native_amount NUMERIC;' + ) + } if (argv.migrations && !migrationRan) { const migrationsToRun = JSON.parse(argv.migrations) @@ -550,11 +571,15 @@ class Db { baseBlockNumber: number, baseCanonicalAmount: number = 0, baseHTokenAmount: number = 0, - baseNativeAmount: number = 0 + baseNativeAmount: number = 0, + lineaBlockNumber: number, + lineaCanonicalAmount: number = 0, + lineaHTokenAmount: number = 0, + lineaNativeAmount: number = 0 ) { await this.tilReady() const stmt = this.db.prepare( - 'INSERT OR REPLACE INTO bonder_balances VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' + 'INSERT OR REPLACE INTO bonder_balances VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ) stmt.run( uuid(), @@ -610,7 +635,11 @@ class Db { baseBlockNumber, baseCanonicalAmount, baseHTokenAmount, - baseNativeAmount + baseNativeAmount, + lineaBlockNumber, + lineaCanonicalAmount, + lineaHTokenAmount, + lineaNativeAmount ) stmt.finalize() } @@ -623,13 +652,14 @@ class Db { optimismFees: number = 0, novaFees: number = 0, baseFees: number = 0, + lineaFees: number = 0, ethereumFees: number = 0, totalFees: number = 0, timestamp: number = 0 ) { await this.tilReady() const stmt = this.db.prepare( - 'INSERT OR REPLACE INTO bonder_fees VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' + 'INSERT OR REPLACE INTO bonder_fees VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ) stmt.run( uuid(), @@ -640,6 +670,7 @@ class Db { optimismFees, novaFees, baseFees, + lineaFees, ethereumFees, totalFees, timestamp @@ -656,6 +687,7 @@ class Db { optimismTxFees: number = 0, novaTxFees: number = 0, baseTxFees: number = 0, + lineaTxFees: number = 0, ethereumTxFees: number = 0, totalFees: number = 0, ethPriceUsd: number = 0, @@ -665,7 +697,7 @@ class Db { ) { await this.tilReady() const stmt = this.db.prepare( - 'INSERT OR REPLACE INTO bonder_tx_fees VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' + 'INSERT OR REPLACE INTO bonder_tx_fees VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ) stmt.run( uuid(), @@ -676,6 +708,7 @@ class Db { optimismTxFees, novaTxFees, baseTxFees, + lineaTxFees, ethereumTxFees, totalFees, ethPriceUsd,