@velora-dex/widget 0.2.5-dev.4 → 0.2.5-dev.5

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.
Files changed (47) hide show
  1. package/dist/components/widget/OrderExpiryInput/index.d.ts.map +1 -1
  2. package/dist/components/widget/OrderExpiryInput/index.js +49 -68
  3. package/dist/components/widget/OrderExpiryInput/index.js.map +1 -1
  4. package/dist/components/widget/SwapModeSwitcher/state/swapSideAtom.d.ts.map +1 -1
  5. package/dist/components/widget/SwapModeSwitcher/state/swapSideAtom.js +0 -5
  6. package/dist/components/widget/SwapModeSwitcher/state/swapSideAtom.js.map +1 -1
  7. package/dist/configurator/Configurator.d.ts.map +1 -1
  8. package/dist/configurator/components/FormPropsInputs.d.ts.map +1 -1
  9. package/dist/core/inputs/state/common.d.ts +7 -9
  10. package/dist/core/inputs/state/common.d.ts.map +1 -1
  11. package/dist/core/inputs/state/common.js +18 -24
  12. package/dist/core/inputs/state/common.js.map +1 -1
  13. package/dist/core/inputs/state/setTokenByAddressAtom.d.ts +1 -1
  14. package/dist/core/inputs/state/setTokenByAddressAtom.d.ts.map +1 -1
  15. package/dist/core/inputs/state/setTokenByAddressAtom.js +46 -40
  16. package/dist/core/inputs/state/setTokenByAddressAtom.js.map +1 -1
  17. package/dist/core/inputs/state/types.d.ts +1 -3
  18. package/dist/core/inputs/state/types.d.ts.map +1 -1
  19. package/dist/core/limit/state/deadlineAtom.d.ts +8 -4
  20. package/dist/core/limit/state/deadlineAtom.d.ts.map +1 -1
  21. package/dist/core/limit/state/deadlineAtom.js +16 -32
  22. package/dist/core/limit/state/deadlineAtom.js.map +1 -1
  23. package/dist/core/limit/state/limitInputActionsAtom.d.ts +3 -3
  24. package/dist/core/limit/state/limitInputActionsAtom.d.ts.map +1 -1
  25. package/dist/core/limit/state/limitInputActionsAtom.js +8 -8
  26. package/dist/core/limit/state/limitInputActionsAtom.js.map +1 -1
  27. package/dist/core/limit/state/utils.d.ts +2 -1
  28. package/dist/core/limit/state/utils.d.ts.map +1 -1
  29. package/dist/core/limit/state/utils.js +13 -1
  30. package/dist/core/limit/state/utils.js.map +1 -1
  31. package/dist/core/otc/state/deadlineAtom.d.ts +7 -6
  32. package/dist/core/otc/state/deadlineAtom.d.ts.map +1 -1
  33. package/dist/core/otc/state/deadlineAtom.js +16 -33
  34. package/dist/core/otc/state/deadlineAtom.js.map +1 -1
  35. package/dist/core/otc/state/otcInputActionsAtom.d.ts +3 -3
  36. package/dist/core/otc/state/otcInputActionsAtom.d.ts.map +1 -1
  37. package/dist/core/otc/state/otcInputActionsAtom.js +8 -8
  38. package/dist/core/otc/state/otcInputActionsAtom.js.map +1 -1
  39. package/dist/core/state/currentSwapInputAtom.d.ts +1 -1
  40. package/dist/core/state/currentSwapInputAtom.d.ts.map +1 -1
  41. package/dist/core/state/currentSwapInputAtom.js +1 -5
  42. package/dist/core/state/currentSwapInputAtom.js.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.d.ts +0 -5
  45. package/dist/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.d.ts.map +0 -1
  46. package/dist/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.js +0 -6
  47. package/dist/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/core/limit/state/utils.ts"],"sourcesContent":["import Big from \"big.js\";\nimport type { TimeUnitObject } from \"./deadlineAtom\";\nimport type { PriceRates } from \"../types\";\nimport { neverTimeUnit, zeroRates } from \"./constants\";\n\nexport function timeUnitToSeconds(timeUnitObj: TimeUnitObject) {\n switch (timeUnitObj.label) {\n case \"minutes\":\n return timeUnitObj.value * 60;\n case \"hours\":\n return timeUnitObj.value * 60 * 60;\n case \"days\":\n return timeUnitObj.value * 60 * 60 * 24;\n case \"months\":\n return timeUnitObj.value * 60 * 60 * 24 * 30;\n default:\n return 0;\n }\n}\n\nconst units = [\n { label: \"months\", ms: 30 * 24 * 60 * 60 * 1000 },\n { label: \"days\", ms: 24 * 60 * 60 * 1000 },\n { label: \"hours\", ms: 60 * 60 * 1000 },\n { label: \"minutes\", ms: 60 * 1000 },\n] as const;\n\nexport function getClosestTimeUnit(timestampS: number) {\n if (timestampS <= 0) return neverTimeUnit;\n const timestampMs = timestampS * 1000;\n\n const now = Date.now();\n\n if (timestampMs <= now) return neverTimeUnit;\n\n const diffMs = timestampMs - now;\n\n for (const unit of units) {\n const value = Math.floor(diffMs / unit.ms);\n if (value > 0) {\n return {\n label: unit.label,\n value,\n };\n }\n }\n return neverTimeUnit;\n}\n\nexport function calculateReceiveAmount(\n payAmount: string,\n priceRates: PriceRates,\n isReversed: boolean\n) {\n const pay = Big(payAmount || \"0\");\n\n if (isReversed) {\n // price = from/to → receive = pay / price\n const price = Big(priceRates.rateReversed || \"0\");\n if (price.eq(0)) return \"0\";\n return pay.div(price).toFixed();\n }\n\n const price = Big(priceRates.rate || \"0\");\n // normal: price = to/from → receive = pay * price\n return pay.mul(price).toFixed();\n}\n\nexport function calculatePayAmount(\n receiveAmount: string,\n priceRates: PriceRates,\n isReversed: boolean\n) {\n const receive = Big(receiveAmount || \"0\");\n\n if (isReversed) {\n // price = from/to → pay = receive * price\n const price = Big(priceRates.rateReversed || \"0\");\n return receive.mul(price).toFixed();\n }\n\n // normal: pay = receive / price\n const price = Big(priceRates.rate || \"0\");\n if (price.eq(0)) return \"0\";\n return receive.div(price).toFixed();\n}\n\nexport function calculateRates(\n receiveAmount: string,\n payAmount: string\n): PriceRates {\n const receive = Big(receiveAmount || \"0\");\n const pay = Big(payAmount || \"0\");\n\n if (pay.eq(0) || receive.eq(0)) return zeroRates;\n\n // normal: price = to/from → price = receive / pay\n const rate = receive.div(pay).toFixed();\n // reversed: price = from/to → price = pay / receive\n const rateReversed = pay.div(receive).toFixed();\n\n return { rate, rateReversed };\n}\n\nexport function getUpdatedRates(\n value: string,\n isReversed: boolean\n): PriceRates {\n const bigPrice = Big(value || 0);\n if (!bigPrice.eq(0)) {\n const rate = bigPrice.toFixed();\n const rateReversed = Big(1).div(bigPrice).toFixed();\n\n return isReversed\n ? { rate: rateReversed, rateReversed: rate }\n : { rate, rateReversed };\n }\n return zeroRates;\n}\n"],"names":["timeUnitToSeconds","timeUnitObj","label","value","units","ms","getClosestTimeUnit","timestampS","neverTimeUnit","timestampMs","now","Date","diffMs","unit","Math","floor","calculateReceiveAmount","payAmount","priceRates","isReversed","pay","Big","price","rateReversed","eq","div","toFixed","rate","mul","calculatePayAmount","receiveAmount","receive","calculateRates","zeroRates","getUpdatedRates","bigPrice"],"mappings":";;;AAKO,SAASA,kBAAkBC,WAAAA,EAA6B;AAC7D,EAAA,QAAQA,YAAYC,KAAAA;AAAK,IACvB,KAAK,SAAA;AACH,MAAA,OAAOD,YAAYE,KAAAA,GAAQ,EAAA;AAAA,IAC7B,KAAK,OAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,QAAQ,EAAA,GAAK,EAAA;AAAA,IAClC,KAAK,MAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,KAAAA,GAAQ,EAAA,GAAK,EAAA,GAAK,EAAA;AAAA,IACvC,KAAK,QAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,KAAAA,GAAQ,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA;AAAA,IAC5C;AACE,MAAA,OAAO,CAAA;AAAA;AAEb;AAEA,MAAMC,QAAQ,CACZ;AAAA,EAAEF,KAAAA,EAAO,QAAA;AAAA,EAAUG,EAAAA,EAAI,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK;AAAK,CAAA,EAChD;AAAA,EAAEH,KAAAA,EAAO,MAAA;AAAA,EAAQG,EAAAA,EAAI,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK;AAAK,CAAA,EACzC;AAAA,EAAEH,KAAAA,EAAO,OAAA;AAAA,EAASG,EAAAA,E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C,IAAAA;AAAAA,IAAMJ;AAAAA,GAAa;AAC9B;AAEO,SAASW,eAAAA,CACd/B,OACAgB,UAAAA,EACY;AACZ,EAAA,MAAMgB,QAAAA,GAAWd,GAAAA,CAAIlB,KAAAA,IAAS,CAAC,CAAA;AAC/B,EAAA,IAAI,CAACgC,QAAAA,CAASX,EAAAA,CAAG,CAAC,CAAA,EAAG;AACnB,IAAA,MAAMG,IAAAA,GAAOQ,SAAST,OAAAA,EAAQ;AAC9B,IAAA,MAAMH,eAAeF,GAAAA,CAAI,CAAC,EAAEI,GAAAA,CAAIU,QAAQ,EAAET,OAAAA,EAAQ;AAElD,IAAA,OAAOP,UAAAA,GACH;AAAA,MAAEQ,IAAAA,EAAMJ,YAAAA;AAAAA,MAAcA,YAAAA,EAAcI;AAAAA,KAAK,GACzC;AAAA,MAAEA,IAAAA;AAAAA,MAAMJ;AAAAA,KAAa;AAAA,EAC3B;AACA,EAAA,OAAOU,SAAAA;AACT;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/core/limit/state/utils.ts"],"sourcesContent":["import Big from \"big.js\";\nimport type { TimeUnitObject, TimeUnitState } from \"./deadlineAtom\";\nimport type { PriceRates } from \"../types\";\nimport { neverTimeUnit, zeroRates } from \"./constants\";\n\nexport function timeUnitToSeconds(timeUnitObj: TimeUnitObject) {\n switch (timeUnitObj.label) {\n case \"minutes\":\n return timeUnitObj.value * 60;\n case \"hours\":\n return timeUnitObj.value * 60 * 60;\n case \"days\":\n return timeUnitObj.value * 60 * 60 * 24;\n case \"months\":\n return timeUnitObj.value * 60 * 60 * 24 * 30;\n default:\n return 0;\n }\n}\n\nexport function getTimeUnitState(\n timeUnitObj: TimeUnitObject | TimeUnitState\n): TimeUnitState {\n if (isTimeUnitState(timeUnitObj)) {\n return timeUnitObj;\n }\n return {\n ...timeUnitObj,\n timestamp:\n timeUnitObj.label === neverTimeUnit.label\n ? 0\n : Math.floor(Date.now() / 1000 + timeUnitToSeconds(timeUnitObj)),\n };\n}\n\nfunction isTimeUnitState(\n timeUnitObj: TimeUnitObject | TimeUnitState\n): timeUnitObj is TimeUnitState {\n return \"timestamp\" in timeUnitObj && timeUnitObj.timestamp !== undefined;\n}\n\nconst units = [\n { label: \"months\", ms: 30 * 24 * 60 * 60 * 1000 },\n { label: \"days\", ms: 24 * 60 * 60 * 1000 },\n { label: \"hours\", ms: 60 * 60 * 1000 },\n { label: \"minutes\", ms: 60 * 1000 },\n] as const;\n\nexport function getClosestTimeUnit(timestampS: number) {\n if (timestampS <= 0) return neverTimeUnit;\n const timestampMs = timestampS * 1000;\n\n const now = Date.now();\n\n if (timestampMs <= now) return neverTimeUnit;\n\n const diffMs = timestampMs - now;\n\n for (const unit of units) {\n const value = Math.floor(diffMs / unit.ms);\n if (value > 0) {\n return {\n label: unit.label,\n value,\n };\n }\n }\n return neverTimeUnit;\n}\n\nexport function calculateReceiveAmount(\n payAmount: string,\n priceRates: PriceRates,\n isReversed: boolean\n) {\n const pay = Big(payAmount || \"0\");\n\n if (isReversed) {\n // price = from/to → receive = pay / price\n const price = Big(priceRates.rateReversed || \"0\");\n if (price.eq(0)) return \"0\";\n return pay.div(price).toFixed();\n }\n\n const price = Big(priceRates.rate || \"0\");\n // normal: price = to/from → receive = pay * price\n return pay.mul(price).toFixed();\n}\n\nexport function calculatePayAmount(\n receiveAmount: string,\n priceRates: PriceRates,\n isReversed: boolean\n) {\n const receive = Big(receiveAmount || \"0\");\n\n if (isReversed) {\n // price = from/to → pay = receive * price\n const price = Big(priceRates.rateReversed || \"0\");\n return receive.mul(price).toFixed();\n }\n\n // normal: pay = receive / price\n const price = Big(priceRates.rate || \"0\");\n if (price.eq(0)) return \"0\";\n return receive.div(price).toFixed();\n}\n\nexport function calculateRates(\n receiveAmount: string,\n payAmount: string\n): PriceRates {\n const receive = Big(receiveAmount || \"0\");\n const pay = Big(payAmount || \"0\");\n\n if (pay.eq(0) || receive.eq(0)) return zeroRates;\n\n // normal: price = to/from → price = receive / pay\n const rate = receive.div(pay).toFixed();\n // reversed: price = from/to → price = pay / receive\n const rateReversed = pay.div(receive).toFixed();\n\n return { rate, rateReversed };\n}\n\nexport function getUpdatedRates(\n value: string,\n isReversed: boolean\n): PriceRates {\n const bigPrice = Big(value || 0);\n if (!bigPrice.eq(0)) {\n const rate = bigPrice.toFixed();\n const rateReversed = Big(1).div(bigPrice).toFixed();\n\n return isReversed\n ? { rate: rateReversed, rateReversed: rate }\n : { rate, rateReversed };\n }\n return zeroRates;\n}\n"],"names":["timeUnitToSeconds","timeUnitObj","label","value","getTimeUnitState","isTimeUnitState","timestamp","neverTimeUnit","Math","floor","Date","now","undefined","units","ms","getClosestTimeUnit","timestampS","timestampMs","diffMs","unit","calculateReceiveAmount","payAmount","priceRates","isReversed","pay","Big","price","rateReversed","eq","div","toFixed","rate","mul","calculatePayAmount","receiveAmount","receive","calculateRates","zeroRates","getUpdatedRates","bigPrice"],"mappings":";;;AAKO,SAASA,kBAAkBC,WAAAA,EAA6B;AAC7D,EAAA,QAAQA,YAAYC,KAAAA;AAAK,IACvB,KAAK,SAAA;AACH,MAAA,OAAOD,YAAYE,KAAAA,GAAQ,EAAA;AAAA,IAC7B,KAAK,OAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,QAAQ,EAAA,GAAK,EAAA;AAAA,IAClC,KAAK,MAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,KAAAA,GAAQ,EAAA,GAAK,EAAA,GAAK,EAAA;AAAA,IACvC,KAAK,QAAA;AACH,MAAA,OAAOF,WAAAA,CAAYE,KAAAA,GAAQ,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA;AAAA,IAC5C;AACE,MAAA,OAAO,CAAA;AAAA;AAEb;AAEO,SAASC,iBACdH,WAAAA,EACe;AACf,EAAA,IAAII,eAAAA,CAAgBJ,WAAW,CAAA,EAAG;AAChC,IAAA,OAAOA,WAAAA;AAAAA,EACT;AACA,EAAA,OAAO;AAAA,IACL,GAAGA,WAAAA;AAAAA,IAC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U,SAAAA;AACT;;;;"}
@@ -1,10 +1,11 @@
1
- import { TimeUnitObject } from '../../limit/state/deadlineAtom';
1
+ import { TimeUnitState } from '../../limit/state/deadlineAtom';
2
2
  import { SetStateAction } from 'jotai';
3
- export declare const timeUnitAtom: import('jotai').WritableAtom<TimeUnitObject, [newTimeUnit: SetStateAction<TimeUnitObject>, resetDeadlineFromProps?: boolean | undefined], void> & {
4
- init: TimeUnitObject;
5
- };
6
- export declare const deadlineFromPropsAtom: import('jotai').WritableAtom<number | undefined, [number | undefined], void> & {
7
- init: number | undefined;
3
+ export declare const timeUnitAtom: import('jotai').WritableAtom<TimeUnitState, [SetStateAction<{
4
+ label: import('../../limit/state/deadlineAtom').TimeUnit;
5
+ value: number;
6
+ timestamp?: number | undefined;
7
+ }>], void> & {
8
+ init: TimeUnitState;
8
9
  };
9
10
  export declare const deadlineAtom: import('jotai').Atom<number>;
10
11
  export declare const useOtcDeadline: () => number;
@@ -1 +1 @@
1
- {"version":3,"file":"deadlineAtom.d.ts","sourceRoot":"","sources":["../../../../src/core/otc/state/deadlineAtom.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAEhE,eAAO,MAAM,YAAY;;CAiBvB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;CAmBjC,CAAC;AAEF,eAAO,MAAM,YAAY,8BAkBvB,CAAC;AAEH,eAAO,MAAM,cAAc,cAE1B,CAAC"}
1
+ {"version":3,"file":"deadlineAtom.d.ts","sourceRoot":"","sources":["../../../../src/core/otc/state/deadlineAtom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAGhE,eAAO,MAAM,YAAY;;;;;;CAyBvB,CAAC;AAEH,eAAO,MAAM,YAAY,8BAA6C,CAAC;AAEvE,eAAO,MAAM,cAAc,cAE1B,CAAC"}
@@ -1,42 +1,25 @@
1
- import { defaultTimeUnit, neverTimeUnit, minTimeUnit } from '../../limit/state/constants.js';
2
- import { getClosestTimeUnit, timeUnitToSeconds } from '../../limit/state/utils.js';
1
+ import { defaultTimeUnit, minTimeUnit } from '../../limit/state/constants.js';
2
+ import { getTimeUnitState } from '../../limit/state/utils.js';
3
3
  import { atom, useAtomValue } from 'jotai';
4
4
 
5
- const timeUnitAtom = atom(defaultTimeUnit, (get, set, newTimeUnit, resetDeadlineFromProps) => {
6
- const updatedTimeUnit = typeof newTimeUnit === "function" ? newTimeUnit(get(timeUnitAtom)) : newTimeUnit;
7
- set(timeUnitAtom, updatedTimeUnit);
8
- if (resetDeadlineFromProps) {
9
- set(deadlineFromPropsAtom, void 0);
5
+ const timeUnitAtom = atom(getTimeUnitState(defaultTimeUnit), (get, set, _newState) => {
6
+ const newState = typeof _newState === "function" ? _newState(get(timeUnitAtom)) : _newState;
7
+ let stateToSet = getTimeUnitState(newState);
8
+ const minTimeUnitState = getTimeUnitState(minTimeUnit);
9
+ const isTimestampInvalid = (
10
+ // OTC can have 0 deadline
11
+ stateToSet.timestamp > 0 && stateToSet.timestamp < minTimeUnitState.timestamp
12
+ );
13
+ const isUnitInvalid = stateToSet.label === minTimeUnit.label && stateToSet.value < minTimeUnitState.value;
14
+ if (isTimestampInvalid || isUnitInvalid) {
15
+ stateToSet = minTimeUnitState;
10
16
  }
17
+ set(timeUnitAtom, stateToSet);
11
18
  });
12
- const deadlineFromPropsAtom = atom(
13
- void 0,
14
- // timestamp in seconds
15
- (get, set, newDeadline) => {
16
- set(deadlineFromPropsAtom, newDeadline);
17
- if (newDeadline === void 0) return;
18
- const currentDeadlineTimeUnit = get(timeUnitAtom);
19
- const newDeadlineTimeUnit = getClosestTimeUnit(newDeadline);
20
- if (currentDeadlineTimeUnit.label !== newDeadlineTimeUnit.label || currentDeadlineTimeUnit.value !== newDeadlineTimeUnit.value) {
21
- set(timeUnitAtom, newDeadlineTimeUnit);
22
- }
23
- }
24
- );
25
- const deadlineAtom = atom((get) => {
26
- const deadlineFromProps = get(deadlineFromPropsAtom);
27
- if (deadlineFromProps) {
28
- return deadlineFromProps;
29
- }
30
- let timeUnit = get(timeUnitAtom);
31
- if (timeUnit.label === neverTimeUnit.label) return 0;
32
- if (timeUnit.label === minTimeUnit.label && timeUnit.value < minTimeUnit.value) {
33
- timeUnit = minTimeUnit;
34
- }
35
- return Math.floor(Date.now() / 1e3 + timeUnitToSeconds(timeUnit));
36
- });
19
+ const deadlineAtom = atom((get) => get(timeUnitAtom).timestamp);
37
20
  const useOtcDeadline = () => {
38
21
  return useAtomValue(deadlineAtom);
39
22
  };
40
23
 
41
- export { deadlineAtom, deadlineFromPropsAtom, timeUnitAtom, useOtcDeadline };
24
+ export { deadlineAtom, timeUnitAtom, useOtcDeadline };
42
25
  //# sourceMappingURL=deadlineAtom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deadlineAtom.js","sources":["../../../../src/core/otc/state/deadlineAtom.ts"],"sourcesContent":["import {\n minTimeUnit,\n neverTimeUnit,\n defaultTimeUnit,\n} from \"@/core/limit/state/constants\";\nimport type { TimeUnitObject } from \"@/core/limit/state/deadlineAtom\";\nimport {\n getClosestTimeUnit,\n timeUnitToSeconds,\n} from \"@/core/limit/state/utils\";\nimport { atom, useAtomValue, type SetStateAction } from \"jotai\";\n\nexport const timeUnitAtom = atom<\n TimeUnitObject,\n [\n newTimeUnit: SetStateAction<TimeUnitObject>,\n resetDeadlineFromProps?: boolean,\n ],\n void\n>(defaultTimeUnit, (get, set, newTimeUnit, resetDeadlineFromProps) => {\n const updatedTimeUnit =\n typeof newTimeUnit === \"function\"\n ? newTimeUnit(get(timeUnitAtom))\n : newTimeUnit;\n set(timeUnitAtom, updatedTimeUnit);\n\n if (resetDeadlineFromProps) {\n set(deadlineFromPropsAtom, undefined);\n }\n});\n\nexport const deadlineFromPropsAtom = atom<\n number | undefined,\n [number | undefined],\n void\n>(\n undefined, // timestamp in seconds\n (get, set, newDeadline) => {\n set(deadlineFromPropsAtom, newDeadline);\n if (newDeadline === undefined) return;\n\n const currentDeadlineTimeUnit = get(timeUnitAtom);\n const newDeadlineTimeUnit = getClosestTimeUnit(newDeadline);\n if (\n currentDeadlineTimeUnit.label !== newDeadlineTimeUnit.label ||\n currentDeadlineTimeUnit.value !== newDeadlineTimeUnit.value\n ) {\n set(timeUnitAtom, newDeadlineTimeUnit);\n }\n }\n);\n\nexport const deadlineAtom = atom((get) => {\n const deadlineFromProps = get(deadlineFromPropsAtom);\n\n if (deadlineFromProps) {\n return deadlineFromProps;\n }\n\n let timeUnit = get(timeUnitAtom);\n if (timeUnit.label === neverTimeUnit.label) return 0;\n\n if (\n timeUnit.label === minTimeUnit.label &&\n timeUnit.value < minTimeUnit.value\n ) {\n timeUnit = minTimeUnit;\n }\n\n return Math.floor(Date.now() / 1000 + timeUnitToSeconds(timeUnit));\n});\n\nexport const useOtcDeadline = () => {\n return useAtomValue(deadlineAtom);\n};\n"],"names":["timeUnitAtom","atom","defaultTimeUnit","get","set","newTimeUnit","resetDeadlineFromProps","updatedTimeUnit","deadlineFromPropsAtom","undefined","newDeadline","currentDeadlineTimeUnit","newDeadlineTimeUnit","getClosestTimeUnit","label","value","deadlineAtom","deadlineFromProps","timeUnit","neverTimeUnit","minTimeUnit","Math","floor","Date","now","timeUnitToSeconds","useOtcDeadline","useAtomValue"],"mappings":";;;;AAYO,MAAMA,eAAeC,IAAAA,CAO1BC,eAAAA,EAAiB,CAACC,GAAAA,EAAKC,GAAAA,EAAKC,aAAaC,sBAAAA,KAA2B;AACpE,EAAA,MAAMC,eAAAA,GACJ,OAAOF,WAAAA,KAAgB,UAAA,GACnBA,YAAYF,GAAAA,CAAIH,YAAY,CAAC,CAAA,GAC7BK,WAAAA;AACND,EAAAA,GAAAA,CAAIJ,cAAcO,eAAe,CAAA;AAEjC,EAAA,IAAID,sBAAAA,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AAC;AAEM,MAAMQ,iBAAiBA,MAAA;AAAA,EAAA,OACrBC,aAAaX,YAAY,CAAA;AAAC;;;;"}
1
+ {"version":3,"file":"deadlineAtom.js","sources":["../../../../src/core/otc/state/deadlineAtom.ts"],"sourcesContent":["import { defaultTimeUnit, minTimeUnit } from \"@/core/limit/state/constants\";\nimport type { TimeUnitState } from \"@/core/limit/state/deadlineAtom\";\nimport { getTimeUnitState } from \"@/core/limit/state/utils\";\nimport { atom, useAtomValue, type SetStateAction } from \"jotai\";\nimport type { MarkOptional } from \"ts-essentials\";\n\nexport const timeUnitAtom = atom<\n TimeUnitState,\n [SetStateAction<MarkOptional<TimeUnitState, \"timestamp\">>],\n void\n>(getTimeUnitState(defaultTimeUnit), (get, set, _newState) => {\n const newState =\n typeof _newState === \"function\" ? _newState(get(timeUnitAtom)) : _newState;\n\n let stateToSet = getTimeUnitState(newState);\n\n const minTimeUnitState = getTimeUnitState(minTimeUnit);\n\n const isTimestampInvalid =\n // OTC can have 0 deadline\n stateToSet.timestamp > 0 &&\n stateToSet.timestamp < minTimeUnitState.timestamp;\n const isUnitInvalid =\n stateToSet.label === minTimeUnit.label &&\n stateToSet.value < minTimeUnitState.value;\n\n if (isTimestampInvalid || isUnitInvalid) {\n stateToSet = minTimeUnitState;\n }\n\n set(timeUnitAtom, stateToSet);\n});\n\nexport const deadlineAtom = atom((get) => get(timeUnitAtom).timestamp);\n\nexport const useOtcDeadline = () => {\n return useAtomValue(deadlineAtom);\n};\n"],"names":["timeUnitAtom","atom","getTimeUnitState","defaultTimeUnit","get","set","_newState","newState","stateToSet","minTimeUnitState","minTimeUnit","isTimestampInvalid","timestamp","isUnitInvalid","label","value","deadlineAtom","useOtcDeadline","useAtomValue"],"mappings":";;;;AAMO,MAAMA,YAAAA,GAAeC,KAI1BC,gBAAAA,CAAiBC,eAAe,GAAG,CAACC,GAAAA,EAAKC,KAAKC,SAAAA,KAAc;AAC5D,EAAA,MAAMC,QAAAA,GACJ,OAAOD,SAAAA,KAAc,UAAA,GAAaA,UAAUF,GAAAA,CAAIJ,YAAY,CAAC,CAAA,GAAIM,SAAAA;AAEnE,EAAA,IAAIE,UAAAA,GAAaN,iBAAiBK,QAAQ,CAAA;AAE1C,EAAA,MAAME,gBAAAA,GAAmBP,iBAAiBQ,WAAW,CAAA;AAErD,EAAA,MAAMC,kBAAAA;AAAAA;AAAAA,IAEJH,UAAAA,CAAWI,SAAAA,GAAY,CAAA,IACvBJ,UAAAA,CAAWI,YAAYH,gBAAAA,CAAiBG;AAAAA,GAAAA;AAC1C,EAAA,MAAMC,gBACJL,UAAAA,CAAWM,KAAAA,KAAUJ,YAAYI,KAAAA,IACjCN,UAAAA,CAAWO,QAAQN,gBAAAA,CAAiBM,KAAAA;AAEtC,EAAA,IAAIJ,sBAAsBE,aAAAA,EAAe;AACvCL,IAAAA,UAAAA,GAAaC,gBAAAA;AAAAA,EACf;AAEAJ,EAAAA,GAAAA,CAAIL,cAAcQ,UAAU,CAAA;AAC9B,CAAC;AAEM,MAAMQ,eAAef,IAAAA,CAAMG,CAAAA,GAAAA,KAAQA,GAAAA,CAAIJ,YAAY,EAAEY,SAAS;AAE9D,MAAMK,iBAAiBA,MAAA;AAAA,EAAA,OACrBC,aAAaF,YAAY,CAAA;AAAC;;;;"}
@@ -5,13 +5,13 @@ export declare const setOtcPriceRatesAtom: import('jotai').WritableAtom<null, [p
5
5
  export declare const setOtcPayAmountAtom: import('jotai').WritableAtom<null, [payAmount: string], void> & {
6
6
  init: null;
7
7
  };
8
- export declare const setOtcAmountAtomFromProps: import('jotai').WritableAtom<null, [amount: string], void> & {
8
+ export declare const setOtcPayAmountAtomFromProps: import('jotai').WritableAtom<null, [amount: string], void> & {
9
9
  init: null;
10
10
  };
11
- export declare const setOtcPriceAmountAtomFromProps: import('jotai').WritableAtom<null, [amount: string], void> & {
11
+ export declare const setOtcReceiveAmountAtom: import('jotai').WritableAtom<null, [receiveAmount: string], void> & {
12
12
  init: null;
13
13
  };
14
- export declare const setOtcReceiveAmountAtom: import('jotai').WritableAtom<null, [receiveAmount: string], void> & {
14
+ export declare const setOtcReceiveAmountAtomFromProps: import('jotai').WritableAtom<null, [amount: string], void> & {
15
15
  init: null;
16
16
  };
17
17
  export declare const resetOtcPriceAtom: import('jotai').WritableAtom<null, [priceRates?: PriceRates | undefined], void> & {
@@ -1 +1 @@
1
- {"version":3,"file":"otcInputActionsAtom.d.ts","sourceRoot":"","sources":["../../../../src/core/otc/state/otcInputActionsAtom.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,eAAO,MAAM,oBAAoB;;CAwBhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAsB9B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;CAMrC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;CAM1C,CAAC;AAEF,eAAO,MAAM,uBAAuB;;CA2BnC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAiB7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAE7B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;CAGjC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;CAGpC,CAAC"}
1
+ {"version":3,"file":"otcInputActionsAtom.d.ts","sourceRoot":"","sources":["../../../../src/core/otc/state/otcInputActionsAtom.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,eAAO,MAAM,oBAAoB;;CAwBhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAsB9B,CAAC;AAEH,eAAO,MAAM,4BAA4B;;CAMxC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;CA2BnC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;CAM5C,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAiB7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAE7B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;CAGjC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;CAGpC,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { atom } from 'jotai';
2
- import { otcReceiveInputAmountAtom, otcPriceRatesAtom, otcPayInputAmountAtom, otcPriceAmountAtom } from './otcInputAmountAtom.js';
2
+ import { otcPayInputAmountAtom, otcPriceRatesAtom, otcPriceAmountAtom, otcReceiveInputAmountAtom } from './otcInputAmountAtom.js';
3
3
  import { isOtcPriceLockedAtom } from './isOtcPriceLockedAtom.js';
4
4
  import Big from 'big.js';
5
5
  import { currentOtcInputAtom } from './currentOtcInputAtom.js';
6
6
  import { isOtcPriceReversedAtom } from './isOtcPriceReversedAtom.js';
7
- import { calculatePayAmount, calculateRates, getUpdatedRates, calculateReceiveAmount } from '../../limit/state/utils.js';
7
+ import { calculateReceiveAmount, calculatePayAmount, calculateRates } from '../../limit/state/utils.js';
8
8
  import { zeroRates } from '../../limit/state/constants.js';
9
9
 
10
10
  const setOtcPriceRatesAtom = atom(null, (get, set, priceRates, recalculateReceive = true) => {
@@ -30,14 +30,10 @@ const setOtcPayAmountAtom = atom(null, (get, set, payAmount) => {
30
30
  const newReceiveAmount = calculateReceiveAmount(payAmount, priceRates, isReversed);
31
31
  set(setOtcReceiveAmountAtom, newReceiveAmount);
32
32
  });
33
- const setOtcAmountAtomFromProps = atom(null, (_, set, amount) => {
33
+ const setOtcPayAmountAtomFromProps = atom(null, (_, set, amount) => {
34
34
  set(currentOtcInputAtom, "from");
35
35
  set(setOtcPayAmountAtom, amount);
36
36
  });
37
- const setOtcPriceAmountAtomFromProps = atom(null, (_, set, amount) => {
38
- const updatedRates = getUpdatedRates(amount, false);
39
- set(setOtcPriceRatesAtom, updatedRates, true);
40
- });
41
37
  const setOtcReceiveAmountAtom = atom(null, (get, set, receiveAmount) => {
42
38
  set(otcReceiveInputAmountAtom, receiveAmount);
43
39
  if (get(currentOtcInputAtom) !== "to") return;
@@ -53,6 +49,10 @@ const setOtcReceiveAmountAtom = atom(null, (get, set, receiveAmount) => {
53
49
  set(setOtcPriceRatesAtom, updatedRates, false);
54
50
  }
55
51
  });
52
+ const setOtcReceiveAmountAtomFromProps = atom(null, (_, set, amount) => {
53
+ set(currentOtcInputAtom, "to");
54
+ set(setOtcReceiveAmountAtom, amount);
55
+ });
56
56
  const resetOtcPriceAtom = atom(null, (get, set, priceRates = zeroRates) => {
57
57
  const isLocked = get(isOtcPriceLockedAtom);
58
58
  if (isLocked) return;
@@ -74,5 +74,5 @@ const toggleOtcPriceReverseAtom = atom(null, (get, set) => {
74
74
  set(isOtcPriceReversedAtom, !isReversed);
75
75
  });
76
76
 
77
- export { resetOtcPriceAtom, setOtcAmountAtomFromProps, setOtcPayAmountAtom, setOtcPriceAmountAtomFromProps, setOtcPriceRatesAtom, setOtcReceiveAmountAtom, toggleOtcPriceLockAtom, toggleOtcPriceReverseAtom, unlockOtcPriceAtom };
77
+ export { resetOtcPriceAtom, setOtcPayAmountAtom, setOtcPayAmountAtomFromProps, setOtcPriceRatesAtom, setOtcReceiveAmountAtom, setOtcReceiveAmountAtomFromProps, toggleOtcPriceLockAtom, toggleOtcPriceReverseAtom, unlockOtcPriceAtom };
78
78
  //# sourceMappingURL=otcInputActionsAtom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"otcInputActionsAtom.js","sources":["../../../../src/core/otc/state/otcInputActionsAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport {\n otcPayInputAmountAtom,\n otcReceiveInputAmountAtom,\n otcPriceAmountAtom,\n otcPriceRatesAtom,\n} from \"./otcInputAmountAtom\";\nimport { isOtcPriceLockedAtom } from \"./isOtcPriceLockedAtom\";\nimport Big from \"big.js\";\nimport { currentOtcInputAtom } from \"./currentOtcInputAtom\";\nimport { isOtcPriceReversedAtom } from \"./isOtcPriceReversedAtom\";\nimport {\n calculateReceiveAmount,\n calculatePayAmount,\n calculateRates,\n getUpdatedRates,\n} from \"@/core/limit/state/utils\";\nimport type { PriceRates } from \"@/core/limit/types\";\nimport { zeroRates } from \"@/core/limit/state/constants\";\n\nexport const setOtcPriceRatesAtom = atom(\n null,\n (get, set, priceRates: PriceRates, recalculateReceive = true) => {\n const isLocked = get(isOtcPriceLockedAtom);\n // ignore updates if price is locked\n if (isLocked) return;\n\n set(otcPriceRatesAtom, priceRates);\n\n const payAmount = get(otcPayInputAmountAtom);\n const payGtZero = Big(payAmount || \"0\").gt(0);\n\n // ignore updates if pay amount is zero,\n // as it would lead to setOtcReceiveAmountAtom(0) anyway\n if (recalculateReceive && payGtZero) {\n const isReversed = get(isOtcPriceReversedAtom);\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n }\n }\n);\n\nexport const setOtcPayAmountAtom = atom(null, (get, set, payAmount: string) => {\n set(otcPayInputAmountAtom, payAmount);\n\n // ignore updates that did not come from pay input\n if (get(currentOtcInputAtom) !== \"from\") return;\n\n const priceRates = get(otcPriceRatesAtom);\n const isReversed = get(isOtcPriceReversedAtom);\n\n const otcPriceAmount = get(otcPriceAmountAtom);\n const otcPriceGtZero = Big(otcPriceAmount || \"0\").gt(0);\n // ignore updates if otc price is zero,\n // as it would lead to setOtcReceiveAmountAtom(0) anyway\n if (!otcPriceGtZero) return;\n\n // update receive amount\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n});\n\nexport const setOtcAmountAtomFromProps = atom(\n null,\n (_, set, amount: string) => {\n set(currentOtcInputAtom, \"from\"); // unblock pay -> receive sync if it was previously blocked\n set(setOtcPayAmountAtom, amount);\n }\n);\n\nexport const setOtcPriceAmountAtomFromProps = atom(\n null,\n (_, set, amount: string) => {\n const updatedRates = getUpdatedRates(amount, false);\n set(setOtcPriceRatesAtom, updatedRates, true);\n }\n);\n\nexport const setOtcReceiveAmountAtom = atom(\n null,\n (get, set, receiveAmount: string) => {\n set(otcReceiveInputAmountAtom, receiveAmount);\n\n // ignore updates that did not come from receive input\n if (get(currentOtcInputAtom) !== \"to\") return;\n\n const isLocked = get(isOtcPriceLockedAtom);\n const isReversed = get(isOtcPriceReversedAtom);\n\n if (isLocked) {\n // update pay amount if price is locked\n const priceRates = get(otcPriceRatesAtom);\n const newPayAmount = calculatePayAmount(\n receiveAmount,\n priceRates,\n isReversed\n );\n set(setOtcPayAmountAtom, newPayAmount);\n } else {\n // update otc price otherwise\n const payAmount = get(otcPayInputAmountAtom);\n const updatedRates = calculateRates(receiveAmount, payAmount);\n set(setOtcPriceRatesAtom, updatedRates, false);\n }\n }\n);\n\nexport const resetOtcPriceAtom = atom(\n null,\n (get, set, priceRates: PriceRates = zeroRates) => {\n const isLocked = get(isOtcPriceLockedAtom);\n if (isLocked) return;\n\n set(setOtcPriceRatesAtom, priceRates);\n\n const isReversed = get(isOtcPriceReversedAtom);\n const payAmount = get(otcPayInputAmountAtom);\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n }\n);\n\nexport const unlockOtcPriceAtom = atom(null, (_, set) => {\n set(isOtcPriceLockedAtom, false);\n});\n\nexport const toggleOtcPriceLockAtom = atom(null, (get, set) => {\n const isLocked = get(isOtcPriceLockedAtom);\n set(isOtcPriceLockedAtom, !isLocked);\n});\n\nexport const toggleOtcPriceReverseAtom = atom(null, (get, set) => {\n const isReversed = get(isOtcPriceReversedAtom);\n set(isOtcPriceReversedAtom, !isReversed);\n});\n"],"names":["setOtcPriceRatesAtom","atom","get","set","priceRates","recalculateReceive","isLocked","isOtcPriceLockedAtom","otcPriceRatesAtom","payAmount","otcPayInputAmountAtom","payGtZero","Big","gt","isReversed","isOtcPriceReversedAtom","newReceiveAmount","calculateReceiveAmount","setOtcReceiveAmountAtom","setOtcPayAmountAtom","currentOtcInputAtom","otcPriceAmount","otcPriceAmountAtom","otcPriceGtZero","setOtcAmountAtomFromProps","_","amount","setOtcPriceAmountAtomFromProps","updatedRates","getUpdatedRates","receiveAmount","otcReceiveInputAmountAtom","newPayAmount","calculatePayAmount","calculateRates","resetOtcPriceAtom","zeroRates","unlockOtcPriceAtom","toggleOtcPriceLockAtom","toggleOtcPriceReverseAtom"],"mappings":";;;;;;;;;AAoBO,MAAMA,oBAAAA,GAAuBC,KAClC,IAAA,EACA,CAACC,KAAKC,GAAAA,EAAKC,UAAAA,EAAwBC,qBAAqB,IAAA,KAAS;AAC/D,EAAA,MAAMC,QAAAA,GAAWJ,IAAIK,oBAAoB,CAAA;AAEzC,EAAA,IAAID,QAAAA,EAAU;AAEdH,EAAAA,GAAAA,CAAIK,mBAAmBJ,UAAU,CAAA;AAEjC,EAAA,MAAMK,SAAAA,GAAYP,IAAIQ,qBAAqB,CAAA;AAC3C,EAAA,MAAMC,YAAYC,GAAAA,CAAIH,SAAAA,IAAa,GAAG,CAAA,CAAEI,GAAG,CAAC,CAAA;AAI5C,EAAA,IAAIR,sBAAsBM,SAAAA,EAAW;AACnC,IAAA,MAAMG,UAAAA,GAAaZ,IAAIa,sBAAsB,CAAA;AAC7C,IAAA,MAAMC,gBAAAA,GAAmBC,sBAAAA,CACvBR,SAAAA,EACAL,UAAAA,EACAU,UACF,CAAA;AACAX,IAAAA,GAAAA,CAAIe,yBAAyBF,gBAAgB,CAAA;AAAA,EAC/C;AACF,CACF;AAEO,MAAMG,sBAAsBlB,IAAAA,CAAK,IAAA,EAAM,CAACC,GAAAA,EAAKC,KAAKM,SAAAA,KAAsB;AAC7EN,EAAAA,GAAAA,CAAIO,uBAAuBD,SAAS,CAAA;AAGpC,EAAA,IAAIP,GAAAA,CAAIkB,mBAAmB,CAAA,KAAM,MAAA,EAAQ;AAEzC,EAAA,MAAMhB,UAAAA,GAAaF,IAAIM,iBAAiB,CAAA;AACxC,EAAA,MAAMM,UAAAA,GAAaZ,IAAIa,sBAAsB,CAAA;AAE7C,EAAA,MAAMM,cAAAA,GAAiBnB,IAAIoB,kBAAkB,CAAA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A,GAA4BtC,IAAAA,CAAK,IAAA,EAAM,CAACC,KAAKC,GAAAA,KAAQ;AAChE,EAAA,MAAMW,UAAAA,GAAaZ,IAAIa,sBAAsB,CAAA;AAC7CZ,EAAAA,GAAAA,CAAIY,sBAAAA,EAAwB,CAACD,UAAU,CAAA;AACzC,CAAC;;;;"}
1
+ {"version":3,"file":"otcInputActionsAtom.js","sources":["../../../../src/core/otc/state/otcInputActionsAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport {\n otcPayInputAmountAtom,\n otcReceiveInputAmountAtom,\n otcPriceAmountAtom,\n otcPriceRatesAtom,\n} from \"./otcInputAmountAtom\";\nimport { isOtcPriceLockedAtom } from \"./isOtcPriceLockedAtom\";\nimport Big from \"big.js\";\nimport { currentOtcInputAtom } from \"./currentOtcInputAtom\";\nimport { isOtcPriceReversedAtom } from \"./isOtcPriceReversedAtom\";\nimport {\n calculateReceiveAmount,\n calculatePayAmount,\n calculateRates,\n} from \"@/core/limit/state/utils\";\nimport type { PriceRates } from \"@/core/limit/types\";\nimport { zeroRates } from \"@/core/limit/state/constants\";\n\nexport const setOtcPriceRatesAtom = atom(\n null,\n (get, set, priceRates: PriceRates, recalculateReceive = true) => {\n const isLocked = get(isOtcPriceLockedAtom);\n // ignore updates if price is locked\n if (isLocked) return;\n\n set(otcPriceRatesAtom, priceRates);\n\n const payAmount = get(otcPayInputAmountAtom);\n const payGtZero = Big(payAmount || \"0\").gt(0);\n\n // ignore updates if pay amount is zero,\n // as it would lead to setOtcReceiveAmountAtom(0) anyway\n if (recalculateReceive && payGtZero) {\n const isReversed = get(isOtcPriceReversedAtom);\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n }\n }\n);\n\nexport const setOtcPayAmountAtom = atom(null, (get, set, payAmount: string) => {\n set(otcPayInputAmountAtom, payAmount);\n\n // ignore updates that did not come from pay input\n if (get(currentOtcInputAtom) !== \"from\") return;\n\n const priceRates = get(otcPriceRatesAtom);\n const isReversed = get(isOtcPriceReversedAtom);\n\n const otcPriceAmount = get(otcPriceAmountAtom);\n const otcPriceGtZero = Big(otcPriceAmount || \"0\").gt(0);\n // ignore updates if otc price is zero,\n // as it would lead to setOtcReceiveAmountAtom(0) anyway\n if (!otcPriceGtZero) return;\n\n // update receive amount\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n});\n\nexport const setOtcPayAmountAtomFromProps = atom(\n null,\n (_, set, amount: string) => {\n set(currentOtcInputAtom, \"from\"); // unblock pay -> receive sync if it was previously blocked\n set(setOtcPayAmountAtom, amount);\n }\n);\n\nexport const setOtcReceiveAmountAtom = atom(\n null,\n (get, set, receiveAmount: string) => {\n set(otcReceiveInputAmountAtom, receiveAmount);\n\n // ignore updates that did not come from receive input\n if (get(currentOtcInputAtom) !== \"to\") return;\n\n const isLocked = get(isOtcPriceLockedAtom);\n const isReversed = get(isOtcPriceReversedAtom);\n\n if (isLocked) {\n // update pay amount if price is locked\n const priceRates = get(otcPriceRatesAtom);\n const newPayAmount = calculatePayAmount(\n receiveAmount,\n priceRates,\n isReversed\n );\n set(setOtcPayAmountAtom, newPayAmount);\n } else {\n // update otc price otherwise\n const payAmount = get(otcPayInputAmountAtom);\n const updatedRates = calculateRates(receiveAmount, payAmount);\n set(setOtcPriceRatesAtom, updatedRates, false);\n }\n }\n);\n\nexport const setOtcReceiveAmountAtomFromProps = atom(\n null,\n (_, set, amount: string) => {\n set(currentOtcInputAtom, \"to\"); // unblock receive -> pay sync if it was previously blocked\n set(setOtcReceiveAmountAtom, amount);\n }\n);\n\nexport const resetOtcPriceAtom = atom(\n null,\n (get, set, priceRates: PriceRates = zeroRates) => {\n const isLocked = get(isOtcPriceLockedAtom);\n if (isLocked) return;\n\n set(setOtcPriceRatesAtom, priceRates);\n\n const isReversed = get(isOtcPriceReversedAtom);\n const payAmount = get(otcPayInputAmountAtom);\n const newReceiveAmount = calculateReceiveAmount(\n payAmount,\n priceRates,\n isReversed\n );\n set(setOtcReceiveAmountAtom, newReceiveAmount);\n }\n);\n\nexport const unlockOtcPriceAtom = atom(null, (_, set) => {\n set(isOtcPriceLockedAtom, false);\n});\n\nexport const toggleOtcPriceLockAtom = atom(null, (get, set) => {\n const isLocked = get(isOtcPriceLockedAtom);\n set(isOtcPriceLockedAtom, !isLocked);\n});\n\nexport const toggleOtcPriceReverseAtom = atom(null, (get, set) => {\n const isReversed = get(isOtcPriceReversedAtom);\n set(isOtcPriceReversedAtom, !isReversed);\n});\n"],"names":["setOtcPriceRatesAtom","atom","get","set","priceRates","recalculateReceive","isLocked","isOtcPriceLockedAtom","otcPriceRatesAtom","payAmount","otcPayInputAmountAtom","payGtZero","Big","gt","isReversed","isOtcPriceReversedAtom","newReceiveAmount","calculateReceiveAmount","setOtcReceiveAmountAtom","setOtcPayAmountAtom","currentOtcInputAtom","otcPriceAmount","otcPriceAmountAtom","otcPriceGtZero","setOtcPayAmountAtomFromProps","_","amount","receiveAmount","otcReceiveInputAmountAtom","newPayAmount","calculatePayAmount","updatedRates","calculateRates","setOtcReceiveAmountAtomFromProps","resetOtcPriceAtom","zeroRates","unlockOtcPriceAtom","toggleOtcPriceLockAtom","toggleOtcPriceReverseAtom"],"mappings":";;;;;;;;;AAmBO,MAAMA,oBAAAA,GAAuBC,KAClC,IAAA,EACA,CAACC,KAAKC,GAAAA,EAAKC,UAAAA,EAAwBC,qBAAqB,IAAA,KAAS;AAC/D,EAAA,MAAMC,QAAAA,GAAWJ,IAAIK,oBAAoB,CAAA;AAEzC,EAAA,IAAID,QAAAA,EAAU;AAEdH,EAAAA,GAAAA,CAAIK,mBAAmBJ,UAAU,CAAA;AAEjC,EAAA,MAAMK,SAAAA,GAAYP,IAAIQ,qBAAqB,CAAA;AAC3C,EAAA,MAAMC,YAAYC,GAAAA,CAAIH,SAAAA,IAAa,GAAG,CAAA,CAAEI,GAAG,CA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,IAAIa,sBAAsB,CAAA;AAC7C,EAAA,MAAMN,SAAAA,GAAYP,IAAIQ,qBAAqB,CAAA;AAC3C,EAAA,MAAMM,gBAAAA,GAAmBC,sBAAAA,CACvBR,SAAAA,EACAL,UAAAA,EACAU,UACF,CAAA;AACAX,EAAAA,GAAAA,CAAIe,yBAAyBF,gBAAgB,CAAA;AAC/C,CACF;AAEO,MAAMoB,kBAAAA,GAAqBnC,IAAAA,CAAK,IAAA,EAAM,CAACwB,GAAGtB,GAAAA,KAAQ;AACvDA,EAAAA,GAAAA,CAAII,sBAAsB,KAAK,CAAA;AACjC,CAAC;AAEM,MAAM8B,sBAAAA,GAAyBpC,IAAAA,CAAK,IAAA,EAAM,CAACC,KAAKC,GAAAA,KAAQ;AAC7D,EAAA,MAAMG,QAAAA,GAAWJ,IAAIK,oBAAoB,CAAA;AACzCJ,EAAAA,GAAAA,CAAII,oBAAAA,EAAsB,CAACD,QAAQ,CAAA;AACrC,CAAC;AAEM,MAAMgC,yBAAAA,GAA4BrC,IAAAA,CAAK,IAAA,EAAM,CAACC,KAAKC,GAAAA,KAAQ;AAChE,EAAA,MAAMW,UAAAA,GAAaZ,IAAIa,sBAAsB,CAAA;AAC7CZ,EAAAA,GAAAA,CAAIY,sBAAAA,EAAwB,CAACD,UAAU,CAAA;AACzC,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- export declare const currentSwapInputAtom: import('jotai').WritableAtom<"from" | "to", ["from" | "to"], void> & {
1
+ export declare const currentSwapInputAtom: import('jotai').PrimitiveAtom<"from" | "to"> & {
2
2
  init: "from" | "to";
3
3
  };
4
4
  //# sourceMappingURL=currentSwapInputAtom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"currentSwapInputAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/currentSwapInputAtom.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;CAOhC,CAAC"}
1
+ {"version":3,"file":"currentSwapInputAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/currentSwapInputAtom.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;;CAA8B,CAAC"}
@@ -1,10 +1,6 @@
1
- import { swapSideFromPropsAtom } from '../../components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.js';
2
1
  import { atom } from 'jotai';
3
2
 
4
- const currentSwapInputAtom = atom("from", (_, set, newInput) => {
5
- set(currentSwapInputAtom, newInput);
6
- set(swapSideFromPropsAtom, void 0);
7
- });
3
+ const currentSwapInputAtom = atom("from");
8
4
 
9
5
  export { currentSwapInputAtom };
10
6
  //# sourceMappingURL=currentSwapInputAtom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currentSwapInputAtom.js","sources":["../../../src/core/state/currentSwapInputAtom.ts"],"sourcesContent":["import { swapSideFromPropsAtom } from \"@/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom\";\nimport { atom } from \"jotai\";\n\nexport const currentSwapInputAtom = atom<\"from\" | \"to\", [\"from\" | \"to\"], void>(\n \"from\",\n (_, set, newInput) => {\n set(currentSwapInputAtom, newInput);\n // reset side from input props to prioritize user selection\n set(swapSideFromPropsAtom, undefined);\n }\n);\n"],"names":["currentSwapInputAtom","atom","_","set","newInput","swapSideFromPropsAtom","undefined"],"mappings":";;;AAGO,MAAMA,uBAAuBC,IAAAA,CAClC,MAAA,EACA,CAACC,CAAAA,EAAGC,KAAKC,QAAAA,KAAa;AACpBD,EAAAA,GAAAA,CAAIH,sBAAsBI,QAAQ,CAAA;AAElCD,EAAAA,GAAAA,CAAIE,uBAAuBC,MAAS,CAAA;AACtC,CACF;;;;"}
1
+ {"version":3,"file":"currentSwapInputAtom.js","sources":["../../../src/core/state/currentSwapInputAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\n\nexport const currentSwapInputAtom = atom<\"from\" | \"to\">(\"from\");\n"],"names":["currentSwapInputAtom","atom"],"mappings":";;AAEO,MAAMA,oBAAAA,GAAuBC,KAAoB,MAAM;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velora-dex/widget",
3
- "version": "0.2.5-dev.4",
3
+ "version": "0.2.5-dev.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,5 +0,0 @@
1
- import { SwapSideUnion } from '@velora-dex/sdk';
2
- export declare const swapSideFromPropsAtom: import('jotai').PrimitiveAtom<SwapSideUnion | undefined> & {
3
- init: SwapSideUnion | undefined;
4
- };
5
- //# sourceMappingURL=swapSideFromPropsAtom.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swapSideFromPropsAtom.d.ts","sourceRoot":"","sources":["../../../../../src/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,eAAO,MAAM,qBAAqB;;CAAwB,CAAC"}
@@ -1,6 +0,0 @@
1
- import { atom } from 'jotai';
2
-
3
- const swapSideFromPropsAtom = atom();
4
-
5
- export { swapSideFromPropsAtom };
6
- //# sourceMappingURL=swapSideFromPropsAtom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swapSideFromPropsAtom.js","sources":["../../../../../src/components/widget/SwapModeSwitcher/state/swapSideFromPropsAtom.ts"],"sourcesContent":["import type { SwapSideUnion } from \"@velora-dex/sdk\";\nimport { atom } from \"jotai\";\n\nexport const swapSideFromPropsAtom = atom<SwapSideUnion>();"],"names":["swapSideFromPropsAtom","atom"],"mappings":";;AAGO,MAAMA,wBAAwBC,IAAAA;;;;"}