Skip to content

Commit

Permalink
Merge pull request #199 from oraichain/feat/update-orderbook-contract…
Browse files Browse the repository at this point in the history
…-sdk

Feat/update orderbook contract sdk
  • Loading branch information
trung2891 authored Mar 11, 2024
2 parents a349628 + d5f2a91 commit d0cdc3e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 91 deletions.
Binary file modified packages/contracts-build/data/oraiswap-limit-order.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/contracts-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-contracts-sdk",
"version": "1.0.37",
"version": "1.0.39",
"main": "build/index.js",
"files": [
"build/",
Expand Down
59 changes: 5 additions & 54 deletions packages/contracts-sdk/src/CoharvestBidPool.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ export interface CoharvestBidPoolReadOnlyInterface {
}) => Promise<ArrayOfBidPool>;
allBidInRound: ({
limit,
orderBy,
round,
startAfter
}: {
limit?: number;
orderBy?: number;
round: number;
startAfter?: number;
}) => Promise<ArrayOfBid>;
Expand Down Expand Up @@ -165,19 +163,16 @@ export class CoharvestBidPoolQueryClient implements CoharvestBidPoolReadOnlyInte
};
allBidInRound = async ({
limit,
orderBy,
round,
startAfter
}: {
limit?: number;
orderBy?: number;
round: number;
startAfter?: number;
}): Promise<ArrayOfBid> => {
return this.client.queryContractSmart(this.contractAddress, {
all_bid_in_round: {
limit,
order_by: orderBy,
round,
start_after: startAfter
}
Expand Down Expand Up @@ -273,31 +268,29 @@ export interface CoharvestBidPoolInterface extends CoharvestBidPoolReadOnlyInter
sender: string;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updateConfig: ({
biddingDuration,
distributionToken,
maxSlot,
minDepositAmount,
owner,
premiumRatePerSlot,
treasury,
underlyingToken
}: {
biddingDuration?: number;
distributionToken?: AssetInfo;
maxSlot?: number;
minDepositAmount?: Uint128;
owner?: Addr;
premiumRatePerSlot?: Decimal;
treasury?: Addr;
underlyingToken?: AssetInfo;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
createNewRound: ({
endTime,
startTime,
totalBidThreshold,
totalDistribution
}: {
endTime: number;
startTime: number;
totalBidThreshold: Uint128;
totalDistribution: Uint128;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
finalizeBiddingRoundResult: ({
Expand All @@ -323,18 +316,6 @@ export interface CoharvestBidPoolInterface extends CoharvestBidPoolReadOnlyInter
premiumSlot: number;
round: number;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
createNewRoundFromTreasury: (_fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updateRound: ({
endTime,
idx,
startTime,
totalDistribution
}: {
endTime?: number;
idx: number;
startTime?: number;
totalDistribution?: Uint128;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class CoharvestBidPoolClient extends CoharvestBidPoolQueryClient implements CoharvestBidPoolInterface {
client: SigningCosmWasmClient;
Expand All @@ -352,8 +333,6 @@ export class CoharvestBidPoolClient extends CoharvestBidPoolQueryClient implemen
this.finalizeBiddingRoundResult = this.finalizeBiddingRoundResult.bind(this);
this.distribute = this.distribute.bind(this);
this.submitBid = this.submitBid.bind(this);
this.createNewRoundFromTreasury = this.createNewRoundFromTreasury.bind(this);
this.updateRound = this.updateRound.bind(this);
}

receive = async ({
Expand All @@ -374,50 +353,47 @@ export class CoharvestBidPoolClient extends CoharvestBidPoolQueryClient implemen
}, _fee, _memo, _funds);
};
updateConfig = async ({
biddingDuration,
distributionToken,
maxSlot,
minDepositAmount,
owner,
premiumRatePerSlot,
treasury,
underlyingToken
}: {
biddingDuration?: number;
distributionToken?: AssetInfo;
maxSlot?: number;
minDepositAmount?: Uint128;
owner?: Addr;
premiumRatePerSlot?: Decimal;
treasury?: Addr;
underlyingToken?: AssetInfo;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_config: {
bidding_duration: biddingDuration,
distribution_token: distributionToken,
max_slot: maxSlot,
min_deposit_amount: minDepositAmount,
owner,
premium_rate_per_slot: premiumRatePerSlot,
treasury,
underlying_token: underlyingToken
}
}, _fee, _memo, _funds);
};
createNewRound = async ({
endTime,
startTime,
totalBidThreshold,
totalDistribution
}: {
endTime: number;
startTime: number;
totalBidThreshold: Uint128;
totalDistribution: Uint128;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
create_new_round: {
end_time: endTime,
start_time: startTime,
total_bid_threshold: totalBidThreshold,
total_distribution: totalDistribution
}
}, _fee, _memo, _funds);
Expand Down Expand Up @@ -467,29 +443,4 @@ export class CoharvestBidPoolClient extends CoharvestBidPoolQueryClient implemen
}
}, _fee, _memo, _funds);
};
createNewRoundFromTreasury = async (_fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
create_new_round_from_treasury: {}
}, _fee, _memo, _funds);
};
updateRound = async ({
endTime,
idx,
startTime,
totalDistribution
}: {
endTime?: number;
idx: number;
startTime?: number;
totalDistribution?: Uint128;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_round: {
end_time: endTime,
idx,
start_time: startTime,
total_distribution: totalDistribution
}
}, _fee, _memo, _funds);
};
}
28 changes: 2 additions & 26 deletions packages/contracts-sdk/src/CoharvestBidPool.types.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import {AssetInfo, Addr, Uint128, Decimal, Binary, Cw20ReceiveMsg} from "./types";
export interface InstantiateMsg {
bidding_duration: number;
distribution_token: AssetInfo;
max_slot: number;
min_deposit_amount: Uint128;
owner: Addr;
premium_rate_per_slot: Decimal;
treasury: Addr;
underlying_token: AssetInfo;
}
export type ExecuteMsg = {
receive: Cw20ReceiveMsg;
} | {
update_config: {
bidding_duration?: number | null;
distribution_token?: AssetInfo | null;
max_slot?: number | null;
min_deposit_amount?: Uint128 | null;
owner?: Addr | null;
premium_rate_per_slot?: Decimal | null;
treasury?: Addr | null;
underlying_token?: AssetInfo | null;
};
} | {
create_new_round: {
end_time: number;
start_time: number;
total_bid_threshold: Uint128;
total_distribution: Uint128;
};
} | {
Expand All @@ -44,15 +41,6 @@ export type ExecuteMsg = {
premium_slot: number;
round: number;
};
} | {
create_new_round_from_treasury: {};
} | {
update_round: {
end_time?: number | null;
idx: number;
start_time?: number | null;
total_distribution?: Uint128 | null;
};
};
export type QueryMsg = {
config: {};
Expand All @@ -78,7 +66,6 @@ export type QueryMsg = {
} | {
all_bid_in_round: {
limit?: number | null;
order_by?: number | null;
round: number;
start_after?: number | null;
};
Expand Down Expand Up @@ -110,16 +97,7 @@ export type QueryMsg = {
round: number;
};
};
export interface MigrateMsg {
bidding_duration: number;
distribution_token: AssetInfo;
max_slot: number;
min_deposit_amount: Uint128;
owner: Addr;
premium_rate_per_slot: Decimal;
treasury: Addr;
underlying_token: AssetInfo;
}
export interface MigrateMsg {}
export type ArrayOfBid = Bid[];
export interface Bid {
amount: Uint128;
Expand Down Expand Up @@ -160,13 +138,11 @@ export interface DistributionInfo {
}
export type ArrayOfUint64 = number[];
export interface Config {
bidding_duration: number;
distribution_token: AssetInfo;
max_slot: number;
min_deposit_amount: Uint128;
owner: Addr;
premium_rate_per_slot: Decimal;
treasury: Addr;
underlying_token: AssetInfo;
}
export interface EstimateAmountReceiveOfBidResponse {
Expand Down
50 changes: 42 additions & 8 deletions packages/contracts-sdk/src/OraiswapLimitOrder.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export interface OraiswapLimitOrderReadOnlyInterface {
}: {
assetInfos: AssetInfo[];
}) => Promise<OrderBookMatchableResponse>;
midPrice: ({
assetInfos
}: {
assetInfos: AssetInfo[];
}) => Promise<Decimal>;
}
export class OraiswapLimitOrderQueryClient implements OraiswapLimitOrderReadOnlyInterface {
client: CosmWasmClient;
Expand All @@ -94,6 +99,7 @@ export class OraiswapLimitOrderQueryClient implements OraiswapLimitOrderReadOnly
this.ticks = this.ticks.bind(this);
this.lastOrderId = this.lastOrderId.bind(this);
this.orderBookMatchable = this.orderBookMatchable.bind(this);
this.midPrice = this.midPrice.bind(this);
}

contractInfo = async (): Promise<ContractInfoResponse> => {
Expand Down Expand Up @@ -228,6 +234,17 @@ export class OraiswapLimitOrderQueryClient implements OraiswapLimitOrderReadOnly
}
});
};
midPrice = async ({
assetInfos
}: {
assetInfos: AssetInfo[];
}): Promise<Decimal> => {
return this.client.queryContractSmart(this.contractAddress, {
mid_price: {
asset_infos: assetInfos
}
});
};
}
export interface OraiswapLimitOrderInterface extends OraiswapLimitOrderReadOnlyInterface {
contractAddress: string;
Expand All @@ -248,12 +265,10 @@ export interface OraiswapLimitOrderInterface extends OraiswapLimitOrderReadOnlyI
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updateConfig: ({
commissionRate,
rewardAddress,
spreadAddress
rewardAddress
}: {
commissionRate?: string;
rewardAddress?: Addr;
spreadAddress?: Addr;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
createOrderBookPair: ({
baseCoinInfo,
Expand All @@ -266,6 +281,13 @@ export interface OraiswapLimitOrderInterface extends OraiswapLimitOrderReadOnlyI
quoteCoinInfo: AssetInfo;
spread?: Decimal;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updateOrderbookPair: ({
assetInfos,
spread
}: {
assetInfos: AssetInfo[];
spread?: Decimal;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
submitOrder: ({
assets,
direction
Expand Down Expand Up @@ -307,6 +329,7 @@ export class OraiswapLimitOrderClient extends OraiswapLimitOrderQueryClient impl
this.updateAdmin = this.updateAdmin.bind(this);
this.updateConfig = this.updateConfig.bind(this);
this.createOrderBookPair = this.createOrderBookPair.bind(this);
this.updateOrderbookPair = this.updateOrderbookPair.bind(this);
this.submitOrder = this.submitOrder.bind(this);
this.cancelOrder = this.cancelOrder.bind(this);
this.executeOrderBookPair = this.executeOrderBookPair.bind(this);
Expand Down Expand Up @@ -343,18 +366,15 @@ export class OraiswapLimitOrderClient extends OraiswapLimitOrderQueryClient impl
};
updateConfig = async ({
commissionRate,
rewardAddress,
spreadAddress
rewardAddress
}: {
commissionRate?: string;
rewardAddress?: Addr;
spreadAddress?: Addr;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_config: {
commission_rate: commissionRate,
reward_address: rewardAddress,
spread_address: spreadAddress
reward_address: rewardAddress
}
}, _fee, _memo, _funds);
};
Expand All @@ -378,6 +398,20 @@ export class OraiswapLimitOrderClient extends OraiswapLimitOrderQueryClient impl
}
}, _fee, _memo, _funds);
};
updateOrderbookPair = async ({
assetInfos,
spread
}: {
assetInfos: AssetInfo[];
spread?: Decimal;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_orderbook_pair: {
asset_infos: assetInfos,
spread
}
}, _fee, _memo, _funds);
};
submitOrder = async ({
assets,
direction
Expand Down
Loading

0 comments on commit d0cdc3e

Please sign in to comment.