@keplr-wallet/stores 0.12.232 → 0.12.233-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/query/cosmos/queries.d.ts +2 -1
- package/build/query/cosmos/queries.js +2 -0
- package/build/query/cosmos/queries.js.map +1 -1
- package/build/query/cosmos/staking/babylon-btc-delegation-reward.d.ts +15 -0
- package/build/query/cosmos/staking/babylon-btc-delegation-reward.js +57 -0
- package/build/query/cosmos/staking/babylon-btc-delegation-reward.js.map +1 -0
- package/build/query/cosmos/staking/index.d.ts +1 -0
- package/build/query/cosmos/staking/index.js +1 -0
- package/build/query/cosmos/staking/index.js.map +1 -1
- package/build/query/cosmos/staking/types.d.ts +14 -0
- package/package.json +11 -11
- package/src/query/cosmos/queries.ts +8 -0
- package/src/query/cosmos/staking/babylon-btc-delegation-reward.ts +96 -0
- package/src/query/cosmos/staking/index.ts +1 -0
- package/src/query/cosmos/staking/types.ts +15 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueriesSetBase } from "../queries";
|
|
2
2
|
import { ChainGetter } from "../../chain";
|
|
3
3
|
import { ObservableQueryAccount } from "./account";
|
|
4
|
-
import { ObservableQueryDelegations, ObservableQueryRewards, ObservableQueryStakingParams, ObservableQueryStakingPool, ObservableQueryUnbondingDelegations, ObservableQueryValidators } from "./staking";
|
|
4
|
+
import { ObservableQueryBabylonBtcDelegationReward, ObservableQueryDelegations, ObservableQueryRewards, ObservableQueryStakingParams, ObservableQueryStakingPool, ObservableQueryUnbondingDelegations, ObservableQueryValidators } from "./staking";
|
|
5
5
|
import { ObservableQueryDenomTrace, ObservableQueryIBCChannel, ObservableQueryIBCClientState } from "./ibc";
|
|
6
6
|
import { ObservableQuerySpendableBalances } from "./balance";
|
|
7
7
|
import { DeepReadonly } from "utility-types";
|
|
@@ -32,6 +32,7 @@ export declare class CosmosQueriesImpl {
|
|
|
32
32
|
readonly queryUnbondingDelegations: DeepReadonly<ObservableQueryUnbondingDelegations>;
|
|
33
33
|
readonly queryInitiaUnbondingDelegations: DeepReadonly<ObservableQueryInitiaUnbondingDelegations>;
|
|
34
34
|
readonly queryValidators: DeepReadonly<ObservableQueryValidators>;
|
|
35
|
+
readonly queryBabylonBtcDelegationReward: DeepReadonly<ObservableQueryBabylonBtcDelegationReward>;
|
|
35
36
|
readonly queryIBCClientState: DeepReadonly<ObservableQueryIBCClientState>;
|
|
36
37
|
readonly queryIBCClientStateV2: DeepReadonly<ObservableQueryIBCClientStateV2>;
|
|
37
38
|
readonly queryIBCChannel: DeepReadonly<ObservableQueryIBCChannel>;
|
|
@@ -37,6 +37,8 @@ class CosmosQueriesImpl {
|
|
|
37
37
|
this.queryInitiaUnbondingDelegations =
|
|
38
38
|
new initia_unbonding_delegations_1.ObservableQueryInitiaUnbondingDelegations(sharedContext, chainId, chainGetter);
|
|
39
39
|
this.queryValidators = new staking_1.ObservableQueryValidators(sharedContext, chainId, chainGetter);
|
|
40
|
+
this.queryBabylonBtcDelegationReward =
|
|
41
|
+
new staking_1.ObservableQueryBabylonBtcDelegationReward(sharedContext, chainId, chainGetter);
|
|
40
42
|
this.queryIBCClientState = new ibc_1.ObservableQueryIBCClientState(sharedContext, chainId, chainGetter);
|
|
41
43
|
this.queryIBCClientStateV2 = new client_state_v2_1.ObservableQueryIBCClientStateV2(sharedContext, chainId, chainGetter);
|
|
42
44
|
this.queryIBCChannel = new ibc_1.ObservableQueryIBCChannel(sharedContext, chainId, chainGetter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmos/queries.ts"],"names":[],"mappings":";;;AAEA,uCAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmos/queries.ts"],"names":[],"mappings":";;;AAEA,uCAAmD;AACnD,uCAQmB;AACnB,+BAIe;AACf,uCAGmB;AAEnB,iDAAmE;AACnE,qCAAoD;AACpD,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AI,CAAC,sBAAsB,GAAG,IAAI,qDAAgC,CAChE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,yBAAyB,GAAG,IAAI,6CAAmC,CACtE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,+BAA+B;YAClC,IAAI,wEAAyC,CAC3C,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACJ,IAAI,CAAC,eAAe,GAAG,IAAI,mCAAyB,CAClD,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,+BAA+B;YAClC,IAAI,mDAAyC,CAC3C,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEJ,IAAI,CAAC,mBAAmB,GAAG,IAAI,mCAA6B,CAC1D,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,qBAAqB,GAAG,IAAI,iDAA+B,CAC9D,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAI,+BAAyB,CAClD,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,kBAAkB,GAAG,IAAI,+BAAyB,CACrD,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,IAAI,mCAA2B,CACtD,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,uBAAuB,GAAG,IAAI,6CAAiC,CAClE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC;CACF;AA1ID,8CA0IC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ObservableChainQuery, ObservableChainQueryMap } from "../../chain-query";
|
|
2
|
+
import { BabylonRewardGauges } from "./types";
|
|
3
|
+
import { ChainGetter } from "../../../chain";
|
|
4
|
+
import { CoinPretty } from "@keplr-wallet/unit";
|
|
5
|
+
import { QuerySharedContext } from "../../../common";
|
|
6
|
+
export declare class ObservableQueryBabylonBtcDelegationRewardInner extends ObservableChainQuery<BabylonRewardGauges> {
|
|
7
|
+
protected bech32Address: string;
|
|
8
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, bech32Address: string);
|
|
9
|
+
protected canFetch(): boolean;
|
|
10
|
+
get claimable(): CoinPretty | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class ObservableQueryBabylonBtcDelegationReward extends ObservableChainQueryMap<BabylonRewardGauges> {
|
|
13
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
14
|
+
getQueryBech32Address(bech32Address: string): ObservableQueryBabylonBtcDelegationRewardInner;
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ObservableQueryBabylonBtcDelegationReward = exports.ObservableQueryBabylonBtcDelegationRewardInner = void 0;
|
|
10
|
+
const chain_query_1 = require("../../chain-query");
|
|
11
|
+
const unit_1 = require("@keplr-wallet/unit");
|
|
12
|
+
const mobx_1 = require("mobx");
|
|
13
|
+
class ObservableQueryBabylonBtcDelegationRewardInner extends chain_query_1.ObservableChainQuery {
|
|
14
|
+
constructor(sharedContext, chainId, chainGetter, bech32Address) {
|
|
15
|
+
super(sharedContext, chainId, chainGetter, `/babylon/incentive/address/${bech32Address}/reward_gauge`);
|
|
16
|
+
(0, mobx_1.makeObservable)(this);
|
|
17
|
+
this.bech32Address = bech32Address;
|
|
18
|
+
}
|
|
19
|
+
canFetch() {
|
|
20
|
+
// If bech32 address is empty, it will always fail, so don't need to fetch it.
|
|
21
|
+
return (this.bech32Address.length > 0 ||
|
|
22
|
+
this.chainGetter.getChain(this.chainId).stakeCurrency != null);
|
|
23
|
+
}
|
|
24
|
+
get claimable() {
|
|
25
|
+
const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
26
|
+
if (!stakeCurrency) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!this.response) {
|
|
30
|
+
return new unit_1.CoinPretty(stakeCurrency, new unit_1.Int(0)).ready(false);
|
|
31
|
+
}
|
|
32
|
+
const btcDelegation = this.response.data.reward_gauges.BTC_STAKER;
|
|
33
|
+
const totalRewards = btcDelegation.coins.find((coin) => coin.denom === stakeCurrency.coinMinimalDenom);
|
|
34
|
+
const withdrawnRewards = btcDelegation.withdrawn_coins.find((coin) => coin.denom === stakeCurrency.coinMinimalDenom);
|
|
35
|
+
if (!totalRewards || !withdrawnRewards) {
|
|
36
|
+
return new unit_1.CoinPretty(stakeCurrency, new unit_1.Int(0)).ready(false);
|
|
37
|
+
}
|
|
38
|
+
const claimable = new unit_1.Int(totalRewards.amount).sub(new unit_1.Int(withdrawnRewards.amount));
|
|
39
|
+
return new unit_1.CoinPretty(stakeCurrency, claimable);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
__decorate([
|
|
43
|
+
mobx_1.computed
|
|
44
|
+
], ObservableQueryBabylonBtcDelegationRewardInner.prototype, "claimable", null);
|
|
45
|
+
exports.ObservableQueryBabylonBtcDelegationRewardInner = ObservableQueryBabylonBtcDelegationRewardInner;
|
|
46
|
+
class ObservableQueryBabylonBtcDelegationReward extends chain_query_1.ObservableChainQueryMap {
|
|
47
|
+
constructor(sharedContext, chainId, chainGetter) {
|
|
48
|
+
super(sharedContext, chainId, chainGetter, (bech32Address) => {
|
|
49
|
+
return new ObservableQueryBabylonBtcDelegationRewardInner(this.sharedContext, this.chainId, this.chainGetter, bech32Address);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
getQueryBech32Address(bech32Address) {
|
|
53
|
+
return this.get(bech32Address);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ObservableQueryBabylonBtcDelegationReward = ObservableQueryBabylonBtcDelegationReward;
|
|
57
|
+
//# sourceMappingURL=babylon-btc-delegation-reward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babylon-btc-delegation-reward.js","sourceRoot":"","sources":["../../../../src/query/cosmos/staking/babylon-btc-delegation-reward.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAG2B;AAG3B,6CAAqD;AACrD,+BAAgD;AAGhD,MAAa,8CAA+C,SAAQ,kCAAyC;IAG3G,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB,EACxB,aAAqB;QAErB,KAAK,CACH,aAAa,EACb,OAAO,EACP,WAAW,EACX,8BAA8B,aAAa,eAAe,CAC3D,CAAC;QACF,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;QAErB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEkB,QAAQ;QACzB,8EAA8E;QAC9E,OAAO,CACL,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,aAAa,IAAI,IAAI,CAC9D,CAAC;IACJ,CAAC;IAGD,IAAI,SAAS;QACX,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;QAE5E,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;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C,WAAW,EAChB,aAAa,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB,CACnB,aAAqB;QAErB,OAAO,IAAI,CAAC,GAAG,CACb,aAAa,CACoC,CAAC;IACtD,CAAC;CACF;AAvBD,8FAuBC"}
|
|
@@ -20,4 +20,5 @@ __exportStar(require("./unbonding-delegations"), exports);
|
|
|
20
20
|
__exportStar(require("./validators"), exports);
|
|
21
21
|
__exportStar(require("./pool"), exports);
|
|
22
22
|
__exportStar(require("./params"), exports);
|
|
23
|
+
__exportStar(require("./babylon-btc-delegation-reward"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/query/cosmos/staking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B;AAC1B,0DAAwC;AACxC,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/query/cosmos/staking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B;AAC1B,0DAAwC;AACxC,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,kEAAgD"}
|
|
@@ -115,3 +115,17 @@ export type StakingPool = {
|
|
|
115
115
|
bonded_tokens: string;
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
|
+
export type BabylonRewardGauges = {
|
|
119
|
+
reward_gauges: {
|
|
120
|
+
BTC_STAKER: {
|
|
121
|
+
coins: {
|
|
122
|
+
denom: string;
|
|
123
|
+
amount: string;
|
|
124
|
+
}[];
|
|
125
|
+
withdrawn_coins: {
|
|
126
|
+
denom: string;
|
|
127
|
+
amount: string;
|
|
128
|
+
}[];
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/stores",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.233-rc.1",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@keplr-wallet/provider-mock": "0.12.
|
|
19
|
+
"@keplr-wallet/provider-mock": "0.12.233-rc.1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@keplr-wallet/common": "0.12.
|
|
23
|
-
"@keplr-wallet/cosmos": "0.12.
|
|
24
|
-
"@keplr-wallet/crypto": "0.12.
|
|
25
|
-
"@keplr-wallet/mobx-utils": "0.12.
|
|
26
|
-
"@keplr-wallet/proto-types": "0.12.
|
|
27
|
-
"@keplr-wallet/simple-fetch": "0.12.
|
|
28
|
-
"@keplr-wallet/types": "0.12.
|
|
29
|
-
"@keplr-wallet/unit": "0.12.
|
|
22
|
+
"@keplr-wallet/common": "0.12.233-rc.1",
|
|
23
|
+
"@keplr-wallet/cosmos": "0.12.233-rc.1",
|
|
24
|
+
"@keplr-wallet/crypto": "0.12.233-rc.1",
|
|
25
|
+
"@keplr-wallet/mobx-utils": "0.12.233-rc.1",
|
|
26
|
+
"@keplr-wallet/proto-types": "0.12.233-rc.1",
|
|
27
|
+
"@keplr-wallet/simple-fetch": "0.12.233-rc.1",
|
|
28
|
+
"@keplr-wallet/types": "0.12.233-rc.1",
|
|
29
|
+
"@keplr-wallet/unit": "0.12.233-rc.1",
|
|
30
30
|
"buffer": "^6.0.3",
|
|
31
31
|
"deepmerge": "^4.2.2",
|
|
32
32
|
"eventemitter3": "^4.0.7",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"mobx": "^6",
|
|
39
39
|
"mobx-utils": "^6"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "ebe9a2ce73373f0ec604f19032a6c4877e8eb531"
|
|
42
42
|
}
|
|
@@ -2,6 +2,7 @@ import { QueriesSetBase } from "../queries";
|
|
|
2
2
|
import { ChainGetter } from "../../chain";
|
|
3
3
|
import { ObservableQueryAccount } from "./account";
|
|
4
4
|
import {
|
|
5
|
+
ObservableQueryBabylonBtcDelegationReward,
|
|
5
6
|
ObservableQueryDelegations,
|
|
6
7
|
ObservableQueryRewards,
|
|
7
8
|
ObservableQueryStakingParams,
|
|
@@ -71,6 +72,7 @@ export class CosmosQueriesImpl {
|
|
|
71
72
|
public readonly queryUnbondingDelegations: DeepReadonly<ObservableQueryUnbondingDelegations>;
|
|
72
73
|
public readonly queryInitiaUnbondingDelegations: DeepReadonly<ObservableQueryInitiaUnbondingDelegations>;
|
|
73
74
|
public readonly queryValidators: DeepReadonly<ObservableQueryValidators>;
|
|
75
|
+
public readonly queryBabylonBtcDelegationReward: DeepReadonly<ObservableQueryBabylonBtcDelegationReward>;
|
|
74
76
|
|
|
75
77
|
public readonly queryIBCClientState: DeepReadonly<ObservableQueryIBCClientState>;
|
|
76
78
|
public readonly queryIBCClientStateV2: DeepReadonly<ObservableQueryIBCClientStateV2>;
|
|
@@ -155,6 +157,12 @@ export class CosmosQueriesImpl {
|
|
|
155
157
|
chainId,
|
|
156
158
|
chainGetter
|
|
157
159
|
);
|
|
160
|
+
this.queryBabylonBtcDelegationReward =
|
|
161
|
+
new ObservableQueryBabylonBtcDelegationReward(
|
|
162
|
+
sharedContext,
|
|
163
|
+
chainId,
|
|
164
|
+
chainGetter
|
|
165
|
+
);
|
|
158
166
|
|
|
159
167
|
this.queryIBCClientState = new ObservableQueryIBCClientState(
|
|
160
168
|
sharedContext,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObservableChainQuery,
|
|
3
|
+
ObservableChainQueryMap,
|
|
4
|
+
} from "../../chain-query";
|
|
5
|
+
import { BabylonRewardGauges } from "./types";
|
|
6
|
+
import { ChainGetter } from "../../../chain";
|
|
7
|
+
import { CoinPretty, Int } from "@keplr-wallet/unit";
|
|
8
|
+
import { computed, makeObservable } from "mobx";
|
|
9
|
+
import { QuerySharedContext } from "../../../common";
|
|
10
|
+
|
|
11
|
+
export class ObservableQueryBabylonBtcDelegationRewardInner extends ObservableChainQuery<BabylonRewardGauges> {
|
|
12
|
+
protected bech32Address: string;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
sharedContext: QuerySharedContext,
|
|
16
|
+
chainId: string,
|
|
17
|
+
chainGetter: ChainGetter,
|
|
18
|
+
bech32Address: string
|
|
19
|
+
) {
|
|
20
|
+
super(
|
|
21
|
+
sharedContext,
|
|
22
|
+
chainId,
|
|
23
|
+
chainGetter,
|
|
24
|
+
`/babylon/incentive/address/${bech32Address}/reward_gauge`
|
|
25
|
+
);
|
|
26
|
+
makeObservable(this);
|
|
27
|
+
|
|
28
|
+
this.bech32Address = bech32Address;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected override canFetch(): boolean {
|
|
32
|
+
// If bech32 address is empty, it will always fail, so don't need to fetch it.
|
|
33
|
+
return (
|
|
34
|
+
this.bech32Address.length > 0 ||
|
|
35
|
+
this.chainGetter.getChain(this.chainId).stakeCurrency != null
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@computed
|
|
40
|
+
get claimable(): CoinPretty | undefined {
|
|
41
|
+
const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
42
|
+
|
|
43
|
+
if (!stakeCurrency) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!this.response) {
|
|
48
|
+
return new CoinPretty(stakeCurrency, new Int(0)).ready(false);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const btcDelegation = this.response.data.reward_gauges.BTC_STAKER;
|
|
52
|
+
|
|
53
|
+
const totalRewards = btcDelegation.coins.find(
|
|
54
|
+
(coin) => coin.denom === stakeCurrency.coinMinimalDenom
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const withdrawnRewards = btcDelegation.withdrawn_coins.find(
|
|
58
|
+
(coin) => coin.denom === stakeCurrency.coinMinimalDenom
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!totalRewards || !withdrawnRewards) {
|
|
62
|
+
return new CoinPretty(stakeCurrency, new Int(0)).ready(false);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const claimable = new Int(totalRewards.amount).sub(
|
|
66
|
+
new Int(withdrawnRewards.amount)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return new CoinPretty(stakeCurrency, claimable);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class ObservableQueryBabylonBtcDelegationReward extends ObservableChainQueryMap<BabylonRewardGauges> {
|
|
74
|
+
constructor(
|
|
75
|
+
sharedContext: QuerySharedContext,
|
|
76
|
+
chainId: string,
|
|
77
|
+
chainGetter: ChainGetter
|
|
78
|
+
) {
|
|
79
|
+
super(sharedContext, chainId, chainGetter, (bech32Address: string) => {
|
|
80
|
+
return new ObservableQueryBabylonBtcDelegationRewardInner(
|
|
81
|
+
this.sharedContext,
|
|
82
|
+
this.chainId,
|
|
83
|
+
this.chainGetter,
|
|
84
|
+
bech32Address
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getQueryBech32Address(
|
|
90
|
+
bech32Address: string
|
|
91
|
+
): ObservableQueryBabylonBtcDelegationRewardInner {
|
|
92
|
+
return this.get(
|
|
93
|
+
bech32Address
|
|
94
|
+
) as ObservableQueryBabylonBtcDelegationRewardInner;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -148,3 +148,18 @@ export type StakingPool = {
|
|
|
148
148
|
bonded_tokens: string;
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
|
+
|
|
152
|
+
export type BabylonRewardGauges = {
|
|
153
|
+
reward_gauges: {
|
|
154
|
+
BTC_STAKER: {
|
|
155
|
+
coins: {
|
|
156
|
+
denom: string;
|
|
157
|
+
amount: string;
|
|
158
|
+
}[];
|
|
159
|
+
withdrawn_coins: {
|
|
160
|
+
denom: string;
|
|
161
|
+
amount: string;
|
|
162
|
+
}[];
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|