Skip to content

Commit

Permalink
Merge pull request #193 from oraichain/feat/update-cw20-staking-with-…
Browse files Browse the repository at this point in the history
…snapshot

Feat/update cw20 staking with snapshot
  • Loading branch information
meomeocoj authored Mar 6, 2024
2 parents d5aba3c + 372d9d7 commit 7f4b267
Show file tree
Hide file tree
Showing 33 changed files with 388 additions and 426 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

```bash
# build code:
cwtools build ../oraiswap/contracts/* ../oraidex-listing-contract ../co-harvest-contracts/contracts/* ../cw20-staking/ -o packages/contracts-build/data
cwtools build ../oraiswap/contracts/* ../oraidex-listing-contract ../co-harvest-contracts/contracts/* ../cw20-staking/contracts/* -o packages/contracts-build/data
# gen code:
cwtools gents ../oraiswap/contracts/* ../oraidex-listing-contract ../co-harvest-contracts/contracts/* ../cw20-staking/ -o packages/contracts-sdk/src
cwtools gents ../oraiswap/contracts/* ../oraidex-listing-contract ../co-harvest-contracts/contracts/* ../cw20-staking/contracts/* -o packages/contracts-sdk/src
# gen doc:
yarn docs

Expand Down
Binary file modified packages/contracts-build/data/coharvest-bid-pool.wasm
Binary file not shown.
Binary file modified packages/contracts-build/data/oraidex-listing-contract.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added packages/contracts-build/data/oraiswap-pair.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified packages/contracts-build/data/oraiswap-staking.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/contracts-build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-contracts-build",
"version": "1.0.26",
"version": "1.0.27",
"main": "build/index.js",
"license": "MIT",
"scripts": {
Expand Down
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.35",
"version": "1.0.36",
"main": "build/index.js",
"files": [
"build/",
Expand Down
54 changes: 54 additions & 0 deletions packages/contracts-sdk/src/CoharvestBidPool.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ export interface CoharvestBidPoolReadOnlyInterface {
}) => Promise<ArrayOfBidPool>;
allBidInRound: ({
limit,
orderBy,
round,
startAfter
}: {
limit?: number;
orderBy?: number;
round: number;
startAfter?: number;
}) => Promise<ArrayOfBid>;
Expand Down Expand Up @@ -163,16 +165,19 @@ 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 @@ -268,18 +273,22 @@ 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: ({
Expand Down Expand Up @@ -314,6 +323,18 @@ 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 @@ -331,6 +352,8 @@ 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 @@ -351,27 +374,33 @@ 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);
Expand Down Expand Up @@ -438,4 +467,29 @@ 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);
};
}
27 changes: 26 additions & 1 deletion packages/contracts-sdk/src/CoharvestBidPool.types.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
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;
};
} | {
Expand All @@ -40,6 +44,15 @@ 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 @@ -65,6 +78,7 @@ export type QueryMsg = {
} | {
all_bid_in_round: {
limit?: number | null;
order_by?: number | null;
round: number;
start_after?: number | null;
};
Expand Down Expand Up @@ -96,7 +110,16 @@ export type QueryMsg = {
round: number;
};
};
export interface MigrateMsg {}
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;
Expand Down Expand Up @@ -137,11 +160,13 @@ 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
Loading

0 comments on commit 7f4b267

Please sign in to comment.