diff --git a/package.json b/package.json index e003669d..c7395dde 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "patch-package", - "test": "jest", + "test": "yarn build && jest", "docs": "typedoc --entryPointStrategy expand --name 'Oraidex SDK' --readme none --tsconfig packages/contracts-sdk/tsconfig.json packages/contracts-sdk/src", "clean": "lerna clean --yes && lerna exec -- rimraf build/ dist/ cache/", "build": "lerna run build --concurrency 1", diff --git a/packages/contracts-build/data/oraiswap_factory.wasm b/packages/contracts-build/data/oraiswap_factory.wasm index a0888444..16fe80d7 100644 Binary files a/packages/contracts-build/data/oraiswap_factory.wasm and b/packages/contracts-build/data/oraiswap_factory.wasm differ diff --git a/packages/contracts-build/data/oraiswap_limit_order.wasm b/packages/contracts-build/data/oraiswap_limit_order.wasm index d761f4a6..f4ce5b38 100644 Binary files a/packages/contracts-build/data/oraiswap_limit_order.wasm and b/packages/contracts-build/data/oraiswap_limit_order.wasm differ diff --git a/packages/contracts-build/data/oraiswap_oracle.wasm b/packages/contracts-build/data/oraiswap_oracle.wasm index 7f782777..494d4247 100644 Binary files a/packages/contracts-build/data/oraiswap_oracle.wasm and b/packages/contracts-build/data/oraiswap_oracle.wasm differ diff --git a/packages/contracts-build/data/oraiswap_pair.wasm b/packages/contracts-build/data/oraiswap_pair.wasm index 1afce7b1..300d55c8 100644 Binary files a/packages/contracts-build/data/oraiswap_pair.wasm and b/packages/contracts-build/data/oraiswap_pair.wasm differ diff --git a/packages/contracts-build/data/oraiswap_router.wasm b/packages/contracts-build/data/oraiswap_router.wasm index afed547d..4685e042 100644 Binary files a/packages/contracts-build/data/oraiswap_router.wasm and b/packages/contracts-build/data/oraiswap_router.wasm differ diff --git a/packages/contracts-build/data/oraiswap_staking.wasm b/packages/contracts-build/data/oraiswap_staking.wasm index d2788ee4..fbe2364f 100644 Binary files a/packages/contracts-build/data/oraiswap_staking.wasm and b/packages/contracts-build/data/oraiswap_staking.wasm differ diff --git a/packages/contracts-sdk/src/OraiswapLimitOrder.client.ts b/packages/contracts-sdk/src/OraiswapLimitOrder.client.ts index 2dba8268..fc4d459e 100644 --- a/packages/contracts-sdk/src/OraiswapLimitOrder.client.ts +++ b/packages/contracts-sdk/src/OraiswapLimitOrder.client.ts @@ -6,7 +6,7 @@ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { Coin, StdFee } from "@cosmjs/amino"; -import {Addr, Uint128, Binary, AssetInfo, Decimal, Cw20ReceiveMsg, Asset} from "./types"; +import {Uint128, Binary, Addr, AssetInfo, Decimal, Cw20ReceiveMsg, Asset} from "./types"; import {InstantiateMsg, ExecuteMsg, OrderDirection, QueryMsg, OrderFilter, MigrateMsg, ContractInfoResponse, LastOrderIdResponse, OrderStatus, OrderResponse, OrderBookResponse, OrderBookMatchableResponse, OrderBooksResponse, OrdersResponse, BaseAmountResponse, TickResponse, TicksResponse} from "./OraiswapLimitOrder.types"; export interface OraiswapLimitOrderReadOnlyInterface { contractAddress: string; @@ -302,6 +302,11 @@ export interface OraiswapLimitOrderInterface extends OraiswapLimitOrderReadOnlyI commissionRate?: string; rewardAddress?: Addr; }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + updateOperator: ({ + operator + }: { + operator?: string; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; createOrderBookPair: ({ baseCoinInfo, minQuoteCoinAmount, @@ -380,6 +385,7 @@ export class OraiswapLimitOrderClient extends OraiswapLimitOrderQueryClient impl this.receive = this.receive.bind(this); this.updateAdmin = this.updateAdmin.bind(this); this.updateConfig = this.updateConfig.bind(this); + this.updateOperator = this.updateOperator.bind(this); this.createOrderBookPair = this.createOrderBookPair.bind(this); this.updateOrderbookPair = this.updateOrderbookPair.bind(this); this.submitOrder = this.submitOrder.bind(this); @@ -432,6 +438,17 @@ export class OraiswapLimitOrderClient extends OraiswapLimitOrderQueryClient impl } }, _fee, _memo, _funds); }; + updateOperator = async ({ + operator + }: { + operator?: string; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + update_operator: { + operator + } + }, _fee, _memo, _funds); + }; createOrderBookPair = async ({ baseCoinInfo, minQuoteCoinAmount, diff --git a/packages/contracts-sdk/src/OraiswapLimitOrder.types.ts b/packages/contracts-sdk/src/OraiswapLimitOrder.types.ts index a3804659..56ce9e34 100644 --- a/packages/contracts-sdk/src/OraiswapLimitOrder.types.ts +++ b/packages/contracts-sdk/src/OraiswapLimitOrder.types.ts @@ -1,9 +1,10 @@ -import {Addr, Uint128, Binary, AssetInfo, Decimal, Cw20ReceiveMsg, Asset} from "./types"; +import {Uint128, Binary, Addr, AssetInfo, Decimal, Cw20ReceiveMsg, Asset} from "./types"; export interface InstantiateMsg { - admin?: Addr | null; + admin?: string | null; commission_rate?: string | null; name?: string | null; - reward_address?: Addr | null; + operator?: string | null; + reward_address: string; version?: string | null; } export type ExecuteMsg = { @@ -17,6 +18,10 @@ export type ExecuteMsg = { commission_rate?: string | null; reward_address?: Addr | null; }; +} | { + update_operator: { + operator?: string | null; + }; } | { create_order_book_pair: { base_coin_info: AssetInfo; @@ -132,6 +137,7 @@ export interface ContractInfoResponse { admin: Addr; commission_rate: string; name: string; + operator?: Addr | null; reward_address: Addr; version: string; } diff --git a/packages/contracts-sdk/src/OraiswapPair.client.ts b/packages/contracts-sdk/src/OraiswapPair.client.ts index 03c909d4..30620bc1 100644 --- a/packages/contracts-sdk/src/OraiswapPair.client.ts +++ b/packages/contracts-sdk/src/OraiswapPair.client.ts @@ -6,8 +6,8 @@ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { Coin, StdFee } from "@cosmjs/amino"; -import {AssetInfo, Addr, Uint128, Binary, Decimal, Cw20ReceiveMsg, Asset, PairInfo} from "./types"; -import {InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, PairResponse, PoolResponse, ReverseSimulationResponse, SimulationResponse} from "./OraiswapPair.types"; +import {Addr, AssetInfo, Uint128, Binary, Decimal, Cw20ReceiveMsg, Asset, PairInfo} from "./types"; +import {InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, String, PairResponse, PoolResponse, ReverseSimulationResponse, SimulationResponse, Boolean} from "./OraiswapPair.types"; export interface OraiswapPairReadOnlyInterface { contractAddress: string; pair: () => Promise; @@ -22,6 +22,12 @@ export interface OraiswapPairReadOnlyInterface { }: { askAsset: Asset; }) => Promise; + traderIsWhitelisted: ({ + trader + }: { + trader: Addr; + }) => Promise; + admin: () => Promise; } export class OraiswapPairQueryClient implements OraiswapPairReadOnlyInterface { client: CosmWasmClient; @@ -34,6 +40,8 @@ export class OraiswapPairQueryClient implements OraiswapPairReadOnlyInterface { this.pool = this.pool.bind(this); this.simulation = this.simulation.bind(this); this.reverseSimulation = this.reverseSimulation.bind(this); + this.traderIsWhitelisted = this.traderIsWhitelisted.bind(this); + this.admin = this.admin.bind(this); } pair = async (): Promise => { @@ -68,6 +76,22 @@ export class OraiswapPairQueryClient implements OraiswapPairReadOnlyInterface { } }); }; + traderIsWhitelisted = async ({ + trader + }: { + trader: Addr; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + trader_is_whitelisted: { + trader + } + }); + }; + admin = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + admin: {} + }); + }; } export interface OraiswapPairInterface extends OraiswapPairReadOnlyInterface { contractAddress: string; @@ -101,6 +125,21 @@ export interface OraiswapPairInterface extends OraiswapPairReadOnlyInterface { offerAsset: Asset; to?: Addr; }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + enableWhitelist: ({ + status + }: { + status: boolean; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + registerTrader: ({ + traders + }: { + traders: Addr[]; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + deregisterTrader: ({ + traders + }: { + traders: Addr[]; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; } export class OraiswapPairClient extends OraiswapPairQueryClient implements OraiswapPairInterface { client: SigningCosmWasmClient; @@ -115,6 +154,9 @@ export class OraiswapPairClient extends OraiswapPairQueryClient implements Orais this.receive = this.receive.bind(this); this.provideLiquidity = this.provideLiquidity.bind(this); this.swap = this.swap.bind(this); + this.enableWhitelist = this.enableWhitelist.bind(this); + this.registerTrader = this.registerTrader.bind(this); + this.deregisterTrader = this.deregisterTrader.bind(this); } receive = async ({ @@ -171,4 +213,37 @@ export class OraiswapPairClient extends OraiswapPairQueryClient implements Orais } }, _fee, _memo, _funds); }; + enableWhitelist = async ({ + status + }: { + status: boolean; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + enable_whitelist: { + status + } + }, _fee, _memo, _funds); + }; + registerTrader = async ({ + traders + }: { + traders: Addr[]; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + register_trader: { + traders + } + }, _fee, _memo, _funds); + }; + deregisterTrader = async ({ + traders + }: { + traders: Addr[]; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + deregister_trader: { + traders + } + }, _fee, _memo, _funds); + }; } \ No newline at end of file diff --git a/packages/contracts-sdk/src/OraiswapPair.types.ts b/packages/contracts-sdk/src/OraiswapPair.types.ts index e84c0d9c..bf33a399 100644 --- a/packages/contracts-sdk/src/OraiswapPair.types.ts +++ b/packages/contracts-sdk/src/OraiswapPair.types.ts @@ -1,5 +1,6 @@ -import {AssetInfo, Addr, Uint128, Binary, Decimal, Cw20ReceiveMsg, Asset, PairInfo} from "./types"; +import {Addr, AssetInfo, Uint128, Binary, Decimal, Cw20ReceiveMsg, Asset, PairInfo} from "./types"; export interface InstantiateMsg { + admin?: Addr | null; asset_infos: [AssetInfo, AssetInfo]; commission_rate?: string | null; oracle_addr: Addr; @@ -20,6 +21,18 @@ export type ExecuteMsg = { offer_asset: Asset; to?: Addr | null; }; +} | { + enable_whitelist: { + status: boolean; + }; +} | { + register_trader: { + traders: Addr[]; + }; +} | { + deregister_trader: { + traders: Addr[]; + }; }; export type QueryMsg = { pair: {}; @@ -33,8 +46,17 @@ export type QueryMsg = { reverse_simulation: { ask_asset: Asset; }; +} | { + trader_is_whitelisted: { + trader: Addr; + }; +} | { + admin: {}; }; -export interface MigrateMsg {} +export interface MigrateMsg { + admin?: string | null; +} +export type String = string; export interface PairResponse { info: PairInfo; } @@ -51,4 +73,5 @@ export interface SimulationResponse { commission_amount: Uint128; return_amount: Uint128; spread_amount: Uint128; -} \ No newline at end of file +} +export type Boolean = boolean; \ No newline at end of file diff --git a/packages/contracts-sdk/src/OraiswapRouter.client.ts b/packages/contracts-sdk/src/OraiswapRouter.client.ts index f57b3609..a0be872b 100644 --- a/packages/contracts-sdk/src/OraiswapRouter.client.ts +++ b/packages/contracts-sdk/src/OraiswapRouter.client.ts @@ -73,9 +73,11 @@ export interface OraiswapRouterInterface extends OraiswapRouterReadOnlyInterface }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; executeSwapOperation: ({ operation, + sender, to }: { operation: SwapOperation; + sender: Addr; to?: Addr; }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; assertMinimumReceive: ({ @@ -142,14 +144,17 @@ export class OraiswapRouterClient extends OraiswapRouterQueryClient implements O }; executeSwapOperation = async ({ operation, + sender, to }: { operation: SwapOperation; + sender: Addr; to?: Addr; }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { return await this.client.execute(this.sender, this.contractAddress, { execute_swap_operation: { operation, + sender, to } }, _fee, _memo, _funds); diff --git a/packages/contracts-sdk/src/OraiswapRouter.types.ts b/packages/contracts-sdk/src/OraiswapRouter.types.ts index 8128108c..f97e7c10 100644 --- a/packages/contracts-sdk/src/OraiswapRouter.types.ts +++ b/packages/contracts-sdk/src/OraiswapRouter.types.ts @@ -14,6 +14,7 @@ export type ExecuteMsg = { } | { execute_swap_operation: { operation: SwapOperation; + sender: Addr; to?: Addr | null; }; } | {