@dhedge/trading-widget 6.2.1 → 6.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/README.md +1 -0
- package/core-kit/utils/dytm.d.ts +6 -0
- package/core-kit/utils/hyperliquid.d.ts +2 -0
- package/core-kit/utils/transaction.d.ts +14 -1
- package/{dytm-DdzHS3o4.js → dytm-D5O16WMt.js} +387 -351
- package/dytm-wondvAJ2.cjs +1 -0
- package/index.cjs +1 -1
- package/index.js +2745 -2684
- package/package.json +1 -1
- package/utils.cjs +1 -1
- package/utils.js +67 -63
- package/dytm-CliLZLfa.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const A=require("wagmi/chains"),a=require("./gmx-DJ0gqvLq.cjs"),p=require("bignumber.js"),d=require("viem"),lt=typeof window<"u",mt=[{inputs:[{internalType:"address",name:"_pool",type:"address"},{internalType:"address",name:"_asset",type:"address"},{internalType:"uint256",name:"_poolTokenAmount",type:"uint256"}],name:"previewGmTokenAmount",outputs:[{internalType:"uint256",name:"gmTokenAmount",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"ondoGMSwap",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"usdc",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}],yt=[{type:"tuple",components:[{name:"attestationSignature",type:"bytes"},{name:"quote",type:"tuple",components:[{name:"chainId",type:"uint256"},{name:"attestationId",type:"uint256"},{name:"userId",type:"bytes32"},{name:"asset",type:"address"},{name:"price",type:"uint256"},{name:"quantity",type:"uint256"},{name:"expiration",type:"uint256"},{name:"side",type:"uint8"},{name:"additionalData",type:"bytes32"}]},{name:"amountOutMinimum",type:"uint256"}]}],At=[{name:"asset",type:"address"},{name:"amount",type:"uint256"},{name:"assetType",type:"uint16"},{name:"isPool",type:"bool"},{name:"isDebt",type:"bool"},{name:"marketId",type:"uint88"},{name:"accountId",type:"uint256"},{name:"tokenId",type:"uint256"},{name:"debtKey",type:"uint248"},{name:"shares",type:"uint256"}],gt=[{inputs:[{internalType:"address",name:"_pool",type:"address"},{internalType:"uint256",name:"_poolTokenAmount",type:"uint256"}],name:"previewWithdrawal",outputs:[{name:"assetData",type:"tuple[]",components:At}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"dytmWithdrawProcessor",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"}],R=[{inputs:[{name:"params",type:"tuple",components:[{name:"account",type:"uint256"},{name:"tokenId",type:"uint256"},{name:"receiver",type:"address"},{name:"assets",type:"uint256"},{name:"shares",type:"uint256"},{name:"extraData",type:"bytes"}]}],name:"withdraw",outputs:[{name:"assets",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"params",type:"tuple",components:[{name:"account",type:"uint256"},{name:"key",type:"uint248"},{name:"withCollateralType",type:"uint8"},{name:"assets",type:"uint256"},{name:"shares",type:"uint256"},{name:"extraData",type:"bytes"}]}],name:"repay",outputs:[{name:"assetsRepaid",type:"uint256"}],stateMutability:"nonpayable",type:"function"}],Et=[{inputs:[{name:"tokenIn",type:"address"},{name:"amountIn",type:"uint256"},{name:"tokenOut",type:"address"},{name:"amountOutMinimum",type:"uint256"},{name:"attestationSignature",type:"bytes"},{name:"quote",type:"tuple",components:[{name:"chainId",type:"uint256"},{name:"attestationId",type:"uint256"},{name:"userId",type:"bytes32"},{name:"asset",type:"address"},{name:"price",type:"uint256"},{name:"quantity",type:"uint256"},{name:"expiration",type:"uint256"},{name:"side",type:"uint8"},{name:"additionalData",type:"bytes32"}]}],name:"swapExactInWithAttestation",outputs:[],stateMutability:"nonpayable",type:"function"}],Tt=[{type:"tuple",components:[{name:"actions",type:"tuple[]",components:[{name:"to",type:"address"},{name:"data",type:"bytes"}]},{name:"outputAsset",type:"address"},{name:"minOutputAmount",type:"uint256"}]}],S={stringErrors:{"currently closed for trading":{title:"The market for this tokenized asset is closed right now",hint:"Wait until the market reopens (the error message says when) and simply retry."},"Synth exchange suspended. Operation prohibited":{title:"Vault includes deprecated synths in portfolio",hint:"Redeem deprecated synth to be able to withdraw."}},selectorErrors:{"0x54971d46":{signature:"SwapFailed(address,(address,uint256,(bytes32,bytes)),bytes)",title:"The token swap failed to execute",hint:"Your assets are still in your wallet — try again, or retry with a higher slippage tolerance."},"0x81a815ef":{signature:"InsufficientAmountReceived(address,uint256,uint256)",title:"Swap output was below the minimum received amount",hint:"Increase slippage tolerance and try again."}}},F=t=>({stringErrors:{...t.stringErrors,...S.stringErrors},selectorErrors:{...t.selectorErrors,...S.selectorErrors}}),ht=["https://cdn.jsdelivr.net/gh/dhedge/V2-Public@master/readmes/errorCodes/registry.json","https://raw.githubusercontent.com/dhedge/V2-Public/master/readmes/errorCodes/registry.json"],St=1,_t=1e4,O=2e6,Dt=2e3,ft=500,wt=120,bt=300,Rt=4,It=/^dh\d{1,3}$/i,W=/[\u0000-\u001f\u007f]/,Nt=/https?:\/\/|[<>`]/i,Ct=t=>t.length<=wt&&!W.test(t)&&(It.test(t)||t.length>=Rt),T=t=>typeof t=="string"&&t.length>0&&t.length<=bt&&!W.test(t)&&!Nt.test(t);let H=S,D=null;const I=()=>H,G=t=>{H=F(t)},Ot=t=>{const e=t;if(e?.schemaVersion!==St)throw new Error(`Unsupported error registry schemaVersion: ${String(e?.schemaVersion)}`);const n={};for(const[o,r]of Object.entries(e.stringErrors??{}))r?.curated===!0&&Ct(o)&&T(r.description)&&T(r.action)&&(n[o]={title:r.description,hint:r.action});const s={};for(const[o,r]of Object.entries(e.selectorErrors??{}))r?.curated===!0&&/^0x[0-9a-f]{8}$/.test(o)&&T(r.signature)&&T(r.description)&&T(r.action)&&(s[o]={signature:r.signature,title:r.description,hint:r.action});if(!Object.keys(n).length)throw new Error("Error registry contained no curated string errors");if(Object.keys(n).length>Dt||Object.keys(s).length>ft)throw new Error("Error registry exceeded expected entry counts");return{stringErrors:n,selectorErrors:s}},$=async({timeoutMs:t=_t}={})=>{const e=[];for(const n of ht){const s=new AbortController,o=setTimeout(()=>s.abort(),t);try{const r=await fetch(n,{headers:{accept:"application/json"},signal:s.signal});if(!r.ok)throw new Error(`HTTP ${r.status}`);const i=Number(r.headers.get("content-length"));if(i>O)throw new Error(`Response too large: ${i} bytes`);const c=await r.text();if(c.length>O)throw new Error(`Response too large: ${c.length} chars`);return F(Ot(JSON.parse(c)))}catch(r){e.push(`${n}: ${r instanceof Error?r.message:String(r)}`)}finally{clearTimeout(o)}}throw new Error(`All error registry sources failed: ${e.join("; ")}`)},Pt=()=>(D??(D=$().then(G).catch(()=>{D=null})),D),xt=()=>typeof window<"u";function Mt(){return xt()&&typeof window.ethereum<"u"}async function Bt(t){try{if(Mt())return window.ethereum.request({method:"wallet_watchAsset",params:{type:"ERC20",options:t}})}catch{return!1}return!1}const m=(t,e)=>t?.toLowerCase()===e?.toLowerCase(),Lt=t=>m(t,a.AddressZero$1),h=t=>{if(!t)throw new Error("Cannot prefix an empty hex value");return t.startsWith("0x")?t:`0x${t}`},y=(t,e)=>{try{return BigInt(t)}catch{throw new Error(`Cannot convert "${e}" value "${t}" to bigint`)}},f=t=>t?d.pad(h(t),{size:32}):d.zeroHash,Y=t=>{if(!t)throw new Error("Cannot decode an empty base64 string");return d.bytesToHex(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))},k=(t,e)=>a.contractsAddressesMap[e]?.[t]??a.AddressZero,Ut=t=>a.contractsAbisMap[t],vt=t=>t&&`${t.substring(0,6)}...${t.substring(t.length-4,t.length)}`,Ft=({address:t,chainId:e})=>{const n=k("aaveLendingPoolV3",e);return m(t,n)},V=({sourceAddress:t,amount:e})=>`${t}_${e}`,Wt=(t,e)=>{const n=t.slice(0,e),s=t.slice(e);return{firstPart:n,secondPart:s}},q=(t,e)=>t/e*100,Ht=t=>t<1?4:t<10?3:2,Gt=(t,e=a.DEFAULT_PRECISION)=>new p(t.toString()).shiftedBy(e).toFixed(0),$t=(t,e,n,s)=>new p(e).dividedBy(n).multipliedBy(t).shiftedBy(-(s||a.DEFAULT_PRECISION)).toNumber(),Yt=t=>BigInt(new p(t||"0").shiftedBy(a.DEFAULT_PRECISION).toFixed(0,p.ROUND_DOWN)),N=t=>{const e=new p(.01),n=new p(t),s=!n.isZero()&&n.lt(e)?e:n;return BigInt(s.multipliedBy(100).toFixed(0))},kt=({chainId:t,slippage:e})=>t===A.hyperEvm.id?BigInt(0):N(e),Vt=({vaultAddress:t,swapData:e,sendTokenAddress:n,sendTokenAmount:s,vaultDepositTokenAddress:o,minVaultTokensReceivedAmount:r,routerKey:i="ONE_INCH",swapDestinationAmount:c,swapSlippage:u})=>{const l=new p(c).multipliedBy(1-u/100).toFixed(0),g=[d.stringToHex(i,{size:32}),e];return[t,[[n,s,g],[o,l]],r]},qt=({receiveAssetAddress:t,assets:e,swapData:n,slippage:s})=>{const o={srcData:[],destAmount:new p("0")},{srcData:r,destAmount:i}=e?.reduce((c,u)=>{const l=n?.[u.address];if(!l)return c;const g=[d.stringToHex(l.routerKey,{size:32}),l.rawTransaction.data],E=[u.address,u.rawBalance,g];return{srcData:[...c.srcData,E],destAmount:c.destAmount.plus(l.destinationAmount)}},o)??o;return[r,[t,i.times(1-s/100).toFixed(0,p.ROUND_DOWN)]]},K=({assetAddress:t,swapQuotes:e,swapParams:n,slippageToleranceForContractTransaction:s,routerKey:o})=>{if(!n)return{supportedAsset:t,withdrawData:"",slippageTolerance:BigInt(0)};const{srcData:r,dstData:i}=n,c=r.map(({asset:g,amount:E})=>{const _=e?.[V({sourceAddress:g,amount:E.toString()})]?.find(pt=>pt.routerKey===o);return{asset:g,amount:E,swapData:{routerKey:d.stringToHex(_?.routerKey??"",{size:32}),txData:_?.rawTransaction.data??"0x"}}}),u=d.encodeAbiParameters(a.ComplexWithdrawalAssetSrcDataAbiItem,[c]),l=d.encodeAbiParameters(a.ComplexWithdrawalDataAbiItem,[{encodedSrcData:u,dstData:{dstAddress:i.asset,dstAmount:i.amount},slippage:s}]);return{supportedAsset:t,withdrawData:l,slippageTolerance:s}},Kt=({chainId:t,txHash:e,error:n})=>{if(t!==A.mainnet.id||!e||!n)return!1;const s=n instanceof Error?n.message:String(n);return/\bNo Result\b/i.test(s)},jt=({chainId:t,action:e,isRabbyWallet:n})=>e==="update_ondo_prices"&&t===A.mainnet.id&&n?a.ONDO_PRICES_RABBY_SETTLE_DELAY:t?a.TRANSACTION_SETTLE_DELAY[t]??0:0,Xt=(t,e)=>a.CHAIN_NATIVE_TOKENS[e]?.nativeTokenSymbol===t,Zt=({nativeTokenBalance:t,tokenDecimals:e,gasPrice:n})=>{const s=new p(n).multipliedBy(a.NATIVE_TOKEN_GAS_RESERVE_UNITS).shiftedBy(-e),o=new p(t).minus(s);return o.gt("0")?o:new p("0")},Qt=t=>a.STABLE_TOKEN_SYMBOLS.includes(t),zt=t=>{const e=Object.values(t).reduce((n,{type:s})=>(n[s]=n[s]+1,n),{string:0,number:0});if(e.string>10)throw new Error("logger params must contain up to 10 string values");if(e.number>40)throw new Error("logger params must contain up to 40 numeric values");return!0},Jt=(t,e=150)=>t.length>e?t.substring(0,e):t,j=()=>({...I().stringErrors,...a.TRANSACTION_ERRORS}),te=()=>[...Object.keys(j()),...Object.keys(a.LIMIT_ORDER_TRANSACTION_ERRORS)],ee=/^dh\d+$/i,ne=(t,e)=>ee.test(e)?new RegExp(`\\b${e}\\b`,"i").test(t):t.includes(e.toLowerCase()),w=(t,e)=>{const n=t.toLowerCase();return[...e??te()].sort((s,o)=>o.length-s.length).find(s=>ne(n,s))},P=t=>j()[t]??a.LIMIT_ORDER_TRANSACTION_ERRORS[t],se=/\b0x[0-9a-f]{8}\b/i,re=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),oe=t=>{const{selectorErrors:e}=I(),n=t.match(se)?.[0]?.toLowerCase(),s=n?e[n]:void 0;if(s)return{title:s.title,hint:s.hint};const o=Object.values(e).find(r=>new RegExp(`\\b${re(r.signature.split("(")[0]??"")}\\b`).test(t));return o?{title:o.title,hint:o.hint}:void 0},ae=({errorMessage:t,abiErrors:e})=>{if(!t||t.includes("User rejected"))return null;const n=e.find(i=>t.includes(i));if(n){const i=w(n);if(i)return P(i)}const s=w(t);if(s)return P(s);const o=oe(t);if(o)return o;const[r]=t.split(n?".":"Contract").map(i=>i.trim());return{title:"Transaction failed",hint:`${Jt(r??"")} ${n?`: ${n}`:""}`}},ie=t=>typeof t=="number"&&Number.isFinite(t),ce=t=>typeof t=="bigint"&&t!==BigInt(0),X=(t,e=a.DEFAULT_PRECISION$1)=>new p(t).shiftedBy(-e).toNumber(),Z=t=>!isNaN(parseFloat(t))&&!isNaN(t),Q=({value:t,minimumFractionDigits:e=2,maximumFractionDigits:n=2,compact:s=!1,normalize:o=!1})=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:s?"compact":void 0,minimumFractionDigits:e,maximumFractionDigits:n}).format(o?X(t):Number(t)),b=t=>Z(t)?new p(t).toFixed():"",x=["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"],z=({value:t,decimals:e=4})=>{const n=new p(t);if(n.isGreaterThan(1)||n.isZero())return b(n.toFixed(e));const o=(/e/i.test(t.toString())?parseFloat(t.toString()).toFixed(a.DEFAULT_PRECISION$1):t.toString()).match(/^0\.(0+)(\d+)$/);if(o){const[,r,i]=o;if(r.length>=e&&r.length<x.length)return`0.0${x[r.length]}${i.slice(0,3)}`}return b(n.toFixed(e))},J=(t,e=0)=>`${t.toLocaleString("en-US",{maximumFractionDigits:e})}%`,ue=t=>t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),de=(t,e,n=0)=>{const s=q(+t,e);return J(s,n)},pe=({currency:t,value:e})=>t==="USD"?Q({value:e}):`${a.CURRENCY_SYMBOL_MAP[t]} ${z({value:e,decimals:a.CURRENCY_DECIMALS_MAP[t]})}`,tt=(t,e)=>new p(new p(t).toFixed(e,p.ROUND_DOWN)).toString(),et=(t,e=3,n=2)=>{if(t.length<=5)return t;const s="...";return t.length<=e+n+s.length?t:`${t.slice(0,e)}${s}${t.slice(-n)}`},le=({balance:t,symbol:e,precision:n,truncateSymbol:s})=>`${tt(t,n)} ${s?et(e):e}`,me=t=>{if(!t)return;const e=t.match(/0x[a-fA-F0-9]{64}/);if(!e)return;const n=e[0];return`${n.slice(0,4)}...${n.slice(-3)}`},ye=t=>m(a.FLATMONEY_EARLY_DEPOSITOR_VAULT_ADDRESS_BASE,t)||m(a.FLATMONEY_DHT_STAKING_VAULT_ADDRESS_BASE,t),Ae=t=>a.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES.some(e=>m(e,t)),ge=t=>a.FLAT_MONEY_COLLATERAL_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:a.AddressZero},Ee=t=>m(t,a.FLAT_MONEY_V1_UNIT_ADDRESS)?a.FLAT_MONEY_V1_UNIT_LINK:a.FLAT_MONEY_UNIT_LINK,nt=t=>`eth_${t}`,Te=({action:t,log:e,symbol:n,vaultAddress:s,chainId:o})=>{const r={[a.TRADING_LOG_EVENT_PARAM.SYMBOL.NAME]:n,[a.TRADING_LOG_EVENT_PARAM.CHAIN_ID.NAME]:o,[a.TRADING_LOG_EVENT_PARAM.ADDRESS.NAME]:nt(s)};a.LOG_EVENT_BY_TRANSACTION_ACTION_MAP[t].forEach(i=>{e?.(i,r)})},he=t=>a.GMX_MARKET_ASSETS.some(e=>m(e,t)),Se=t=>a.GMX_WITHDRAW_ASSET_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:a.AddressZero},_e=t=>a.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS[t.toLowerCase()],st="0x3333333333333333333333333333333333333333";A.arbitrum.id+"",a.USDC_ARBITRUM.address,A.base.id+"",a.USDC_BASE.address,A.optimism.id+"",a.USDC_OPTIMISM.address,A.polygon.id+"",a.USDC_POLYGON.address,A.mainnet.id+"",a.USDC_MAINNET.address,A.hyperEvm.id+"",a.USDC_HYPEREVM.address;const De="0x2222222222222222222222222222222222222222",M=BigInt("0x2000000000000000000000000000000000000000"),fe=10000n,rt=t=>m(t,st),ot=t=>{if(m(t,De))return!0;try{const e=BigInt(t);return e>=M&&e<M+fe}catch{return!1}},we=t=>rt(t)||ot(t),be=()=>a.USDC_HYPEREVM,Re=new Map,C=(t,e)=>!e||e.size===0?t:t.map(n=>{const s=e.get(n.supportedAsset.toLowerCase());return s?{...n,withdrawData:s.withdrawData,slippageTolerance:s.slippageTolerance}:n}),at=t=>{const e=t.find(({swapQuotes:n})=>n);return e?.swapQuotes?Object.values(e.swapQuotes)[0]?.map(({routerKey:n})=>n)??[]:[]},it=(t,e,n)=>t.map(({asset:s,swapParams:o,swapQuotes:r})=>!o||!r?{supportedAsset:s,withdrawData:"",slippageTolerance:n}:K({assetAddress:s,swapQuotes:r,swapParams:o,slippageToleranceForContractTransaction:n,routerKey:e})),ct=async(t,e,n,s,o,r)=>{for(const i of t){const c=C(it(e,i,n),r),{error:u}=await s(...o,c);if(!u)return c}return null},Ie=(t,e,n)=>{const s=(t??[]).map(o=>({supportedAsset:o,withdrawData:"",slippageTolerance:e}));return C(s,n)},Ne=async(t,e,n,s,o)=>{for(const r of t){const i=N(r);try{const c=await e(r),u=at(c),l=await ct(u,c,i,n,s,o);if(l)return console.debug(`[Init Withdraw] Auto slippage simulation succeeded: slippage=${r}%`),console.debug("[Init Withdraw] Complex asset data:",l),l}catch(c){console.error(`[Init Withdraw] Failed to fetch quotes for slippage=${r}%:`,c)}}return null},Ce=async(t,e,{fetchAaveSwapParams:n,fetchAaveSwapQuotes:s,withdrawAmountD18:o,slippage:r})=>Promise.all((t??[]).map(async i=>{if(!m(i,e))return{asset:i};try{const u=await n({withdrawAmountD18:o,slippage:r});if(u?.srcData.length){const l=await s({swapParams:u,slippage:r});return{asset:i,swapParams:u,swapQuotes:l}}return{asset:i}}catch(u){return console.error(u),{asset:i}}})),B=t=>Math.round(t*100)/100,Oe=({maxSlippage:t,candidates:e=a.SLIPPAGE_AUTO_SIMULATION_CANDIDATES})=>{if(!Number.isFinite(t)||t<=0)return[];const n=B(Math.min(t,100)),s=e.filter(r=>r>0&&r<=n).map(B),o=new Set(s);return o.add(n),o.add(t),Array.from(o).sort((r,i)=>r-i)},L=1000000000000000000n,Pe=1000000n,U=10000n,v=100n,xe=t=>({quotes:t.quotes.map(e=>({chainId:y(e.chainId,"chainId"),attestationId:y(e.attestationId,"attestationId"),userId:h(e.userId),asset:e.asset,price:y(e.price,"price"),quantity:y(e.quantity,"quantity"),expiration:y(e.expiration,"expiration"),side:Number(e.side),additionalData:h(e.additionalData)})),signatures:t.signatures.map(h)}),ut=(t,e,n)=>{const s=BigInt(Math.max(0,Math.round(n*100))),o=s>v?v:s,r=U-o,c=t*e/L*r*Pe,u=U*L;return(c+u-1n)/u},dt=(t,e)=>({chainId:e,attestationId:y(t.attestationId,"attestationId"),userId:f(t.userId),asset:t.assetAddress,price:y(t.price,"price"),quantity:y(t.tokenAmount,"tokenAmount"),expiration:y(t.expiration,"expiration"),side:Number(t.side),additionalData:f(t.additionalData)}),Me=({attestation:t,chainId:e,slippagePercent:n})=>{const s=dt(t,e);return d.encodeAbiParameters(yt,[{attestationSignature:Y(t.signature),quote:s,amountOutMinimum:ut(s.quantity,s.price,n)}])},Be=t=>[...t.reduce((n,s)=>n.has(s.accountId)?n:n.set(s.accountId,s),new Map).values()].map(({accountId:n,marketId:s})=>({accountId:n,marketId:s,collaterals:t.filter(o=>o.accountId===n&&!o.isDebt),debt:t.find(o=>o.accountId===n&&o.isDebt)})),Le=({collateral:t,dytmOffice:e,processor:n,gmToken:s,ondoGMSwap:o,usdc:r,gmAmount:i,amountOutMinimum:c,signature:u,quote:l})=>[{to:e,data:d.encodeFunctionData({abi:R,functionName:"withdraw",args:[{account:t.accountId,tokenId:t.tokenId,receiver:n,assets:i,shares:0n,extraData:"0x"}]})},{to:s,data:d.encodeFunctionData({abi:d.erc20Abi,functionName:"approve",args:[o,i]})},{to:o,data:d.encodeFunctionData({abi:Et,functionName:"swapExactInWithAttestation",args:[s,i,r,c,u,l]})}],Ue=({collateral:t,dytmOffice:e,processor:n})=>({to:e,data:d.encodeFunctionData({abi:R,functionName:"withdraw",args:[{account:t.accountId,tokenId:t.tokenId,receiver:n,assets:0n,shares:d.maxUint256,extraData:"0x"}]})}),ve=({accountId:t,debtKey:e,dytmOffice:n,usdc:s})=>[{to:s,data:d.encodeFunctionData({abi:d.erc20Abi,functionName:"approve",args:[n,d.maxUint256]})},{to:n,data:d.encodeFunctionData({abi:R,functionName:"repay",args:[{account:t,key:e,withCollateralType:0,assets:d.maxUint256,shares:0n,extraData:"0x"}]})}],Fe=({actions:t,outputAsset:e,minOutputAmount:n})=>d.encodeAbiParameters(Tt,[{actions:t,outputAsset:e,minOutputAmount:n}]);exports.DytmOfficeAssetGuardAbi=gt;exports.EMPTY_PER_ASSET_WITHDRAW_DATA=Re;exports.HYPERLIQUID_PERPS_ACCOUNT_ADDRESS=st;exports.OndoGMTokenAssetGuardAbi=mt;exports.THIRD_PARTY_CONTRACT_ERRORS=S;exports.addTokenToWallet=Bt;exports.applyContractErrorRegistry=G;exports.base64ToHex=Y;exports.buildAaveWithdrawAssetTransactionData=K;exports.buildComplexAssetDataForRouter=it;exports.buildDytmActions=Le;exports.buildDytmOutputAssetWithdrawAction=Ue;exports.buildDytmRepayActions=ve;exports.buildSwapQuoteKeyForAave=V;exports.buildSwapWithdrawTransactionData=qt;exports.buildZapDepositTransactionArguments=Vt;exports.clientSide=lt;exports.commify=ue;exports.computeAmountOutMinimumUsdc=ut;exports.createDefaultComplexAssetData=Ie;exports.encodeOndoWithdrawData=Me;exports.encodeUnwindPlan=Fe;exports.enrichAssetsWithSwapQuotes=Ce;exports.ensureContractErrorRegistryLoaded=Pt;exports.ensureHexPrefix=h;exports.extractAvailableRouterKeys=at;exports.fetchContractErrorRegistry=$;exports.formatBalance=tt;exports.formatByCurrency=pe;exports.formatNumberToLimitedDecimals=z;exports.formatNumeratorToPercentage=de;exports.formatPercentage=J;exports.formatToUsd=Q;exports.formatTokenBalance=le;exports.getAutoSlippageSimulationCandidates=Oe;exports.getComplexAssetDataSlippageTolerance=kt;exports.getContractAbiById=Ut;exports.getContractAddressById=k;exports.getContractErrorRegistry=I;exports.getConventionalTokenPriceDecimals=Ht;exports.getErrorKey=w;exports.getFlatMoneyCollateralByLeverageAddress=ge;exports.getFlatMoneyLinkByUnitAddress=Ee;exports.getGmxWithdrawAssetByLeverageAddress=Se;exports.getGmxWithdrawAssetByVaultAddress=_e;exports.getHyperliquidWithdrawAsset=be;exports.getNativeTokenInvestableBalance=Zt;exports.getPercent=q;exports.getPoolFraction=$t;exports.getSettleDelay=jt;exports.getSlippageToleranceForContractTransaction=N;exports.getTxHashShort=me;exports.groupPreviewByAccount=Be;exports.isAaveLendAndBorrowAsset=Ft;exports.isEqualAddress=m;exports.isFlatMoneyLeveragedAsset=Ae;exports.isFmpAirdropVaultAddress=ye;exports.isGmxLeveragedAsset=he;exports.isHyperliquidCorePositionAsset=we;exports.isHyperliquidPerpsAsset=rt;exports.isHyperliquidSpotSystemAsset=ot;exports.isNativeToken=Xt;exports.isNumberType=ie;exports.isNumeric=Z;exports.isStableSymbol=Qt;exports.isZeroAddress=Lt;exports.logTransactionByActionType=Te;exports.mapAttestationToOndoQuote=dt;exports.mapOndoApiResponseToUpdatePricesArgs=xe;exports.nonZeroBigInt=ce;exports.normalizeNumber=X;exports.overlayWithdrawData=C;exports.parseAmountToD18=Yt;exports.parseContractErrorMessage=ae;exports.removeInsignificantTrailingZeros=b;exports.shiftBy=Gt;exports.shortenAddress=vt;exports.shouldSwallowMainnetPollError=Kt;exports.sliceByIndex=Wt;exports.toBigInt=y;exports.toBytes32Hex=f;exports.transformAddressForAnalytics=nt;exports.truncateString=et;exports.tryEstimateWithRouters=ct;exports.tryEstimateWithSlippageValues=Ne;exports.validateLoggerEventParams=zt;
|