From 466a7215228ebd0bcad91ec6d49b93040571448e Mon Sep 17 00:00:00 2001 From: apporc Date: Thu, 19 Sep 2024 18:00:11 +0800 Subject: [PATCH 1/9] earn: add rexfund into staked value --- src/pages/earn/index.svelte | 56 +++++++++++++++------------- src/pages/earn/step/bootstrap.svelte | 2 +- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index e3397b0c..e347cbc1 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -121,9 +121,32 @@ return Asset.fromUnits(result, $systemToken!.symbol) } + const rexEOSBalance: Writable = writable(Asset.from(0, $systemToken!.symbol)) + onMount(async () => { + const client = getClient($activeBlockchain.chainId) + const unsubscribe = currentAccount.subscribe(async (account) => { + const result = await client.v1.chain.get_table_rows({ + code: 'eosio', + scope: 'eosio', + table: 'rexfund', + json: true, + lower_bound: $currentAccount?.account_name, + upper_bound: $currentAccount?.account_name, + }) + if (result.rows.length > 0) { + rexEOSBalance.set(Asset.from(result.rows[0].balance, $systemToken!.symbol)) + } else { + rexEOSBalance.set(Asset.from(0, $systemToken!.symbol)) + } + }) + return () => { + unsubscribe() + } + }) + const rexInfo: Readable = derived( - [currentAccount, stateREX, systemToken], - ([$currentAccount, $stateREX, $systemToken]) => { + [currentAccount, stateREX, systemToken, rexEOSBalance], + ([$currentAccount, $stateREX, $systemToken, $rexEOSBalance]) => { let defaultZero = Asset.from(0, $systemToken!.symbol) let total = defaultZero let savings = defaultZero @@ -138,6 +161,12 @@ apy = ((annualReward / totalStaked) * 100).toFixed(2) if ($currentAccount && $currentAccount.rex_info) { total = convertRexToEos($currentAccount.rex_info.rex_balance.value) + if ($rexEOSBalance.value > 0) { + total = Asset.fromUnits( + total.units.adding($rexEOSBalance.units), + $systemToken!.symbol + ) + } const claimableBuckets = $currentAccount.rex_info.rex_maturities.filter( (maturity) => +new Date(maturity.first!.toString()) < +now @@ -190,29 +219,6 @@ return result }) - const rexEOSBalance: Writable = writable(Asset.from(0, $systemToken!.symbol)) - onMount(async () => { - const client = getClient($activeBlockchain.chainId) - const unsubscribe = currentAccount.subscribe(async (account) => { - const result = await client.v1.chain.get_table_rows({ - code: 'eosio', - scope: 'eosio', - table: 'rexfund', - json: true, - lower_bound: $currentAccount?.account_name, - upper_bound: $currentAccount?.account_name, - }) - if (result.rows.length > 0) { - rexEOSBalance.set(Asset.from(result.rows[0].balance, $systemToken!.symbol)) - } else { - rexEOSBalance.set(Asset.from(0, $systemToken!.symbol)) - } - }) - return () => { - unsubscribe() - } - }) - const initialStep: Step = Step.Bootstrap const step: Writable = writable(initialStep, () => { const unsubscribeStep = defaultStep.subscribe((s) => { diff --git a/src/pages/earn/step/bootstrap.svelte b/src/pages/earn/step/bootstrap.svelte index 80f4d290..8e41e32b 100644 --- a/src/pages/earn/step/bootstrap.svelte +++ b/src/pages/earn/step/bootstrap.svelte @@ -7,7 +7,7 @@ import Form from '~/components/elements/form.svelte' import InputAsset from '~/components/elements/input/asset.svelte' import InputLabel from '~/components/elements/input/label.svelte' - import {REXInfo} from '../types' + import type {REXInfo} from '../types' export let amount: string export let availableTokens: Asset From 4b69f8b223e021e41e8a392610c5cb9c8281c43c Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:32:10 -0700 Subject: [PATCH 2/9] Update src/pages/earn/index.svelte Co-authored-by: Daniel Fugere --- src/pages/earn/index.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index e347cbc1..eb03637f 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -125,6 +125,7 @@ onMount(async () => { const client = getClient($activeBlockchain.chainId) const unsubscribe = currentAccount.subscribe(async (account) => { + if !$systemToken return const result = await client.v1.chain.get_table_rows({ code: 'eosio', scope: 'eosio', From 3cca49495273ee97e818e86b0ae4f2919d459cfe Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:32:20 -0700 Subject: [PATCH 3/9] Update src/pages/earn/index.svelte Co-authored-by: Daniel Fugere --- src/pages/earn/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index eb03637f..d18416e9 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -135,7 +135,7 @@ upper_bound: $currentAccount?.account_name, }) if (result.rows.length > 0) { - rexEOSBalance.set(Asset.from(result.rows[0].balance, $systemToken!.symbol)) + rexEOSBalance.set(Asset.from(result.rows[0].balance, $systemToken.symbol)) } else { rexEOSBalance.set(Asset.from(0, $systemToken!.symbol)) } From 2b717e56a8a703e6fab2e2c1831bcd22efa55aa8 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:32:30 -0700 Subject: [PATCH 4/9] Update src/pages/earn/index.svelte Co-authored-by: Daniel Fugere --- src/pages/earn/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index d18416e9..e15dc073 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -137,7 +137,7 @@ if (result.rows.length > 0) { rexEOSBalance.set(Asset.from(result.rows[0].balance, $systemToken.symbol)) } else { - rexEOSBalance.set(Asset.from(0, $systemToken!.symbol)) + rexEOSBalance.set(Asset.from(0, $systemToken.symbol)) } }) return () => { From fdd9654aac76a025be9b786c16271bd79f851d53 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:32:37 -0700 Subject: [PATCH 5/9] Update src/pages/earn/index.svelte Co-authored-by: Daniel Fugere --- src/pages/earn/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index e15dc073..ecaf7709 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -160,7 +160,7 @@ const annualReward = 31250000 const totalStaked = Number($stateREX.total_lendable.value) apy = ((annualReward / totalStaked) * 100).toFixed(2) - if ($currentAccount && $currentAccount.rex_info) { + if ($currentAccount && $systemToken && $currentAccount.rex_info) { total = convertRexToEos($currentAccount.rex_info.rex_balance.value) if ($rexEOSBalance.value > 0) { total = Asset.fromUnits( From d865319ba7e64f39e1c79b265383bd9616a0d533 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:32:45 -0700 Subject: [PATCH 6/9] Update src/pages/earn/index.svelte Co-authored-by: Daniel Fugere --- src/pages/earn/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index ecaf7709..9fae39e1 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -165,7 +165,7 @@ if ($rexEOSBalance.value > 0) { total = Asset.fromUnits( total.units.adding($rexEOSBalance.units), - $systemToken!.symbol + $systemToken.symbol ) } From c315ce958c75ac7a9ec6c78cdc7e01538bbcdfa3 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:52:28 -0700 Subject: [PATCH 7/9] Syntax fixes --- src/pages/earn/index.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/earn/index.svelte b/src/pages/earn/index.svelte index 9fae39e1..c84bc957 100644 --- a/src/pages/earn/index.svelte +++ b/src/pages/earn/index.svelte @@ -125,7 +125,7 @@ onMount(async () => { const client = getClient($activeBlockchain.chainId) const unsubscribe = currentAccount.subscribe(async (account) => { - if !$systemToken return + if (!$systemToken) return const result = await client.v1.chain.get_table_rows({ code: 'eosio', scope: 'eosio', @@ -160,7 +160,7 @@ const annualReward = 31250000 const totalStaked = Number($stateREX.total_lendable.value) apy = ((annualReward / totalStaked) * 100).toFixed(2) - if ($currentAccount && $systemToken && $currentAccount.rex_info) { + if ($currentAccount && $systemToken && $currentAccount.rex_info) { total = convertRexToEos($currentAccount.rex_info.rex_balance.value) if ($rexEOSBalance.value > 0) { total = Asset.fromUnits( From c5ac2d17641b56e9e7313a2eb14c3db9814349bd Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 09:53:30 -0700 Subject: [PATCH 8/9] browser list updates --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 82c8148c..053b9c2b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1995,9 +1995,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332: - version "1.0.30001332" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz#39476d3aa8d83ea76359c70302eafdd4a1d727dd" - integrity sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw== + version "1.0.30001666" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz" + integrity sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g== chalk@^2.0.0: version "2.4.2" From 71ddbd9ebae5b77fb54b33ca4d5f8ebd1904eb52 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 2 Oct 2024 10:06:32 -0700 Subject: [PATCH 9/9] Revert "browser list updates" This reverts commit c5ac2d17641b56e9e7313a2eb14c3db9814349bd. --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 053b9c2b..82c8148c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1995,9 +1995,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332: - version "1.0.30001666" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz" - integrity sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g== + version "1.0.30001332" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz#39476d3aa8d83ea76359c70302eafdd4a1d727dd" + integrity sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw== chalk@^2.0.0: version "2.4.2"