Skip to content

Commit e384ab9

Browse files
committed
build: upgrade all dependencies
1 parent 3c3de3c commit e384ab9

File tree

4 files changed

+28
-65
lines changed

4 files changed

+28
-65
lines changed

packages/token-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@saberhq/solana-contrib": "^1.12.72",
1919
"@solana/buffer-layout": "^4.0.0",
2020
"@solana/spl-token": "^0.1.8",
21-
"@ubeswap/token-math": "^4.4.7",
21+
"@ubeswap/token-math": "^4.4.8",
2222
"tiny-invariant": "^1.2.0",
2323
"tslib": "^2.4.0"
2424
},

packages/token-utils/src/price.ts

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { BigintIsh } from "@ubeswap/token-math";
22
import { Price as UPrice } from "@ubeswap/token-math";
3-
import invariant from "tiny-invariant";
43

54
import type { Token } from "./token";
6-
import { TokenAmount } from "./tokenAmount";
75

86
/**
97
* A price of one token relative to another.
@@ -25,32 +23,18 @@ export class Price extends UPrice<Token> {
2523
super(baseCurrency, quoteCurrency, denominator, numerator);
2624
}
2725

28-
override invert(): Price {
29-
return new Price(
30-
this.quoteCurrency,
31-
this.baseCurrency,
32-
this.numerator,
33-
this.denominator
34-
);
35-
}
36-
37-
override multiply(other: Price): Price {
38-
invariant(
39-
this.quoteCurrency.equals(other.baseCurrency),
40-
`multiply token mismatch: ${this.quoteCurrency.toString()} !== ${other.baseCurrency.toString()}`
41-
);
42-
const fraction = super.asFraction.multiply(other);
26+
new(
27+
baseCurrency: Token,
28+
quoteCurrency: Token,
29+
denominator: BigintIsh,
30+
numerator: BigintIsh
31+
): this {
4332
return new Price(
44-
this.baseCurrency,
45-
other.quoteCurrency,
46-
fraction.denominator,
47-
fraction.numerator
48-
);
49-
}
50-
51-
override quote(tokenAmount: TokenAmount): TokenAmount {
52-
const amt = super.quote(tokenAmount);
53-
return new TokenAmount(this.quoteCurrency, amt.raw);
33+
baseCurrency,
34+
quoteCurrency,
35+
denominator,
36+
numerator
37+
) as this;
5438
}
5539

5640
static fromUPrice(price: UPrice<Token>): Price {

packages/token-utils/src/tokenAmount.ts

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { u64 } from "@solana/spl-token";
2-
import type { BigintIsh, NumberFormat, Percent } from "@ubeswap/token-math";
2+
import type { BigintIsh, NumberFormat } from "@ubeswap/token-math";
33
import {
4+
parseAmountFromString,
45
parseBigintIsh,
56
TokenAmount as UTokenAmount,
67
validateU64,
@@ -9,22 +10,17 @@ import BN from "bn.js";
910

1011
import type { Token } from "./token";
1112

12-
export interface IFormatUint {
13-
/**
14-
* If specified, format this according to `toLocaleString`
15-
*/
16-
numberFormatOptions?: Intl.NumberFormatOptions;
17-
/**
18-
* Locale of the number
19-
*/
20-
locale?: string;
21-
}
13+
export { IFormatUint } from "@ubeswap/token-math";
2214

2315
export class TokenAmount extends UTokenAmount<Token> {
2416
// amount _must_ be raw, i.e. in the native representation
2517
constructor(token: Token, amount: BigintIsh) {
26-
super(token, amount);
27-
validateU64(this.raw);
18+
super(token, amount, validateU64);
19+
}
20+
21+
new(token: Token, amount: BigintIsh): this {
22+
// unsafe but nobody will be extending this anyway probably
23+
return new TokenAmount(token, amount) as this;
2824
}
2925

3026
/**
@@ -34,25 +30,8 @@ export class TokenAmount extends UTokenAmount<Token> {
3430
* @returns
3531
*/
3632
static parse(token: Token, uiAmount: string): TokenAmount {
37-
const prev = UTokenAmount.parseFromString(token, uiAmount);
38-
return new TokenAmount(token, prev.raw);
39-
}
40-
41-
override add(other: TokenAmount): TokenAmount {
42-
const result = super.add(other);
43-
return new TokenAmount(this.token, result.raw);
44-
}
45-
override subtract(other: TokenAmount): TokenAmount {
46-
const result = super.subtract(other);
47-
return new TokenAmount(this.token, result.raw);
48-
}
49-
override multiplyBy(percent: Percent): TokenAmount {
50-
const result = super.multiplyBy(percent);
51-
return new TokenAmount(this.token, result.raw);
52-
}
53-
override reduceBy(percent: Percent): TokenAmount {
54-
const result = super.reduceBy(percent);
55-
return new TokenAmount(this.token, result.raw);
33+
const prev = parseAmountFromString(token, uiAmount);
34+
return new TokenAmount(token, prev);
5635
}
5736

5837
/**

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,7 +3284,7 @@ __metadata:
32843284
"@solana/spl-token": ^0.1.8
32853285
"@solana/web3.js": ^1.41.3
32863286
"@types/bn.js": ^5.1.0
3287-
"@ubeswap/token-math": ^4.4.7
3287+
"@ubeswap/token-math": ^4.4.8
32883288
jsbi: ^4.3.0
32893289
tiny-invariant: ^1.2.0
32903290
tslib: ^2.4.0
@@ -4349,9 +4349,9 @@ __metadata:
43494349
languageName: node
43504350
linkType: hard
43514351

4352-
"@ubeswap/token-math@npm:^4.4.7":
4353-
version: 4.4.7
4354-
resolution: "@ubeswap/token-math@npm:4.4.7"
4352+
"@ubeswap/token-math@npm:^4.4.8":
4353+
version: 4.4.8
4354+
resolution: "@ubeswap/token-math@npm:4.4.8"
43554355
dependencies:
43564356
big.js: ^6.1.1
43574357
decimal.js-light: ^2.5.1
@@ -4361,7 +4361,7 @@ __metadata:
43614361
peerDependencies:
43624362
bn.js: ^5.2.0
43634363
jsbi: ^3 || ^4
4364-
checksum: 3d6da02df49ca54d8b55f8c25e214be35f387eeb1d4be131d61b01b8027ede443163e4c8a19060d4b07b5f6b87c2503740374d95ad3abb6418def615fa1faae1
4364+
checksum: cd4c456e25ed22757e869173e58f52b38a2a38062cf4a5518ecb9cbd5c8a3361683b3bdfb2914f03b1eb12a00190f057e627ab5e489a9374b614ce72f31214b3
43654365
languageName: node
43664366
linkType: hard
43674367

0 commit comments

Comments
 (0)