Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
napalmpapalam committed Mar 3, 2023
1 parent 5665886 commit 0f6c69a
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 28 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.3.0] - 2023-03-03
### Added
- `all`: Build to CommonJS and ES modules
- `all`: `tsc-alias` package to use aliases in TypeScript
- `root`: `yarn rsc` Release Sanity Check script
- `root`: Publish to NPM GitHub Action
- `@rarimo/nft-checkout`: Mainnet contract to the chain list

### Fixed
- `@rarimo/provider`: Solflare wallet naming [issue](https://github.com/rarimo/js-sdk/issues/12)
- `@rarimo/nft-checkout`: Estimate swap for input native token

## [1.2.0] - 2023-02-28
### Added
Expand Down Expand Up @@ -64,7 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Under the hood changes
- Initiated repo with `@rarimo/provider` and `@rarimo/nft-checkout` packages

[Unreleased]: https://github.com/rarimo/js-sdk/compare/1.2.0...HEAD
[Unreleased]: https://github.com/rarimo/js-sdk/compare/1.3.0...HEAD
[1.3.0]: https://github.com/rarimo/js-sdk/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/rarimo/js-sdk/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/rarimo/js-sdk/compare/1.0.1...1.1.0
[1.0.1]: https://github.com/rarimo/js-sdk/compare/1.0.0...1.0.1
Expand Down
2 changes: 1 addition & 1 deletion packages/nft-checkout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/nft-checkout",
"version": "1.2.0",
"version": "1.3.0",
"description": "Tools to create cross-train transactions with the Rarimo Protocol",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/nft-checkout/src/const/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EVM_CHAINS: BridgeChain[] = [
explorerUrl: 'https://etherscan.io',
type: ChainTypes.EVM,
icon: 'https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/app/images/eth_logo.svg',
contractAddress: '',
contractAddress: '0x85718348D854CE2768e96D87a2ed6d12d619b67B',
contactVersion: SwapContractVersion.UniswapV3,
},
{
Expand Down Expand Up @@ -106,7 +106,7 @@ export const EVM_CHAINS: BridgeChain[] = [
},
explorerUrl: 'https://cchain.explorer.avax.network',
type: ChainTypes.EVM,
contractAddress: '',
contractAddress: '0x2021Fa349Ec57F33F03961E430f54d9b05781E3c',
icon: 'https://github.com/MetaMask/metamask-extension/blob/develop/app/images/avax-token.png',
contactVersion: SwapContractVersion.TraderJoe,
},
Expand Down Expand Up @@ -137,7 +137,7 @@ export const EVM_CHAINS: BridgeChain[] = [
explorerUrl: 'https://bscscan.com',
type: ChainTypes.EVM,
icon: 'https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/app/images/bnb.png',
contractAddress: '',
contractAddress: '0x85718348D854CE2768e96D87a2ed6d12d619b67B',
contactVersion: SwapContractVersion.PancakeSwap,
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/nft-checkout/src/entities/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class Amount extends AmountBase {
super(value, decimals)
}

static fromRaw(value: string, decimals: number): Amount {
static fromFraction(value: string, decimals: number): Amount {
return new Amount(value, decimals)
}

static fromFraction(value: string, decimals: number): Amount {
return new Amount(new BN(value).fromFraction(decimals).toString(), decimals)
static fromRaw(value: string, decimals: number): Amount {
return new Amount(new BN(value).toFraction(decimals).toString(), decimals)
}
}
14 changes: 7 additions & 7 deletions packages/nft-checkout/src/enums/chain.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export enum ChainNames {
Ethereum = 'Ethereum Mainnet',
Polygon = 'Polygon Mainnet',
Avalanche = 'Avalanche C-Chain',
Goerli = 'Görli',
Ethereum = 'Ethereum',
Polygon = 'Polygon',
Avalanche = 'Avalanche',
Goerli = 'Goerli',
Sepolia = 'Sepolia',
Mumbai = 'Polygon Mumbai',
Fuji = 'Avalanche Fuji-Chain',
BinanceSmartChain = 'Binance Smart Chain',
Mumbai = 'Mumbai',
Fuji = 'fuji',
BinanceSmartChain = 'BSC',
Chapel = 'Binance Smart Chain Testnet',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export const estimateJoeTrader = async (
return {
impact: trade.priceImpact.toSignificant(3),
path: trade.route.path.map(token => token.address),
from,
to,
from: _from,
to: _to,
price: Price.fromFraction(
trade.maximumAmountIn(getSlippage(target.slippage)).numerator.toString(),
from.decimals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export const estimatePancakeSwap = async (
return {
impact: trade.priceImpact.toSignificant(3),
path: trade.route.path.map(token => token.address),
from,
to,
from: _from,
to: _to,
price: Price.fromFraction(
trade.maximumAmountIn(getSlippage(target.slippage)).numerator.toString(),
from.decimals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export const estimateUniswapV3 = async (
)

return {
from,
to,
from: _from,
to: _to,
impact: trade ? computeRealizedPriceImpact(trade) : undefined,
price: getPrice(from, amount),
path: getRoutePath(route.route),
Expand Down
4 changes: 2 additions & 2 deletions packages/nft-checkout/src/operations/evm/helpers/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createPaymentToken = (

return PaymentToken.fromToken(
internalToken,
Amount.fromRaw(token.balance, token.decimals),
Amount.fromFraction(token.balance, token.decimals),
)
}

Expand Down Expand Up @@ -76,7 +76,7 @@ export const getPaymentTokens = async (
? [
PaymentToken.fromToken(
Token.fromChain(chain),
Amount.fromRaw(nativeBalance.toString(), chain.token.decimals),
Amount.fromFraction(nativeBalance.toString(), chain.token.decimals),
),
]
: []),
Expand Down
10 changes: 6 additions & 4 deletions packages/nft-checkout/src/operations/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ export class EVMOperation
}

#getNativeAmountIn(price: Price) {
return new BN(
new BN(price.toString())
.mul(NATIVE_TOKEN_WRAP_SLIPPAGE_MULTIPLIER)
.round(price.decimals),
const amount = new BN(
new BN(price.toString(), { decimals: price.decimals }).mul(
NATIVE_TOKEN_WRAP_SLIPPAGE_MULTIPLIER,
),
)
.toFraction(price.decimals)
.toString()

return amount.split('.')[0]
}

#getFunctionFragment(from: Token, to: Token) {
Expand Down
2 changes: 1 addition & 1 deletion packages/provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/provider",
"version": "1.2.0",
"version": "1.3.0",
"description": "Features of the Rarimo SDK that provide access to wallets and wrap the wallet extension providers from different EVM and non-EVM chains to one common interface for ease of use",
"repository": {
"type": "git",
Expand Down

0 comments on commit 0f6c69a

Please sign in to comment.