diff --git a/.github/workflows/suins-build-tx.yaml b/.github/workflows/suins-build-tx.yaml index 2c87cf4a..990ad357 100644 --- a/.github/workflows/suins-build-tx.yaml +++ b/.github/workflows/suins-build-tx.yaml @@ -14,6 +14,7 @@ on: - Withdraw Auction Profits - Transfer Reserved Names - Main package upgrade + - Create Deepbook Pools sui_tools_image: description: 'image reference of sui_tools' default: 'mysten/sui-tools:mainnet' @@ -146,6 +147,16 @@ jobs: run: | cd scripts && pnpm disable-free-claims + - name: Create Deepbook Pools + if: ${{ inputs.transaction_type == 'Create Deepbook Pools' }} + env: + NODE_ENV: production + GAS_OBJECT: ${{ inputs.gas_object_id }} + NETWORK: mainnet + ORIGIN: gh_action + run: | + cd scripts && pnpm create-deepbook-pools + - name: Show Transaction Data (To sign) run: | cat scripts/tx/tx-data.txt diff --git a/scripts/package.json b/scripts/package.json index 61bc6d59..0b41a9fb 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -14,7 +14,8 @@ "authorize-utils": "ts-node transactions/authorize_utils.ts", "publish-discounts": "ts-node transactions/publish_discounts.ts", "authorize-discounts": "ts-node transactions/quest_3_setup.ts", - "disable-free-claims": "ts-node transactions/quest3/disable_free_claims.ts" + "disable-free-claims": "ts-node transactions/quest3/disable_free_claims.ts", + "create-deepbook-pools": "ts-node transactions/deepbook/create_pools.ts" }, "keywords": [], "author": "", diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts new file mode 100644 index 00000000..e4ff4939 --- /dev/null +++ b/scripts/transactions/deepbook/create_pools.ts @@ -0,0 +1,155 @@ +// Copyright (c) 2023, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import dotenv from "dotenv"; +dotenv.config(); +import { + executeTx, + prepareMultisigTx, + prepareSigner, +} from "../../airdrop/helper"; +import { Network, mainPackage } from "../../config/constants"; +import { TransactionBlock } from "@mysten/sui.js"; + +const SUI = + "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"; +const WUSDCETH = + "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN"; +const WBTC = + "0xbc3a676894871284b3ccfb2eec66f428612000e2a6e6d23f592ce8833c27c973::coin::COIN"; +const WETH = + "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN"; +const USDT = + "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN"; +const TESTNET_COIN = + "0x0c5f16ebb22a354ccb8f4dc163df0e729d0d37b565b4178046ea342ea0a93391::gold::GOLD"; +export const CREATION_FEE = 100 * 1e9; +export const PACKAGE_ID = "0xdee9"; +export const MODULE_CLOB = "clob_v2"; + +// 2 - 2 for fees on the more volatile assets +const DEFAULT_MAKER_FEE = 200000; +const DEFAULT_TAKER_FEE = 200000; + +// 1 - 1 for fees +const DEFAULT_STABLE_MAKER_FEE = 100000; +const DEFAULT_STABLE_TAKER_FEE = 100000; + +// List of deepbook pools today +// data: [ +// { BTC / USDC pool +// poolId: '0xf0f663cf87f1eb124da2fc9be813e0ce262146f3df60bc2052d738eb41a25899', +// baseAsset: '0xbc3a676894871284b3ccfb2eec66f428612000e2a6e6d23f592ce8833c27c973::coin::COIN', +// quoteAsset: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN' +// tick: 1000000 +// lot: 1000 +// }, +// WETH / USDC POOL +// { +// poolId: '0xd9e45ab5440d61cc52e3b2bd915cdd643146f7593d587c715bc7bfa48311d826', +// baseAsset: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN', +// quoteAsset: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN' +// tick: 1000000, +// lot: 10000 +// }, +// { // USDT / USDC POOL +// poolId: '0x5deafda22b6b86127ea4299503362638bea0ca33bb212ea3a67b029356b8b955', +// baseAsset: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', +// quoteAsset: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN' +// tick: 100000 +// lot: 100000 +// }, +// { SUI / USDC POOL (This one is the one in Kriya) +// poolId: '0x7f526b1263c4b91b43c9e646419b5696f424de28dda3c1e6658cc0a54558baa7', +// baseAsset: '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', +// quoteAsset: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN' +// tick: 100 +// lot: 100000000 +// }, +// { +// poolId: '0x18d871e3c3da99046dfc0d3de612c5d88859bc03b8f0568bd127d0e70dbc58be', +// baseAsset: '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', +// quoteAsset: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN' +// tick: 10000, +// lot: 100000000 +// } +// ], + +// Setup Deepbook Pool. +const setup = async (network: Network) => { + const setup = mainPackage[network]; + + const txb = new TransactionBlock(); + // txb.mergeCoins(txb.gas, [ + // txb.object( + // "0xbb210191c48a3acbe8c306ef836037c7dc0e5920c7337d569755b52e38120554" + // ), + // ]); + const [coin] = txb.splitCoins(txb.gas, [txb.pure(CREATION_FEE)]); + + // Create SUI/ USDC + txb.moveCall({ + typeArguments: [SUI, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure(100), + txb.pure(100000000), + txb.pure(DEFAULT_TAKER_FEE), + txb.pure(DEFAULT_MAKER_FEE), + coin, + ], + }); + + const [coin2] = txb.splitCoins(txb.gas, [txb.pure(CREATION_FEE)]); + + // Create USDT / USDC + txb.moveCall({ + typeArguments: [USDT, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure(100000), + txb.pure(100000), + txb.pure(DEFAULT_STABLE_TAKER_FEE), + txb.pure(DEFAULT_STABLE_MAKER_FEE), + coin2, + ], + }); + + const [coin3] = txb.splitCoins(txb.gas, [txb.pure(CREATION_FEE)]); + + // Create WETH / USDC + txb.moveCall({ + typeArguments: [WETH, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure(1000000), + txb.pure(10000), + txb.pure(DEFAULT_STABLE_TAKER_FEE), + txb.pure(DEFAULT_STABLE_MAKER_FEE), + coin3, + ], + }); + const [coin4] = txb.splitCoins(txb.gas, [txb.pure(CREATION_FEE)]); + + // Create WBTC / USDC + txb.moveCall({ + typeArguments: [WBTC, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure(1000000), + txb.pure(1000), + txb.pure(DEFAULT_STABLE_TAKER_FEE), + txb.pure(DEFAULT_STABLE_MAKER_FEE), + coin4, + ], + }); + + // for mainnet, we prepare the multi-sig tx. + if (network === "mainnet") return prepareMultisigTx(txb, "mainnet"); + + // For testnet, we execute the TX directly. + return executeTx(prepareSigner(setup.provider), txb); +}; + +if (process.env.NETWORK === "mainnet") setup("mainnet"); +else setup("testnet");