File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @cowprotocol/cow-sdk" ,
3- "version" : " 5.8.0-RC.6 " ,
3+ "version" : " 5.8.0-RC.7 " ,
44 "license" : " (MIT OR Apache-2.0)" ,
55 "files" : [
66 " /dist"
Original file line number Diff line number Diff line change @@ -18,4 +18,4 @@ export { getEthFlowTransaction } from './getEthFlowTransaction'
1818
1919export * from './appDataUtils'
2020export * from './calculateUniqueOrderId'
21- export { swapParamsToLimitOrderParams } from './utils'
21+ export { swapParamsToLimitOrderParams , mapQuoteAmountsAndCosts } from './utils'
Original file line number Diff line number Diff line change @@ -36,3 +36,39 @@ export function getSigner(signer: Signer | ExternalProvider | PrivateKey): Signe
3636export function isAccountAddress ( address : any ) : address is AccountAddress {
3737 return typeof address === 'string' && / ^ 0 x [ 0 - 9 a - f A - F ] { 40 } $ / . test ( address )
3838}
39+
40+ export function mapQuoteAmountsAndCosts < T , R > (
41+ value : QuoteAmountsAndCosts < T > ,
42+ mapper : ( value : T ) => R
43+ ) : QuoteAmountsAndCosts < R > {
44+ const {
45+ costs : { networkFee, partnerFee } ,
46+ } = value
47+
48+ function serializeAmounts ( value : { sellAmount : T ; buyAmount : T } ) : { sellAmount : R ; buyAmount : R } {
49+ return {
50+ sellAmount : mapper ( value . sellAmount ) ,
51+ buyAmount : mapper ( value . buyAmount ) ,
52+ }
53+ }
54+
55+ return {
56+ ...value ,
57+ costs : {
58+ ...value . costs ,
59+ networkFee : {
60+ ...networkFee ,
61+ amountInSellCurrency : mapper ( networkFee . amountInSellCurrency ) ,
62+ amountInBuyCurrency : mapper ( networkFee . amountInBuyCurrency ) ,
63+ } ,
64+ partnerFee : {
65+ ...partnerFee ,
66+ amount : mapper ( partnerFee . amount ) ,
67+ } ,
68+ } ,
69+ beforeNetworkCosts : serializeAmounts ( value . beforeNetworkCosts ) ,
70+ afterNetworkCosts : serializeAmounts ( value . afterNetworkCosts ) ,
71+ afterPartnerFees : serializeAmounts ( value . afterPartnerFees ) ,
72+ afterSlippage : serializeAmounts ( value . afterSlippage ) ,
73+ }
74+ }
You can’t perform that action at this time.
0 commit comments