diff --git a/packages/contracts-build/data/coharvest-bid-pool.wasm b/packages/contracts-build/data/coharvest-bid-pool.wasm new file mode 100644 index 00000000..4e2dcbd4 Binary files /dev/null and b/packages/contracts-build/data/coharvest-bid-pool.wasm differ diff --git a/packages/contracts-build/package.json b/packages/contracts-build/package.json index 6fc8b2fe..00ee2055 100644 --- a/packages/contracts-build/package.json +++ b/packages/contracts-build/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-contracts-build", - "version": "1.0.30", + "version": "1.0.31", "main": "build/index.js", "license": "MIT", "scripts": { diff --git a/packages/contracts-sdk/package.json b/packages/contracts-sdk/package.json index 13198e25..39dfb746 100644 --- a/packages/contracts-sdk/package.json +++ b/packages/contracts-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-contracts-sdk", - "version": "1.0.41", + "version": "1.0.42", "main": "build/index.js", "files": [ "build/", diff --git a/packages/contracts-sdk/src/CoharvestBidPool.client.ts b/packages/contracts-sdk/src/CoharvestBidPool.client.ts new file mode 100644 index 00000000..f407e42f --- /dev/null +++ b/packages/contracts-sdk/src/CoharvestBidPool.client.ts @@ -0,0 +1,495 @@ +/** +* This file was automatically generated by @oraichain/ts-codegen@0.35.8. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @oraichain/ts-codegen generate command to regenerate this file. +*/ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; +import { Coin, StdFee } from "@cosmjs/amino"; +import {AssetInfo, Addr, Uint128, Decimal, Binary, Cw20ReceiveMsg} from "./types"; +import {InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, ArrayOfBid, Bid, ArrayOfBidPool, BidPool, BiddingInfoResponse, BiddingInfo, DistributionInfo, ArrayOfUint64, Config, EstimateAmountReceiveOfBidResponse, Uint64} from "./CoharvestBidPool.types"; +export interface CoharvestBidPoolReadOnlyInterface { + contractAddress: string; + config: () => Promise; + bid: ({ + idx + }: { + idx: number; + }) => Promise; + biddingInfo: ({ + round + }: { + round: number; + }) => Promise; + lastRoundId: () => Promise; + bidPool: ({ + round, + slot + }: { + round: number; + slot: number; + }) => Promise; + allBidPoolInRound: ({ + round + }: { + round: number; + }) => Promise; + allBidInRound: ({ + limit, + orderBy, + round, + startAfter + }: { + limit?: number; + orderBy?: number; + round: number; + startAfter?: number; + }) => Promise; + bidsIdxByUser: ({ + round, + user + }: { + round: number; + user: Addr; + }) => Promise; + bidsByUser: ({ + round, + user + }: { + round: number; + user: Addr; + }) => Promise; + estimateAmountReceiveOfBid: ({ + exchangeRate, + idx, + round + }: { + exchangeRate: Decimal; + idx: number; + round: number; + }) => Promise; + estimateAmountReceive: ({ + bidAmount, + exchangeRate, + round, + slot + }: { + bidAmount: Uint128; + exchangeRate: Decimal; + round: number; + slot: number; + }) => Promise; + numbersBidInRound: ({ + round + }: { + round: number; + }) => Promise; +} +export class CoharvestBidPoolQueryClient implements CoharvestBidPoolReadOnlyInterface { + client: CosmWasmClient; + contractAddress: string; + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client; + this.contractAddress = contractAddress; + this.config = this.config.bind(this); + this.bid = this.bid.bind(this); + this.biddingInfo = this.biddingInfo.bind(this); + this.lastRoundId = this.lastRoundId.bind(this); + this.bidPool = this.bidPool.bind(this); + this.allBidPoolInRound = this.allBidPoolInRound.bind(this); + this.allBidInRound = this.allBidInRound.bind(this); + this.bidsIdxByUser = this.bidsIdxByUser.bind(this); + this.bidsByUser = this.bidsByUser.bind(this); + this.estimateAmountReceiveOfBid = this.estimateAmountReceiveOfBid.bind(this); + this.estimateAmountReceive = this.estimateAmountReceive.bind(this); + this.numbersBidInRound = this.numbersBidInRound.bind(this); + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {} + }); + }; + bid = async ({ + idx + }: { + idx: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + bid: { + idx + } + }); + }; + biddingInfo = async ({ + round + }: { + round: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + bidding_info: { + round + } + }); + }; + lastRoundId = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + last_round_id: {} + }); + }; + bidPool = async ({ + round, + slot + }: { + round: number; + slot: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + bid_pool: { + round, + slot + } + }); + }; + allBidPoolInRound = async ({ + round + }: { + round: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_bid_pool_in_round: { + round + } + }); + }; + allBidInRound = async ({ + limit, + orderBy, + round, + startAfter + }: { + limit?: number; + orderBy?: number; + round: number; + startAfter?: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_bid_in_round: { + limit, + order_by: orderBy, + round, + start_after: startAfter + } + }); + }; + bidsIdxByUser = async ({ + round, + user + }: { + round: number; + user: Addr; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + bids_idx_by_user: { + round, + user + } + }); + }; + bidsByUser = async ({ + round, + user + }: { + round: number; + user: Addr; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + bids_by_user: { + round, + user + } + }); + }; + estimateAmountReceiveOfBid = async ({ + exchangeRate, + idx, + round + }: { + exchangeRate: Decimal; + idx: number; + round: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + estimate_amount_receive_of_bid: { + exchange_rate: exchangeRate, + idx, + round + } + }); + }; + estimateAmountReceive = async ({ + bidAmount, + exchangeRate, + round, + slot + }: { + bidAmount: Uint128; + exchangeRate: Decimal; + round: number; + slot: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + estimate_amount_receive: { + bid_amount: bidAmount, + exchange_rate: exchangeRate, + round, + slot + } + }); + }; + numbersBidInRound = async ({ + round + }: { + round: number; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + numbers_bid_in_round: { + round + } + }); + }; +} +export interface CoharvestBidPoolInterface extends CoharvestBidPoolReadOnlyInterface { + contractAddress: string; + sender: string; + receive: ({ + amount, + msg, + sender + }: { + amount: Uint128; + msg: Binary; + sender: string; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + 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; + createNewRound: ({ + endTime, + startTime, + totalDistribution + }: { + endTime: number; + startTime: number; + totalDistribution: Uint128; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + finalizeBiddingRoundResult: ({ + exchangeRate, + round + }: { + exchangeRate: Decimal; + round: number; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + distribute: ({ + limit, + round, + startAfter + }: { + limit?: number; + round: number; + startAfter?: number; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + submitBid: ({ + premiumSlot, + round + }: { + premiumSlot: number; + round: number; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + createNewRoundFromTreasury: (_fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; + updateRound: ({ + endTime, + idx, + startTime, + totalDistribution + }: { + endTime?: number; + idx: number; + startTime?: number; + totalDistribution?: Uint128; + }, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise; +} +export class CoharvestBidPoolClient extends CoharvestBidPoolQueryClient implements CoharvestBidPoolInterface { + client: SigningCosmWasmClient; + sender: string; + contractAddress: string; + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress); + this.client = client; + this.sender = sender; + this.contractAddress = contractAddress; + this.receive = this.receive.bind(this); + this.updateConfig = this.updateConfig.bind(this); + this.createNewRound = this.createNewRound.bind(this); + 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 ({ + amount, + msg, + sender + }: { + amount: Uint128; + msg: Binary; + sender: string; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + receive: { + amount, + msg, + sender + } + }, _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 => { + 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, + totalDistribution + }: { + endTime: number; + startTime: number; + totalDistribution: Uint128; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + create_new_round: { + end_time: endTime, + start_time: startTime, + total_distribution: totalDistribution + } + }, _fee, _memo, _funds); + }; + finalizeBiddingRoundResult = async ({ + exchangeRate, + round + }: { + exchangeRate: Decimal; + round: number; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + finalize_bidding_round_result: { + exchange_rate: exchangeRate, + round + } + }, _fee, _memo, _funds); + }; + distribute = async ({ + limit, + round, + startAfter + }: { + limit?: number; + round: number; + startAfter?: number; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + distribute: { + limit, + round, + start_after: startAfter + } + }, _fee, _memo, _funds); + }; + submitBid = async ({ + premiumSlot, + round + }: { + premiumSlot: number; + round: number; + }, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + submit_bid: { + premium_slot: premiumSlot, + round + } + }, _fee, _memo, _funds); + }; + createNewRoundFromTreasury = async (_fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise => { + 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 => { + return await this.client.execute(this.sender, this.contractAddress, { + update_round: { + end_time: endTime, + idx, + start_time: startTime, + total_distribution: totalDistribution + } + }, _fee, _memo, _funds); + }; +} \ No newline at end of file diff --git a/packages/contracts-sdk/src/CoharvestBidPool.types.ts b/packages/contracts-sdk/src/CoharvestBidPool.types.ts new file mode 100644 index 00000000..92c33b96 --- /dev/null +++ b/packages/contracts-sdk/src/CoharvestBidPool.types.ts @@ -0,0 +1,176 @@ +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_distribution: Uint128; + }; +} | { + finalize_bidding_round_result: { + exchange_rate: Decimal; + round: number; + }; +} | { + distribute: { + limit?: number | null; + round: number; + start_after?: number | null; + }; +} | { + submit_bid: { + 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: {}; +} | { + bid: { + idx: number; + }; +} | { + bidding_info: { + round: number; + }; +} | { + last_round_id: {}; +} | { + bid_pool: { + round: number; + slot: number; + }; +} | { + all_bid_pool_in_round: { + round: number; + }; +} | { + all_bid_in_round: { + limit?: number | null; + order_by?: number | null; + round: number; + start_after?: number | null; + }; +} | { + bids_idx_by_user: { + round: number; + user: Addr; + }; +} | { + bids_by_user: { + round: number; + user: Addr; + }; +} | { + estimate_amount_receive_of_bid: { + exchange_rate: Decimal; + idx: number; + round: number; + }; +} | { + estimate_amount_receive: { + bid_amount: Uint128; + exchange_rate: Decimal; + round: number; + slot: number; + }; +} | { + numbers_bid_in_round: { + 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 type ArrayOfBid = Bid[]; +export interface Bid { + amount: Uint128; + amount_received: Uint128; + bidder: Addr; + idx: number; + is_distributed: boolean; + premium_slot: number; + residue_bid: Uint128; + round: number; + timestamp: number; +} +export type ArrayOfBidPool = BidPool[]; +export interface BidPool { + index_snapshot: Decimal; + premium_rate: Decimal; + received_per_token: Decimal; + slot: number; + total_bid_amount: Uint128; +} +export interface BiddingInfoResponse { + bid_info: BiddingInfo; + distribution_info: DistributionInfo; +} +export interface BiddingInfo { + end_time: number; + round: number; + start_time: number; + total_bid_amount: Uint128; + total_bid_matched: Uint128; +} +export interface DistributionInfo { + actual_distributed: Uint128; + exchange_rate: Decimal; + is_released: boolean; + num_bids_distributed: number; + total_distribution: Uint128; +} +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 { + receive: Uint128; + residue_bid: Uint128; +} +export type Uint64 = number; \ No newline at end of file diff --git a/packages/contracts-sdk/src/index.ts b/packages/contracts-sdk/src/index.ts index b2e7e292..772a966b 100644 --- a/packages/contracts-sdk/src/index.ts +++ b/packages/contracts-sdk/src/index.ts @@ -1,3 +1,5 @@ +export * as CoharvestBidPoolTypes from './CoharvestBidPool.types'; +export * from './CoharvestBidPool.client'; export * as Cw20StakingTypes from './Cw20Staking.types'; export * from './Cw20Staking.client'; export * as OraidexListingContractTypes from './OraidexListingContract.types'; diff --git a/packages/contracts-sdk/src/types.ts b/packages/contracts-sdk/src/types.ts index 4742ff0a..fa60bf11 100644 --- a/packages/contracts-sdk/src/types.ts +++ b/packages/contracts-sdk/src/types.ts @@ -1,6 +1,3 @@ -export type Addr = string; -export type Uint128 = string; -export type Binary = string; export type AssetInfo = { token: { contract_addr: Addr; @@ -10,6 +7,10 @@ export type AssetInfo = { denom: string; }; }; +export type Addr = string; +export type Uint128 = string; +export type Decimal = string; +export type Binary = string; export interface Cw20ReceiveMsg { amount: Uint128; msg: Binary; @@ -23,7 +24,6 @@ export interface RewardMsg { staking_token: Addr; total_accumulation_amount: Uint128; } -export type Decimal = string; export type Logo = { url: string; } | {