From 3d40786b0d2b1dc7ef8ce7d79ba22c03acfd5939 Mon Sep 17 00:00:00 2001 From: Xavier Date: Thu, 12 Dec 2024 21:59:18 +0900 Subject: [PATCH] feat: add sonic mainnet --- package-lock.json | 4 ++-- package.json | 2 +- src/constants/addresses.ts | 12 ++++++++++++ src/constants/chain.ts | 3 +++ src/constants/currency.ts | 15 +++++++++++++++ src/constants/fee.ts | 2 ++ src/constants/sonic-mainnet-chain.ts | 27 +++++++++++++++++++++++++++ src/constants/subgraph.ts | 2 ++ 8 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 src/constants/sonic-mainnet-chain.ts diff --git a/package-lock.json b/package-lock.json index 08e718e..3a05f58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@clober/v2-sdk", - "version": "0.0.91", + "version": "0.0.92", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@clober/v2-sdk", - "version": "0.0.91", + "version": "0.0.92", "license": "MIT", "dependencies": { "axios": "^1.7.7", diff --git a/package.json b/package.json index f728f83..c8dc2e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@clober/v2-sdk", - "version": "0.0.91", + "version": "0.0.92", "description": "🛠 An SDK for building applications on top of Clober V2", "files": [ "dist" diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 28b04ff..3c89c73 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -94,6 +94,18 @@ export const CONTRACT_ADDRESSES: { ElectionGovernor: zeroAddress, KeepersRegistry: zeroAddress, }, + [CHAIN_IDS.SONIC_MAINNET]: { + Controller: getAddress('0xADc0CC0c3Ea12e57b8BcB7d7C8ac03222487E337'), + BookManager: getAddress('0xD4aD5Ed9E1436904624b6dB8B1BE31f36317C636'), + BookViewer: getAddress('0xe81e78f946e34d13Dcb6fd46a78713E0FFDA5613'), + Rebalancer: zeroAddress, + Strategy: zeroAddress, + Minter: zeroAddress, + Operator: zeroAddress, + VoteLockedCloberToken: zeroAddress, + ElectionGovernor: zeroAddress, + KeepersRegistry: zeroAddress, + }, [CHAIN_IDS.ZKSYNC]: { Controller: getAddress('0x2Bd904F455928833F8E8C706d1cf01Eb5daaee7C'), BookManager: getAddress('0xAc6AdB2727F99C309acd511D942c0b2812e03614'), diff --git a/src/constants/chain.ts b/src/constants/chain.ts index 3133173..63f5803 100644 --- a/src/constants/chain.ts +++ b/src/constants/chain.ts @@ -3,6 +3,7 @@ import { arbitrumSepolia, base, type Chain, zkSync } from 'viem/chains' import { cloberTestChain, cloberTestChain2 } from './test-chain' import { berachainBartioTestnet } from './bera-bartio-chain' import { mitosisTestnet } from './mitosis-testnet-chain' +import { sonicMainnet } from './sonic-mainnet-chain' export enum CHAIN_IDS { CLOBER_TESTNET = cloberTestChain.id, @@ -11,6 +12,7 @@ export enum CHAIN_IDS { BASE = base.id, BERACHAIN_TESTNET = berachainBartioTestnet.id, MITOSIS_TESTNET = mitosisTestnet.id, + SONIC_MAINNET = sonicMainnet.id, ZKSYNC = zkSync.id, } @@ -23,6 +25,7 @@ export const CHAIN_MAP: { [CHAIN_IDS.BASE]: base, [CHAIN_IDS.BERACHAIN_TESTNET]: berachainBartioTestnet, [CHAIN_IDS.MITOSIS_TESTNET]: mitosisTestnet, + [CHAIN_IDS.SONIC_MAINNET]: sonicMainnet, [CHAIN_IDS.ZKSYNC]: zkSync, } diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 73caedc..2d823f3 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -25,6 +25,13 @@ export const MITO: Currency = { decimals: 18, } +export const S: Currency = { + address: zeroAddress, + name: 'Sonic', + symbol: 'S', + decimals: 18, +} + export const NATIVE_CURRENCY: { [chain in CHAIN_IDS]: Currency } = { @@ -34,6 +41,7 @@ export const NATIVE_CURRENCY: { [CHAIN_IDS.BASE]: ETH, [CHAIN_IDS.BERACHAIN_TESTNET]: BERA, [CHAIN_IDS.MITOSIS_TESTNET]: MITO, + [CHAIN_IDS.SONIC_MAINNET]: S, [CHAIN_IDS.ZKSYNC]: ETH, } @@ -54,6 +62,9 @@ export const WETH_ADDRESSES: { [CHAIN_IDS.MITOSIS_TESTNET]: [ '0x8B71fD76b23721d0D73CA14Ea6464AAD70149B67', // WMITO ], + [CHAIN_IDS.SONIC_MAINNET]: [ + '0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38', // wS + ], [CHAIN_IDS.ZKSYNC]: ['0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91'], } @@ -76,6 +87,7 @@ export const STABLE_COIN_ADDRESSES: { '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', // USDbC '0x4621b7A9c75199271F773Ebd9A499dbd165c3191', // DOLA '0xB79DD08EA68A908A97220C76d19A6aA9cBDE4376', // USD+ + '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb', // DAI ], [CHAIN_IDS.BERACHAIN_TESTNET]: [ '0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03', // HONEY @@ -86,6 +98,9 @@ export const STABLE_COIN_ADDRESSES: { '0xCB0CedF61be0Bf4d5F6596b8ab296614b154db91', // USDT '0xb8f230Ea91516787F2cbB2c63b147Ec79988E3ED', // USDe ], + [CHAIN_IDS.SONIC_MAINNET]: [ + // TODO: add stable coin at day 1 + ], [CHAIN_IDS.ZKSYNC]: [ '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', // USDC ], diff --git a/src/constants/fee.ts b/src/constants/fee.ts index 4619cd5..f6ad02e 100644 --- a/src/constants/fee.ts +++ b/src/constants/fee.ts @@ -11,6 +11,7 @@ export const MAKER_DEFAULT_POLICY: { [CHAIN_IDS.BASE]: new FeePolicy(true, 0n), // 0%, [CHAIN_IDS.BERACHAIN_TESTNET]: new FeePolicy(true, 0n), // 0%, [CHAIN_IDS.MITOSIS_TESTNET]: new FeePolicy(true, 0n), // 0%, + [CHAIN_IDS.SONIC_MAINNET]: new FeePolicy(true, 0n), // 0%, [CHAIN_IDS.ZKSYNC]: new FeePolicy(true, 0n), // 0%, } @@ -23,5 +24,6 @@ export const TAKER_DEFAULT_POLICY: { [CHAIN_IDS.BASE]: new FeePolicy(true, 100n), // 0.01% [CHAIN_IDS.BERACHAIN_TESTNET]: new FeePolicy(true, 100n), // 0.01% [CHAIN_IDS.MITOSIS_TESTNET]: new FeePolicy(true, 100n), // 0.01% + [CHAIN_IDS.SONIC_MAINNET]: new FeePolicy(true, 100n), // 0.01% [CHAIN_IDS.ZKSYNC]: new FeePolicy(true, 100n), // 0.01% } diff --git a/src/constants/sonic-mainnet-chain.ts b/src/constants/sonic-mainnet-chain.ts new file mode 100644 index 0000000..e5f7b89 --- /dev/null +++ b/src/constants/sonic-mainnet-chain.ts @@ -0,0 +1,27 @@ +import { defineChain } from 'viem' + +export const sonicMainnet = /*#__PURE__*/ defineChain({ + id: 146, + name: 'Sonic Mainnet', + nativeCurrency: { + decimals: 18, + name: 'Sonic', + symbol: 'S', + }, + rpcUrls: { + default: { http: ['https://rpc.soniclabs.com'] }, + }, + blockExplorers: { + default: { + name: 'Sonic Mainnet', + url: 'https://sonicscan.org', + }, + }, + testnet: false, + contracts: { + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 60, + }, + }, +}) diff --git a/src/constants/subgraph.ts b/src/constants/subgraph.ts index 5e6a482..b75473a 100644 --- a/src/constants/subgraph.ts +++ b/src/constants/subgraph.ts @@ -17,6 +17,8 @@ const SUBGRAPH_URL: { 'https://api.goldsky.com/api/public/project_clsljw95chutg01w45cio46j0/subgraphs/v2-core-subgraph-berachain-bartio/v1.8.1/gn', [CHAIN_IDS.MITOSIS_TESTNET]: 'https://api.goldsky.com/api/public/project_clsljw95chutg01w45cio46j0/subgraphs/v2-core-subgraph-mitosis-testnet/v1.8.1/gn', + [CHAIN_IDS.SONIC_MAINNET]: + 'https://subgraph.satsuma-prod.com/f6a8c4889b7b/clober/v2-core-subgraph-sonic-mainnet/api', [CHAIN_IDS.ZKSYNC]: 'https://api.goldsky.com/api/public/project_clsljw95chutg01w45cio46j0/subgraphs/v2-core-subgraph-zksync-era/v1.5.5/gn', }