@velora-dex/widget 0.4.2 → 0.4.3
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/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js +2 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListRow.js +2 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListRow.js.map +1 -1
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/utils.d.ts.map +1 -1
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/utils.js.map +1 -1
- package/dist/components/widget/PayReceiveInfo/PayReceiveInfo.d.ts +1 -1
- package/dist/components/widget/PayReceiveInfo/PayReceiveInfo.d.ts.map +1 -1
- package/dist/components/widget/PayReceiveInfo/PayReceiveInfo.js +137 -87
- package/dist/components/widget/PayReceiveInfo/PayReceiveInfo.js.map +1 -1
- package/dist/components/widget/PayReceiveInfo/types.d.ts +5 -3
- package/dist/components/widget/PayReceiveInfo/types.d.ts.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/utils.d.ts.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/utils.js +2 -2
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/utils.js.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.d.ts +2 -2
- package/dist/components/widget/SwapRate/SwapRate.d.ts.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.js.map +1 -1
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.js +76 -67
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/FillOtcOrderTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/FillOtcOrderTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/FillOtcOrderTradeOverview.js +14 -12
- package/dist/components/widget/TradeOverview/FillOtcOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/LimitOrderTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/LimitOrderTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/LimitOrderTradeOverview.js +15 -13
- package/dist/components/widget/TradeOverview/LimitOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/MarketSwapTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/MarketSwapTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/MarketSwapTradeOverview.js +72 -63
- package/dist/components/widget/TradeOverview/MarketSwapTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/OtcOrderTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/OtcOrderTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/OtcOrderTradeOverview.js +15 -13
- package/dist/components/widget/TradeOverview/OtcOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/Step/utils.d.ts +2 -1
- package/dist/components/widget/TradeOverview/Step/utils.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/Step/utils.js +4 -2
- package/dist/components/widget/TradeOverview/Step/utils.js.map +1 -1
- package/dist/components/widget/TradeOverview/Stepper.d.ts +1 -1
- package/dist/components/widget/TradeOverview/Stepper.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/Stepper.js +59 -62
- package/dist/components/widget/TradeOverview/Stepper.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeDetails.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeDetails.js +181 -13
- package/dist/components/widget/TradeOverview/TradeDetails.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeDetailsDisplay.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorFooter.d.ts +2 -2
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorFooter.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorFooter.js +4 -4
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorFooter.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.d.ts +18 -2
- package/dist/components/widget/TradeOverview/TradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.js +145 -111
- package/dist/components/widget/TradeOverview/TradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.d.ts +2 -0
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.js +37 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.js.map +1 -1
- package/dist/components/widget/TradeOverview/steps.d.ts +32 -0
- package/dist/components/widget/TradeOverview/steps.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/steps.js +12 -2
- package/dist/components/widget/TradeOverview/steps.js.map +1 -1
- package/dist/components/widget/TradeOverview/tradeFlowContext.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/tradeFlowContext.js +13 -1
- package/dist/components/widget/TradeOverview/tradeFlowContext.js.map +1 -1
- package/dist/components/widget/TradeOverview/utils/isNonFlowStep.d.ts +4 -0
- package/dist/components/widget/TradeOverview/utils/isNonFlowStep.d.ts.map +1 -0
- package/dist/components/widget/TradeOverview/utils/isNonFlowStep.js +6 -0
- package/dist/components/widget/TradeOverview/utils/isNonFlowStep.js.map +1 -0
- package/dist/components/widget/TransactionDetails/LimitOrderDetails/utils.d.ts.map +1 -1
- package/dist/components/widget/TransactionDetails/LimitOrderDetails/utils.js.map +1 -1
- package/dist/configurator/Configurator.d.ts.map +1 -1
- package/dist/core/inputs/hooks/useMaxButtonProps.js +2 -2
- package/dist/core/inputs/hooks/useMaxButtonProps.js.map +1 -1
- package/dist/hooks/otc/mutations/useFillOrder.js +0 -1
- package/dist/hooks/otc/mutations/useFillOrder.js.map +1 -1
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.d.ts.map +1 -1
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.js +9 -8
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js +1 -27
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js +1 -27
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.d.ts +9 -0
- package/dist/hooks/swap/prices/usePricesParams.d.ts.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.js +32 -1
- package/dist/hooks/swap/prices/usePricesParams.js.map +1 -1
- package/dist/hooks/swap/prices/useSwapPrices.d.ts.map +1 -1
- package/dist/hooks/swap/prices/useSwapPrices.js +117 -125
- package/dist/hooks/swap/prices/useSwapPrices.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/useApproveOrPermit.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/useApproveOrPermit.js +35 -35
- package/dist/hooks/swap/tradeFlow/common/useApproveOrPermit.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts +2 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +59 -13
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.d.ts +3 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js +185 -93
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js +7 -6
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts +2 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js +37 -11
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketSwapStep.d.ts +2 -0
- package/dist/hooks/swap/tradeFlow/useMarketSwapStep.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketSwapStep.js +161 -79
- package/dist/hooks/swap/tradeFlow/useMarketSwapStep.js.map +1 -1
- package/dist/hooks/tokens/allowance/utils.d.ts +10 -2
- package/dist/hooks/tokens/allowance/utils.d.ts.map +1 -1
- package/dist/hooks/tokens/allowance/utils.js +19 -8
- package/dist/hooks/tokens/allowance/utils.js.map +1 -1
- package/dist/lib/constants/urls.d.ts.map +1 -1
- package/dist/lib/constants/urls.js.map +1 -1
- package/dist/lib/utils/fee.js +1 -1
- package/dist/lib/utils/fee.js.map +1 -1
- package/dist/lib/utils/slippage.d.ts.map +1 -1
- package/dist/lib/utils/slippage.js +1 -1
- package/dist/lib/utils/slippage.js.map +1 -1
- package/dist/lib/utils/toDecimal.d.ts.map +1 -1
- package/dist/lib/utils/toDecimal.js +5 -3
- package/dist/lib/utils/toDecimal.js.map +1 -1
- package/dist/lib/web3/privy/config.js +1 -1
- package/dist/lib/web3/wagmi/config.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { GenericTokenAllowanceMin } from './types';
|
|
2
2
|
import { SwapSideUnion } from '@velora-dex/sdk';
|
|
3
3
|
/**
|
|
4
|
-
* Adjusts
|
|
4
|
+
* Adjusts GenericTokenAllowance by applying slippage for BUY side.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function genericAllowanceWithSlippage({ allowance, swapSide, slippage, }: {
|
|
7
7
|
allowance: GenericTokenAllowanceMin;
|
|
8
8
|
swapSide: SwapSideUnion;
|
|
9
9
|
slippage: number;
|
|
10
10
|
}): GenericTokenAllowanceMin;
|
|
11
|
+
/**
|
|
12
|
+
* Adjusts allowance by applying slippage for BUY side.
|
|
13
|
+
*/
|
|
14
|
+
export declare function allowanceWithSlippage({ allowance, swapSide, slippage, }: {
|
|
15
|
+
allowance?: bigint | string;
|
|
16
|
+
swapSide: SwapSideUnion;
|
|
17
|
+
slippage: number;
|
|
18
|
+
}): bigint | undefined;
|
|
11
19
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/hooks/tokens/allowance/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;GAEG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/hooks/tokens/allowance/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,wBAAwB,CAAC;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,wBAAwB,CAS3B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,GAAG,SAAS,CAQrB"}
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
import { amountAfterSlippage } from '../../../lib/utils/slippage.js';
|
|
2
2
|
|
|
3
|
+
function genericAllowanceWithSlippage({
|
|
4
|
+
allowance,
|
|
5
|
+
swapSide,
|
|
6
|
+
slippage
|
|
7
|
+
}) {
|
|
8
|
+
return {
|
|
9
|
+
...allowance,
|
|
10
|
+
allowanceToSet: allowanceWithSlippage({
|
|
11
|
+
allowance: allowance.allowanceToSet,
|
|
12
|
+
swapSide,
|
|
13
|
+
slippage
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
}
|
|
3
17
|
function allowanceWithSlippage({
|
|
4
18
|
allowance,
|
|
5
19
|
swapSide,
|
|
6
20
|
slippage
|
|
7
21
|
}) {
|
|
8
|
-
if (allowance
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
...allowance,
|
|
12
|
-
allowanceToSet: withSlippage
|
|
13
|
-
};
|
|
22
|
+
if (allowance === void 0) return;
|
|
23
|
+
if (swapSide === "BUY") {
|
|
24
|
+
return BigInt(amountAfterSlippage(allowance.toString(), slippage, swapSide).toFixed(0));
|
|
14
25
|
}
|
|
15
|
-
return allowance;
|
|
26
|
+
return BigInt(allowance);
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
export { allowanceWithSlippage };
|
|
29
|
+
export { allowanceWithSlippage, genericAllowanceWithSlippage };
|
|
19
30
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/hooks/tokens/allowance/utils.ts"],"sourcesContent":["import { amountAfterSlippage } from \"@/lib/utils/slippage\";\nimport type { GenericTokenAllowanceMin } from \"./types\";\nimport type { SwapSideUnion } from \"@velora-dex/sdk\";\n\n/**\n * Adjusts
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/hooks/tokens/allowance/utils.ts"],"sourcesContent":["import { amountAfterSlippage } from \"@/lib/utils/slippage\";\nimport type { GenericTokenAllowanceMin } from \"./types\";\nimport type { SwapSideUnion } from \"@velora-dex/sdk\";\n\n/**\n * Adjusts GenericTokenAllowance by applying slippage for BUY side.\n */\nexport function genericAllowanceWithSlippage({\n allowance,\n swapSide,\n slippage,\n}: {\n allowance: GenericTokenAllowanceMin;\n swapSide: SwapSideUnion;\n slippage: number;\n}): GenericTokenAllowanceMin {\n return {\n ...allowance,\n allowanceToSet: allowanceWithSlippage({\n allowance: allowance.allowanceToSet,\n swapSide,\n slippage,\n }),\n };\n}\n\n/**\n * Adjusts allowance by applying slippage for BUY side.\n */\nexport function allowanceWithSlippage({\n allowance,\n swapSide,\n slippage,\n}: {\n allowance?: bigint | string;\n swapSide: SwapSideUnion;\n slippage: number;\n}): bigint | undefined {\n if (allowance === undefined) return;\n if (swapSide === \"BUY\") {\n return BigInt(\n amountAfterSlippage(allowance.toString(), slippage, swapSide).toFixed(0)\n );\n }\n return BigInt(allowance);\n}\n"],"names":["genericAllowanceWithSlippage","allowance","swapSide","slippage","allowanceToSet","allowanceWithSlippage","undefined","BigInt","amountAfterSlippage","toString","toFixed"],"mappings":";;AAOO,SAASA,4BAAAA,CAA6B;AAAA,EAC3CC,SAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC;AAKF,CAAA,EAA6B;AAC3B,EAAA,OAAO;AAAA,IACL,GAAGF,SAAAA;AAAAA,IACHG,gBAAgBC,qBAAAA,CAAsB;AAAA,MACpCJ,WAAWA,SAAAA,CAAUG,cAAAA;AAAAA,MACrBF,QAAAA;AAAAA,MACAC;AAAAA,KACD;AAAA,GACH;AACF;AAKO,SAASE,qBAAAA,CAAsB;AAAA,EACpCJ,SAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC;AAKF,CAAA,EAAuB;AACrB,EAAA,IAAIF,cAAcK,MAAAA,EAAW;AAC7B,EAAA,IAAIJ,aAAa,KAAA,EAAO;AACtB,IAAA,OAAOK,MAAAA,CACLC,mBAAAA,CAAoBP,SAAAA,CAAUQ,QAAAA,EAAS,EAAGN,UAAUD,QAAQ,CAAA,CAAEQ,OAAAA,CAAQ,CAAC,CACzE,CAAA;AAAA,EACF;AACA,EAAA,OAAOH,OAAON,SAAS,CAAA;AACzB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../../src/lib/constants/urls.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../../src/lib/constants/urls.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,IAAI,MAAM,CAKlC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAKvC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAIvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","sources":["../../../src/lib/constants/urls.ts"],"sourcesContent":["import { jotaiStore } from \"@/core/store\";\nimport { devURLsAtom } from \"@/core/state/configAtom\";\n\nconst PROD_API_URL = \"https://api.paraswap.io\";\nconst PROD_PROXY_API_URL = \"https://proxy.paraswap.io\";\nconst PROD_EXPLORER_URL = \"https://explorer.velora.xyz\";\n\nexport function getApiURL(): string {\n const
|
|
1
|
+
{"version":3,"file":"urls.js","sources":["../../../src/lib/constants/urls.ts"],"sourcesContent":["import { jotaiStore } from \"@/core/store\";\nimport { devURLsAtom } from \"@/core/state/configAtom\";\n\nconst PROD_API_URL = \"https://api.paraswap.io\";\nconst PROD_PROXY_API_URL = \"https://proxy.paraswap.io\";\nconst PROD_EXPLORER_URL = \"https://explorer.velora.xyz\";\n\nexport function getApiURL(): string {\n const { apiURL } = jotaiStore.get(devURLsAtom);\n if (apiURL) return apiURL;\n\n return PROD_API_URL;\n}\n\nexport function getApiProxyURL(): string {\n const { apiProxyURL } = jotaiStore.get(devURLsAtom);\n if (apiProxyURL) return apiProxyURL;\n\n return PROD_PROXY_API_URL;\n}\n\nexport function getExplorerURL(): string {\n const { explorerURL } = jotaiStore.get(devURLsAtom);\n if (explorerURL) return explorerURL;\n return PROD_EXPLORER_URL;\n}\n"],"names":["PROD_API_URL","PROD_PROXY_API_URL","PROD_EXPLORER_URL","getApiURL","apiURL","jotaiStore","get","devURLsAtom","getApiProxyURL","apiProxyURL","getExplorerURL","explorerURL"],"mappings":";;;AAGA,MAAMA,YAAAA,GAAe,yBAAA;AACrB,MAAMC,kBAAAA,GAAqB,2BAAA;AAC3B,MAAMC,iBAAAA,GAAoB,6BAAA;AAEnB,SAASC,SAAAA,GAAoB;AAClC,EAAA,MAAM;AAAA,IAAEC;AAAAA,GAAO,GAAIC,UAAAA,CAAWC,GAAAA,CAAIC,WAAW,CAAA;AAC7C,EAAA,IAAIH,QAAQ,OAAOA,MAAAA;AAEnB,EAAA,OAAOJ,YAAAA;AACT;AAEO,SAASQ,cAAAA,GAAyB;AACvC,EAAA,MAAM;AAAA,IAAEC;AAAAA,GAAY,GAAIJ,UAAAA,CAAWC,GAAAA,CAAIC,WAAW,CAAA;AAClD,EAAA,IAAIE,aAAa,OAAOA,WAAAA;AAExB,EAAA,OAAOR,kBAAAA;AACT;AAEO,SAASS,cAAAA,GAAyB;AACvC,EAAA,MAAM;AAAA,IAAEC;AAAAA,GAAY,GAAIN,UAAAA,CAAWC,GAAAA,CAAIC,WAAW,CAAA;AAClD,EAAA,IAAII,aAAa,OAAOA,WAAAA;AACxB,EAAA,OAAOT,iBAAAA;AACT;;;;"}
|
package/dist/lib/utils/fee.js
CHANGED
|
@@ -5,7 +5,7 @@ function calculateFeeUSD(partnerFeePercent, destUSD) {
|
|
|
5
5
|
return Big(destUSD).times(partnerFeePercent).div(100);
|
|
6
6
|
}
|
|
7
7
|
function subtractFee(amount, fee) {
|
|
8
|
-
if (fee === 0) return amount.
|
|
8
|
+
if (fee === 0) return typeof amount === "string" ? amount : amount.toFixed();
|
|
9
9
|
const feePercent = Big(fee).div(100);
|
|
10
10
|
const multiplier = Big(1).minus(feePercent);
|
|
11
11
|
return Big(amount).mul(multiplier).toFixed(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee.js","sources":["../../../src/lib/utils/fee.ts"],"sourcesContent":["import Big from \"big.js\";\n\nexport function calculateFeeUSD(partnerFeePercent: number, destUSD: string) {\n if (partnerFeePercent === 0 || destUSD === \"0\") return Big(0);\n\n return Big(destUSD).times(partnerFeePercent).div(100);\n}\n\nexport function subtractFee(\n amount: string | Big,\n fee: number // e.g. 1 for 1%\n): string {\n if (fee === 0) return amount.
|
|
1
|
+
{"version":3,"file":"fee.js","sources":["../../../src/lib/utils/fee.ts"],"sourcesContent":["import Big from \"big.js\";\n\nexport function calculateFeeUSD(partnerFeePercent: number, destUSD: string) {\n if (partnerFeePercent === 0 || destUSD === \"0\") return Big(0);\n\n return Big(destUSD).times(partnerFeePercent).div(100);\n}\n\nexport function subtractFee(\n amount: string | Big,\n fee: number // e.g. 1 for 1%\n): string {\n if (fee === 0) return typeof amount === \"string\" ? amount : amount.toFixed(); // avoid e-notation\n\n const feePercent = Big(fee).div(100);\n const multiplier = Big(1).minus(feePercent);\n return Big(amount).mul(multiplier).toFixed(0);\n}\n"],"names":["calculateFeeUSD","partnerFeePercent","destUSD","Big","times","div","subtractFee","amount","fee","toFixed","feePercent","multiplier","minus","mul"],"mappings":";;AAEO,SAASA,eAAAA,CAAgBC,mBAA2BC,OAAAA,EAAiB;AAC1E,EAAA,IAAID,sBAAsB,CAAA,IAAKC,OAAAA,KAAY,GAAA,EAAK,OAAOC,IAAI,CAAC,CAAA;AAE5D,EAAA,OAAOA,IAAID,OAAO,CAAA,CAAEE,MAAMH,iBAAiB,CAAA,CAAEI,IAAI,GAAG,CAAA;AACtD;AAEO,SAASC,WAAAA,CACdC,QACAC,GAAAA,EACQ;AACR,EAAA,IAAIA,GAAAA,KAAQ,GAAG,OAAO,OAAOD,WAAW,QAAA,GAAWA,MAAAA,GAASA,OAAOE,OAAAA,EAAQ;AAE3E,EAAA,MAAMC,UAAAA,GAAaP,GAAAA,CAAIK,GAAG,CAAA,CAAEH,IAAI,GAAG,CAAA;AACnC,EAAA,MAAMM,UAAAA,GAAaR,GAAAA,CAAI,CAAC,CAAA,CAAES,MAAMF,UAAU,CAAA;AAC1C,EAAA,OAAOP,IAAII,MAAM,CAAA,CAAEM,IAAIF,UAAU,CAAA,CAAEF,QAAQ,CAAC,CAAA;AAC9C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slippage.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/slippage.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAEzB,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,GAAG,EACpB,eAAe,EAAE,MAAM,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"slippage.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/slippage.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAEzB,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,GAAG,EACpB,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAAE,oBAAoB;AACtC,IAAI,EAAE,MAAM,GAAG,KAAK,GACnB,GAAG,CAGL"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
2
|
|
|
3
3
|
function subtractSlippage(amount, slippagePercent) {
|
|
4
|
-
if (slippagePercent === 0) return amount.
|
|
4
|
+
if (slippagePercent === 0) return typeof amount === "string" ? amount : amount.toFixed();
|
|
5
5
|
const multiplier = Big(1).minus(slippagePercent / 100);
|
|
6
6
|
return Big(amount).mul(multiplier).toFixed(0);
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slippage.js","sources":["../../../src/lib/utils/slippage.ts"],"sourcesContent":["import Big from \"big.js\";\n\nexport function subtractSlippage(\n amount: string | Big,\n slippagePercent: number // e.g. 0.5 for 0.5%\n): string {\n if (slippagePercent === 0)
|
|
1
|
+
{"version":3,"file":"slippage.js","sources":["../../../src/lib/utils/slippage.ts"],"sourcesContent":["import Big from \"big.js\";\n\nexport function subtractSlippage(\n amount: string | Big,\n slippagePercent: number // e.g. 0.5 for 0.5%\n): string {\n if (slippagePercent === 0)\n return typeof amount === \"string\" ? amount : amount.toFixed(); // avoid e-notation\n\n const multiplier = Big(1).minus(slippagePercent / 100);\n return Big(amount).mul(multiplier).toFixed(0);\n}\n\n/**\n * Calculates the amount after applying slippage. Decimals are possible after the operation.\n * take care that the resulting amount will be with a decimal number,\n * if afterwards it needs to be treated as an int (e.g.BigInt(amount)), apply .toFixed(0)\n */\nexport function amountAfterSlippage(\n amount: string,\n slippage: number, // e.g. 0.5 for 0.5%\n type: \"SELL\" | \"BUY\"\n): Big {\n const multiplier = type === \"BUY\" ? 1 + slippage / 100 : 1 - slippage / 100;\n return new Big(amount).mul(multiplier);\n}\n"],"names":["subtractSlippage","amount","slippagePercent","toFixed","multiplier","Big","minus","mul","amountAfterSlippage","slippage","type"],"mappings":";;AAEO,SAASA,gBAAAA,CACdC,QACAC,eAAAA,EACQ;AACR,EAAA,IAAIA,eAAAA,KAAoB,GACtB,OAAO,OAAOD,WAAW,QAAA,GAAWA,MAAAA,GAASA,OAAOE,OAAAA,EAAQ;AAE9D,EAAA,MAAMC,aAAaC,GAAAA,CAAI,CAAC,CAAA,CAAEC,KAAAA,CAAMJ,kBAAkB,GAAG,CAAA;AACrD,EAAA,OAAOG,IAAIJ,MAAM,CAAA,CAAEM,IAAIH,UAAU,CAAA,CAAED,QAAQ,CAAC,CAAA;AAC9C;AAOO,SAASK,mBAAAA,CACdP,MAAAA,EACAQ,QAAAA,EACAC,IAAAA,EACK;AACL,EAAA,MAAMN,aAAaM,IAAAA,KAAS,KAAA,GAAQ,IAAID,QAAAA,GAAW,GAAA,GAAM,IAAIA,QAAAA,GAAW,GAAA;AACxE,EAAA,OAAO,IAAIJ,GAAAA,CAAIJ,MAAM,CAAA,CAAEM,IAAIH,UAAU,CAAA;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDecimal.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/toDecimal.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"toDecimal.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/toDecimal.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,MAU1C,CAAC;AAKF,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,KAAG,MAKpE,CAAC"}
|
|
@@ -7,9 +7,11 @@ const MAX_DECIMAL_PLACES = 30;
|
|
|
7
7
|
Big.RM = Big.roundDown;
|
|
8
8
|
Big.DP = MAX_DECIMAL_PLACES;
|
|
9
9
|
const toDecimal = (number) => {
|
|
10
|
-
if (Number.isNaN(number)) return "";
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (Number.isNaN(number) || !Number.isFinite(number)) return "";
|
|
11
|
+
const big = Big(number);
|
|
12
|
+
if (number > TEN_POWER_DECIMAL_PRECISION) return big.toFixed(0);
|
|
13
|
+
if (number > 0 && number < 1 / TEN_POWER_DECIMAL_PRECISION) return big.toFixed();
|
|
14
|
+
return big.toPrecision(DECIMAL_PRECISION);
|
|
13
15
|
};
|
|
14
16
|
const toDecimalTrimmed = (number) => {
|
|
15
17
|
if (number === void 0) return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDecimal.js","sources":["../../../src/lib/utils/toDecimal.ts"],"sourcesContent":["import Big from \"big.js\";\nimport { removeTrailingZeros } from \"./removeZeroDecimals\";\n\nconst DECIMAL_PRECISION = 6;\nconst TEN_POWER_DECIMAL_PRECISION = 10 ** DECIMAL_PRECISION;\n\nconst MAX_DECIMAL_PLACES = 30;\n\n/*\n Let's set the rounding mode to round down.\n\n The reason its because the div function in Big always applies rounding,\n so we want it to round below the user balance (otherwise swap could fail)\n\n Also, let's set decimal places to 30, the reason is that the default on Big is 20\n and there are tokens that have 18 decimals (i.e ETH) and if a user wants to trade\n 0.0001 ETH, we wont have the entire value when converting it to decimals (WEI).\n*/\nBig.RM = Big.roundDown; // ex: 1.23456789 -> 1.234567\nBig.DP = MAX_DECIMAL_PLACES;\n\n/*\n Let's be careful about which rounding mode we use with `Big.toFixed()`:\n\n If the value of this Big number in normal notation has more digits to the right of the decimal point than is specified by dp, \n the return value will be rounded to dp decimal places using rounding mode rm.\n\n If the value of this Big number in normal notation has fewer fraction digits then is specified by dp,\n the return value will be appended with zeros accordingly.\n*/\n\nexport const toDecimal = (number: number): string => {\n if (Number.isNaN(number)) return \"\";\n\n if (number > TEN_POWER_DECIMAL_PRECISION) return
|
|
1
|
+
{"version":3,"file":"toDecimal.js","sources":["../../../src/lib/utils/toDecimal.ts"],"sourcesContent":["import Big from \"big.js\";\nimport { removeTrailingZeros } from \"./removeZeroDecimals\";\n\nconst DECIMAL_PRECISION = 6;\nconst TEN_POWER_DECIMAL_PRECISION = 10 ** DECIMAL_PRECISION;\n\nconst MAX_DECIMAL_PLACES = 30;\n\n/*\n Let's set the rounding mode to round down.\n\n The reason its because the div function in Big always applies rounding,\n so we want it to round below the user balance (otherwise swap could fail)\n\n Also, let's set decimal places to 30, the reason is that the default on Big is 20\n and there are tokens that have 18 decimals (i.e ETH) and if a user wants to trade\n 0.0001 ETH, we wont have the entire value when converting it to decimals (WEI).\n*/\nBig.RM = Big.roundDown; // ex: 1.23456789 -> 1.234567\nBig.DP = MAX_DECIMAL_PLACES;\n\n/*\n Let's be careful about which rounding mode we use with `Big.toFixed()`:\n\n If the value of this Big number in normal notation has more digits to the right of the decimal point than is specified by dp, \n the return value will be rounded to dp decimal places using rounding mode rm.\n\n If the value of this Big number in normal notation has fewer fraction digits then is specified by dp,\n the return value will be appended with zeros accordingly.\n*/\n\nexport const toDecimal = (number: number): string => {\n if (Number.isNaN(number) || !Number.isFinite(number)) return \"\";\n const big = Big(number);\n\n if (number > TEN_POWER_DECIMAL_PRECISION) return big.toFixed(0); // avoid e-notation for large numbers\n\n if (number > 0 && number < 1 / TEN_POWER_DECIMAL_PRECISION)\n return big.toFixed(); // avoid e-notation for small numbers\n\n return big.toPrecision(DECIMAL_PRECISION);\n};\n\n/*\n Same as toDecimal, but removes trailing zeros.\n*/\nexport const toDecimalTrimmed = (number?: number | bigint | string): string => {\n if (number === undefined) return \"\";\n\n const decimal = toDecimal(Number(number));\n return removeTrailingZeros(decimal);\n};\n"],"names":["DECIMAL_PRECISION","TEN_POWER_DECIMAL_PRECISION","MAX_DECIMAL_PLACES","Big","RM","roundDown","DP","toDecimal","number","Number","isNaN","isFinite","big","toFixed","toPrecision","toDecimalTrimmed","undefined","decimal","removeTrailingZeros"],"mappings":";;;AAGA,MAAMA,iBAAAA,GAAoB,CAAA;AAC1B,MAAMC,8BAA8B,EAAA,IAAMD,iBAAAA;AAE1C,MAAME,kBAAAA,GAAqB,EAAA;AAY3BC,GAAAA,CAAIC,KAAKD,GAAAA,CAAIE,SAAAA;AACbF,GAAAA,CAAIG,EAAAA,GAAKJ,kBAAAA;AAYF,MAAMK,SAAAA,GAAYA,CAACC,MAAAA,KAA2B;AACnD,EAAA,IAAIC,MAAAA,CAAOC,MAAMF,MAAM,CAAA,IAAK,CAACC,MAAAA,CAAOE,QAAAA,CAASH,MAAM,CAAA,EAAG,OAAO,EAAA;AAC7D,EAAA,MAAMI,GAAAA,GAAMT,IAAIK,MAAM,CAAA;AAEtB,EAAA,IAAIA,MAAAA,GAASP,2BAAAA,EAA6B,OAAOW,GAAAA,CAAIC,QAAQ,CAAC,CAAA;AAE9D,EAAA,IAAIL,SAAS,CAAA,IAAKA,MAAAA,GAAS,IAAIP,2BAAAA,EAC7B,OAAOW,IAAIC,OAAAA,EAAQ;AAErB,EAAA,OAAOD,GAAAA,CAAIE,YAAYd,iBAAiB,CAAA;AAC1C;AAKO,MAAMe,gBAAAA,GAAmBA,CAACP,MAAAA,KAA8C;AAC7E,EAAA,IAAIA,MAAAA,KAAWQ,QAAW,OAAO,EAAA;AAEjC,EAAA,MAAMC,OAAAA,GAAUV,SAAAA,CAAUE,MAAAA,CAAOD,MAAM,CAAC,CAAA;AACxC,EAAA,OAAOU,oBAAoBD,OAAO,CAAA;AACpC;;;;"}
|
|
@@ -28,7 +28,7 @@ const privyConfig = {
|
|
|
28
28
|
},
|
|
29
29
|
// another option is to give an invalid ID,
|
|
30
30
|
// but then it retries indefinitely
|
|
31
|
-
walletConnectCloudProjectId: "
|
|
31
|
+
walletConnectCloudProjectId: "9796e40630a6bea7605ac281b0deb939",
|
|
32
32
|
// Privy doesn't accept const Chain[]
|
|
33
33
|
supportedChains: chains
|
|
34
34
|
// defaultChain: chains[0], @TODO set to App's selected chain
|
|
@@ -7,7 +7,7 @@ import { LOCAL_STORAGE_PREFIX } from '../../constants/storage.js';
|
|
|
7
7
|
|
|
8
8
|
const connectors = [
|
|
9
9
|
walletConnect({
|
|
10
|
-
projectId: "
|
|
10
|
+
projectId: "9796e40630a6bea7605ac281b0deb939"
|
|
11
11
|
}),
|
|
12
12
|
injected(),
|
|
13
13
|
// metaMask() as CreateConnectorFn, // injected() detects metamask already
|
package/dist/styles.css
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
:root, :host {
|
|
74
74
|
--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
75
75
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
76
76
|
--color-red-800: oklch(44.4% .177 26.899);
|