From 078e585dbdbb2f7334e07862617d5635ee668c68 Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:07:38 -0400 Subject: [PATCH 1/6] adding new script to create pools --- scripts/transactions/deepbook/create_pools.ts | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 scripts/transactions/deepbook/create_pools.ts diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts new file mode 100644 index 00000000..86871fcf --- /dev/null +++ b/scripts/transactions/deepbook/create_pools.ts @@ -0,0 +1,140 @@ +// 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"; +export const CREATION_FEE = 100 * 1e9; +export const PACKAGE_ID = "0xdee9"; +export const MODULE_CLOB = "clob_v2"; +const DEFAULT_MAKER_FEE = 0; +const DEFAULT_TAKER_FEE = 400000; + +const DEFAULT_STABLE_MAKER_FEE = 0; +const DEFAULT_STABLE_TAKER_FEE = 200000; + +// 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(); + const [coin] = txb.splitCoins(txb.gas, [CREATION_FEE]); + + // Create SUI/ USDC + txb.moveCall({ + typeArguments: [SUI, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure.u64(100), + txb.pure.u64(100000000), + txb.pure.u64(DEFAULT_TAKER_FEE), + txb.pure.u64(DEFAULT_MAKER_FEE), + coin, + ], + }); + + // Create USDT / USDC + txb.moveCall({ + typeArguments: [USDT, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure.u64(100000), + txb.pure.u64(100000), + txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), + txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), + coin, + ], + }); + + // Create WETH / USDC + txb.moveCall({ + typeArguments: [WETH, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure.u64(1000000), + txb.pure.u64(10000), + txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), + txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), + coin, + ], + }); + + // Create WBTC / USDC + txb.moveCall({ + typeArguments: [WBTC, WUSDCETH], + target: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`, + arguments: [ + txb.pure.u64(1000000), + txb.pure.u64(1000), + txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), + txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), + coin, + ], + }); + + // 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"); From 5a36bc9b9c7629081517a5aae2a8a54e9de1dc55 Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:30:42 -0400 Subject: [PATCH 2/6] creating deepbook with new pools --- .github/workflows/suins-build-tx.yaml | 11 +++++++++++ scripts/package.json | 3 ++- scripts/transactions/deepbook/create_pools.ts | 11 +++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) 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 index 86871fcf..33cc5e6a 100644 --- a/scripts/transactions/deepbook/create_pools.ts +++ b/scripts/transactions/deepbook/create_pools.ts @@ -24,11 +24,14 @@ const USDT = export const CREATION_FEE = 100 * 1e9; export const PACKAGE_ID = "0xdee9"; export const MODULE_CLOB = "clob_v2"; -const DEFAULT_MAKER_FEE = 0; -const DEFAULT_TAKER_FEE = 400000; -const DEFAULT_STABLE_MAKER_FEE = 0; -const DEFAULT_STABLE_TAKER_FEE = 200000; +// 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: [ From cb7c5788ce64de49a218c838f702c4b00958d182 Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:33:44 -0400 Subject: [PATCH 3/6] fixing deployment script --- scripts/transactions/deepbook/create_pools.ts | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts index 33cc5e6a..1bd921d0 100644 --- a/scripts/transactions/deepbook/create_pools.ts +++ b/scripts/transactions/deepbook/create_pools.ts @@ -21,6 +21,8 @@ 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"; @@ -33,6 +35,7 @@ const DEFAULT_TAKER_FEE = 200000; const DEFAULT_STABLE_MAKER_FEE = 100000; const DEFAULT_STABLE_TAKER_FEE = 100000; +// export ADMIN_PHRASE="trophy conduct student type result lamp seven slam chest category tenant inherit" // List of deepbook pools today // data: [ // { BTC / USDC pool @@ -78,57 +81,62 @@ const setup = async (network: Network) => { const setup = mainPackage[network]; const txb = new TransactionBlock(); - const [coin] = txb.splitCoins(txb.gas, [CREATION_FEE]); + 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.u64(100), - txb.pure.u64(100000000), - txb.pure.u64(DEFAULT_TAKER_FEE), - txb.pure.u64(DEFAULT_MAKER_FEE), + 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.u64(100000), - txb.pure.u64(100000), - txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), - txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), - coin, + 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.u64(1000000), - txb.pure.u64(10000), - txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), - txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), - coin, + 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.u64(1000000), - txb.pure.u64(1000), - txb.pure.u64(DEFAULT_STABLE_TAKER_FEE), - txb.pure.u64(DEFAULT_STABLE_MAKER_FEE), - coin, + txb.pure(1000000), + txb.pure(1000), + txb.pure(DEFAULT_STABLE_TAKER_FEE), + txb.pure(DEFAULT_STABLE_MAKER_FEE), + coin4, ], }); @@ -139,5 +147,7 @@ const setup = async (network: Network) => { return executeTx(prepareSigner(setup.provider), txb); }; -if (process.env.NETWORK === "mainnet") setup("mainnet"); -else setup("testnet"); +// if (process.env.NETWORK === "mainnet") setup("mainnet"); +// else setup("testnet"); + +setup("testnet"); From a288687dcf4d3f90e9dcc85bff955252a156db5e Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:35:27 -0400 Subject: [PATCH 4/6] reverting so this will run on mainnet --- scripts/transactions/deepbook/create_pools.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts index 1bd921d0..d76e65d6 100644 --- a/scripts/transactions/deepbook/create_pools.ts +++ b/scripts/transactions/deepbook/create_pools.ts @@ -35,7 +35,6 @@ const DEFAULT_TAKER_FEE = 200000; const DEFAULT_STABLE_MAKER_FEE = 100000; const DEFAULT_STABLE_TAKER_FEE = 100000; -// export ADMIN_PHRASE="trophy conduct student type result lamp seven slam chest category tenant inherit" // List of deepbook pools today // data: [ // { BTC / USDC pool @@ -147,7 +146,5 @@ const setup = async (network: Network) => { return executeTx(prepareSigner(setup.provider), txb); }; -// if (process.env.NETWORK === "mainnet") setup("mainnet"); -// else setup("testnet"); - -setup("testnet"); +if (process.env.NETWORK === "mainnet") setup("mainnet"); +else setup("testnet"); From 7cbcc0e6f7751eb4227438d66e2ba419cb9bf293 Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:08:04 -0400 Subject: [PATCH 5/6] merging gas coin --- scripts/transactions/deepbook/create_pools.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts index d76e65d6..2a5ad465 100644 --- a/scripts/transactions/deepbook/create_pools.ts +++ b/scripts/transactions/deepbook/create_pools.ts @@ -80,6 +80,11 @@ 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 From 17d337f088a7e6547079a0b9930494707bf76a29 Mon Sep 17 00:00:00 2001 From: Jian Lu <123408603+healthydeve@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:09:28 -0400 Subject: [PATCH 6/6] test --- scripts/transactions/deepbook/create_pools.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/transactions/deepbook/create_pools.ts b/scripts/transactions/deepbook/create_pools.ts index 2a5ad465..e4ff4939 100644 --- a/scripts/transactions/deepbook/create_pools.ts +++ b/scripts/transactions/deepbook/create_pools.ts @@ -80,11 +80,11 @@ const setup = async (network: Network) => { const setup = mainPackage[network]; const txb = new TransactionBlock(); - txb.mergeCoins(txb.gas, [ - txb.object( - "0xbb210191c48a3acbe8c306ef836037c7dc0e5920c7337d569755b52e38120554" - ), - ]); + // txb.mergeCoins(txb.gas, [ + // txb.object( + // "0xbb210191c48a3acbe8c306ef836037c7dc0e5920c7337d569755b52e38120554" + // ), + // ]); const [coin] = txb.splitCoins(txb.gas, [txb.pure(CREATION_FEE)]); // Create SUI/ USDC