@saberhq/token-utils
Advanced tools
Comparing version 1.7.4 to 1.8.0
{ | ||
"name": "@saberhq/token-utils", | ||
"description": "Token-related math and transaction utilities for Solana.", | ||
"version": "1.7.4", | ||
"version": "1.8.0", | ||
"repository": "git@github.com:saber-hq/solana-common.git", | ||
@@ -13,3 +13,3 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "tsc && tsc -P tsconfig.esm.json", | ||
"clean": "rm -fr dist/", | ||
@@ -19,10 +19,11 @@ "prepublishOnly": "npm run build" | ||
"dependencies": { | ||
"@saberhq/solana-contrib": "^1.7.4", | ||
"@saberhq/solana-contrib": "^1.8.0", | ||
"@solana/buffer-layout": "^3.0.0", | ||
"@solana/spl-token": "^0.1.8", | ||
"@ubeswap/token-math": "^4.3.0", | ||
"@ubeswap/token-math": "^4.3.1", | ||
"tiny-invariant": "^1.2.0", | ||
"tslib": "^2.3.1" | ||
}, | ||
"main": "dist/index.js", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"files": [ | ||
@@ -33,4 +34,4 @@ "dist/", | ||
"devDependencies": { | ||
"@solana/spl-token-registry": "^0.2.300", | ||
"@solana/web3.js": "^1.30.2", | ||
"@solana/spl-token-registry": "^0.2.467", | ||
"@solana/web3.js": "^1.31.0", | ||
"@types/bn.js": "^5.1.0", | ||
@@ -48,3 +49,3 @@ "jsbi": "^4.1.0" | ||
}, | ||
"gitHead": "a7c5759302c3bcd47fff25305bb643438627d725" | ||
"gitHead": "0b76ec82acbe47ddcac6afbfb6375d33034e5695" | ||
} |
@@ -0,1 +1,2 @@ | ||
import type { BigintIsh } from "@ubeswap/token-math"; | ||
import { Price as UPrice } from "@ubeswap/token-math"; | ||
@@ -11,2 +12,18 @@ import invariant from "tiny-invariant"; | ||
export class Price extends UPrice<Token> { | ||
/** | ||
* Constructs a price. | ||
* @param baseCurrency | ||
* @param quoteCurrency | ||
* @param denominator | ||
* @param numerator | ||
*/ | ||
public constructor( | ||
baseCurrency: Token, | ||
quoteCurrency: Token, | ||
denominator: BigintIsh, | ||
numerator: BigintIsh | ||
) { | ||
super(baseCurrency, quoteCurrency, denominator, numerator); | ||
} | ||
public override invert(): Price { | ||
@@ -13,0 +30,0 @@ return new Price( |
import { u64 } from "@solana/spl-token"; | ||
import type { BigintIsh, Percent } from "@ubeswap/token-math"; | ||
import type { BigintIsh, NumberFormat, Percent } from "@ubeswap/token-math"; | ||
import { | ||
@@ -41,15 +41,15 @@ parseBigintIsh, | ||
add(other: TokenAmount): TokenAmount { | ||
override add(other: TokenAmount): TokenAmount { | ||
const result = super.add(other); | ||
return new TokenAmount(this.token, result.raw); | ||
} | ||
subtract(other: TokenAmount): TokenAmount { | ||
override subtract(other: TokenAmount): TokenAmount { | ||
const result = super.subtract(other); | ||
return new TokenAmount(this.token, result.raw); | ||
} | ||
multiplyBy(percent: Percent): TokenAmount { | ||
override multiplyBy(percent: Percent): TokenAmount { | ||
const result = super.multiplyBy(percent); | ||
return new TokenAmount(this.token, result.raw); | ||
} | ||
reduceBy(percent: Percent): TokenAmount { | ||
override reduceBy(percent: Percent): TokenAmount { | ||
const result = super.reduceBy(percent); | ||
@@ -75,4 +75,4 @@ return new TokenAmount(this.token, result.raw); | ||
*/ | ||
formatUnits(): string { | ||
return `${this.toExact()} ${this.token.symbol}`; | ||
formatUnits(format: NumberFormat = { groupSeparator: "," }): string { | ||
return `${this.toExact(format)} ${this.token.symbol}`; | ||
} | ||
@@ -83,3 +83,3 @@ | ||
*/ | ||
toString(): string { | ||
override toString(): string { | ||
return `TokenAmount[Token=(${this.token.toString()}), amount=${this.toExact()}`; | ||
@@ -86,0 +86,0 @@ } |
@@ -6,2 +6,23 @@ import type * as tokenRegistry from "@solana/spl-token-registry"; | ||
/** | ||
* Known origin chains. | ||
*/ | ||
export const ORIGIN_CHAINS = [ | ||
"bitcoin", | ||
"ethereum", | ||
"terra", | ||
"avalanche", | ||
"binance", | ||
"celo", | ||
"polygon", | ||
"fantom", | ||
"polygon", | ||
"heco", | ||
] as const; | ||
/** | ||
* Known origin chains. | ||
*/ | ||
export type OriginChain = typeof ORIGIN_CHAINS[number]; | ||
/** | ||
* Token extensions with additional information. | ||
@@ -29,2 +50,6 @@ */ | ||
readonly currency?: string; | ||
/** | ||
* If this token is a bridged token, this is the chain that the asset originates from. | ||
*/ | ||
readonly originChain?: OriginChain; | ||
}; | ||
@@ -31,0 +56,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
257277
120
3622
1
Updated@ubeswap/token-math@^4.3.1