-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
570 additions
and
51 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
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
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
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 |
---|---|---|
@@ -1,16 +1,41 @@ | ||
import { calcScalarWinnings } from "./calc-scalar-winnings"; | ||
import { | ||
calcScalarResolvedPrices, | ||
calcScalarWinnings, | ||
} from "./calc-scalar-winnings"; | ||
|
||
describe("calcScalarWinnings", () => { | ||
test("should calculate winnings correctly for short tokens", () => { | ||
const winnings = calcScalarWinnings(0, 10, 5, 100, 0); | ||
expect(winnings.toNumber()).toEqual(50); | ||
}); | ||
|
||
test("should calculate winnings correctly for long tokens", () => { | ||
const winnings = calcScalarWinnings(0, 40, 10, 0, 100); | ||
expect(winnings.toNumber()).toEqual(25); | ||
}); | ||
|
||
test("should calculate winnings correctly for both long and short tokens", () => { | ||
const winnings = calcScalarWinnings(0, 40, 10, 100, 100); | ||
expect(winnings.toNumber()).toEqual(100); | ||
}); | ||
|
||
test("long value should be capped at 1 if resolved outcome is outside of bounds", () => { | ||
const { longTokenValue } = calcScalarResolvedPrices(0, 40, 50); | ||
expect(longTokenValue.toNumber()).toEqual(1); | ||
}); | ||
|
||
test("long value should not fall below 0 if resolved outcome is outside of bounds", () => { | ||
const { longTokenValue } = calcScalarResolvedPrices(10, 40, 0); | ||
expect(longTokenValue.toNumber()).toEqual(0); | ||
}); | ||
|
||
test("short value should not fall below 0 if resolved outcome is outside of bounds", () => { | ||
const { shortTokenValue } = calcScalarResolvedPrices(0, 40, 50); | ||
expect(shortTokenValue.toNumber()).toEqual(0); | ||
}); | ||
|
||
test("short value should be capped at 1 resolved outcome is outside of bounds", () => { | ||
const { shortTokenValue } = calcScalarResolvedPrices(10, 40, 0); | ||
expect(shortTokenValue.toNumber()).toEqual(1); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
"@zeitgeistpm/avatara-react": "^1.3.2", | ||
"@zeitgeistpm/avatara-util": "^1.2.0", | ||
"@zeitgeistpm/sdk": "^1.0.3", | ||
"@zeitgeistpm/sdk-next": "npm:@zeitgeistpm/[email protected].20", | ||
"@zeitgeistpm/sdk-next": "npm:@zeitgeistpm/[email protected].21", | ||
"@zeitgeistpm/utility": "^2.18.12", | ||
"axios": "^0.21.4", | ||
"boring-avatars": "^1.6.1", | ||
|
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.