@zubari/sdk 0.2.7 → 0.3.0
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/{TransactionService-8xSEGoWA.d.mts → TransactionService-DURp3bRL.d.ts} +34 -10
- package/dist/{TransactionService-CaIcCoqY.d.ts → TransactionService-DuMJmrG3.d.mts} +34 -10
- package/dist/{WalletManager-B1qvFF4K.d.mts → WalletManager-D0xMpgfo.d.mts} +133 -50
- package/dist/{WalletManager-CCs4Jsv7.d.ts → WalletManager-DsAg7MwL.d.ts} +133 -50
- package/dist/{index-Cx389p_j.d.mts → index-DF0Gf8NK.d.mts} +7 -1
- package/dist/{index-Cx389p_j.d.ts → index-DF0Gf8NK.d.ts} +7 -1
- package/dist/{index-xZYY0MEX.d.mts → index-N2u4haqL.d.mts} +23 -11
- package/dist/{index-BPojlGT6.d.ts → index-kS-xopkl.d.ts} +23 -11
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3070 -1772
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3070 -1772
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.d.mts +54 -22
- package/dist/protocols/index.d.ts +54 -22
- package/dist/protocols/index.js +1008 -76
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs +1008 -76
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.d.mts +5 -4
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +884 -884
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +884 -884
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +2 -2
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +152 -71
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +152 -71
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +5 -4
- package/dist/wallet/index.d.ts +5 -4
- package/dist/wallet/index.js +1358 -1107
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +1358 -1107
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +9 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, v as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, d as TransactionHistoryResponse, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-
|
|
2
|
-
import { N as NFTCurrency } from '../index-
|
|
1
|
+
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, v as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, d as TransactionHistoryResponse, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-DuMJmrG3.mjs';
|
|
2
|
+
import { N as NFTCurrency } from '../index-DF0Gf8NK.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Zubari API Client
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, v as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, d as TransactionHistoryResponse, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-
|
|
2
|
-
import { N as NFTCurrency } from '../index-
|
|
1
|
+
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, v as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, d as TransactionHistoryResponse, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-DURp3bRL.js';
|
|
2
|
+
import { N as NFTCurrency } from '../index-DF0Gf8NK.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Zubari API Client
|
package/dist/services/index.js
CHANGED
|
@@ -15,111 +15,171 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// src/config/contracts.ts
|
|
18
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
19
|
-
var ZUBARI_CONTRACTS = {
|
|
20
|
-
testnet: {
|
|
21
|
-
// Ethereum Sepolia (11155111) - Deployed 2024-12-30
|
|
22
|
-
registry: "0xe5CE1Eb986f58BE42EEDFe5C18ee5956803b2BDC",
|
|
23
|
-
nft: "0xCb1AB134a75c4D504792233efC5dE949aDE3f29f",
|
|
24
|
-
marketplace: "0xfcEfDa6C73aC357b8695E5F8F8d17820750BF207",
|
|
25
|
-
tips: "0x86a9A306C7fCC9e0B8cd6859f6f15498d0046BB7",
|
|
26
|
-
subscriptions: "0xaB7F17A85F61d9ab9f96bCB4e73e910D019978F7",
|
|
27
|
-
payouts: "0x8aaB23Fb2a83A259E965Aae8Ee0938b1400B7E6b",
|
|
28
|
-
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
29
|
-
paymaster: ZERO_ADDRESS,
|
|
30
|
-
// Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
|
|
31
|
-
accountFactory: ZERO_ADDRESS,
|
|
32
|
-
// Not yet deployed
|
|
33
|
-
usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
|
|
34
|
-
// USDT on Sepolia
|
|
35
|
-
weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
|
|
36
|
-
},
|
|
37
|
-
mainnet: {
|
|
38
|
-
// Ethereum Mainnet (1)
|
|
39
|
-
registry: ZERO_ADDRESS,
|
|
40
|
-
nft: ZERO_ADDRESS,
|
|
41
|
-
marketplace: ZERO_ADDRESS,
|
|
42
|
-
tips: ZERO_ADDRESS,
|
|
43
|
-
subscriptions: ZERO_ADDRESS,
|
|
44
|
-
payouts: ZERO_ADDRESS,
|
|
45
|
-
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
46
|
-
paymaster: ZERO_ADDRESS,
|
|
47
|
-
accountFactory: ZERO_ADDRESS,
|
|
48
|
-
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
49
|
-
// USDT on Ethereum
|
|
50
|
-
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
18
|
var PLATFORM_CONFIG = {
|
|
54
19
|
// Default slippage tolerance for swaps (50 = 0.5%)
|
|
55
|
-
defaultSlippageBps: 50
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
20
|
+
defaultSlippageBps: 50,
|
|
21
|
+
// Swap deadline in seconds (30 minutes)
|
|
22
|
+
swapDeadlineSecs: 30 * 60
|
|
23
|
+
};
|
|
59
24
|
|
|
60
25
|
// src/services/SwapService.ts
|
|
26
|
+
var UNISWAP_ADDRESSES = {
|
|
27
|
+
mainnet: {
|
|
28
|
+
swapRouter: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
29
|
+
quoter: "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6",
|
|
30
|
+
factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984"
|
|
31
|
+
},
|
|
32
|
+
sepolia: {
|
|
33
|
+
swapRouter: "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E",
|
|
34
|
+
quoter: "0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3",
|
|
35
|
+
factory: "0x0227628f3F023bb0B980b67D528571c95c6DaC1c"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var UNISWAP_SELECTORS = {
|
|
39
|
+
quoteExactInputSingle: "0xf7729d43",
|
|
40
|
+
// quoteExactInputSingle(address,address,uint24,uint256,uint160)
|
|
41
|
+
exactInputSingle: "0x414bf389"
|
|
42
|
+
// exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))
|
|
43
|
+
};
|
|
44
|
+
var TOKENS = {
|
|
45
|
+
mainnet: {
|
|
46
|
+
WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
47
|
+
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
48
|
+
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
49
|
+
},
|
|
50
|
+
sepolia: {
|
|
51
|
+
WETH: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
|
|
52
|
+
USDT: "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06",
|
|
53
|
+
USDC: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
61
57
|
var SwapService = class {
|
|
62
|
-
|
|
58
|
+
chainId;
|
|
63
59
|
isTestnet;
|
|
60
|
+
addresses;
|
|
61
|
+
tokens;
|
|
64
62
|
constructor(chainId, isTestnet = false) {
|
|
65
|
-
this.
|
|
63
|
+
this.chainId = chainId;
|
|
66
64
|
this.isTestnet = isTestnet;
|
|
65
|
+
this.addresses = isTestnet ? UNISWAP_ADDRESSES.sepolia : UNISWAP_ADDRESSES.mainnet;
|
|
66
|
+
this.tokens = isTestnet ? TOKENS.sepolia : TOKENS.mainnet;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Get a swap quote
|
|
69
|
+
* Get a swap quote from Uniswap V3 Quoter
|
|
70
70
|
*/
|
|
71
|
-
async getQuote(tokenIn, tokenOut, amountIn) {
|
|
71
|
+
async getQuote(tokenIn, tokenOut, amountIn, provider) {
|
|
72
72
|
if (amountIn <= 0n) {
|
|
73
73
|
throw new Error("Amount must be greater than 0");
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
const actualTokenIn = tokenIn === ETH_ADDRESS ? this.tokens.WETH : tokenIn;
|
|
76
|
+
const actualTokenOut = tokenOut === ETH_ADDRESS ? this.tokens.WETH : tokenOut;
|
|
77
|
+
if (!provider) {
|
|
78
|
+
console.warn("No provider for quote, returning estimate");
|
|
79
|
+
return {
|
|
80
|
+
tokenIn,
|
|
81
|
+
tokenOut,
|
|
82
|
+
amountIn,
|
|
83
|
+
amountOut: amountIn * BigInt(95) / BigInt(100),
|
|
84
|
+
// Rough estimate
|
|
85
|
+
priceImpact: 0.5,
|
|
86
|
+
route: [tokenIn, tokenOut],
|
|
87
|
+
estimatedGas: BigInt(15e4)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const encodedTokenIn = actualTokenIn.toLowerCase().replace("0x", "").padStart(64, "0");
|
|
92
|
+
const encodedTokenOut = actualTokenOut.toLowerCase().replace("0x", "").padStart(64, "0");
|
|
93
|
+
const encodedFee = 3e3.toString(16).padStart(64, "0");
|
|
94
|
+
const encodedAmountIn = amountIn.toString(16).padStart(64, "0");
|
|
95
|
+
const encodedSqrtPriceLimit = "0".padStart(64, "0");
|
|
96
|
+
const data = `${UNISWAP_SELECTORS.quoteExactInputSingle}${encodedTokenIn}${encodedTokenOut}${encodedFee}${encodedAmountIn}${encodedSqrtPriceLimit}`;
|
|
97
|
+
const result = await provider.call({
|
|
98
|
+
to: this.addresses.quoter,
|
|
99
|
+
data
|
|
100
|
+
});
|
|
101
|
+
const amountOut = BigInt(result);
|
|
102
|
+
const priceImpact = this.calculatePriceImpact(amountIn, amountOut, tokenIn, tokenOut);
|
|
103
|
+
return {
|
|
104
|
+
tokenIn,
|
|
105
|
+
tokenOut,
|
|
106
|
+
amountIn,
|
|
107
|
+
amountOut,
|
|
108
|
+
priceImpact,
|
|
109
|
+
route: [tokenIn, tokenOut],
|
|
110
|
+
estimatedGas: BigInt(15e4)
|
|
111
|
+
};
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error("Failed to get quote:", error);
|
|
114
|
+
throw new Error(`Quote failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
115
|
+
}
|
|
84
116
|
}
|
|
85
117
|
/**
|
|
86
|
-
* Execute a swap with slippage protection
|
|
118
|
+
* Execute a swap with slippage protection via Uniswap V3 SwapRouter
|
|
87
119
|
*/
|
|
88
|
-
async executeSwap(quote, slippageToleranceBps = PLATFORM_CONFIG.defaultSlippageBps) {
|
|
89
|
-
quote.amountOut - quote.amountOut * BigInt(slippageToleranceBps) / BigInt(1e4);
|
|
120
|
+
async executeSwap(quote, signer, recipient, slippageToleranceBps = PLATFORM_CONFIG.defaultSlippageBps) {
|
|
121
|
+
const minAmountOut = quote.amountOut - quote.amountOut * BigInt(slippageToleranceBps) / BigInt(1e4);
|
|
122
|
+
const deadline = Math.floor(Date.now() / 1e3) + PLATFORM_CONFIG.swapDeadlineSecs;
|
|
90
123
|
if (quote.priceImpact > 5) {
|
|
91
124
|
console.warn(`High price impact: ${quote.priceImpact}%`);
|
|
92
125
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
126
|
+
const actualTokenIn = quote.tokenIn === ETH_ADDRESS ? this.tokens.WETH : quote.tokenIn;
|
|
127
|
+
const actualTokenOut = quote.tokenOut === ETH_ADDRESS ? this.tokens.WETH : quote.tokenOut;
|
|
128
|
+
const isETHIn = quote.tokenIn === ETH_ADDRESS;
|
|
129
|
+
try {
|
|
130
|
+
const encodedTokenIn = actualTokenIn.toLowerCase().replace("0x", "").padStart(64, "0");
|
|
131
|
+
const encodedTokenOut = actualTokenOut.toLowerCase().replace("0x", "").padStart(64, "0");
|
|
132
|
+
const encodedFee = 3e3.toString(16).padStart(64, "0");
|
|
133
|
+
const encodedRecipient = recipient.toLowerCase().replace("0x", "").padStart(64, "0");
|
|
134
|
+
const encodedDeadline = deadline.toString(16).padStart(64, "0");
|
|
135
|
+
const encodedAmountIn = quote.amountIn.toString(16).padStart(64, "0");
|
|
136
|
+
const encodedMinAmountOut = minAmountOut.toString(16).padStart(64, "0");
|
|
137
|
+
const encodedSqrtPriceLimit = "0".padStart(64, "0");
|
|
138
|
+
const data = `${UNISWAP_SELECTORS.exactInputSingle}${encodedTokenIn}${encodedTokenOut}${encodedFee}${encodedRecipient}${encodedDeadline}${encodedAmountIn}${encodedMinAmountOut}${encodedSqrtPriceLimit}`;
|
|
139
|
+
const tx = await signer.sendTransaction({
|
|
140
|
+
to: this.addresses.swapRouter,
|
|
141
|
+
data,
|
|
142
|
+
value: isETHIn ? `0x${quote.amountIn.toString(16)}` : "0x0"
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
hash: tx.hash,
|
|
146
|
+
network: "ethereum",
|
|
147
|
+
status: "pending",
|
|
148
|
+
metadata: {
|
|
149
|
+
tokenIn: quote.tokenIn,
|
|
150
|
+
tokenOut: quote.tokenOut,
|
|
151
|
+
amountIn: quote.amountIn.toString(),
|
|
152
|
+
minAmountOut: minAmountOut.toString(),
|
|
153
|
+
deadline
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Failed to execute swap:", error);
|
|
158
|
+
throw new Error(`Swap failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
159
|
+
}
|
|
98
160
|
}
|
|
99
161
|
/**
|
|
100
162
|
* Convert earnings to USDT, keeping some ETH for gas
|
|
101
163
|
*/
|
|
102
|
-
async convertEarningsToStable(ethBalance, reserveForGas = BigInt("10000000000000000")) {
|
|
164
|
+
async convertEarningsToStable(ethBalance, signer, recipient, provider, reserveForGas = BigInt("10000000000000000")) {
|
|
103
165
|
const amountToSwap = ethBalance - reserveForGas;
|
|
104
166
|
if (amountToSwap <= 0n) {
|
|
105
167
|
throw new Error("Insufficient balance after gas reserve");
|
|
106
168
|
}
|
|
107
|
-
const contracts = getContractAddresses(this.isTestnet ? "testnet" : "mainnet");
|
|
108
169
|
const quote = await this.getQuote(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
amountToSwap
|
|
170
|
+
ETH_ADDRESS,
|
|
171
|
+
this.tokens.USDT,
|
|
172
|
+
amountToSwap,
|
|
173
|
+
provider
|
|
114
174
|
);
|
|
115
|
-
return this.executeSwap(quote);
|
|
175
|
+
return this.executeSwap(quote, signer, recipient);
|
|
116
176
|
}
|
|
117
177
|
/**
|
|
118
178
|
* Check if a swap route exists
|
|
119
179
|
*/
|
|
120
|
-
async hasRoute(tokenIn, tokenOut) {
|
|
180
|
+
async hasRoute(tokenIn, tokenOut, provider) {
|
|
121
181
|
try {
|
|
122
|
-
const quote = await this.getQuote(tokenIn, tokenOut, BigInt(
|
|
182
|
+
const quote = await this.getQuote(tokenIn, tokenOut, BigInt(10 ** 18), provider);
|
|
123
183
|
return quote.amountOut > 0n;
|
|
124
184
|
} catch {
|
|
125
185
|
return false;
|
|
@@ -129,7 +189,28 @@ var SwapService = class {
|
|
|
129
189
|
* Get supported tokens for swapping
|
|
130
190
|
*/
|
|
131
191
|
async getSupportedTokens() {
|
|
132
|
-
return [
|
|
192
|
+
return [
|
|
193
|
+
{ address: ETH_ADDRESS, symbol: "ETH", decimals: 18, name: "Ether" },
|
|
194
|
+
{ address: this.tokens.WETH, symbol: "WETH", decimals: 18, name: "Wrapped Ether" },
|
|
195
|
+
{ address: this.tokens.USDT, symbol: "USDT", decimals: 6, name: "Tether USD" },
|
|
196
|
+
{ address: this.tokens.USDC, symbol: "USDC", decimals: 6, name: "USD Coin" }
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get Uniswap router address for approvals
|
|
201
|
+
*/
|
|
202
|
+
getRouterAddress() {
|
|
203
|
+
return this.addresses.swapRouter;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Calculate price impact (simplified)
|
|
207
|
+
*/
|
|
208
|
+
calculatePriceImpact(amountIn, amountOut, _tokenIn, _tokenOut) {
|
|
209
|
+
if (amountIn === 0n || amountOut === 0n) return 0;
|
|
210
|
+
const expectedOut = amountIn;
|
|
211
|
+
const actualRatio = Number(amountOut) / Number(expectedOut);
|
|
212
|
+
const impact = (1 - actualRatio) * 100;
|
|
213
|
+
return Math.max(0, impact);
|
|
133
214
|
}
|
|
134
215
|
};
|
|
135
216
|
|