Skip to content

Commit

Permalink
Merge branch 'master' into feat/upgrade-sdk-7.4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Mar 26, 2024
2 parents 8d5eb2a + 83dc745 commit 9f6e2e3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
22 changes: 14 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"decentraland": "3.3.0",
"decentraland-builder-scripts": "^0.24.0",
"decentraland-crypto-fetch": "^2.0.1",
"decentraland-dapps": "^19.2.0",
"decentraland-dapps": "^19.2.4",
"decentraland-ecs": "6.12.4-7784644013.commit-f770b3e",
"decentraland-experiments": "^1.0.2",
"decentraland-transactions": "^2.0.3",
Expand Down
12 changes: 6 additions & 6 deletions src/modules/collection/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ describe('when getting the fiat commodity amount', () => {
unitPrice = '10000000000'
})

it('should return 0.00000001', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(0.00000001)
it('should return 0.00000002', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(0.00000002)
})
})

Expand All @@ -287,8 +287,8 @@ describe('when getting the fiat commodity amount', () => {
unitPrice = '123456789000000000'
})

it('should return 0.12345679', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(0.12345679)
it('should return 0.12382716', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(0.12382716)
})
})

Expand All @@ -298,7 +298,7 @@ describe('when getting the fiat commodity amount', () => {
})

it('should return 1', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(1)
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(1.003)
})
})
})
Expand All @@ -314,7 +314,7 @@ describe('when getting the fiat commodity amount', () => {
})

it('should return 10', () => {
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(10)
expect(getFiatGatewayCommodityAmount(unitPrice, items)).toBe(10.03)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/modules/collection/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ export const toPaginationStats = (collectionPaginationData: CollectionPagination
export const getFiatGatewayCommodityAmount = (unitPrice: string, items: number) => {
const unitPriceWei = ethers.BigNumber.from(unitPrice)
const totalPriceWei = unitPriceWei.mul(items)
const totalPriceEth = ethers.utils.formatEther(totalPriceWei.toString())
const totalPriceEth = Number(ethers.utils.formatEther(totalPriceWei.toString())) * 1.003 // 0.3% extra to safeguard against price fluctuations.
const factor = Math.pow(10, 8)

// Wert supports up to 8 decimal places.
// It is important to round up to this amount of decimal places to avoid issues with the widget.
return Math.ceil(Number(totalPriceEth) * factor) / factor
return Math.ceil(totalPriceEth * factor) / factor
}

0 comments on commit 9f6e2e3

Please sign in to comment.