Skip to content

Commit

Permalink
Support Bitlayer Mainnet (#10)
Browse files Browse the repository at this point in the history
* Supported of sdk-core

* Bump version of sdk-core

* Publish sdk-core

* Supported of v2-sdk and v3-sdk

* Bump version of v2-sdk and v3-sdk

* Publish v2-sdk and v3-sdk

* Fix yarn.lock

* Update dependencies for router-sdk

* Bump version of router-sdk

* Publish router-sdk

* Update dependencies for uniswapx-sdk

* Bump version of uniswapx-sdk

* Publish uniswapx-sdk

* Supported of universal-router-sdk

* Bump version of universal-router-sdk

* Publish universal-router-sdk
  • Loading branch information
JayJay1024 authored Jul 11, 2024
1 parent c345121 commit d9a8ab6
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 54 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ jobs:
yarn config unset npmAuthToken
- name: Build packages
run: yarn g:build
# run: yarn g:build
run: |
yarn sdk @helix-bridge/universal-router-sdk build
- name: Publish to GitHub Packages
run: |
npm publish -w @helix-bridge/sdk-core
npm publish -w @helix-bridge/v2-sdk
npm publish -w @helix-bridge/v3-sdk
npm publish -w @helix-bridge/router-sdk
npm publish -w @helix-bridge/uniswapx-sdk
npm publish -w @helix-bridge/universal-router-sdk
# npm publish -w @helix-bridge/uniswapx-sdk
# npm publish -w @helix-bridge/router-sdk
# npm publish -w @helix-bridge/v2-sdk
# npm publish -w @helix-bridge/v3-sdk
# npm publish -w @helix-bridge/sdk-core
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
8 changes: 4 additions & 4 deletions sdks/router-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/router-sdk",
"version": "1.0.4",
"version": "1.0.5",
"description": "An sdk for routing swaps using Uniswap v2 and Uniswap v3.",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand All @@ -22,9 +22,9 @@
},
"dependencies": {
"@ethersproject/abi": "^5.5.0",
"@helix-bridge/sdk-core": "1.0.1",
"@helix-bridge/v2-sdk": "1.0.2",
"@helix-bridge/v3-sdk": "1.0.2",
"@helix-bridge/sdk-core": "1.0.5",
"@helix-bridge/v2-sdk": "1.0.5",
"@helix-bridge/v3-sdk": "1.0.5",
"@uniswap/swap-router-contracts": "^1.3.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sdks/sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/sdk-core",
"version": "1.0.4",
"version": "1.0.5",
"description": "⚒️ An SDK for building applications on top of Uniswap V3",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand Down
8 changes: 8 additions & 0 deletions sdks/sdk-core/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ const BITLAYER_TESTNET_ADDRESSES: ChainAddresses = {
nonfungiblePositionManagerAddress: '0x6b5622503fe2ca3cd371f7dfe5393df04b63ce22',
}

const BITLAYER_ADDRESSES: ChainAddresses = {
v3CoreFactoryAddress: '0x9bc1C7567DDBcaF2212185b6665D755d842d01E4',
multicallAddress: '0x876a4f6ecf13eeb101f9e75fcef58f19ff383eeb',
quoterAddress: '0x61B6B8c7C00aA7F060a2BEDeE6b11927CC9c3eF1',
nonfungiblePositionManagerAddress: '0xFBAD806Bdf9cEC2943be281FB355Da05068DE925',
}

export const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses> = {
[ChainId.MAINNET]: MAINNET_ADDRESSES,
[ChainId.OPTIMISM]: OPTIMISM_ADDRESSES,
Expand All @@ -266,6 +273,7 @@ export const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses>
// [ChainId.ROOTSTOCK]: ROOTSTOCK_ADDRESSES,
[ChainId.BLAST]: BLAST_ADDRESSES,
[ChainId.BITLAYER_TESTNET]: BITLAYER_TESTNET_ADDRESSES,
[ChainId.BITLAYER]: BITLAYER_ADDRESSES,
}

/* V3 Contract Addresses */
Expand Down
7 changes: 7 additions & 0 deletions sdks/sdk-core/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export enum ChainId {
// ROOTSTOCK = 30,
BLAST = 81457,
BITLAYER_TESTNET = 200810,
BITLAYER = 200901,
}

export const SUPPORTED_CHAINS = [
Expand All @@ -48,6 +49,7 @@ export const SUPPORTED_CHAINS = [
// ChainId.ROOTSTOCK,
ChainId.BLAST,
ChainId.BITLAYER_TESTNET,
ChainId.BITLAYER,
] as const
export type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number]

Expand All @@ -62,3 +64,8 @@ export enum NativeCurrencyName {
AVAX = 'AVAX',
// ROOTSTOCK = 'RBTC',
}

export const CHAINS_SUPPORTED_BY_HELIXSWAP = [
ChainId.BITLAYER_TESTNET,
ChainId.BITLAYER,
]
12 changes: 11 additions & 1 deletion sdks/sdk-core/src/entities/ether.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ import { NativeCurrency } from './nativeCurrency'
import { Token } from './token'
import { WETH9 } from './weth9'

function getSymbolAndName(chainId: number) {
switch (chainId) {
case 200810:
case 200901:
return ['BTC', 'BTC']
default:
return ['ETH', 'Ether']
}
}

/**
* Ether is the main usage of a 'native' currency, i.e. for Ethereum mainnet and all testnets
*/
export class Ether extends NativeCurrency {
protected constructor(chainId: number) {
super(chainId, 18, 'ETH', 'Ether')
super(chainId, 18, getSymbolAndName(chainId)[0], getSymbolAndName(chainId)[1])
}

public get wrapped(): Token {
Expand Down
3 changes: 3 additions & 0 deletions sdks/sdk-core/src/entities/weth9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ export const WETH9: { [chainId: number]: Token } = {
137: new Token(137, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 18, 'WMATIC', 'Wrapped MATIC'),
43114: new Token(43114, '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 18, 'WAVAX', 'Wrapped AVAX'),

// Bitlayer Testnet
200810: new Token(200810, '0x5F8D4232367759bCe5d9488D3ade77FCFF6B9b6B', 18, 'WBTC', 'Wrapped BTC'),
// Bitlayer
200901: new Token(200901, '0xfF204e2681A6fA0e2C3FaDe68a1B28fb90E4Fc5F', 18, 'WBTC', 'Wrapped BTC'),
}
4 changes: 2 additions & 2 deletions sdks/uniswapx-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/uniswapx-sdk",
"version": "1.0.4",
"version": "1.0.5",
"author": "Uniswap",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand Down Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@helix-bridge/sdk-core": "1.0.1",
"@helix-bridge/sdk-core": "1.0.5",
"@uniswap/permit2-sdk": "^1.2.1",
"ethers": "^5.7.0"
},
Expand Down
10 changes: 5 additions & 5 deletions sdks/universal-router-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/universal-router-sdk",
"version": "1.0.4",
"version": "1.0.5",
"description": "sdk for integrating with the Universal Router contracts",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand Down Expand Up @@ -31,10 +31,10 @@
"test:hardhat": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' hardhat test"
},
"dependencies": {
"@helix-bridge/router-sdk": "1.0.3",
"@helix-bridge/sdk-core": "1.0.1",
"@helix-bridge/v2-sdk": "1.0.2",
"@helix-bridge/v3-sdk": "1.0.2",
"@helix-bridge/router-sdk": "1.0.5",
"@helix-bridge/sdk-core": "1.0.5",
"@helix-bridge/v2-sdk": "1.0.5",
"@helix-bridge/v3-sdk": "1.0.5",
"@uniswap/permit2-sdk": "^1.2.1",
"@uniswap/universal-router": "1.6.0",
"bignumber.js": "^9.0.2",
Expand Down
6 changes: 6 additions & 0 deletions sdks/universal-router-sdk/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ const CHAIN_CONFIGS: { [key: number]: ChainConfig } = {
weth: '0x5F8D4232367759bCe5d9488D3ade77FCFF6B9b6B',
creationBlock: 3937748,
},
// bitlayer mainnet
[200901]: {
router: '0x0ac58df0cc3542bec4cda71b16d06c3ccc39f405',
weth: '0xfF204e2681A6fA0e2C3FaDe68a1B28fb90E4Fc5F',
creationBlock: 2753030,
}
}

export const UNIVERSAL_ROUTER_ADDRESS = (chainId: number): string => {
Expand Down
4 changes: 2 additions & 2 deletions sdks/v2-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/v2-sdk",
"version": "1.0.4",
"version": "1.0.5",
"description": "🛠 An SDK for building applications on top of Uniswap V2",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand All @@ -27,7 +27,7 @@
"dependencies": {
"@ethersproject/address": "^5.0.2",
"@ethersproject/solidity": "^5.0.9",
"@helix-bridge/sdk-core": "1.0.1",
"@helix-bridge/sdk-core": "1.0.5",
"tiny-invariant": "^1.1.0",
"tiny-warning": "^1.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions sdks/v3-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helix-bridge/v3-sdk",
"version": "1.0.4",
"version": "1.0.5",
"description": "⚒️ An SDK for building applications on top of Uniswap V3",
"repository": "https://github.com/Uniswap/sdks.git",
"keywords": [
Expand All @@ -27,7 +27,7 @@
"dependencies": {
"@ethersproject/abi": "^5.5.0",
"@ethersproject/solidity": "^5.0.9",
"@helix-bridge/sdk-core": "1.0.1",
"@helix-bridge/sdk-core": "1.0.5",
"@uniswap/swap-router-contracts": "^1.3.0",
"@uniswap/v3-periphery": "^1.1.1",
"@uniswap/v3-staker": "1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions sdks/v3-sdk/src/utils/computePoolAddress.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defaultAbiCoder } from '@ethersproject/abi'
import { getCreate2Address } from '@ethersproject/address'
import { keccak256 } from '@ethersproject/solidity'
import { ChainId, Token } from '@helix-bridge/sdk-core'
import { ChainId, CHAINS_SUPPORTED_BY_HELIXSWAP, Token } from '@helix-bridge/sdk-core'
import { FeeAmount, POOL_INIT_CODE_HASH } from '../constants'

function getInitCodeOfSpecialChain(chainId: ChainId) {
if (chainId === ChainId.BITLAYER_TESTNET) {
function getInitCodeHash(chainId: ChainId) {
if (CHAINS_SUPPORTED_BY_HELIXSWAP.includes(chainId)) {
return '0x9b06af945a15e497de0a98c56727a90114ae2d082285037c0045493ce98241aa'
}
return POOL_INIT_CODE_HASH
Expand Down Expand Up @@ -40,6 +40,6 @@ export function computePoolAddress({
['bytes'],
[defaultAbiCoder.encode(['address', 'address', 'uint24'], [token0.address, token1.address, fee])]
),
initCodeHashManualOverride ?? getInitCodeOfSpecialChain(token0.chainId)
initCodeHashManualOverride ?? getInitCodeHash(token0.chainId)
)
}
68 changes: 41 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2216,16 +2216,16 @@ __metadata:
languageName: node
linkType: hard

"@helix-bridge/router-sdk@npm:1.0.3":
version: 1.0.3
resolution: "@helix-bridge/router-sdk@npm:1.0.3::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Frouter-sdk%2F1.0.3%2F6108f0a62da2a2329d10890ede5d9c1fb73ab026"
"@helix-bridge/router-sdk@npm:1.0.5":
version: 1.0.5
resolution: "@helix-bridge/router-sdk@npm:1.0.5::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Frouter-sdk%2F1.0.5%2F61669a7a2b82ba3ee71314b979ad7c8ff0e1cf4f"
dependencies:
"@ethersproject/abi": ^5.5.0
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/v2-sdk": 1.0.2
"@helix-bridge/v3-sdk": 1.0.2
"@helix-bridge/sdk-core": 1.0.5
"@helix-bridge/v2-sdk": 1.0.5
"@helix-bridge/v3-sdk": 1.0.5
"@uniswap/swap-router-contracts": ^1.3.0
checksum: 22ceedaf9704546e46cf38e63b1436e4a0864706eba5f261802b3af3f548baa79f50c354d19991bfc113e7149488ed78ea7cf61c6deec5344b1f5729a0974d22
checksum: 0ada524ee42f6ebd8e5963b4addfb6320a1b4b8cbe32e7f887e89ff0a5c4f8cc6a6dbbe7d23c273c0b4055018a5d1f2cd5e3611bf2baf13653c8234587b091b9
languageName: node
linkType: hard

Expand All @@ -2234,9 +2234,9 @@ __metadata:
resolution: "@helix-bridge/router-sdk@workspace:sdks/router-sdk"
dependencies:
"@ethersproject/abi": ^5.5.0
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/v2-sdk": 1.0.2
"@helix-bridge/v3-sdk": 1.0.2
"@helix-bridge/sdk-core": 1.0.5
"@helix-bridge/v2-sdk": 1.0.5
"@helix-bridge/v3-sdk": 1.0.5
"@types/jest": ^24.0.25
"@uniswap/swap-router-contracts": ^1.3.0
prettier: ^2.4.1
Expand All @@ -2258,6 +2258,20 @@ __metadata:
languageName: node
linkType: hard

"@helix-bridge/sdk-core@npm:1.0.5":
version: 1.0.5
resolution: "@helix-bridge/sdk-core@npm:1.0.5::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Fsdk-core%2F1.0.5%2F9ce81e268c84d0c8dd7126bf198d7b93da9c41eb"
dependencies:
"@ethersproject/address": ^5.0.2
big.js: ^5.2.2
decimal.js-light: ^2.5.0
jsbi: ^3.1.4
tiny-invariant: ^1.1.0
toformat: ^2.0.0
checksum: e63e456044542c0e8c5ea6b44dcd377c44c3be984c63625d9ef67dbf69bdd1c08691dda61d75b5ff0d3022120613c40afb02ba7dc11c97933139855fc34e84c7
languageName: node
linkType: hard

"@helix-bridge/sdk-core@workspace:sdks/sdk-core":
version: 0.0.0-use.local
resolution: "@helix-bridge/sdk-core@workspace:sdks/sdk-core"
Expand All @@ -2280,7 +2294,7 @@ __metadata:
dependencies:
"@ethersproject/bytes": ^5.7.0
"@ethersproject/providers": ^5.7.0
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/sdk-core": 1.0.5
"@typechain/ethers-v5": ^10.1.0
"@types/jest": ^24.0.25
"@types/node": ^18.7.16
Expand Down Expand Up @@ -2309,10 +2323,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "@helix-bridge/universal-router-sdk@workspace:sdks/universal-router-sdk"
dependencies:
"@helix-bridge/router-sdk": 1.0.3
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/v2-sdk": 1.0.2
"@helix-bridge/v3-sdk": 1.0.2
"@helix-bridge/router-sdk": 1.0.5
"@helix-bridge/sdk-core": 1.0.5
"@helix-bridge/v2-sdk": 1.0.5
"@helix-bridge/v3-sdk": 1.0.5
"@types/chai": ^4.3.3
"@types/mocha": ^9.1.1
"@types/node": ^18.7.16
Expand All @@ -2334,16 +2348,16 @@ __metadata:
languageName: unknown
linkType: soft

"@helix-bridge/v2-sdk@npm:1.0.2":
version: 1.0.2
resolution: "@helix-bridge/v2-sdk@npm:1.0.2::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Fv2-sdk%2F1.0.2%2F94ae6c6a3c6060b69c5a21a427b683f0b84f8f23"
"@helix-bridge/v2-sdk@npm:1.0.5":
version: 1.0.5
resolution: "@helix-bridge/v2-sdk@npm:1.0.5::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Fv2-sdk%2F1.0.5%2Fc346994af25ca6540c435b7bfa46eb999fdcdaae"
dependencies:
"@ethersproject/address": ^5.0.2
"@ethersproject/solidity": ^5.0.9
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/sdk-core": 1.0.5
tiny-invariant: ^1.1.0
tiny-warning: ^1.0.3
checksum: 2260124a4aad0f102d59af5ee80ccedc327a1c9f37d74ef6a021ed6c11f9d9965eb2a2602d46b93dad81a567d7064fd21c0549f9ba40a86d06ac25ff6c8b33fc
checksum: ada184f380c97e5a7282854682cdba49244fb6ba99734a165d8992293faad35e50a18c1887117fe6abc9d37a9b73f135d91e80a6b992ff50a7a47e81f8657813
languageName: node
linkType: hard

Expand All @@ -2353,7 +2367,7 @@ __metadata:
dependencies:
"@ethersproject/address": ^5.0.2
"@ethersproject/solidity": ^5.0.9
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/sdk-core": 1.0.5
"@types/big.js": ^4.0.5
"@types/jest": ^24.0.25
"@uniswap/v2-core": ^1.0.1
Expand All @@ -2364,19 +2378,19 @@ __metadata:
languageName: unknown
linkType: soft

"@helix-bridge/v3-sdk@npm:1.0.2":
version: 1.0.2
resolution: "@helix-bridge/v3-sdk@npm:1.0.2::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Fv3-sdk%2F1.0.2%2F3d798efe8945d324b732b53a78201b87f2bbb28d"
"@helix-bridge/v3-sdk@npm:1.0.5":
version: 1.0.5
resolution: "@helix-bridge/v3-sdk@npm:1.0.5::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40helix-bridge%2Fv3-sdk%2F1.0.5%2F9c1d40d7e3ff8a7e00e68084e6cc78375193e360"
dependencies:
"@ethersproject/abi": ^5.5.0
"@ethersproject/solidity": ^5.0.9
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/sdk-core": 1.0.5
"@uniswap/swap-router-contracts": ^1.3.0
"@uniswap/v3-periphery": ^1.1.1
"@uniswap/v3-staker": 1.0.0
tiny-invariant: ^1.1.0
tiny-warning: ^1.0.3
checksum: c42ffa8dc7da913218c2185bc3b546fae0f99badcbbc432c1c540443acfb5390194360a64b3a5b6e69b1a8a8d58483f539d4aa362d7674e5ee7a2910195be787
checksum: 0b11c3ffd741a4bd45edfd09950f1b2e8b0b629c3b7a31f8553e0b1f238e37765287bd488917d77bdc1302bd79b1eb097576b7486fe19ea8bdba6510314d10f0
languageName: node
linkType: hard

Expand All @@ -2386,7 +2400,7 @@ __metadata:
dependencies:
"@ethersproject/abi": ^5.5.0
"@ethersproject/solidity": ^5.0.9
"@helix-bridge/sdk-core": 1.0.1
"@helix-bridge/sdk-core": 1.0.5
"@types/jest": ^24.0.25
"@uniswap/swap-router-contracts": ^1.3.0
"@uniswap/v3-core": 1.0.0
Expand Down

0 comments on commit d9a8ab6

Please sign in to comment.