Skip to content

Commit

Permalink
Deepbook SDK Updates (MystenLabs#19302)
Browse files Browse the repository at this point in the history
## Description 

setTreasuryAddress function in SDK
Admin createPoolFunction updates
Constant Updates

## Test plan 

How did you test the new or updated feature?

Testnet

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
tonylee08 authored Sep 11, 2024
1 parent 52a3fba commit ebe2ae8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-horses-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/deepbook-v3': minor
---

Admin function updates, package constant updates
28 changes: 22 additions & 6 deletions sdk/deepbook-v3/src/transactions/deepbookAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { coinWithBalance } from '@mysten/sui/transactions';
import type { Transaction } from '@mysten/sui/transactions';

import type { CreatePoolAdminParams } from '../types/index.js';
import type { DeepBookConfig } from '../utils/config.js';
import { FLOAT_SCALAR, POOL_CREATION_FEE } from '../utils/config.js';
import { FLOAT_SCALAR } from '../utils/config.js';

/**
* DeepBookAdminContract class for managing admin actions.
Expand Down Expand Up @@ -44,9 +43,7 @@ export class DeepBookAdminContract {
params;
const baseCoin = this.#config.getCoin(baseCoinKey);
const quoteCoin = this.#config.getCoin(quoteCoinKey);
const deepCoinType = this.#config.getCoin('DEEP').type;

const creationFee = coinWithBalance({ type: deepCoinType, balance: POOL_CREATION_FEE });
const baseScalar = baseCoin.scalar;
const quoteScalar = quoteCoin.scalar;

Expand All @@ -61,7 +58,6 @@ export class DeepBookAdminContract {
tx.pure.u64(adjustedTickSize), // adjusted tick_size
tx.pure.u64(adjustedLotSize), // adjusted lot_size
tx.pure.u64(adjustedMinSize), // adjusted min_size
creationFee, // 0x2::balance::Balance<0x2::sui::SUI>
tx.pure.bool(whitelisted),
tx.pure.bool(stablePool),
tx.object(this.#adminCap()),
Expand All @@ -81,7 +77,11 @@ export class DeepBookAdminContract {
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::unregister_pool_admin`,
arguments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],
arguments: [
tx.object(pool.address),
tx.object(this.#config.REGISTRY_ID),
tx.object(this.#adminCap()),
],
typeArguments: [baseCoin.type, quoteCoin.type],
});
};
Expand Down Expand Up @@ -137,4 +137,20 @@ export class DeepBookAdminContract {
],
});
};

/**
* @description Sets the treasury address where pool creation fees will be sent
* @param {string} treasuryAddress The treasury address
* @returns A function that takes a Transaction object
*/
setTreasuryAddress = (treasuryAddress: string) => (tx: Transaction) => {
tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::set_treasury_address`,
arguments: [
tx.object(this.#config.REGISTRY_ID),
tx.pure.address(treasuryAddress),
tx.object(this.#adminCap()),
],
});
};
}
1 change: 0 additions & 1 deletion sdk/deepbook-v3/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from './constants.js';

export const FLOAT_SCALAR = 1000000000;
export const POOL_CREATION_FEE = 10000 * 1000000;
export const MAX_TIMESTAMP = 1844674407370955161n;
export const GAS_BUDGET = 0.5 * 500000000; // Adjust based on benchmarking
export const DEEP_SCALAR = 1000000;
Expand Down
24 changes: 17 additions & 7 deletions sdk/deepbook-v3/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export interface DeepbookPackageIds {
}

export const testnetPackageIds = {
DEEPBOOK_PACKAGE_ID: '0x103145af17de55d4e191374a2e971f4d5eef2205c7e789aed7aa6dfc0349fb3b',
REGISTRY_ID: '0x25f80b2d9ae3a2108e3ccbfafb458872261795e409949f82ab417e159d5e76e2',
DEEPBOOK_PACKAGE_ID: '0x48cc688a15bdda6017c730a3c65b30414e642d041f2931ef14e08f6b0b2a1b7f',
REGISTRY_ID: '0x60517d0cae6f1168c1ba94cb45c06191f9837ec695d0d465d594b2f6287534f0',
DEEP_TREASURY_ID: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',
} satisfies DeepbookPackageIds;

Expand Down Expand Up @@ -58,6 +58,11 @@ export const mainnetCoins: CoinMap = {
scalar: 1000000000,
},
USDC: {
address: ``,
type: ``,
scalar: 0,
},
WUSDC: {
address: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf`,
type: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN`,
scalar: 1000000,
Expand All @@ -67,7 +72,12 @@ export const mainnetCoins: CoinMap = {
type: `0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN`,
scalar: 100000000,
},
USDT: {
WBTC: {
address: `0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881`,
type: `0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN`,
scalar: 0,
},
WUSDT: {
address: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c`,
type: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN`,
scalar: 1000000,
Expand All @@ -76,22 +86,22 @@ export const mainnetCoins: CoinMap = {

export const testnetPools: PoolMap = {
DEEP_SUI: {
address: `0xd69b2abe6169964d320801e3a94c9f508274085246a25c44f15ba3fa51bed055`,
address: `0x877c81b2d760a91a405dc12974742ba2401dc1da727681d2de32c861f807ec28`,
baseCoin: 'DEEP',
quoteCoin: 'SUI',
},
SUI_DBUSDC: {
address: `0xe82f5d1a08fa7aef1a49bdc8006b82d771724b47a7d3975e69e7bc645fcf6919`,
address: `0x966c99a5ce0ce3e09dacac0a42cc2b888d9e1a0c5f39b69f556c38f38ef0b81d`,
baseCoin: 'SUI',
quoteCoin: 'DBUSDC',
},
DEEP_DBUSDC: {
address: `0x748341bbd25a1a40d3fe7fcbf1519d8b69869b7170003b2725917982e9443389`,
address: `0x6546ae819e61770c6070962157a2868c012c121ef4e6dd93e81e98900c61b799`,
baseCoin: 'DEEP',
quoteCoin: 'DBUSDC',
},
DBUSDT_DBUSDC: {
address: `0xe4141fee12c3c4897d8fe6e0ed25734d702a84f03642d125ac3add9b155e82bd`,
address: `0x9c0a6ef057b5f81d9f2d95a38ad753b8b5b8f535f9c10bb3e7d7256296eb4e18`,
baseCoin: 'DBUSDT',
quoteCoin: 'DBUSDC',
},
Expand Down

0 comments on commit ebe2ae8

Please sign in to comment.