Skip to content

Commit

Permalink
minor unrelated fix on stats price check
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Jan 9, 2025
1 parent 82276c0 commit 9d45eb6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,23 @@ export async function createAsset(
cap: "100000",
feeAmount: "0",
paymentCollector: await owner.getAddress(),
// use ocean token as default for fees, only if we don't have another specific fee token
feeToken: ddo?.stats?.price?.tokenAddress ? ddo.stats.price.tokenAddress : config.oceanTokenAddress,
minter: await owner.getAddress(),
mpFeeAddress: ZERO_ADDRESS,
};

let bundleNFT;
if (!ddo.stats?.price?.value) {
const hasStatsPrice = ddo.stats && ddo.stats.price // are price stats defined?
const hasPriceValue = hasStatsPrice && !isNaN(ddo.stats.price) // avoid confusion with value '0'
// no price set
if (!hasPriceValue) { // !ddo.stats?.price?.value
bundleNFT = await nftFactory.createNftWithDatatoken(
nftParamsAsset,
datatokenParams
);
} else if (ddo?.stats?.price?.value === "0") {
// price is 0
} else if (hasPriceValue && Number(ddo.stats.price) === 0) { // ddo?.stats?.price?.value === "0"
const dispenserParams: DispenserCreationParams = {
dispenserAddress: config.dispenserAddress,
maxTokens: "1",
Expand All @@ -144,14 +149,15 @@ export async function createAsset(
dispenserParams
);
} else {
// price is <> 0
const fixedPriceParams: FreCreationParams = {
fixedRateAddress: config.fixedRateExchangeAddress,
baseTokenAddress: config.oceanTokenAddress,
owner: await owner.getAddress(),
marketFeeCollector: await owner.getAddress(),
baseTokenDecimals: 18,
datatokenDecimals: 18,
fixedRate: ddo.stats.price.value,
fixedRate: ddo.stats.price.value, // we have a fixed rate price here
marketFee: "0",
allowedConsumer: await owner.getAddress(),
withMint: true,
Expand Down

0 comments on commit 9d45eb6

Please sign in to comment.