Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade starknet packages & new CI jobs #287

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Core

on:
push:
paths: [packages/core/**]
pull_request:
paths: [packages/core/**]

permissions: read-all

jobs:
check:
defaults:
run:
working-directory: packages/core

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: yarn install
working-directory: ./

- name: Lint
run: yarn lint

- name: Test
run: yarn test

- name: Build
run: yarn build
32 changes: 32 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Frontend

on:
push:
paths: [packages/core/**, packages/hooks/**, packages/frontend/**]
pull_request:
paths: [packages/core/**, packages/hooks/**, packages/frontend/**]

permissions: read-all

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: yarn install

- name: Lint
run: yarn lint
working-directory: packages/frontend

- name: Build
run: yarn g:build
44 changes: 44 additions & 0 deletions .github/workflows/hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Hooks

on:
push:
paths: [packages/hooks/**]
pull_request:
paths: [packages/hooks/**]

permissions: read-all

jobs:
check:
defaults:
run:
working-directory: packages/hooks

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: yarn install
working-directory: ./

# Core package is required for hooks to test and build
- name: Build Core
run: yarn build
working-directory: ./packages/core

- name: Lint
run: yarn lint

- name: Test
run: yarn test

- name: Build Hooks
run: yarn build
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"moment": "^2.30.1"
},
"peerDependencies": {
"starknet": ">=5.0.0"
"starknet": ">=6.8.0"
},
"devDependencies": {
"@uniswap/eslint-config": "^1.2.0",
"prettier": "^3.1.0",
"starknet": "5.24.3",
"starknet": "^6.18.0",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.5.0"
Expand Down
37 changes: 19 additions & 18 deletions packages/core/src/constants/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
import { MultichainAddress } from 'src/types'
import { constants, json } from 'starknet'

import EkuboPositions from '../abis/EkuboPositions.json'
import JediswapPair from '../abis/JediswapPair.json'
import Multicall from '../abis/Multicall.json'

export const TOKEN_CLASS_HASH = {
[constants.StarknetChainId.SN_GOERLI]: '0x05ba9aea47a8dd7073ab82b9e91721bdb3a2c1b259cffd68669da1454faa80ac',
export const TOKEN_CLASS_HASH: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x063ee878d3559583ceae80372c6088140e1180d9893aa65fbefc81f45ddaaa17',
[constants.StarknetChainId.SN_MAIN]: '0x063ee878d3559583ceae80372c6088140e1180d9893aa65fbefc81f45ddaaa17',
}

export const FACTORY_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x076c3112e95994507c44c72b8dfb7f8d568a370d2f7c2d918ed9f55327671385',
export const FACTORY_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x06b5096ba5a3c30e231e7b74ca565594d167a0a22d71cce0ebf9ae2b06584097',
[constants.StarknetChainId.SN_MAIN]: '0x01a46467a9246f45c8c340f1f155266a26a71c07bd55d36e8d1c7d0d438a2dbc',
}

export const EKUBO_POSITIONS_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x073fa8432bf59f8ed535f29acfd89a7020758bda7be509e00dfed8a9fde12ddc',
export const EKUBO_POSITIONS_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x06a2aee84bb0ed5dded4384ddd0e40e9c1372b818668375ab8e3ec08807417e5',
[constants.StarknetChainId.SN_MAIN]: '0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067',
}

export const ETH_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
export const ETH_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
[constants.StarknetChainId.SN_MAIN]: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
}
export const STRK_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d',
export const STRK_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d',
[constants.StarknetChainId.SN_MAIN]: '0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d',
}

export const USDC_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x5a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426',
export const USDC_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x5a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426',
[constants.StarknetChainId.SN_MAIN]: '0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8',
}

export const MULTICALL_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: '0x01a33330996310a1e3fa1df5b16c1e07f0491fdd20c441126e02613b948f0225',
export const MULTICALL_ADDRESSES: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x01a33330996310a1e3fa1df5b16c1e07f0491fdd20c441126e02613b948f0225',
[constants.StarknetChainId.SN_MAIN]: '0x01a33330996310a1e3fa1df5b16c1e07f0491fdd20c441126e02613b948f0225',
}

export const JEDISWAP_ETH_USDC = {
[constants.StarknetChainId.SN_GOERLI]: '0x05a2b2b37f66157f767ea711cb4e034c40d41f2f5acf9ff4a19049fa11c1a884',
export const JEDISWAP_ETH_USDC: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x05a2b2b37f66157f767ea711cb4e034c40d41f2f5acf9ff4a19049fa11c1a884',
[constants.StarknetChainId.SN_MAIN]: '0x04d0390b777b424e43839cd1e744799f3de6c176c7e32c1812a41dbd9c19db6a',
}

export const JEDISWAP_STRK_USDC = {
[constants.StarknetChainId.SN_GOERLI]: '0x018b129b1a372b3288077521ad8749f5a2b2ddfb67ef5a37e2d02190fa11c40f',
export const JEDISWAP_STRK_USDC: MultichainAddress = {
[constants.StarknetChainId.SN_SEPOLIA]: '0x018b129b1a372b3288077521ad8749f5a2b2ddfb67ef5a37e2d02190fa11c40f',
[constants.StarknetChainId.SN_MAIN]: '0x5726725e9507c3586cc0516449e2c74d9b201ab2747752bb0251aaa263c9a26',
}

Expand Down
32 changes: 16 additions & 16 deletions packages/core/src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export enum QUOTE_TOKEN_SYMBOL {

// ETH
export const Ether: MultichainToken = {
[constants.StarknetChainId.SN_GOERLI]: {
address: ETH_ADDRESSES[constants.StarknetChainId.SN_GOERLI],
[constants.StarknetChainId.SN_SEPOLIA]: {
address: ETH_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA],
symbol: QUOTE_TOKEN_SYMBOL.ETH,
name: 'Ether',
decimals: 18,
camelCased: true,
usdcPair: {
address: JEDISWAP_ETH_USDC[constants.StarknetChainId.SN_GOERLI],
address: JEDISWAP_ETH_USDC[constants.StarknetChainId.SN_SEPOLIA],
reversed: true,
},
},
Expand All @@ -37,14 +37,14 @@ export const Ether: MultichainToken = {

// STRK
export const Stark: MultichainToken = {
[constants.StarknetChainId.SN_GOERLI]: {
address: STRK_ADDRESSES[constants.StarknetChainId.SN_GOERLI],
[constants.StarknetChainId.SN_SEPOLIA]: {
address: STRK_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA],
symbol: QUOTE_TOKEN_SYMBOL.STRK,
name: 'Stark',
decimals: 18,
camelCased: true,
usdcPair: {
address: JEDISWAP_STRK_USDC[constants.StarknetChainId.SN_GOERLI],
address: JEDISWAP_STRK_USDC[constants.StarknetChainId.SN_SEPOLIA],
reversed: true,
},
},
Expand All @@ -63,8 +63,8 @@ export const Stark: MultichainToken = {

// USDC
export const USDCoin: MultichainToken = {
[constants.StarknetChainId.SN_GOERLI]: {
address: USDC_ADDRESSES[constants.StarknetChainId.SN_GOERLI],
[constants.StarknetChainId.SN_SEPOLIA]: {
address: USDC_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA],
symbol: QUOTE_TOKEN_SYMBOL.USDC,
name: 'USD Coin',
decimals: 6,
Expand All @@ -82,15 +82,15 @@ export const USDCoin: MultichainToken = {
// Quote tokens

export const QUOTE_TOKENS: { [chainId in constants.StarknetChainId]: Record<string, Token> } = {
[constants.StarknetChainId.SN_GOERLI]: {
[getChecksumAddress(ETH_ADDRESSES[constants.StarknetChainId.SN_GOERLI])]:
Ether[constants.StarknetChainId.SN_GOERLI],
[constants.StarknetChainId.SN_SEPOLIA]: {
[getChecksumAddress(ETH_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA])]:
Ether[constants.StarknetChainId.SN_SEPOLIA],

[getChecksumAddress(STRK_ADDRESSES[constants.StarknetChainId.SN_GOERLI])]:
Stark[constants.StarknetChainId.SN_GOERLI],
[getChecksumAddress(STRK_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA])]:
Stark[constants.StarknetChainId.SN_SEPOLIA],

[getChecksumAddress(USDC_ADDRESSES[constants.StarknetChainId.SN_GOERLI])]:
USDCoin[constants.StarknetChainId.SN_GOERLI],
[getChecksumAddress(USDC_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA])]:
USDCoin[constants.StarknetChainId.SN_SEPOLIA],
},

[constants.StarknetChainId.SN_MAIN]: {
Expand All @@ -101,6 +101,6 @@ export const QUOTE_TOKENS: { [chainId in constants.StarknetChainId]: Record<stri
}

export const DEFAULT_QUOTE_TOKEN_ADDRESSES = {
[constants.StarknetChainId.SN_GOERLI]: getChecksumAddress(ETH_ADDRESSES[constants.StarknetChainId.SN_GOERLI]),
[constants.StarknetChainId.SN_SEPOLIA]: getChecksumAddress(ETH_ADDRESSES[constants.StarknetChainId.SN_SEPOLIA]),
[constants.StarknetChainId.SN_MAIN]: getChecksumAddress(ETH_ADDRESSES[constants.StarknetChainId.SN_MAIN]),
}
6 changes: 3 additions & 3 deletions packages/core/src/factory/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class Factory implements FactoryInterface {
//

private async getJediswapLiquidityLockPosition(liquidity: Pick<JediswapLiquidity, 'lockManager' | 'lockPosition'>) {
const { result } = await this.config.provider.callContract({
const result = await this.config.provider.callContract({
contractAddress: liquidity.lockManager,
entrypoint: Entrypoint.GET_LOCK_DETAILS,
calldata: [liquidity.lockPosition],
Expand All @@ -205,7 +205,7 @@ export class Factory implements FactoryInterface {
}

private async getEkuboLiquidityLockPosition(liquidity: Pick<EkuboLiquidity, 'lockManager' | 'ekuboId'>) {
const { result } = await this.config.provider.callContract({
const result = await this.config.provider.callContract({
contractAddress: liquidity.lockManager,
entrypoint: Entrypoint.LIQUIDITY_POSITION_DETAILS,
calldata: [liquidity.ekuboId],
Expand Down Expand Up @@ -250,7 +250,7 @@ export class Factory implements FactoryInterface {
])

// call ekubo position to get collectable fees details
const { result } = await this.config.provider.callContract({
const result = await this.config.provider.callContract({
contractAddress: EKUBO_POSITIONS_ADDRESSES[this.config.chainId],
entrypoint: Entrypoint.GET_TOKEN_INFOS,
calldata,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export type Token = {
}

export type MultichainToken = { [chainId in constants.StarknetChainId]: Token }

export type MultichainAddress = { [chainId in constants.StarknetChainId]: `0x${string}` }
2 changes: 1 addition & 1 deletion packages/core/src/utils/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function multiCallContract(
entrypoint: Entrypoint.AGGREGATE,
calldata: [calldata.length, ...calldata.flat()],
})
const raw = rawResult.result.slice(2)
const raw = rawResult.slice(2)

const result: string[][] = []
let idx = 0
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { decimalsScale } from './helpers'
export async function getPairPrice(
provider: ProviderInterface,
pair?: USDCPair,
blockNumber: BlockNumber = BlockTag.latest,
blockNumber: BlockNumber = BlockTag.LATEST,
) {
if (!pair) return new Fraction(1, 1)

const { result } = await provider.callContract(
const result = await provider.callContract(
{
contractAddress: pair.address,
entrypoint: Entrypoint.GET_RESERVES,
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/craco.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
eslint: {
enable: true,
mode: 'file',
pluginOptions(eslintConfig) {
return Object.assign(eslintConfig, {
cache: true,
Expand Down
11 changes: 6 additions & 5 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"dependencies": {
"@avnu/avnu-sdk": "^2.0.0",
"@hookform/resolvers": "^3.3.2",
"@starknet-react/chains": "^0.1.0",
"@starknet-react/core": "^2.2.4",
"@tanstack/react-query": "^5.0.1",
"@starknet-io/types-js": "^0.7.10",
"@starknet-react/chains": "^3.1.0",
"@starknet-react/core": "^3.6.2",
"@tanstack/react-query": "^5.25.0",
"@types/react-dom": "^18.2.1",
"@uniswap/sdk-core": "^4.0.9",
"@vanilla-extract/css": "^1.11.0",
Expand All @@ -33,7 +34,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.0",
"react-router-dom": "^6.11.0",
"starknet": "^5.10.0",
"starknet": "^6.18.0",
"starknetkit": "^1.0.22",
"ua-parser-js": "^1.0.35",
"zod": "^3.22.4",
Expand All @@ -52,7 +53,7 @@
"get-graphql-schema": "^2.1.2",
"mini-css-extract-plugin": "^2.7.5",
"node-polyfill-webpack-plugin": "^2.0.1",
"prettier": "^2.4.1",
"prettier": "^3.2.5",
"react-scripts": "^5.0.1",
"typescript": "^5.0.4"
},
Expand Down
Loading
Loading