From 103c2fddd83550e303650f5579e9aef212edc746 Mon Sep 17 00:00:00 2001 From: Wraeth Date: Thu, 5 Dec 2024 15:23:54 +1000 Subject: [PATCH] use 61166 as eth and set as base currency --- src/packages/v4/models/v4CurrencyOption.ts | 6 ++-- src/packages/v4/utils/currency.ts | 29 ++++++++++++------- src/packages/v4/utils/editRuleset.ts | 3 +- .../v4/utils/launchProjectTransformers.ts | 3 +- src/packages/v4/utils/shared/currency.ts | 1 + 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 src/packages/v4/utils/shared/currency.ts diff --git a/src/packages/v4/models/v4CurrencyOption.ts b/src/packages/v4/models/v4CurrencyOption.ts index 3f8b85a472..caf7053b1e 100644 --- a/src/packages/v4/models/v4CurrencyOption.ts +++ b/src/packages/v4/models/v4CurrencyOption.ts @@ -1,4 +1,4 @@ -// same as v2v3 for now (@todo: make V4 specific) -export type V4CurrencyETH = 1 -export type V4CurrencyUSD = 2 +// TODO: This is for backward compatibility - correct token codes are listed as comments +export type V4CurrencyETH = 1 // TODO: 61166 +export type V4CurrencyUSD = 2 // TODO: 1 export type V4CurrencyOption = V4CurrencyETH | V4CurrencyUSD diff --git a/src/packages/v4/utils/currency.ts b/src/packages/v4/utils/currency.ts index e7bad5d225..cf5d920f5d 100644 --- a/src/packages/v4/utils/currency.ts +++ b/src/packages/v4/utils/currency.ts @@ -1,16 +1,23 @@ -import { CURRENCY_METADATA, CurrencyMetadata, CurrencyName } from "constants/currency" -import { V4CurrencyETH, V4CurrencyOption, V4CurrencyUSD } from "../models/v4CurrencyOption" +import { + CURRENCY_METADATA, + CurrencyMetadata, + CurrencyName, +} from 'constants/currency' +import { + V4CurrencyETH, + V4CurrencyOption, + V4CurrencyUSD, +} from '../models/v4CurrencyOption' -export const V4_CURRENCY_ETH: V4CurrencyETH = 1 -export const V4_CURRENCY_USD: V4CurrencyUSD = 2 +// TODO: This is for backward compatibility - correct token codes are listed as comments +export const V4_CURRENCY_ETH: V4CurrencyETH = 1 // TODO: 61166 +export const V4_CURRENCY_USD: V4CurrencyUSD = 2 // TODO: 1 -export const V4_CURRENCY_METADATA: Record< - V4CurrencyOption, - CurrencyMetadata -> = { - [V4_CURRENCY_ETH]: CURRENCY_METADATA.ETH, - [V4_CURRENCY_USD]: CURRENCY_METADATA.USD, -} +export const V4_CURRENCY_METADATA: Record = + { + [V4_CURRENCY_ETH]: CURRENCY_METADATA.ETH, + [V4_CURRENCY_USD]: CURRENCY_METADATA.USD, + } export const V4CurrencyName = ( currency?: V4CurrencyOption, diff --git a/src/packages/v4/utils/editRuleset.ts b/src/packages/v4/utils/editRuleset.ts index 38f28dbd09..5ab3d38fd2 100644 --- a/src/packages/v4/utils/editRuleset.ts +++ b/src/packages/v4/utils/editRuleset.ts @@ -4,6 +4,7 @@ import { issuanceRateFrom } from 'packages/v2v3/utils/math' import { parseWad } from 'utils/format/formatNumber' import { otherUnitToSeconds } from 'utils/format/formatTime' import { EditCycleFormFields } from '../views/V4ProjectSettings/EditCyclePage/EditCycleFormFields' +import { BASE_CURRENCY_ETH } from './shared/currency' export function transformEditCycleFormFieldsToTxArgs({ formValues, @@ -38,7 +39,7 @@ export function transformEditCycleFormFieldsToTxArgs({ metadata: { reservedPercent: formValues.reservedPercent * 100, redemptionRate: formValues.redemptionRate * 100, - baseCurrency: 1, // Assuming base currency is a constant value, typically USD + baseCurrency: BASE_CURRENCY_ETH, pausePay: formValues.pausePay, pauseRedeem: false, // Defaulting this value since it's not in formValues pauseCreditTransfers: !formValues.tokenTransfers, diff --git a/src/packages/v4/utils/launchProjectTransformers.ts b/src/packages/v4/utils/launchProjectTransformers.ts index 0effb3028b..3627112d2d 100644 --- a/src/packages/v4/utils/launchProjectTransformers.ts +++ b/src/packages/v4/utils/launchProjectTransformers.ts @@ -17,6 +17,7 @@ import { Address } from 'viem' import { FundAccessLimitGroup } from '../models/fundAccessLimits' import { GroupedSplits as V4GroupedSplits } from '../models/splits' import { LaunchProjectJBTerminal } from '../models/terminals' +import { BASE_CURRENCY_ETH } from './shared/currency' export type LaunchV2V3ProjectArgs = [ string, // _owner @@ -100,7 +101,7 @@ export function transformFCMetadataToRulesetMetadata({ return { reservedPercent: fundingCycleMetadata.reservedRate.toNumber(), redemptionRate: fundingCycleMetadata.redemptionRate.toNumber(), - baseCurrency: 1, // Not present in v2v3, passing 1 by default + baseCurrency: BASE_CURRENCY_ETH, pausePay: fundingCycleMetadata.pausePay, pauseRedeem: fundingCycleMetadata.pauseRedeem, pauseCreditTransfers: Boolean(fundingCycleMetadata.global.pauseTransfers), diff --git a/src/packages/v4/utils/shared/currency.ts b/src/packages/v4/utils/shared/currency.ts new file mode 100644 index 0000000000..5c84cc8dee --- /dev/null +++ b/src/packages/v4/utils/shared/currency.ts @@ -0,0 +1 @@ +export const BASE_CURRENCY_ETH = 61166