diff --git a/Cargo.lock b/Cargo.lock index 6d283d787..cf6b4169a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,9 +1117,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide 0.8.5", @@ -1350,9 +1350,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-util", @@ -1366,9 +1366,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.62" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2fd658b06e56721792c5df4475705b6cda790e9298d19d2f8af083457bcd127" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1504,10 +1504,11 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.2", "libc", ] @@ -2492,9 +2493,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags", "errno", @@ -3307,11 +3308,37 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ - "windows-targets", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] @@ -3320,6 +3347,24 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/README.md b/README.md index 8b06aeb1d..ababae700 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Heartfelt thanks go out to every donor on [Nostr](https://primal.net/p/npub1jagm If you'd like to have your own instance hosted for you please contact [hosting@bitcoinresearchkit.org](mailto:hosting@bitcoinresearchkit.org). -- 2 separate servers (1 GB/s each) with different ISPs and Cloudflare integration for enhanced performance and optimal availability +- 2 separate dedicated servers (1 GB/s each) with different ISPs and Cloudflare integration for enhanced performance and optimal availability - Direct communication for feature requests and support - Updates delivered at your convenience - Optional subdomains: `*.bitcoinresearchkit.org`, `*.kibo.money` and `*.satonomics.xyz` diff --git a/crates/brk_indexer/src/stores/base.rs b/crates/brk_indexer/src/stores/base.rs index 247cb7c46..940beaeca 100644 --- a/crates/brk_indexer/src/stores/base.rs +++ b/crates/brk_indexer/src/stores/base.rs @@ -27,7 +27,7 @@ pub struct Store { } const CHECK_COLLISISONS: bool = true; -const FJALL_VERSION: Version = Version::TWO; +const MAJOR_FJALL_VERSION: Version = Version::TWO; impl Store where @@ -36,7 +36,7 @@ where >::Error: error::Error + Send + Sync + 'static, { pub fn import(path: &Path, version: Version) -> color_eyre::Result { - let version = FJALL_VERSION + version; + let version = MAJOR_FJALL_VERSION + version; let meta = StoreMeta::checked_open(path, version)?; @@ -92,6 +92,10 @@ where } pub fn remove(&mut self, key: K) { + if self.is_empty() { + return; + } + if !self.puts.is_empty() { unreachable!("Shouldn't reach this"); // self.puts.remove(&key); diff --git a/crates/brk_indexer/src/stores/mod.rs b/crates/brk_indexer/src/stores/mod.rs index d23b6af7e..abaac46eb 100644 --- a/crates/brk_indexer/src/stores/mod.rs +++ b/crates/brk_indexer/src/stores/mod.rs @@ -46,6 +46,13 @@ impl Stores { vecs: &mut Vecs, starting_indexes: &Indexes, ) -> color_eyre::Result<()> { + if self.addresshash_to_addressindex.is_empty() + && self.blockhash_prefix_to_height.is_empty() + && self.txid_prefix_to_txindex.is_empty() + { + return Ok(()); + } + vecs.height_to_blockhash .iter_from(starting_indexes.height, |(_, blockhash, ..)| { let blockhash_prefix = BlockHashPrefix::from(blockhash); diff --git a/crates/brk_server/src/lib.rs b/crates/brk_server/src/lib.rs index 9b940085f..5c64f9ec7 100644 --- a/crates/brk_server/src/lib.rs +++ b/crates/brk_server/src/lib.rs @@ -144,6 +144,7 @@ impl Server { }, ) .on_body_chunk(()) + .on_failure(()) .on_eos(()); let router = Router::new() diff --git a/crates/brk_vec/src/lib.rs b/crates/brk_vec/src/lib.rs index 0d473e9a2..2a9382fc6 100644 --- a/crates/brk_vec/src/lib.rs +++ b/crates/brk_vec/src/lib.rs @@ -200,6 +200,10 @@ where .to_usize() .unwrap(); + if len == 0 { + return Err(Error::IndexTooHigh); + } + let from = from.map_or(0, |from| { if from >= 0 { from as usize diff --git a/websites/kibo.money/packages/lean-qr/v2.3.4/script.js b/websites/kibo.money/packages/lean-qr/v2.3.4/script.js index caee6aeda..898deb8cd 100644 --- a/websites/kibo.money/packages/lean-qr/v2.3.4/script.js +++ b/websites/kibo.money/packages/lean-qr/v2.3.4/script.js @@ -1 +1,2 @@ +// @ts-nocheck const t=[.2,3/8,5/9,2/3],o=(o,e)=>r=>{const n=4*o+r-4,s="*-04-39?2$%%$%%'$%''%'''%')(%'))%(++'(++'(+.'+-.',/3',33)-/5)-43).36)058*18<+37<+4:<,4:E,5C/8@F/:EH/8?s:1,c=e/f|0,i=e%f,l=f-i,a=n>8?c*t[r]+(o>5)&-2:s,u=c-a;return{t:8*(l*u+i*(u+1)),o:i?[[l,u],[i,u+1]]:[[l,u]],i:a}},e={min:0,L:0,M:1,Q:2,H:3,max:3},r=t=>new Uint8Array(t),n=t=>{const o=new Error(`lean-qr error ${t}`);throw o.code=t,o},s=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),f=t=>t.charCodeAt(0),c=(...t)=>(o,e)=>t.forEach((t=>t(o,e))),i=t=>o=>{o.eci!==t&&(o.push(7,4),o.push(t,8),o.eci=t)},l=t=>(o,e)=>{o.push(4,4),o.push(t.length,8+8*(e>9)),t.forEach((t=>o.push(t,8)))},a=(t,o,e,r,n=((t,o)=>e(t.length,o)),s=(r?o=>c(i(r),t(o)):t))=>(s.test=o,s.l=e,s.est=n,s.eci=r&&[r],s),u=a((t=>(o,e)=>{o.push(1,4),o.push(t.length,10+2*(e>26)+2*(e>9));let r=0;for(;r14+2*(o>26)+2*(o>9)+10*t/3)),_=a((t=>(o,e)=>{o.push(2,4),o.push(t.length,9+2*(e>26)+2*(e>9));let r=0;for(;rs(t)>=0),((t,o)=>13+2*(o>26)+2*(o>9)+5.5*t)),d=a((t=>l([...t].map(f))),(t=>f(t)<128),((t,o)=>12+8*(o>9)+8*t));d.u=!0;const m=a(d,(t=>f(t)<256),d.l,3);m.u=!0;const p=new TextEncoder,h=a((t=>l(p.encode(t))),(()=>1),0,26,((t,o)=>12+8*(o>9)+8*p.encode(t).length));h.u=!0;let w=()=>{const t=new Map,o=new TextDecoder("sjis"),e=r(2);for(let r=0;r<7973;++r)e[0]=r/192+129+64*(r>5951),e[1]=r%192+64,t.set(o.decode(e),r);return t.delete("\ufffd"),w=()=>t,t};const g=a((t=>(o,e)=>{o.push(8,4),o.push(t.length,8+2*(e>26)+2*(e>9));for(const e of t)o.push(w().get(e),13)}),(t=>w().has(t)),((t,o)=>12+2*(o>26)+2*(o>9)+13*t));g.u=!0;const y=[u,_,d,m,g,h],x={auto:(t,{modes:o=y}={})=>(e,r)=>{let s=1;for(const e of o){const o=new Map;e._=s<<=1,e.m=e.est("",r),e.h=e.l?(t,n)=>{const s=n-t,f=o.get(s)??e.l(s,r);return o.set(s,f),f}:(n,s)=>{const f=t.slice(n,s),c=o.get(f)??e.est(f,r);return o.set(f,c),c}}let f=[{S:0}],c=0,i=0,l=-1;for(const e of[...t,""]){let t=0;if(e)for(const r of o)r.test(e)&&(t|=r._);if(!e||t!==l){if(-1!==l){const t=new Set(f.map((t=>t.v))),e=[];for(const r of o.filter((t=>l&t._))){const o=r.h(c,i);for(const n of r.eci??t){if(r===d&&n)continue;let t;for(const e of f)if(e.v===n||r.eci){const s=e.C===r&&e.v===n,f=s?e.D:e,l=s?e.V:c;let a;a=r.u&&s?e.S+o-r.m:f.S+12*(f.v!==n)+(l===c?o:r.h(l,i)),(!t||ao.St(e,r)))},multi:c,eci:i,numeric:u,alphaNumeric:_,bytes:l,ascii:d,iso8859_1:m,shift_jis:g,utf8:h},z=()=>({A:r(2956),F:0,push(t,o){for(let e=o,r=8-(7&this.F);e>0;e-=r,r=8)this.A[this.F>>3]|=t<>e,this.F+=e({size:t,I:e,get:(o,r)=>o>=0&&o!(1&(t^o)),(t,o)=>!(1&o),t=>!(t%3),(t,o)=>!((t+o)%3),(t,o)=>!(1&(t/3^o>>1)),(t,o)=>!((t&o&1)+t*o%3),(t,o)=>!((t&o&1)+t*o%3&1),(t,o)=>!((1&(t^o))+t*o%3&1)],S=r(512);S[0]=1;for(let t=0,o=1;t<255;S[++t]=o)S[o+256]=t,o*=2,256&o&&(o^=285);const v=t=>S[t%255],C=t=>S[t+256],D=(t,o)=>{const e=r(t.length+o.length-1);for(let r=0;r{const e=r(t.length+o.length-1);e.set(t,0);for(let r=0;r{const e=[[],[]];let n=0,s=0;for(const[r,f]of o.o)for(let c=0;c{let r=t<>=1)r&t&&(r^=o*(t>>e-1));return r},A=({size:t,I:o,K:e},r)=>{const n=(e,r,n,s,f)=>{for(;s-- >0;){const c=(r+s)*t+e;o.fill(f,c,c+n)}},s=(t,o)=>{n(t-3,o-3,7,7,3),n(t-2,o-2,5,5,2),n(t-1,o-1,3,3,3)},f=(t,o)=>{n(t-2,o-2,5,5,3),n(t-1,o-1,3,3,2),e(t,o,3)};n(7,0,2,9,2),n(t-8,0,8,9,2);for(let o=0;o1){const o=1+(r/7|0),e=2*((t-13)/o/2+.75|0);for(let r=0;r6)for(let o=r<<12|b(r,7973,13),n=0;n<6;++n)for(let r=12;r-- >9;o>>=1)e(t-r,n,2|1&o);for(let e=0;e{const e=[];for(let r=t-2,n=t,s=-1;r>=0;r-=2){for(5===r&&(r=4);n+=s,-1!==n&&n!==t;){const s=n*t+r;o[s+1]<2&&e.push(s+1),o[s]<2&&e.push(s)}s*=-1}return e},H=({I:t},o,e)=>o.forEach(((o,r)=>t[o]=e[r>>3]>>7-(7&r)&1)),I=({size:t,I:o,K:e},r,n,s)=>{for(let e=0;e>1^1)}const f=(1^s)<<3|n;let c=21522^(f<<10|b(f,1335,11));for(let o=8;o-- >0;c>>=1)e(8,(o>1?7:8)-o,c),e(t-8+o,8,c);for(let o=7;o-- >0;c>>=1)e(o>5?7:o,8,c),e(8,t-o-1,c)},K=({size:t,I:o},e=0,r=0)=>{for(let n=0;n>1|2098176)&(3047517^a-1),2049&i&&(e+=40),a!==f?(l=1,f=a):++l>4&&(e+=l<6?3:1)}if(n)for(let r=1,s=1&o[n-1],f=(1&o[n])===s;r{s>3);if(c(r).t=r;--t){const o=c(t);if(o.t{const n=E(e.size,e.I);return I(n,o,i??r,t),n.s=K(n),n})).reduce(((t,o)=>o.s(o,e)=>P(o,{modes:[...y,...t],...e});export{e as correction,P as generate,x as mode}; \ No newline at end of file diff --git a/websites/kibo.money/packages/lightweight-charts/README.md b/websites/kibo.money/packages/lightweight-charts/README.md deleted file mode 100644 index cba23e01c..000000000 --- a/websites/kibo.money/packages/lightweight-charts/README.md +++ /dev/null @@ -1,3 +0,0 @@ -URL + Version: - -https://unpkg.com/browse/lightweight-charts@latest/ diff --git a/websites/kibo.money/packages/lightweight-charts/types.d.ts b/websites/kibo.money/packages/lightweight-charts/types.d.ts deleted file mode 100644 index 934db5fe8..000000000 --- a/websites/kibo.money/packages/lightweight-charts/types.d.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Signal } from "../solid-signals/types"; -import { Accessor } from "../solid-signals/v0.2.4-treeshaked/types/signals"; -import { - DeepPartial, - BaselineStyleOptions, - CandlestickStyleOptions, - LineStyleOptions, - SeriesOptionsCommon, - Time, - ISeriesApi, - BaselineData, -} from "./v5.0.5-treeshaked/types"; -import { VecId } from "../../scripts/vecid-to-indexes"; - -interface BaseSeriesBlueprint { - title: string; - defaultActive?: boolean; -} -interface BaselineSeriesBlueprint extends BaseSeriesBlueprint { - type: "Baseline"; - color?: Color; - options?: DeepPartial; - data?: Accessor[]>; -} -interface CandlestickSeriesBlueprint extends BaseSeriesBlueprint { - type: "Candlestick"; - color?: Color; - options?: DeepPartial; - data?: Accessor; -} -interface LineSeriesBlueprint extends BaseSeriesBlueprint { - type?: "Line"; - color: Color; - options?: DeepPartial; - data?: Accessor[]>; -} -type AnySpecificSeriesBlueprint = - | BaselineSeriesBlueprint - | CandlestickSeriesBlueprint - | LineSeriesBlueprint; - -type SeriesType = NonNullable; -type PriceSeriesType = "Candlestick" | "Line"; - -type RemoveSeriesBlueprintFluff = - Omit; - -type SplitSeriesBlueprint<> = { - key: VecId; -} & AnySpecificSeriesBlueprint; - -type SingleSeriesBlueprint = AnySpecificSeriesBlueprint; - -interface CreateBaseSeriesParameters extends BaseSeriesBlueprint { - id: string; - disabled?: Accessor; - color?: Color; -} -interface BaseSeries { - id: string; - title: string; - color: Color | Color[]; - active: Signal; - visible: Accessor; -} -interface SingleSeries extends BaseSeries { - iseries: ISeriesApi; - dataset: Accessor<(SingleValueData | CandlestickData)[] | null>; -} -interface SplitSeries extends BaseSeries { - chunks: Array | undefined>>; - // dataset: ResourceDataset; -} -type AnySeries = SingleSeries | SplitSeries; - -interface CreateSingleSeriesParameters { - blueprint: SingleSeriesBlueprint; - id: string; -} - -interface CreateSplitSeriesParameters { - // dataset: ResourceDataset; - blueprint: SplitSeriesBlueprint; - id: string; - index: number; - disabled?: Accessor; -} - -type ChartPane = IChartApi & { - whitespace: ISeriesApi<"Line">; - hidden: () => boolean; - setHidden: (b: boolean) => void; - setInitialVisibleTimeRange: VoidFunction; - createSingleSeries: (a: CreateSingleSeriesParameters) => SingleSeries; - createSplitSeries: (a: CreateSplitSeriesParameters) => SplitSeries[]; - anySeries: AnySeries[]; - singleSeries: SingleSeries[]; - splitSeries: SplitSeries[]; - remove: VoidFunction; -}; - -interface CreatePaneParameters { - options?: DeepPartial; - config?: SingleSeriesBlueprint[]; -} - -interface Marker { - weight: number; - time: Time; - value: number; - seriesChunk: ISeriesApi; -} - -interface HoveredLegend { - label: HTMLLabelElement; - series: AnySeries; -} diff --git a/websites/kibo.money/packages/lightweight-charts/wrapper.js b/websites/kibo.money/packages/lightweight-charts/wrapper.js index 2a32d288a..4fad3fb37 100644 --- a/websites/kibo.money/packages/lightweight-charts/wrapper.js +++ b/websites/kibo.money/packages/lightweight-charts/wrapper.js @@ -1,6 +1,26 @@ // @ts-check -/** @import {IChartApi, ISeriesApi, SeriesDefinition} from './v5.0.5-treeshaked/types' */ +/** @import {IChartApi, ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData} from './v5.0.5-treeshaked/types' */ + +/** + * @typedef {[number, number, number, number]} OHLCTuple + * + * @typedef {Object} Valued + * @property {number} value + * + * @typedef {Object} Indexed + * @property {number} index + */ + +/** + * @template T + * @typedef {T & Valued & Indexed} ChartData + */ + +/** + * @typedef {ChartData<_SingleValueData>} SingleValueData + * @typedef {ChartData<_CandlestickData>} CandlestickData + */ export default import("./v5.0.5-treeshaked/script.js").then((lc) => { const oklchToRGBA = createOklchToRGBA(); @@ -752,6 +772,7 @@ function createPriceScaleSelectorIfNeeded({ }, }, ); + const field = utils.dom.createHorizontalChoiceField({ title: unit, selected: serializedValue(), @@ -759,6 +780,7 @@ function createPriceScaleSelectorIfNeeded({ id: unit, signals, }); + field.addEventListener("change", (event) => { // @ts-ignore const value = event.target.value; diff --git a/websites/kibo.money/packages/solid-signals/README.md b/websites/kibo.money/packages/solid-signals/README.md deleted file mode 100644 index 86c60cb62..000000000 --- a/websites/kibo.money/packages/solid-signals/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Compiled version of: https://github.com/solidjs/signals/commits/main/ - -Head: -- SHA: 4d75d3f84ce22b560988f3b27a5065c0fd2e69a8 -- Date: Apr 17, 2024 diff --git a/websites/kibo.money/scripts/main.js b/websites/kibo.money/scripts/main.js index 9621356ce..47b6be97e 100644 --- a/websites/kibo.money/scripts/main.js +++ b/websites/kibo.money/scripts/main.js @@ -1,8 +1,8 @@ // @ts-check /** - * @import { Option, Weighted, Color, DatasetCandlestickData, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple, Unit } from "./types/self" - * @import { Marker, CreatePaneParameters, HoveredLegend, ChartPane, SplitSeries, SingleSeries, CreateSplitSeriesParameters, LineSeriesBlueprint, CandlestickSeriesBlueprint, BaselineSeriesBlueprint, CreateBaseSeriesParameters, BaseSeries, RemoveSeriesBlueprintFluff, SplitSeriesBlueprint, AnySeries, PriceSeriesType } from "../packages/lightweight-charts/types"; + * @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Unit } from "./types/self" + * @import {Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple} from "../packages/lightweight-charts/wrapper" * @import * as _ from "../packages/ufuzzy/v1.0.14/types" * @import { createChart as CreateClassicChart, LineStyleOptions, DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, ISeriesApi, Time, LineData, LogicalRange, SeriesType, BaselineStyleOptions, SeriesOptionsCommon } from "../packages/lightweight-charts/v5.0.5-treeshaked/types" * @import { SignalOptions } from "../packages/solid-signals/v0.2.4-treeshaked/types/core/core" @@ -885,12 +885,12 @@ function createUtils() { return v ? Number(v) : null; }, }, - date: { + optDate: { /** - * @param {Date} v + * @param {Date | null} date */ - serialize(v) { - return date.toString(v); + serialize(date) { + return date !== null ? date.toString() : ""; }, /** * @param {string} v @@ -1609,6 +1609,8 @@ function createColors(dark, elements) { } /** * @typedef {ReturnType} Colors + * @typedef {Colors["orange"]} Color + * @typedef {keyof Colors} ColorName */ /** @@ -1676,7 +1678,7 @@ function initWebSockets(signals, utils) { } /** - * @param {(candle: DatasetCandlestickData) => void} callback + * @param {(candle: CandlestickData) => void} callback * @param {number} interval */ function krakenCandleWebSocketCreator(callback, interval) { @@ -1706,7 +1708,7 @@ function initWebSockets(signals, utils) { const dateStr = utils.date.toString(date); - /** @type {DatasetCandlestickData} */ + /** @type {CandlestickData} */ const candle = { index: -1, time: dateStr, diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index 3c801b96b..81aae29b5 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -2,7 +2,7 @@ /** * @import { CohortOption, CohortOptions, Color, DefaultCohortOption, DefaultCohortOptions, OptionsGroup, PartialChartOption, PartialOptionsGroup, PartialOptionsTree, RatioOption, RatioOptions, Unit } from "./types/self" - * @import {AnySpecificSeriesBlueprint, SplitSeriesBlueprint} from '../packages/lightweight-charts/types'; + * @import { AnySeriesBlueprint} from '../packages/lightweight-charts/wrapper'; */ function initGroups() { @@ -2815,7 +2815,7 @@ function createPartialOptions(colors) { // generateSeriesBlueprints(arg, blueprint) { // return this.toList(arg).map( // ({ scale, datasetId, color, name }) => - // /** @satisfies {SplitSeriesBlueprint} */ ({ + // /** @satisfies {AnySeriesBlueprint} */ ({ // title: cohortOptionOrOptions.toLegendName( // arg, // name, @@ -5159,7 +5159,7 @@ export function initOptions({ const optionsIds = env.localhost ? [] : undefined; // /** - // * @param {SplitSeriesBlueprint[]} array + // * @param {AnySeriesBlueprint[]} array // */ // function getMainIdFromBlueprints(array) { // const searchArray = array.filter( diff --git a/websites/kibo.money/scripts/simulation.js b/websites/kibo.money/scripts/simulation.js index 67a11b94e..db0ad166d 100644 --- a/websites/kibo.money/scripts/simulation.js +++ b/websites/kibo.money/scripts/simulation.js @@ -10,8 +10,6 @@ */ export function init({ colors, elements, lightweightCharts, signals, utils }) { /** - * @import { ColorName } from './types/self'; - * * @typedef {Object} Frequency * @property {string} name * @property {string} value @@ -151,7 +149,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { initial: { amount: signals.createSignal(/** @type {number | null} */ (1000), { save: { - ...utils.serde.number, + ...utils.serde.optNumber, keyPrefix, key: "initial-amount", }, @@ -160,7 +158,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { topUp: { amount: signals.createSignal(/** @type {number | null} */ (150), { save: { - ...utils.serde.number, + ...utils.serde.optNumber, keyPrefix, key: "top-up-amount", }, @@ -181,14 +179,14 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { investment: { initial: signals.createSignal(/** @type {number | null} */ (1000), { save: { - ...utils.serde.number, + ...utils.serde.optNumber, keyPrefix, key: "initial-swap", }, }), recurrent: signals.createSignal(/** @type {number | null} */ (5), { save: { - ...utils.serde.number, + ...utils.serde.optNumber, keyPrefix, key: "recurrent-swap", }, @@ -210,7 +208,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { /** @type {Date | null} */ (new Date("2021-04-15")), { save: { - ...utils.serde.date, + ...utils.serde.optDate, keyPrefix, key: "interval-start", }, @@ -218,7 +216,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { ), end: signals.createSignal(/** @type {Date | null} */ (new Date()), { save: { - ...utils.serde.date, + ...utils.serde.optDate, keyPrefix, key: "interval-end", }, @@ -227,7 +225,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { fees: { percentage: signals.createSignal(/** @type {number | null} */ (0.25), { save: { - ...utils.serde.number, + ...utils.serde.optNumber, keyPrefix, key: "percentage", }, @@ -545,8 +543,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { signals, colors, id: `simulation-0`, - kind: "static", - scale: "date", + fitContentOnResize: true, utils, config: [ { @@ -586,8 +583,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { signals, colors, id: `simulation-1`, - scale: "date", - kind: "static", + fitContentOnResize: true, utils, config: [ { @@ -609,8 +605,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { signals, colors, id: `simulation-average-price`, - scale: "date", - kind: "static", + fitContentOnResize: true, utils, config: [ { @@ -638,8 +633,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { signals, colors, id: `simulation-return-ratio`, - scale: "date", - kind: "static", + fitContentOnResize: true, utils, config: [ { @@ -670,8 +664,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { signals, colors, id: `simulation-profitability-ratios`, - kind: "static", - scale: "date", + fitContentOnResize: true, utils, owner, config: [ @@ -939,36 +932,43 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) { p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`; - signals.createEffect(lastValues, (lastValues) => { - const lowestAnnual4YReturn = 0.2368; - // const lowestAnnual4YReturn = lastValues?.["price-4y-compound-return"] || 0 - const serLowestAnnual4YReturn = c( - "cyan", - `${fp(lowestAnnual4YReturn)}`, - ); - - const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn; - /** - * @param {number} power - */ - function bitcoinValueReturn(power) { - return ( - bitcoinValue * Math.pow(lowestAnnual4YReturnPercentage, power) + signals.createEffect( + () => 0.2368, + (lowestAnnual4YReturn) => { + const serLowestAnnual4YReturn = c( + "cyan", + `${fp(lowestAnnual4YReturn)}`, ); - } - const bitcoinValueAfter4y = bitcoinValueReturn(4); - const serBitcoinValueAfter4y = c("purple", fd(bitcoinValueAfter4y)); - const bitcoinValueAfter10y = bitcoinValueReturn(10); - const serBitcoinValueAfter10y = c( - "fuchsia", - fd(bitcoinValueAfter10y), - ); - const bitcoinValueAfter21y = bitcoinValueReturn(21); - const serBitcoinValueAfter21y = c("pink", fd(bitcoinValueAfter21y)); - /** @param {number} v */ - p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.
Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`; - }); + const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn; + /** + * @param {number} power + */ + function bitcoinValueReturn(power) { + return ( + bitcoinValue * Math.pow(lowestAnnual4YReturnPercentage, power) + ); + } + const bitcoinValueAfter4y = bitcoinValueReturn(4); + const serBitcoinValueAfter4y = c( + "purple", + fd(bitcoinValueAfter4y), + ); + const bitcoinValueAfter10y = bitcoinValueReturn(10); + const serBitcoinValueAfter10y = c( + "fuchsia", + fd(bitcoinValueAfter10y), + ); + const bitcoinValueAfter21y = bitcoinValueReturn(21); + const serBitcoinValueAfter21y = c( + "pink", + fd(bitcoinValueAfter21y), + ); + + /** @param {number} v */ + p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.
Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`; + }, + ); totalInvestedAmountData.set((a) => a); bitcoinValueData.set((a) => a); diff --git a/websites/kibo.money/scripts/types/self.d.ts b/websites/kibo.money/scripts/types/self.d.ts index 8266f5115..51e2bcc3a 100644 --- a/websites/kibo.money/scripts/types/self.d.ts +++ b/websites/kibo.money/scripts/types/self.d.ts @@ -1,28 +1,17 @@ -import { - Accessor, - Setter, -} from "../../packages/solid-signals/v0.2.4-treeshaked/types/signals"; +import { Accessor } from "../../packages/solid-signals/v0.2.4-treeshaked/types/signals"; import { DeepPartial, BaselineStyleOptions, CandlestickStyleOptions, LineStyleOptions, SeriesOptionsCommon, - IRange, Time, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, - SeriesType, - ISeriesApi, BaselineData, } from "../../packages/lightweight-charts/v5.0.5-treeshaked/types"; -import { AnyPossibleCohortId, Groups } from "../options"; +import { AnyPossibleCohortId } from "../options"; -type Color = () => string; -type ColorName = keyof Colors; - -// TODO: Compute from VecId when displaying the Unit -// And write a checker when localhost, similar to the dup one type Unit = | "" | "Bitcoin" @@ -47,11 +36,39 @@ interface PartialOption { name: string; } +interface BaseSeriesBlueprint { + title: string; + key: VecId; + defaultActive?: boolean; +} +interface BaselineSeriesBlueprint extends BaseSeriesBlueprint { + type: "Baseline"; + color?: Color; + options?: DeepPartial; + data?: Accessor[]>; +} +interface CandlestickSeriesBlueprint extends BaseSeriesBlueprint { + type: "Candlestick"; + color?: Color; + options?: DeepPartial; + data?: Accessor; +} +interface LineSeriesBlueprint extends BaseSeriesBlueprint { + type?: "Line"; + color: Color; + options?: DeepPartial; + data?: Accessor[]>; +} +type AnySeriesBlueprint = + | BaselineSeriesBlueprint + | CandlestickSeriesBlueprint + | LineSeriesBlueprint; + interface PartialChartOption extends PartialOption { title?: string; unit?: Unit; - top?: SplitSeriesBlueprint[]; - bottom?: SplitSeriesBlueprint[]; + top?: AnySeriesBlueprint[]; + bottom?: AnySeriesBlueprint[]; } interface PartialSimulationOption extends PartialOption { @@ -105,34 +122,6 @@ interface OptionsGroup extends PartialOptionsGroup { tree: OptionsTree; } -type OHLCTuple = [number, number, number, number]; - -interface Valued { - value: number; -} -interface Indexed { - index: number; -} -type ChartData = T & Valued & Indexed; -type SingleValueData = ChartData<_SingleValueData>; -type CandlestickData = ChartData<_CandlestickData>; - -type FetchedSource = string; - -interface FetchedChunk { - id: number; - previous: string | null; - next: string | null; -} - -interface Weighted { - weight: number; -} - -type DatasetCandlestickData = ChartData; - -// type NotFunction = T extends Function ? never : T; - type DefaultCohortOption = CohortOption; interface CohortOption { @@ -162,7 +151,3 @@ interface RatioOptions { title: string; list: RatioOption[]; } - -// TODO: Remove -// Fetch last of each individually when in viewport -// type LastValues = Record | null;