-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IND-498]: Add TradingRewardsHandler (#902)
* [IND-498]: Add TradingRewardHandler * fix everything * nits, add helper functions, update precision and scale * lint
- Loading branch information
1 parent
0459917
commit b1ac285
Showing
24 changed files
with
599 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
indexer/packages/postgres/__tests__/helpers/conversion-helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Big from 'big.js'; | ||
|
||
export const DENOM_TO_COIN_CONVERSION: number = 1e-18; | ||
export const DENOM_COIN_SCALE: number = 18; | ||
|
||
export function denomToHumanReadableConversion(denom: number): string { | ||
return Big(denom).times(DENOM_TO_COIN_CONVERSION).toFixed(DENOM_COIN_SCALE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...s/src/db/migrations/migration_files/20231221153944_update_trading_rewards_amount_scale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as Knex from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('trading_rewards', (table) => { | ||
// 27 is the max precision and 18 is scale, which means 9 digits before the decimal point | ||
// and 18 after | ||
table.decimal('amount', 27, 18).notNullable().alter(); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('trading_rewards', (table) => { | ||
table.decimal('amount').notNullable().alter(); | ||
}); | ||
} |
19 changes: 19 additions & 0 deletions
19
...db/migrations/migration_files/20231221165820_update_wallet_total_trading_rewards_scale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as Knex from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('wallets', (table) => { | ||
// 27 is the max precision and 18 is scale, which means 9 digits before the decimal point | ||
// and 18 after | ||
table.decimal('totalTradingRewards', 27, 18).notNullable().alter(); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('wallets', (table) => { | ||
table.decimal('totalTradingRewards').notNullable().alter(); | ||
}); | ||
} |
19 changes: 19 additions & 0 deletions
19
...rations/migration_files/20231221233356_update_trading_reward_aggregations_amount_scale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as Knex from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('trading_reward_aggregations', (table) => { | ||
// 27 is the max precision and 18 is scale, which means 9 digits before the decimal point | ||
// and 18 after | ||
table.decimal('amount', 27, 18).notNullable().alter(); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex | ||
.schema | ||
.alterTable('trading_reward_aggregations', (table) => { | ||
table.decimal('amount').notNullable().alter(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.