Skip to content

Commit

Permalink
Merge branch 'fix/xtz-baker-balance' into 'develop'
Browse files Browse the repository at this point in the history
fix: fix wrong amount a delegator can take

See merge request papers/airgap/airgap-wallet!781
  • Loading branch information
isordo committed Jan 21, 2025
2 parents 41ff03a + 72220cc commit 79ffcb7
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 308 deletions.
558 changes: 279 additions & 279 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@
},
"dependencies": {
"@airgap-community/iso-rootstock": "1.0.0",
"@airgap/acurast": "0.13.35",
"@airgap/aeternity": "0.13.35",
"@airgap/acurast": "0.13.38-beta.0",
"@airgap/aeternity": "0.13.38-beta.0",
"@airgap/angular-core": "0.0.51",
"@airgap/angular-ngrx": "0.0.51",
"@airgap/astar": "0.13.35",
"@airgap/astar": "0.13.38-beta.0",
"@airgap/beacon-sdk": "3.1.5-beta.0",
"@airgap/bitcoin": "0.13.35",
"@airgap/coinlib-core": "0.13.35",
"@airgap/coreum": "0.13.35",
"@airgap/cosmos": "0.13.35",
"@airgap/cosmos-core": "0.13.35",
"@airgap/crypto": "0.13.35",
"@airgap/ethereum": "0.13.35",
"@airgap/groestlcoin": "0.13.35",
"@airgap/icp": "0.13.35",
"@airgap/module-kit": "0.13.35",
"@airgap/moonbeam": "0.13.35",
"@airgap/optimism": "0.13.35",
"@airgap/polkadot": "0.13.35",
"@airgap/bitcoin": "0.13.38-beta.0",
"@airgap/coinlib-core": "0.13.38-beta.0",
"@airgap/coreum": "0.13.38-beta.0",
"@airgap/cosmos": "0.13.38-beta.0",
"@airgap/cosmos-core": "0.13.38-beta.0",
"@airgap/crypto": "0.13.38-beta.0",
"@airgap/ethereum": "0.13.38-beta.0",
"@airgap/groestlcoin": "0.13.38-beta.0",
"@airgap/icp": "0.13.38-beta.0",
"@airgap/module-kit": "0.13.38-beta.0",
"@airgap/moonbeam": "0.13.38-beta.0",
"@airgap/optimism": "0.13.38-beta.0",
"@airgap/polkadot": "0.13.38-beta.0",
"@airgap/sapling-wasm": "0.0.7",
"@airgap/serializer": "0.13.35",
"@airgap/substrate": "0.13.35",
"@airgap/tezos": "0.13.35",
"@airgap/serializer": "0.13.38-beta.0",
"@airgap/substrate": "0.13.38-beta.0",
"@airgap/tezos": "0.13.38-beta.0",
"@angular/animations": "^16.1.1",
"@angular/common": "^16.1.1",
"@angular/core": "^16.1.1",
Expand Down
14 changes: 11 additions & 3 deletions src/app/extensions/delegation/TezosDelegationExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,21 @@ export class TezosDelegationExtensions extends V1ProtocolDelegationExtensions<Te
bakerDetails: DelegateeDetails,
address: string
): Promise<AirGapDelegateeDetails> {
const [bakerInfo, delegateeDetails, knownBakers] = await Promise.all([
const [bakerInfo, delegateeDetails, knownBakers, stakedBalance] = await Promise.all([
adapter.protocolV1.bakerDetails(bakerDetails.address),
adapter.getDelegateeDetails(bakerDetails.address),
this.getKnownBakers()
this.getKnownBakers(),
adapter.protocolV1.getstakeBalance(bakerDetails.address)
])

const { balance, delegatedBalance, totalDelegatedStake } = bakerInfo

const ownBalance = new BigNumber(balance.value).minus(stakedBalance.total.value)

const bakerCurrentUsage = new BigNumber(delegatedBalance.value).minus(totalDelegatedStake.value).plus(ownBalance)

const knownBaker = knownBakers[bakerDetails.address]

const name = knownBaker
? knownBaker.alias
: (await this.addressService.getAlias(bakerDetails.address, adapter)) ||
Expand All @@ -169,7 +178,6 @@ export class TezosDelegationExtensions extends V1ProtocolDelegationExtensions<Te
? knownBaker.stakingCapacity.shiftedBy(adapter.decimals)
: new BigNumber(bakerInfo.bakerCapacity).multipliedBy(0.7)

const bakerCurrentUsage = BigNumber.minimum(new BigNumber(bakerInfo.stakingBalance.value), bakerTotalUsage)
const bakerUsage = bakerCurrentUsage.dividedBy(bakerTotalUsage)

let status: string
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Token hinzufügen",
"collectibles_label": "Sammlerstücke",
"import-accounts_label": "Konten importieren",
"delegate_label": "Delegation",
"delegate_label": "Delegate & Stake",
"undelegate_label": "Aufheben der Delegation",
"claim_rewards_label": "Belohnung entgegennehmen",
"vote_label": "Wählen",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Add Tokens",
"collectibles_label": "Collectibles",
"import-accounts_label": "Import Accounts",
"delegate_label": "Delegation",
"delegate_label": "Delegate & Stake",
"undelegate_label": "Undelegate",
"claim_rewards_label": "Claim Rewards",
"vote_label": "Voting",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Añadir Token",
"collectibles_label": "NFTs",
"import-accounts_label": "Importar Cuentas",
"delegate_label": "Delegación",
"delegate_label": "Delegar y stakear",
"undelegate_label": "Desdelegar",
"claim_rewards_label": "Reclamar Recompensas",
"vote_label": "Votación",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Ajouter des jetons",
"collectibles_label": "Objets de collection",
"import-accounts_label": "Comptes d'importation",
"delegate_label": "Délégation",
"delegate_label": "Déléguer et staker",
"undelegate_label": "Annuler la délégation",
"claim_rewards_label": "Réclamez des récompenses",
"vote_label": "Vote",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Adicionar Tokens",
"collectibles_label": "Colecionáveis",
"import-accounts_label": "Importar contas",
"delegate_label": "Delegar",
"delegate_label": "Delegar e fazer staking",
"undelegate_label": "Cancelar delegação",
"claim_rewards_label": "Reivindicar recompensas",
"vote_label": "Votar",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "Добавить токены",
"collectibles_label": "Коллекционные",
"import-accounts_label": "Импорт аккаунтов",
"delegate_label": "Делегирование",
"delegate_label": "Делегировать и стейкать",
"undelegate_label": "Отменить делегирование",
"claim_rewards_label": "Забрать награду",
"vote_label": "Голосование",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"add-tokens_label": "添加代币",
"collectibles_label": "收藏品",
"import-accounts_label": "导入帐户",
"delegate_label": "委托",
"delegate_label": "委托和质押",
"undelegate_label": "取消委托",
"claim_rewards_label": "领取奖励",
"vote_label": "投票",
Expand Down

0 comments on commit 79ffcb7

Please sign in to comment.