Skip to content

Commit

Permalink
Merge pull request #45 from FinBook/1.5.1
Browse files Browse the repository at this point in the history
expose stakev2wrappe
  • Loading branch information
yizhoucao committed Aug 19, 2019
2 parents 3f892bd + 9f0d327 commit b1a95e0
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 42 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finbook/duo-contract-wrapper",
"version": "1.5.0",
"version": "1.5.1",
"description": "DUO Contract Wrapper",
"author": "FinBook Pte Ltd",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/StakeV2Wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const web3Wrapper = {
maxOracleStakeAmtInWei: jest.fn(() => ({
call: jest.fn(() => Promise.resolve('50000000000000000000000'))
})),
totalAwardsToDistributeInWei: jest.fn(() => ({
totalRewardsToDistributeInWei: jest.fn(() => ({
call: jest.fn(() => Promise.resolve('50000000000000000000000'))
})),
getOracleSize: jest.fn(() => ({
Expand Down
24 changes: 12 additions & 12 deletions src/StakeV2Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class StakeV2Wrapper extends BaseContractWrapper {
maxStakePerOracle: Web3Wrapper.fromWei(
(await this.contract.methods.maxOracleStakeAmtInWei().call()).valueOf()
),
totalAwardsToDistribute: Web3Wrapper.fromWei(
(await this.contract.methods.totalAwardsToDistributeInWei().call()).valueOf()
totalRewardsToDistribute: Web3Wrapper.fromWei(
(await this.contract.methods.totalRewardsToDistributeInWei().call()).valueOf()
)
};
}
Expand Down Expand Up @@ -71,8 +71,8 @@ export class StakeV2Wrapper extends BaseContractWrapper {

public async getStagingAddReward(index: number): Promise<IRewardList> {
const userReward: IRewardFromContract = await this.contract.methods
.addRewardStagingList()
.call(index);
.addRewardStagingList(index)
.call();
return {
user: userReward.user,
amount: Web3Wrapper.fromWei(userReward.amtInWei)
Expand All @@ -81,8 +81,8 @@ export class StakeV2Wrapper extends BaseContractWrapper {

public async getStagingReduceReward(index: number): Promise<IRewardList> {
const userReward: IRewardFromContract = await this.contract.methods
.reduceRewardStagingList()
.call(index);
.reduceRewardStagingList(index)
.call();
return {
user: userReward.user,
amount: Web3Wrapper.fromWei(userReward.amtInWei)
Expand Down Expand Up @@ -206,7 +206,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.STAKE_V2_STAGE_ADD_REWAD_LIMIT,
CST.STAKE_V2_STAGE_ADD_REWAD_GAS,
option
);

Expand All @@ -227,7 +227,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.STAKE_V2_STAGE_REDUCE_REWAD_LIMIT,
CST.STAKE_V2_STAGE_REDUCE_REWAD_GAS,
option
);

Expand All @@ -247,7 +247,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.DEFAULT_TX_GAS_LIMIT,
CST.STAKE_V2_COMMIT_ADD_REWAD_GAS,
option
);

Expand All @@ -267,7 +267,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.DEFAULT_TX_GAS_LIMIT,
CST.STAKE_V2_COMMIT_ADD_REWAD_GAS,
option
);

Expand All @@ -286,7 +286,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.DEFAULT_TX_GAS_LIMIT,
CST.STAKE_V2_RESET_STAGING_GAS,
option
);

Expand All @@ -307,7 +307,7 @@ export class StakeV2Wrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
const txOption = await this.web3Wrapper.getTransactionOption(
account,
CST.DEFAULT_TX_GAS_LIMIT,
CST.STAKE_V2_AUTO_ROLL_GAS,
option
);

Expand Down
18 changes: 9 additions & 9 deletions src/__snapshots__/StakeV2Wrapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ exports[`autoRoll 5`] = `
Array [
Array [
"account",
30000,
200000,
Object {},
],
Array [
"account",
30000,
200000,
Object {
"gasLimit": 20000,
"gasPrice": 1000000000,
Expand Down Expand Up @@ -133,12 +133,12 @@ exports[`commitAddReward 5`] = `
Array [
Array [
"account",
30000,
500000,
Object {},
],
Array [
"account",
30000,
500000,
Object {
"gasLimit": 20000,
"gasPrice": 1000000000,
Expand Down Expand Up @@ -169,12 +169,12 @@ exports[`commitReduceReward 5`] = `
Array [
Array [
"account",
30000,
500000,
Object {},
],
Array [
"account",
30000,
500000,
Object {
"gasLimit": 20000,
"gasPrice": 1000000000,
Expand Down Expand Up @@ -335,7 +335,7 @@ Object {
"maxStakePerOracle": 50000,
"minStakeAmt": 5000,
"stakingEnabled": true,
"totalAwardsToDistribute": 50000,
"totalRewardsToDistribute": 50000,
}
`;

Expand Down Expand Up @@ -419,12 +419,12 @@ exports[`resetStagingAwards 5`] = `
Array [
Array [
"account",
30000,
100000,
Object {},
],
Array [
"account",
30000,
100000,
Object {
"gasLimit": 20000,
"gasPrice": 1000000000,
Expand Down
8 changes: 6 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ export const STAKE_V2_UNSTAKING_GAS = 240000;
export const STAKE_V2_CLAIM_REWARD_GAS = 60000;
export const STAKE_V2_ENABLE_STAKING_GAS = 50000;
export const STAKE_V2_DISENABLE_STAKING_GAS = 50000;
export const STAKE_V2_STAGE_ADD_REWAD_LIMIT = 500000;
export const STAKE_V2_STAGE_REDUCE_REWAD_LIMIT = 500000;
export const STAKE_V2_STAGE_ADD_REWAD_GAS = 500000;
export const STAKE_V2_STAGE_REDUCE_REWAD_GAS = 500000;
export const STAKE_V2_COMMIT_REDUCE_REWAD_GAS = 500000;
export const STAKE_V2_COMMIT_ADD_REWAD_GAS = 500000;
export const STAKE_V2_AUTO_ROLL_GAS = 200000;
export const STAKE_V2_RESET_STAGING_GAS = 100000;

export const BTV_STATE = {
LAST_OPERATION_TIME: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const mainnet: IContractAddresses = {
StakesV2: [
{
code: 'Stake-0',
address: '0x0000000000000000000000000000000000000000'
address: '0xb74437bb3bc31821d2f3446f2e75f615ac03f412'
}
],
DUO: {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export { MagiWrapper } from './MagiWrapper';
export * from './types';
export { Web3Wrapper } from './Web3Wrapper';
export { VivaldiWrapper } from './VivaldiWrapper';
export { StakeWrapper } from './StakeWrapper';
export { StakeWrapper } from './StakeWrapper';
export { StakeV2Wrapper } from './StakeV2Wrapper';
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ export interface IStakeBaseStates {
lockMinTimeInSecond: number;
minStakeAmt: number;
maxStakePerOracle: number;
totalAwardsToDistribute: number;

}
export interface IStakeStates extends IStakeBaseStates {
canStake: boolean;
canUnstake: boolean;
totalAwardsToDistribute: number;
}

export interface IStakeV2States extends IStakeBaseStates {
stakingEnabled: boolean;
totalRewardsToDistribute: number;
}

export interface IStakeAddress {
Expand Down

0 comments on commit b1a95e0

Please sign in to comment.