88 BQFunctionArgument ,
99 BQProcedure ,
1010 BQScalarFunction ,
11+ BQStruct ,
1112 BQTableFunction ,
1213 FLOAT64 ,
1314 INT64 ,
@@ -35,6 +36,13 @@ const as_of_args = [
3536 new BQFunctionArgument ( 'migration_id' , INT64 ) ,
3637] ;
3738
39+ const rewardsStruct = new BQStruct ( [
40+ { name : 'appRewardAmount' , type : BIGNUMERIC } ,
41+ { name : 'validatorRewardAmount' , type : BIGNUMERIC } ,
42+ { name : 'svRewardAmount' , type : BIGNUMERIC } ,
43+ { name : 'unclaimedActivityRecordAmount' , type : BIGNUMERIC } ,
44+ ] ) ;
45+
3846const iso_timestamp = new BQScalarFunction (
3947 'iso_timestamp' ,
4048 [ new BQFunctionArgument ( 'iso8601_string' , STRING ) ] ,
@@ -254,13 +262,14 @@ const unminted = new BQScalarFunction(
254262const TransferSummary_minted = new BQScalarFunction (
255263 'TransferSummary_minted' ,
256264 [ new BQFunctionArgument ( 'tr_json' , json ) ] ,
257- BIGNUMERIC ,
265+ rewardsStruct ,
258266 `
259- \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [0]) -- .inputAppRewardAmount
260- + \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [1]) -- .inputValidatorRewardAmount
261- + \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [2]) -- .inputSvRewardAmount
262- + IFNULL(\`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [11]), 0) -- .inputUnclaimedActivityRecordAmount (was added only in Splice 0.4.4)
263-
267+ STRUCT(
268+ \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [0]) AS appRewardAmount,
269+ \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [1]) AS validatorRewardAmount,
270+ \`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [2]) AS svRewardAmount,
271+ IFNULL(\`$$FUNCTIONS_DATASET$$.daml_record_numeric\`(tr_json, [11]), 0) AS unclaimedActivityRecordAmount -- (was added only in Splice 0.4.4)
272+ )
264273 `
265274) ;
266275
@@ -293,12 +302,23 @@ const choice_result_TransferSummary = new BQScalarFunction(
293302const minted = new BQScalarFunction (
294303 'minted' ,
295304 as_of_args ,
296- BIGNUMERIC ,
305+ rewardsStruct ,
297306 `
298307 (SELECT
299- COALESCE(SUM(\`$$FUNCTIONS_DATASET$$.TransferSummary_minted\`(
300- \`$$FUNCTIONS_DATASET$$.choice_result_TransferSummary\`(e.choice, e.result))),
301- 0)
308+ STRUCT(
309+ COALESCE(SUM(\`$$FUNCTIONS_DATASET$$.TransferSummary_minted\`(
310+ \`$$FUNCTIONS_DATASET$$.choice_result_TransferSummary\`(e.choice, e.result)).appRewardAmount),
311+ 0) AS appRewardAmount,
312+ COALESCE(SUM(\`$$FUNCTIONS_DATASET$$.TransferSummary_minted\`(
313+ \`$$FUNCTIONS_DATASET$$.choice_result_TransferSummary\`(e.choice, e.result)).validatorRewardAmount),
314+ 0) AS validatorRewardAmount,
315+ COALESCE(SUM(\`$$FUNCTIONS_DATASET$$.TransferSummary_minted\`(
316+ \`$$FUNCTIONS_DATASET$$.choice_result_TransferSummary\`(e.choice, e.result)).svRewardAmount),
317+ 0) AS svRewardAmount,
318+ COALESCE(SUM(\`$$FUNCTIONS_DATASET$$.TransferSummary_minted\`(
319+ \`$$FUNCTIONS_DATASET$$.choice_result_TransferSummary\`(e.choice, e.result)).unclaimedActivityRecordAmount),
320+ 0) AS unclaimedActivityRecordAmount
321+ )
302322 FROM
303323 \`$$SCAN_DATASET$$.scan_sv_1_update_history_exercises\` e
304324 WHERE
@@ -316,6 +336,24 @@ const minted = new BQScalarFunction(
316336 `
317337) ;
318338
339+ const total_minted = new BQScalarFunction (
340+ 'total_minted' ,
341+ as_of_args ,
342+ BIGNUMERIC ,
343+ `
344+ (SELECT
345+ SUM(mint_amount)
346+ FROM
347+ UNNEST(ARRAY[
348+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).appRewardAmount,
349+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).validatorRewardAmount,
350+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).svRewardAmount,
351+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).unclaimedActivityRecordAmount
352+ ]) AS mint_amount
353+ )
354+ `
355+ ) ;
356+
319357const transferresult_fees = new BQScalarFunction (
320358 'transferresult_fees' ,
321359 [ new BQFunctionArgument ( 'tr_json' , json ) ] ,
@@ -527,8 +565,10 @@ const all_stats = new BQTableFunction(
527565 new BQColumn ( 'unlocked' , BIGNUMERIC ) ,
528566 new BQColumn ( 'current_supply_total' , BIGNUMERIC ) ,
529567 new BQColumn ( 'unminted' , BIGNUMERIC ) ,
530- new BQColumn ( 'minted' , BIGNUMERIC ) ,
531- new BQColumn ( 'allowed_mint' , BIGNUMERIC ) ,
568+ new BQColumn ( 'minted_app_rewards' , BIGNUMERIC ) ,
569+ new BQColumn ( 'minted_validator_rewards' , BIGNUMERIC ) ,
570+ new BQColumn ( 'minted_sv_rewards' , BIGNUMERIC ) ,
571+ new BQColumn ( 'minted_unclaimed_activity_records' , BIGNUMERIC ) ,
532572 new BQColumn ( 'burned' , BIGNUMERIC ) ,
533573 new BQColumn ( 'monthly_burn' , BIGNUMERIC ) ,
534574 new BQColumn ( 'num_amulet_holders' , INT64 ) ,
@@ -544,8 +584,10 @@ const all_stats = new BQTableFunction(
544584 \`$$FUNCTIONS_DATASET$$.unlocked\`(as_of_record_time, migration_id) as unlocked,
545585 \`$$FUNCTIONS_DATASET$$.locked\`(as_of_record_time, migration_id) + \`$$FUNCTIONS_DATASET$$.unlocked\`(as_of_record_time, migration_id) as current_supply_total,
546586 \`$$FUNCTIONS_DATASET$$.unminted\`(as_of_record_time, migration_id) as unminted,
547- \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id) as minted,
548- \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id) + \`$$FUNCTIONS_DATASET$$.unminted\`(as_of_record_time, migration_id) as allowed_mint,
587+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).appRewardAmount as minted_app_rewards,
588+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).validatorRewardAmount as minted_validator_rewards,
589+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).svRewardAmount as minted_sv_rewards,
590+ \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id).unclaimedActivityRecordAmount as minted_unclaimed_activity_records,
549591 IFNULL(\`$$FUNCTIONS_DATASET$$.burned\`(as_of_record_time, migration_id), 0) as burned,
550592 IFNULL(\`$$FUNCTIONS_DATASET$$.burned\`(as_of_record_time, migration_id) - \`$$FUNCTIONS_DATASET$$.burned\`(TIMESTAMP_SUB(as_of_record_time, INTERVAL 30 DAY), \`$$FUNCTIONS_DATASET$$.migration_id_at_time\`(TIMESTAMP_SUB(as_of_record_time, INTERVAL 30 DAY))), 0) as monthly_burn,
551593 \`$$FUNCTIONS_DATASET$$.num_amulet_holders\`(as_of_record_time, migration_id) as num_amulet_holders,
@@ -595,8 +637,10 @@ const days_with_missing_stats = new BQTableFunction(
595637 AND unlocked IS NOT NULL
596638 AND current_supply_total IS NOT NULL
597639 AND unminted IS NOT NULL
598- AND minted IS NOT NULL
599- AND allowed_mint IS NOT NULL
640+ AND minted_app_rewards IS NOT NULL
641+ AND minted_validator_rewards IS NOT NULL
642+ AND minted_sv_rewards IS NOT NULL
643+ AND minted_unclaimed_activity_records IS NOT NULL
600644 AND burned IS NOT NULL
601645 AND monthly_burn IS NOT NULL
602646 AND num_amulet_holders IS NOT NULL
@@ -637,6 +681,7 @@ export const allScanFunctions = [
637681 TransferSummary_minted ,
638682 choice_result_TransferSummary ,
639683 minted ,
684+ total_minted ,
640685 transferresult_fees ,
641686 result_burn ,
642687 burned ,
0 commit comments