1
- import { calculatePrettyBalance , type Token } from "@covalenthq/client-sdk" ;
1
+ import { prettifyCurrency , type Token } from "@covalenthq/client-sdk" ;
2
2
import { type Abi , decodeEventLog } from "viem" ;
3
3
import { Decoder } from "../../decoder" ;
4
4
import { TimestampParser } from "../../../../utils/functions" ;
@@ -113,15 +113,25 @@ Decoder.on(
113
113
ticker_symbol : inputToken ?. contract_ticker_symbol ?? null ,
114
114
value : inputValue . toString ( ) ,
115
115
decimals : inputDecimals ,
116
- pretty : calculatePrettyBalance ( inputValue , inputDecimals ) ,
116
+ pretty_quote : prettifyCurrency (
117
+ inputToken ?. quote_rate ??
118
+ 0 *
119
+ ( Number ( inputValue ) /
120
+ Math . pow ( 10 , inputDecimals ) )
121
+ ) ,
117
122
heading : "Input" ,
118
123
} ,
119
124
{
120
125
ticker_logo : outputToken ?. logo_url ?? null ,
121
126
ticker_symbol : outputToken ?. contract_ticker_symbol ?? null ,
122
127
value : outputValue . toString ( ) ,
123
128
decimals : outputDecimals ,
124
- pretty : calculatePrettyBalance ( outputValue , outputDecimals ) ,
129
+ pretty_quote : prettifyCurrency (
130
+ outputToken ?. quote_rate ??
131
+ 0 *
132
+ ( Number ( outputValue ) /
133
+ Math . pow ( 10 , outputDecimals ) )
134
+ ) ,
125
135
heading : "Output" ,
126
136
} ,
127
137
] ,
@@ -188,9 +198,14 @@ Decoder.on(
188
198
ticker_symbol : token0 ?. contract_ticker_symbol ?? null ,
189
199
value : value0 . toString ( ) ,
190
200
decimals : + ( token0 ?. contract_decimals ?? 18 ) ,
191
- pretty : calculatePrettyBalance (
192
- value0 ,
193
- + ( token0 ?. contract_decimals ?? 18 )
201
+ pretty_quote : prettifyCurrency (
202
+ token0 ?. quote_rate ??
203
+ 0 *
204
+ ( Number ( value0 ) /
205
+ Math . pow (
206
+ 10 ,
207
+ + ( token0 ?. contract_decimals ?? 18 )
208
+ ) )
194
209
) ,
195
210
heading : "Input" ,
196
211
} ,
@@ -199,9 +214,14 @@ Decoder.on(
199
214
ticker_symbol : token1 ?. contract_ticker_symbol ?? null ,
200
215
value : value1 . toString ( ) ,
201
216
decimals : + ( token1 ?. contract_decimals ?? 18 ) ,
202
- pretty : calculatePrettyBalance (
203
- value1 ,
204
- + ( token1 ?. contract_decimals ?? 18 )
217
+ pretty_quote : prettifyCurrency (
218
+ token1 ?. quote_rate ??
219
+ 0 *
220
+ ( Number ( value1 ) /
221
+ Math . pow (
222
+ 10 ,
223
+ + ( token1 ?. contract_decimals ?? 18 )
224
+ ) )
205
225
) ,
206
226
heading : "Output" ,
207
227
} ,
0 commit comments