ccxt-ir 4.22.0 → 4.23.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 +4 -4
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/swapwallet.js +219 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/swapwallet.d.ts +8 -0
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/coinbaseexchange.d.ts +1 -1
- package/js/src/protobuf/mexc/compiled.d.cts +0 -6
- package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/static_dependencies/qs/formats.d.cts +0 -6
- package/js/src/static_dependencies/qs/index.d.cts +0 -6
- package/js/src/static_dependencies/qs/parse.d.cts +0 -6
- package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
- package/js/src/static_dependencies/qs/utils.d.cts +0 -6
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
- package/js/src/swapwallet.d.ts +20 -0
- package/js/src/swapwallet.js +218 -0
- package/js/test.d.ts +1 -1
- package/js/test.js +62 -35
- package/package.json +1 -1
package/dist/ccxt.browser.min.js
CHANGED
|
@@ -23,11 +23,11 @@ const h=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc
|
|
|
23
23
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
24
24
|
function s(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(...e){const t=(e,t)=>i=>e(t(i));return{encode:Array.from(e).reverse().reduce(((e,i)=>e?t(e,i.encode):i.encode),void 0),decode:e.reduce(((e,i)=>e?t(e,i.decode):i.decode),void 0)}}function a(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(s(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const i=e.indexOf(t);if(-1===i)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return i}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function n(e,t="="){if(s(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(i){if(!Array.isArray(i)||i.length&&"string"!=typeof i[0])throw new Error("padding.encode input should be array of strings");for(let e of i)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;i.length*e%8;)i.push(t);return i},decode(i){if(!Array.isArray(i)||i.length&&"string"!=typeof i[0])throw new Error("padding.encode input should be array of strings");for(let e of i)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let s=i.length;if(s*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;s>0&&i[s-1]===t;s--)if(!((s-1)*e%8))throw new Error("Invalid padding: string has too much padding");return i.slice(0,s)}}}function d(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function h(e,t,i){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(i<2)throw new Error(`convertRadix: wrong to=${i}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const a=[],o=Array.from(e);for(o.forEach((e=>{if(s(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,s=!0;for(let a=r;a<o.length;a++){const n=o[a],d=t*e+n;if(!Number.isSafeInteger(d)||t*e/t!==e||d-n!=t*e)throw new Error("convertRadix: carry overflow");if(e=d%i,o[a]=Math.floor(d/i),!Number.isSafeInteger(o[a])||o[a]*i+e!==d)throw new Error("convertRadix: carry overflow");s&&(o[a]?s=!1:r=a)}if(a.push(e),s)break}for(let t=0;t<e.length-1&&0===e[t];t++)a.push(0);return a.reverse()}i.d(t,{As:()=>M,K3:()=>y,RG:()=>v,tw:()=>w,xn:()=>g});const c=(e,t)=>t?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function u(e,t,i,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(i<=0||i>32)throw new Error(`convertRadix2: wrong to=${i}`);if(l(t,i)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${i} carryBits=${l(t,i)}`);let a=0,o=0;const n=2**i-1,d=[];for(const r of e){if(s(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(a=a<<t|r,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=i;o-=i)d.push((a>>o-i&n)>>>0);a&=2**o-1}if(a=a<<i-o&n,!r&&o>=t)throw new Error("Excess padding");if(!r&&a)throw new Error(`Non-zero padding: ${a}`);return r&&o>0&&d.push(a>>>0),d}function f(e){return s(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return h(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(h(t,e,256))}}}function p(e,t=!1){if(s(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:i=>{if(!(i instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(i),8,e,!t)},decode:i=>{if(!Array.isArray(i)||i.length&&"number"!=typeof i[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(i,e,8,t))}}}function m(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const g=r(p(4),a("0123456789abcdef"),o("")),v=r(p(5),a("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),n(5),o("")),y=(r(p(5),a("0123456789ABCDEFGHIJKLMNOPQRSTUV"),n(5),o("")),r(p(5),a("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),o(""),d((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),n(6),o(""))),b=(r(p(6),a("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),n(6),o("")),e=>r(f(58),a(e),o(""))),w=b("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),k=(b("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),b("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),r(a("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o(""))),S=[996825010,642813549,513874426,1027748829,705979059];function O(e){const t=e>>25;let i=(33554431&e)<<5;for(let e=0;e<S.length;e++)1==(t>>e&1)&&(i^=S[e]);return i}function T(e,t,i=1){const s=e.length;let r=1;for(let t=0;t<s;t++){const i=e.charCodeAt(t);if(i<33||i>126)throw new Error(`Invalid prefix (${e})`);r=O(r)^i>>5}r=O(r);for(let t=0;t<s;t++)r=O(r)^31&e.charCodeAt(t);for(let e of t)r=O(r)^e;for(let e=0;e<6;e++)r=O(r);return r^=i,k.encode(u([r%2**30],30,5,!1))}function P(e){const t="bech32"===e?1:734539939,i=p(5),s=i.decode,r=i.encode,a=m(s);function o(e,i=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==i&&e.length>i)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${i})`);const s=e.toLowerCase();if(e!==s&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=s).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const a=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const n=k.decode(o).slice(0,-6),d=T(a,n,t);if(!o.endsWith(d))throw new Error(`Invalid checksum in ${e}: expected "${d}"`);return{prefix:a,words:n}}return{encode:function(e,i,s=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(i)||i.length&&"number"!=typeof i[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof i);const r=e.length+7+i.length;if(!1!==s&&r>s)throw new TypeError(`Length ${r} exceeds limit ${s}`);return`${e=e.toLowerCase()}1${k.encode(i)}${T(e,i,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:i}=o(e,!1);return{prefix:t,words:i,bytes:s(i)}},decodeUnsafe:m(o),fromWords:s,fromWordsUnsafe:a,toWords:r}}P("bech32"),P("bech32m");const M={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)};r(p(4),a("0123456789abcdef"),o(""),d((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})))},33187:(e,t,i)=>{i.d(t,{$u:()=>I,Dq:()=>N,Ef:()=>H,NO:()=>L,_S:()=>w,b:()=>x,pd:()=>G});var s=i(38432),r=i(54852),a=i(41094),o=i(71064),n=i(71357),d=i(92442),h=i(30191),c=i(31999);
|
|
25
25
|
/*! scure-starknet - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
26
|
-
const l=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),u=BigInt("0x800000000000000000000000000000000000000000000000000000000000000");function f(e){for(;0===e[0];)e=e.subarray(1);const t=8*e.length-252,i=h.Ph(e);return t>0?i>>BigInt(t):i}function p(e){return"string"==typeof e&&1&(e=M(e)).length&&(e="0"+e),h.aT(e)}const m=(0,d.x3)({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:(0,o.Fp)(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:l,nBitLength:252,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...(0,c.Z)(r.s),bits2int:f,bits2int_modN:e=>{const t=h.Ph(e).toString(16);return 63===t.length&&(e=p(t+"0")),(0,o.zi)(f(e),l)}});function g(e){return h.qj("","string"==typeof e?p(e):e)}function v(e){return h.My(g(e)).padStart(64,"0")}function y(e){const{r:t,s:i}=e;if(t<0n||t>=u)throw new Error(`Signature.r should be [1, ${u})`);const s=(0,o.B8)(i,l);if(s<0n||s>=u)throw new Error(`inv(Signature.s) should be [1, ${u})`)}function b(e){const t=g(e);if(h.Ph(t)>=u)throw new Error(`msgHash should be [0, ${u})`);return t}function w(e,t,i){const s=m.sign(b(e),v(t),i);return y(s),s}const{CURVE:k,ProjectivePoint:S,Signature:O,utils:T}=m;function P(e){return`0x${h.My(e.subarray(1)).replace(/^0+/gm,"")}`}function M(e){return e.replace(/^0x/i,"")}function I(e){return P(function(e,t=!1){return m.getPublicKey(v(e),t)}(e,!0))}function x(e){if(130!==(e=M(e)).length)throw new Error("Wrong ethereum signature");return function(e){const t=g(e),i=2n**256n,s=i-(0,o.zi)(i,l);for(let e=0;;e++){const i=D(h.Id(t,h.IV(BigInt(e))));if(i<s)return(0,o.zi)(i,l).toString(16);if(1e5===e)throw new Error("grindKey is broken: tried 100k vals")}}(e.substring(0,64))}const A=[new S(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new S(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new S(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new S(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new S(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function C(e,t){const i=[];let s=e;for(let e=0;e<248;e++)i.push(s),s=s.double();s=t;for(let e=0;e<4;e++)i.push(s),s=s.double();return i}const _=C(A[1],A[2]),B=C(A[3],A[4]);function E(e,t,i){let s=function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e){if(!Number.isSafeInteger(e))throw new Error(`Invalid pedersenArg: ${e}`);t=BigInt(e)}else t=h.Ph(g(e));if(!(0n<=t&&t<m.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}(t);for(let t=0;t<252;t++){const r=i[t];if(!r)throw new Error("invalid constant index");if(r.equals(e))throw new Error("Same point");0n!==(1n&s)&&(e=e.add(r)),s>>=1n}return e}function L(e,t){let i=A[0];return i=E(i,e,_),i=E(i,t,B),P(i.toRawBytes(!0))}const R=h.OG(250),N=e=>h.Ph((0,s.lY)(e))&R,D=e=>h.Ph((0,r.s)(e));function q(e,t,i){const s=e.fromBytes((0,r.s)((0,a.AI)(`${t}${i}`)));return e.create(s)}function V(e,t){if((0,o.jr)(e.Fp),!Number.isSafeInteger(e.rate)||!Number.isSafeInteger(e.capacity))throw new Error(`Wrong poseidon opts: ${e}`);const i=e.rate+e.capacity,s=e.roundsFull+e.roundsPartial,r=[];for(let t=0;t<s;t++){const s=[];for(let r=0;r<i;r++)s.push(q(e.Fp,"Hades",i*t+r));r.push(s)}const a=(0,n.sN)({...e,t:i,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:r});return a.m=i,a.rate=e.rate,a.capacity=e.capacity,a}const F=V({Fp:(0,o.Fp)(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481")),rate:2,capacity:1,roundsFull:8,roundsPartial:83},[[3,1,1],[1,-1,1],[1,1,-2]].map((e=>e.map(BigInt))));function H(e,t,i=F){return i([e,t,2n])[0]}function G(e,t=F){const{m:i,rate:s}=t;if(!Array.isArray(e))throw new Error("bigint array expected in values");const r=Array.from(e);for(r.push(1n);r.length%s!=0;)r.push(0n);let a=new Array(i).fill(0n);for(let e=0;e<r.length;e+=s){for(let t=0;t<s;t++){const i=r[e+t];if(void 0===i)throw new Error("invalid index");a[t]+=i}a=t(a)}return a[0]}},58325:(e,t,i)=>{i.d(t,{He:()=>h,Kp:()=>d,Vi:()=>o,bE:()=>c,n$:()=>r,p7:()=>s,s9:()=>a});const s=31,r=2n**250n-1n,a=2n**251n+17n*2n**192n+1n,o=2n**251n-256n,n=(e,t)=>({min:e,max:t}),d=n(0n,a-1n),h=n(-(2n**127n),2n**127n-1n),c=n(0n,2n**128n-1n);var l,u,f,p;!function(e){e.SN_MAIN="https://alpha-mainnet.starknet.io",e.SN_SEPOLIA="https://alpha-sepolia.starknet.io"}(l||(l={})),function(e){e.SN_MAIN="SN_MAIN",e.SN_SEPOLIA="SN_SEPOLIA"}(u||(u={})),function(e){e.SN_MAIN="0x534e5f4d41494e",e.SN_SEPOLIA="0x534e5f5345504f4c4941"}(f||(f={})),function(e){e.DECLARE="0x6465636c617265",e.DEPLOY="0x6465706c6f79",e.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",e.INVOKE="0x696e766f6b65",e.L1_HANDLER="0x6c315f68616e646c6572"}(p||(p={}))},20040:(e,t,i)=>{var s,r,a;i.d(t,{Fg:()=>r,fE:()=>s,uS:()=>a}),function(e){e.DEPLOY="DEPLOY",e.CALL="CALL",e.INVOKE="INVOKE"}(s||(s={})),function(e){e.u8="core::integer::u8",e.u16="core::integer::u16",e.u32="core::integer::u32",e.u64="core::integer::u64",e.u128="core::integer::u128",e.u256="core::integer::u256",e.u512="core::integer::u512"}(r||(r={})),function(e){e.ClassHash="core::starknet::class_hash::ClassHash",e.ContractAddress="core::starknet::contract_address::ContractAddress",e.Secp256k1Point="core::starknet::secp256k1::Secp256k1Point"}(a||(a={}))},30162:(e,t,i)=>{i.d(t,{K:()=>s});const s={Active:"1",Legacy:"0"}},79550:(e,t,i)=>{function s(e,t){if(!e)throw new Error(t||"Assertion failure")}i.d(t,{A:()=>s})},54921:(e,t,i)=>{i.d(t,{e:()=>a});var s=i(11686),r=i(67925);function a(e){if((0,s.sI)(e)||Number.isInteger(e))return e.toString();if((0,r.Kg)(e)){if((0,s.qv)(e))return BigInt(e).toString();if((0,r.KH)(e)){if(!(0,r.O4)(e))throw new Error(`${e} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt((0,r.Mu)(e)).toString()}if((0,s.A6)(e))return e}if((0,s.Lm)(e))return""+ +e;throw new Error(`${e} can't be computed by felt()`)}},13283:(e,t,i)=>{i.d(t,{is:()=>n,wO:()=>a});var s=i(90178),r=i(54921);const a=(1n<<128n)-1n,o=(1n<<256n)-1n;class n{constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const t=n.validateProps(e[0].low,e[0].high);this.low=t.low,this.high=t.high}else if(1===e.length){const t=n.validate(e[0]);this.low=t&a,this.high=t>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const t=n.validateProps(e[0],e[1]);this.low=t.low,this.high=t.high}}}static validate(e){const t=BigInt(e);if(t<0n)throw Error("bigNumberish is smaller than UINT_256_MIN");if(t>o)throw new Error("bigNumberish is bigger than UINT_256_MAX");return t}static validateProps(e,t){const i=BigInt(e),s=BigInt(t);if(i<0n||i>340282366920938463463374607431768211455n)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(s<0n||s>340282366920938463463374607431768211455n)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:i,high:s}}static is(e){try{n.validate(e)}catch(e){return!1}return!0}static isAbiType(e){return e===n.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:(0,s.VO)(this.low.toString(16)),high:(0,s.VO)(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[(0,r.e)(this.low),(0,r.e)(this.high)]}}n.abiSelector="core::integer::u256"},40274:(e,t,i)=>{i.d(t,{Ns:()=>n});var s=i(90178),r=i(54921),a=i(13283);const o=(1n<<512n)-1n;class n{constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const t=n.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else if(1===e.length){const t=n.validate(e[0]);this.limb0=t&a.wO,this.limb1=(t&a.wO<<128n)>>128n,this.limb2=(t&a.wO<<256n)>>256n,this.limb3=t>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const t=n.validateProps(e[0],e[1],e[2],e[3]);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}}}static validate(e){const t=BigInt(e);if(t<0n)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(t>o)throw Error("bigNumberish is bigger than UINT_512_MAX.");return t}static validateProps(e,t,i,s){const r=BigInt(e),o=BigInt(t),n=BigInt(i),d=BigInt(s);return[r,o,n,d].forEach(((e,t)=>{if(e<0n||e>a.wO)throw Error(`limb${t} is not in the range of a u128 number`)})),{limb0:r,limb1:o,limb2:n,limb3:d}}static is(e){try{n.validate(e)}catch(e){return!1}return!0}static isAbiType(e){return e===n.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:(0,s.VO)(this.limb0.toString(16)),limb1:(0,s.VO)(this.limb1.toString(16)),limb2:(0,s.VO)(this.limb2.toString(16)),limb3:(0,s.VO)(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[(0,r.e)(this.limb0),(0,r.e)(this.limb1),(0,r.e)(this.limb2),(0,r.e)(this.limb3)]}}n.abiSelector="core::integer::u512"},62256:(e,t,i)=>{i.d(t,{f:()=>a,p:()=>o});var s=i(11686),r=i(67925);function a(e){const t=0n===BigInt(e.pending_word)?"":(0,r.Wb)((0,s.nj)(e.pending_word));return e.data.reduce(((e,t)=>e+(0n===BigInt(t)?"":(0,r.Wb)((0,s.nj)(t)))),"")+t}function o(e){const t=(0,r.mE)(e),i=t[t.length-1],s=t.map(r.Mu),[a,o]=void 0===i||31===i.length?["0x00",0]:[s.pop(),i.length];return{data:0===s.length?[]:s,pending_word:a,pending_word_len:o}}},15307:(e,t,i)=>{i.d(t,{$H:()=>m,AB:()=>M,CS:()=>O,Fi:()=>v,G$:()=>d,GY:()=>y,Gw:()=>g,Z$:()=>k,Zm:()=>h,ak:()=>w,cl:()=>T,ct:()=>o,e4:()=>f,gr:()=>b,iN:()=>P,iO:()=>u,mQ:()=>c,s8:()=>S,sB:()=>n,u:()=>p,wJ:()=>l});var s=i(20040),r=i(54921),a=i(13283);const o=e=>/_len$/.test(e),n=e=>"felt"===e||"core::felt252"===e,d=e=>/\*/.test(e)||e.startsWith("core::array::Array::")||e.startsWith("core::array::Span::"),h=e=>/^\(.*\)$/i.test(e),c=e=>/\(.*\)/i.test(e)&&e.includes(":"),l=(e,t)=>e in t,u=(e,t)=>e in t,f=e=>e.startsWith("core::option::Option::"),p=e=>e.startsWith("core::result::Result::"),m=e=>Object.values(s.Fg).includes(e),g=e=>Object.values(s.uS).includes(e),v=e=>"core::bool"===e,y=e=>"core::starknet::eth_address::EthAddress"===e,b=e=>"core::bytes_31::bytes31"===e,w=e=>"core::byte_array::byteArray.js"===e,k=e=>"core::starknet::secp256k1::Secp256k1Point"===e,S=e=>e.includes("::"),O=e=>S(e)?e.substring(e.indexOf("<")+1,e.lastIndexOf(">")):e.replace("*","");function T(e){const{cairo:t}=function(e){if(e.find((e=>"interface"===e.type)))return{cairo:"1",compiler:"2"};const t=e.find((e=>"function"===e.type&&(e.inputs.length||e.outputs.length)));if(!t)return{cairo:void 0,compiler:void 0};const i=t.inputs.length?t.inputs:t.outputs;if(S(i[0].type))return{cairo:"1",compiler:"1"};return{cairo:"0",compiler:"0"}}(e);if(void 0===t)throw Error("Unable to determine Cairo version");return"1"===t}const P=e=>new a.is(e).toUint256DecimalString();function M(e){return(0,r.e)(e)}},36863:(e,t,i)=>{i.d(t,{b:()=>s});class s{constructor(e){const t=Object.values(e);if(0===t.length)throw new Error("This Enum must have at least 1 variant");if(1!==t.filter((e=>void 0!==e)).length)throw new Error("This Enum must have exactly one active variant");this.variant=e}unwrap(){const e=Object.entries(this.variant).find((e=>void 0!==e[1]));if(void 0!==e)return e[1]}activeVariant(){const e=Object.entries(this.variant).find((e=>void 0!==e[1]));return void 0===e?"":e[0]}}},49620:(e,t,i)=>{var s;i.d(t,{R:()=>s,c:()=>r}),function(e){e[e.Some=0]="Some",e[e.None=1]="None"}(s||(s={}));class r{constructor(e,t){if(!(e in s))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(e===s.Some){if(void 0===t)throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=t,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(void 0===this.Some)}isNone(){return!0===this.None}}},41668:(e,t,i)=>{var s;i.d(t,{B:()=>s,G:()=>r}),function(e){e[e.Ok=0]="Ok",e[e.Err=1]="Err"}(s||(s={}));class r{constructor(e,t){if(!(e in s))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");e===s.Ok?(this.Ok=t,this.Err=void 0):(this.Ok=void 0,this.Err=t)}unwrap(){if(void 0!==this.Ok)return this.Ok;if(void 0!==this.Err)return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(void 0===this.Ok)}isErr(){return!(void 0===this.Err)}}},79161:(e,t,i)=>{i.d(t,{A:()=>o});var s=i(11686),r=i(67925);const a={isBN:(e,t,i)=>{if(!(0,s.sI)(e[i]))throw new Error(`Data and formatter mismatch on ${i}:${t[i]}, expected response data ${i}:${e[i]} to be BN instead it is ${typeof e[i]}`)},unknown:(e,t,i)=>{throw new Error(`Unhandled formatter type on ${i}:${t[i]} for data ${i}:${e[i]}`)}};function o(e,t,i){return Object.entries(e).reduce(((s,[n,d])=>{const h=i??t[n];if(!(n in t)&&!i)return s[n]=d,s;if("string"===h){if(Array.isArray(e[n])){const t=o(e[n],e[n].map((e=>h)));return s[n]=Object.values(t).join(""),s}return a.isBN(e,t,n),s[n]=(0,r.Wb)(d),s}if("number"===h)return a.isBN(e,t,n),s[n]=Number(d),s;if("function"==typeof h)return s[n]=h(d),s;if(Array.isArray(h)){const t=o(e[n],h,h[0]);return s[n]=Object.values(t),s}return"object"==typeof h?(s[n]=o(e[n],h),s):(a.unknown(e,t,n),s)}),{})}},46907:(e,t,i)=>{i.d(t,{fP:()=>y});var s=i(20040),r=i(79550),a=i(11686),o=i(69793),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(79161),f=i(591),p=i(90916),m=i(14365),g=i(43463),v=i(39873);class y{constructor(e){this.structs=y.getAbiStruct(e),this.enums=y.getAbiEnum(e),this.parser=(0,f.k)(e),this.abi=this.parser.getLegacyFormat()}validate(e,t,i=[]){if(e!==s.fE.DEPLOY){const i=this.abi.filter((t=>{if("function"!==t.type)return!1;const i="view"===t.stateMutability||"view"===t.state_mutability;return e===s.fE.INVOKE?!i:i})).map((e=>e.name));(0,r.A)(i.includes(t),(e===s.fE.INVOKE?"invocable":"viewable")+" method not found in abi")}const a=this.abi.find((i=>e===s.fE.DEPLOY?i.name===t&&"constructor"===i.type:i.name===t&&"function"===i.type));if((0,f.CO)(t,i,a))return;const o=this.parser.methodInputsLength(a);if(i.length!==o)throw Error(`Invalid number of arguments, expected ${o} arguments, but got ${i.length}`);(0,v.A)(a,i,this.structs,this.enums)}compile(e,t){const i=this.abi.find((t=>t.name===e));if((0,f.CO)(e,t,i))return[];let s;if(Array.isArray(t))s=t;else{const e=(0,p.A)(t,i.inputs,this.structs,this.enums);s=Object.values(e),(0,v.A)(i,s,this.structs,this.enums)}const r=s[Symbol.iterator](),a=i.inputs.reduce(((e,t)=>(0,h.ct)(t.name)&&!(0,h.s8)(t.type)?e:e.concat((0,m.A)(r,t,this.structs,this.enums))),[]);return Object.defineProperty(a,"__compiled__",{enumerable:!1,writable:!1,value:!0}),a}static compile(e){const t=e=>{const t=(e,i=".")=>{const s=Array.isArray(e)?[e.length.toString(),...e]:e;return Object.entries(s).flatMap((([e,r])=>{let u=r;"entrypoint"===e?u=(0,o.BK)(u):(0,n.IN)(u)&&(u=(0,d.p)(u));const f=Array.isArray(s)&&"0"===e?"$$len":e;if((0,a.sI)(u))return[[`${i}${f}`,(0,h.AB)(u)]];if(Object(u)===u){const e=Object.getOwnPropertyNames(Object.getPrototypeOf(u)),s=[...Object.getOwnPropertyNames(u),...e];if(s.includes("isSome")&&s.includes("isNone")){const e=u,s=e.isSome()?c.R.Some:c.R.None;return e.isSome()?t({0:s,1:e.unwrap()},`${i}${f}.`):[[`${i}${f}`,(0,h.AB)(s)]]}if(s.includes("isOk")&&s.includes("isErr")){const e=u,s=e.isOk()?l.B.Ok:l.B.Err;return t({0:s,1:e.unwrap()},`${i}${f}.`)}if(s.includes("variant")&&s.includes("activeVariant")){const e=u,s=e.activeVariant(),r=Object.keys(e.variant).findIndex((e=>e===s));return"object"==typeof e.unwrap()&&0===Object.keys(e.unwrap()).length?[[`${i}${f}`,(0,h.AB)(r)]]:t({0:r,1:e.unwrap()},`${i}${f}.`)}return t(u,`${i}${f}.`)}return[[`${i}${f}`,(0,h.AB)(u)]]}))};return Object.fromEntries(t(e))};let i;if(Array.isArray(e)){const s=t({...e});i=Object.values(s)}else{const s=t(e);i=Object.values(s)}return Object.defineProperty(i,"__compiled__",{enumerable:!1,writable:!1,value:!0}),i}parse(e,t){const{outputs:i}=this.abi.find((t=>t.name===e)),s=t.flat()[Symbol.iterator](),r=i.flat().reduce(((e,t,i)=>{const r=t.name??i;return e[r]=(0,g.A)(s,t,this.structs,this.enums,e),e[r]&&e[`${r}_len`]&&delete e[`${r}_len`],e}),{});return 1===Object.keys(r).length&&0 in r?r[0]:r}format(e,t,i){const s=this.parse(e,t);return(0,u.A)(s,i)}static getAbiStruct(e){return e.filter((e=>"struct"===e.type)).reduce(((e,t)=>({...e,[t.name]:t})),{})}static getAbiEnum(e){const t=e.filter((e=>"enum"===e.type)).reduce(((e,t)=>({...e,[t.name]:t})),{});return delete t["core::bool"],t}static toCalldata(e=[]){return y.compile(e)}static toHex(e=[]){return y.compile(e).map((e=>(0,a.nj)(e)))}decodeParameters(e,t){const i=Array.isArray(e)?e:[e],s=t.flat()[Symbol.iterator](),r=i.map((e=>(0,g.A)(s,{name:"",type:e},this.structs,this.enums)));return 1===r.length?r[0]:r}}},591:(e,t,i)=>{i.d(t,{CO:()=>n,k:()=>o});var s=i(15307),r=i(30568),a=i(17799);function o(e){const t=function(e){return e.find((e=>"interface"===e.type))?2:(0,s.cl)(e)?1:0}(e);if(0===t||1===t)return new r.V(e);if(2===t)return new a.O(e);throw Error(`Unsupported ABI version ${t}`)}function n(e,t,i){return"constructor"===e&&!i&&!t.length}},30568:(e,t,i)=>{i.d(t,{V:()=>r});var s=i(15307);class r{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.reduce(((e,t)=>(0,s.ct)(t.name)?e:e+1),0)}getMethod(e){return this.abi.find((t=>t.name===e))}getLegacyFormat(){return this.abi}}},17799:(e,t,i)=>{i.d(t,{O:()=>s});class s{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.length}getMethod(e){return this.abi.find((e=>"interface"===e.type)).items.find((t=>t.name===e))}getLegacyFormat(){return this.abi.flatMap((e=>"interface"===e.type?e.items:e))}}},90916:(e,t,i)=>{i.d(t,{A:()=>l});var s=i(13283),r=i(40274),a=i(15307),o=i(41668),n=i(49620),d=i(36863),h=i(37593),c=i(67925);function l(e,t,i,l){const u=(e,t)=>{if((0,a.G$)(t))return function(e,t){const i=(0,a.CS)(t);if((0,c.Kg)(e))return e;return e.map((e=>u(e,i)))}(e,t);if((0,a.iO)(t,l)){const i=l[t];return p(e,i)}if((0,a.Zm)(t))return function(e,t){const i=(0,h.A)(t).reduce(((t,i,s)=>{const r=Object.keys(e),a=i=>Object.defineProperty(t,s.toString(),{enumerable:!0,value:i??e[r[s]]}),o=i?.type?i.type:i;return a(u(e[r[s]],o)),t}),{});return i}(e,t);if((0,a.GY)(t))return e;if((0,a.ak)(t))return e;if((0,a.Z$)(t))return e;if(s.is.isAbiType(t)){const i=e;if("object"!=typeof i)return i;if(!("low"in i)||!("high"in i))throw Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`);return{low:i.low,high:i.high}}if(r.Ns.isAbiType(t)){const i=e;if("object"!=typeof i)return i;if(!["limb0","limb1","limb2","limb3"].every((e=>e in i)))throw function(e){return Error(`Your object includes the property : ${e}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(t);return{limb0:i.limb0,limb1:i.limb1,limb2:i.limb2,limb3:i.limb3}}if((0,a.wJ)(t,i)){const s=i[t].members;return f(e,s)}return e},f=(e,t)=>t.reduce(((t,i)=>{if("undefined"===e[i.name]&&((0,a.s8)(i.type)||!(0,a.ct)(i.name)))throw Error(`Your object needs a property with key : ${i.name} .`);var s;return s=u(e[i.name],i.type),Object.defineProperty(t,i.name,{enumerable:!0,value:s??e[i.name]}),t}),{});const p=(e,t)=>{if((0,a.u)(t.name)){const i=e,s=t.name.substring(t.name.indexOf("<")+1,t.name.lastIndexOf(",")),r=t.name.substring(t.name.indexOf(",")+1,t.name.lastIndexOf(">"));return i.isOk()?new o.G(o.B.Ok,u(e.unwrap(),s)):new o.G(o.B.Err,u(e.unwrap(),r))}if((0,a.e4)(t.name)){const i=e,s=t.name.substring(t.name.indexOf("<")+1,t.name.lastIndexOf(">"));return i.isSome()?new n.c(n.R.Some,u(i.unwrap(),s)):new n.c(n.R.None,{})}const i=e,s=Object.entries(i.variant).map((e=>{if(void 0===e[1])return e;const s=t.type.substring(t.type.lastIndexOf("<")+1,t.type.lastIndexOf(">"));return"()"===s?e:[e[0],u(i.unwrap(),s)]}));return new d.b(Object.fromEntries(s))};return t.reduce(((t,i)=>{return(0,a.ct)(i.name)&&!(0,a.s8)(i.type)||(s=u(e[i.name],i.type),Object.defineProperty(t,i.name,{enumerable:!0,value:s})),t;var s}),{})}},14365:(e,t,i)=>{i.d(t,{A:()=>m});var s=i(13283),r=i(40274),a=i(90178),o=i(11686),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(37593);function f(e,t){switch(!0){case s.is.isAbiType(e):return new s.is(t).toApiRequest();case r.Ns.isAbiType(e):return new r.Ns(t).toApiRequest();case(0,h.gr)(e):return(0,n.Mu)(t.toString());case(0,h.Z$)(e):{const e=(0,a.ow)((0,o.nj)(t)).padStart(128,"0"),i=(0,h.iN)((0,a.VO)(e.slice(-64))),s=(0,h.iN)((0,a.VO)(e.slice(0,-64)));return[(0,h.AB)(s.low),(0,h.AB)(s.high),(0,h.AB)(i.low),(0,h.AB)(i.high)]}default:return(0,h.AB)(t)}}function p(e,t,i,a){if(void 0===e)throw Error(`Missing parameter for type ${t}`);if(Array.isArray(e)){const s=[];s.push((0,h.AB)(e.length));const r=(0,h.CS)(t);return e.reduce(((e,t)=>e.concat(p(t,r,i,a))),s)}if(i[t]&&i[t].members.length){if(s.is.isAbiType(t))return new s.is(e).toApiRequest();if(r.Ns.isAbiType(t))return new r.Ns(e).toApiRequest();if("core::starknet::eth_address::EthAddress"===t)return f(t,e);if("core::byte_array::ByteArray"===t)return function(e){const t=(0,d.p)(e);return[t.data.length.toString(),...t.data.map((e=>e.toString())),t.pending_word.toString(),t.pending_word_len.toString()]}(e);const{members:o}=i[t],n=e;return o.reduce(((e,t)=>e.concat(p(n[t.name],t.type,i,a))),[])}if((0,h.Zm)(t)){const s=function(e,t){const i=(0,u.A)(t),s=Object.values(e);if(s.length!==i.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${s} \n expected: ${i}`);return i.map(((e,t)=>({element:s[t],type:e.type??e})))}(e,t);return s.reduce(((e,t)=>{const s=p(t.element,t.type,i,a);return e.concat(s)}),[])}if(s.is.isAbiType(t))return new s.is(e).toApiRequest();if(r.Ns.isAbiType(t))return new r.Ns(e).toApiRequest();if((0,h.iO)(t,a)){const{variants:s}=a[t];if((0,h.e4)(t)){const t=e;if(t.isSome()){const e=s.find((e=>"Some"===e.name));if(void 0===e)throw Error("Error in abi : Option has no 'Some' variant.");const r=e.type;if("()"===r)return c.R.Some.toString();const o=p(t.unwrap(),r,i,a);return Array.isArray(o)?[c.R.Some.toString(),...o]:[c.R.Some.toString(),o]}return c.R.None.toString()}if((0,h.u)(t)){const t=e;if(t.isOk()){const e=s.find((e=>"Ok"===e.name));if(void 0===e)throw Error("Error in abi : Result has no 'Ok' variant.");const r=e.type;if("()"===r)return l.B.Ok.toString();const o=p(t.unwrap(),r,i,a);return Array.isArray(o)?[l.B.Ok.toString(),...o]:[l.B.Ok.toString(),o]}const r=s.find((e=>"Err"===e.name));if(void 0===r)throw Error("Error in abi : Result has no 'Err' variant.");const o=r.type;if("()"===o)return l.B.Err.toString();const n=p(t.unwrap(),o,i,a);return Array.isArray(n)?[l.B.Err.toString(),...n]:[l.B.Err.toString(),n]}const r=e,o=r.activeVariant(),n=s.find((e=>e.name===o));if(void 0===n)throw Error(`Not find in abi : Enum has no '${o}' variant.`);const d=n.type,u=s.findIndex((e=>e.name===o));if("()"===d)return u.toString();const f=p(r.unwrap(),d,i,a);return Array.isArray(f)?[u.toString(),...f]:[u.toString(),f]}if("object"==typeof e)throw Error(`Parameter ${e} do not align with abi parameter ${t}`);return f(t,e)}function m(e,t,i,r){const{name:a,type:o}=t;let{value:d}=e.next();switch(!0){case(0,h.G$)(o):if(!Array.isArray(d)&&!(0,n.KH)(d))throw Error(`ABI expected parameter ${a} to be array or long string, got ${d}`);return(0,n.Kg)(d)&&(d=(0,n.mE)(d)),p(d,t.type,i,r);case"core::starknet::eth_address::EthAddress"===o:return f(o,d);case(0,h.wJ)(o,i)||(0,h.Zm)(o)||s.is.isAbiType(o)||s.is.isAbiType(o):case(0,h.iO)(o,r):return p(d,o,i,r);default:return f(o,d)}}},43463:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(13283),r=i(40274),a=i(90178),o=i(11686),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(36863),f=i(37593);function p(e,t){let i;switch(!0){case(0,h.Fi)(e):return i=t.next().value,Boolean(BigInt(i));case s.is.isAbiType(e):const o=t.next().value,d=t.next().value;return new s.is(o,d).toBigInt();case r.Ns.isAbiType(e):const c=t.next().value,l=t.next().value,u=t.next().value,f=t.next().value;return new r.Ns(c,l,u,f).toBigInt();case"core::starknet::eth_address::EthAddress"===e:return i=t.next().value,BigInt(i);case"core::bytes_31::bytes31"===e:return i=t.next().value,(0,n.Wb)(i);case(0,h.Z$)(e):const p=(0,a.ow)(t.next().value).padStart(32,"0"),m=(0,a.ow)(t.next().value).padStart(32,"0"),g=(0,a.ow)(t.next().value).padStart(32,"0"),v=(0,a.ow)(t.next().value).padStart(32,"0");return BigInt((0,a.VO)(m+p+v+g));default:return i=t.next().value,BigInt(i)}}function m(e,t,i,a){if("()"===t.type)return{};if(s.is.isAbiType(t.type)){const t=e.next().value,i=e.next().value;return new s.is(t,i).toBigInt()}if(r.Ns.isAbiType(t.type)){const t=e.next().value,i=e.next().value,s=e.next().value,a=e.next().value;return new r.Ns(t,i,s,a).toBigInt()}if((0,h.ak)(t.type)){const t=[],i=BigInt(e.next().value);for(;t.length<i;)t.push((0,o.nj)(e.next().value));const s={data:t,pending_word:(0,o.nj)(e.next().value),pending_word_len:BigInt(e.next().value)};return(0,d.f)(s)}if((0,h.G$)(t.type)){const s=[],r={name:"",type:(0,h.CS)(t.type)},o=BigInt(e.next().value);for(;s.length<o;)s.push(m(e,r,i,a));return s}if(i&&t.type in i&&i[t.type])return"core::starknet::eth_address::EthAddress"===t.type?p(t.type,e):i[t.type].members.reduce(((t,s)=>(t[s.name]=m(e,s,i,a),t)),{});if(a&&t.type in a&&a[t.type]){const s=Number(e.next().value),r=a[t.type].variants.reduce(((t,r,o)=>o===s?(t[r.name]=m(e,{name:"",type:r.type},i,a),t):(t[r.name]=void 0,t)),{});if(t.type.startsWith("core::option::Option")){const e=s===c.R.Some?r.Some:void 0;return new c.c(s,e)}if(t.type.startsWith("core::result::Result")){let e;return e=s===l.B.Ok?r.Ok:r.Err,new l.G(s,e)}return new u.b(r)}if((0,h.Zm)(t.type)){return(0,f.A)(t.type).reduce(((t,s,r)=>{const o=s?.name?s.name:r,n={name:o,type:s?.type?s.type:s};return t[o]=m(e,n,i,a),t}),{})}if((0,h.G$)(t.type)){const s=[],r={name:"",type:(0,h.CS)(t.type)},o=BigInt(e.next().value);for(;s.length<o;)s.push(m(e,r,i,a));return s}return p(t.type,e)}function g(e,t,i,s,r){const{name:a,type:o}=t;let n;switch(!0){case(0,h.ct)(a):return n=e.next().value,BigInt(n);case i&&o in i||(0,h.Zm)(o):case s&&(0,h.iO)(o,s):return m(e,t,i,s);case(0,h.G$)(o):if((0,h.s8)(o))return m(e,t,i,s);const d=[];if(r&&r[`${a}_len`]){const o=r[`${a}_len`];for(;d.length<o;)d.push(m(e,{name:a,type:t.type.replace("*","")},i,s))}return d;default:return p(o,e)}}},37593:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(15307);function r(e,t,i){for(let s=0,r=0;s<e.length;s++)if(e[s]===t)r++;else if(e[s]===i&&0==--r)return s;return Number.POSITIVE_INFINITY}function a(e){return(0,s.s8)(e)?function(e){const t=e.slice(1,-1),i=[];let s,a=0;for(;a<t.length;){switch(!0){case"("===t[a]:s=a+r(t.slice(a),"(",")")+1;break;case t.startsWith("core::result::Result::<",a)||t.startsWith("core::array::Array::<",a)||t.startsWith("core::option::Option::<",a):s=a+r(t.slice(a),"<",">")+1;break;default:{const e=t.indexOf(",",a);s=-1!==e?e:Number.POSITIVE_INFINITY}}i.push(t.slice(a,s)),a=s+2}return i}(e):function(e){const t=e.replace(/\s/g,"").slice(1,-1),{subTuple:i,result:r}=function(e){if(!e.includes("("))return{subTuple:[],result:e};const t=[];let i="",s=0;for(;s<e.length;){if("("===e[s]){let r=1;const a=s;for(s++;r;)")"===e[s]&&r--,"("===e[s]&&r++,s++;t.push(e.substring(a,s)),i+=" ",s--}else i+=e[s];s++}return{subTuple:t,result:i}}(t);let a=r.split(",").map((e=>i.length?e.replace(" ",i.shift()):e));return(0,s.mQ)(e)&&(a=a.reduce(((e,t)=>e.concat(function(e){const t=e.substring(0,e.indexOf(":"));return{name:t,type:e.substring(t.length+1)}}(t))),[])),a}(e)}},39873:(e,t,i)=>{i.d(t,{A:()=>b});var s=i(20040),r=i(79550),a=i(13283),o=i(40274),n=i(11686),d=i(67925),h=i(15307);const c=(e,t)=>{if((0,r.A)((0,d.Kg)(e)||(0,n.Et)(e)||(0,n.sI)(e),`Validate: arg ${t.name} should be a felt typed as (String, Number or BigInt)`),(0,d.Kg)(e)&&!(0,n.qv)(e))return;const i=BigInt(e.toString(10));(0,r.A)(i>=0n&&i<=2n**252n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^252-1]`)},l=(e,t)=>{(0,r.A)((0,d.Kg)(e),`Validate: arg ${t.name} should be a string.`),(0,r.A)(e.length<32,`Validate: arg ${t.name} cairo typed ${t.type} should be a string of less than 32 characters.`)},u=(e,t)=>{(0,r.A)((0,d.Kg)(e),`Validate: arg ${t.name} should be a string.`)},f=(e,t)=>{let i;switch((0,n.Et)(e)&&(0,r.A)(e<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),(0,r.A)((0,d.Kg)(e)||(0,n.Et)(e)||(0,n.sI)(e)||"object"==typeof e&&"low"in e&&"high"in e||"object"==typeof e&&["limb0","limb1","limb2","limb3"].every((t=>t in e)),`Validate: arg ${t.name} of cairo type ${t.type} should be type (String, Number or BigInt), but is ${typeof e} ${e}.`),t.type){case s.Fg.u256:i=new a.is(e).toBigInt();break;case s.Fg.u512:i=new o.Ns(e).toBigInt();break;default:i=(0,n.Dg)(e)}switch(t.type){case s.Fg.u8:(0,r.A)(i>=0n&&i<=255n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0 - 255]`);break;case s.Fg.u16:(0,r.A)(i>=0n&&i<=65535n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 65535]`);break;case s.Fg.u32:(0,r.A)(i>=0n&&i<=4294967295n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 4294967295]`);break;case s.Fg.u64:(0,r.A)(i>=0n&&i<=2n**64n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^64-1]`);break;case s.Fg.u128:(0,r.A)(i>=0n&&i<=2n**128n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^128-1]`);break;case s.Fg.u256:(0,r.A)(i>=0n&&i<=2n**256n-1n,`Validate: arg ${t.name} is ${t.type} 0 - 2^256-1`);break;case s.Fg.u512:(0,r.A)(o.Ns.is(i),`Validate: arg ${t.name} is ${t.type} 0 - 2^512-1`);break;case s.uS.ClassHash:case s.uS.ContractAddress:(0,r.A)(i>=0n&&i<=2n**252n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^252-1]`);break;case s.uS.Secp256k1Point:(0,r.A)(i>=0n&&i<=2n**512n-1n,`Validate: arg ${t.name} must be ${t.type} : a 512 bits number.`)}},p=(e,t)=>{(0,r.A)((0,n.Lm)(e),`Validate: arg ${t.name} of cairo type ${t.type} should be type (Boolean)`)},m=(e,t,i)=>{if(t.type!==s.Fg.u256&&t.type!==s.Fg.u512)if("core::starknet::eth_address::EthAddress"!==t.type)(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} is cairo type struct (${t.type}), and should be defined as js object (not array)`),i[t.type].members.forEach((({name:i})=>{(0,r.A)(Object.keys(e).includes(i),`Validate: arg ${t.name} should have a property ${i}`)}));else{(0,r.A)("object"!=typeof e,`EthAddress type is waiting a BigNumberish. Got ${e}`);const i=BigInt(e.toString(10));(0,r.A)(i>=0n&&i<=2n**160n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^160-1]`)}else f(e,t)},g=(e,t)=>{(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} is cairo type Enum (${t.type}), and should be defined as js object (not array)`);const i=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),s=[...Object.getOwnPropertyNames(e),...i];if(!((0,h.e4)(t.type)&&s.includes("isSome")&&s.includes("isNone")||(0,h.u)(t.type)&&s.includes("isOk")&&s.includes("isErr")||s.includes("variant")&&s.includes("activeVariant")))throw new Error(`Validate Enum: argument ${t.name}, type ${t.type}, value received ${e}, is not an Enum.`)},v=(e,t)=>{(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} should be a tuple (defined as object)`)},y=(e,t,i,s)=>{const a=(0,h.CS)(t.type);if(!(0,h.sB)(a)||!(0,d.IN)(e))switch((0,r.A)(Array.isArray(e),`Validate: arg ${t.name} should be an Array`),!0){case(0,h.sB)(a):e.forEach((e=>c(e,t)));break;case(0,h.Zm)(a):e.forEach((e=>v(e,{name:t.name,type:a})));break;case(0,h.G$)(a):e.forEach((e=>y(e,{name:"",type:a},i,s)));break;case(0,h.wJ)(a,i):e.forEach((e=>m(e,{name:t.name,type:a},i)));break;case(0,h.iO)(a,s):e.forEach((e=>g(e,{name:t.name,type:a})));break;case(0,h.$H)(a)||(0,h.Gw)(a):e.forEach((e=>f(e,{name:"",type:a})));break;case(0,h.Fi)(a):e.forEach((e=>p(e,t)));break;default:throw new Error(`Validate Unhandled: argument ${t.name}, type ${t.type}, value ${e}`)}};function b(e,t,i,s){e.inputs.reduce(((e,r)=>{const a=t[e];switch(!0){case(0,h.ct)(r.name):return e;case(0,h.sB)(r.type):c(a,r);break;case(0,h.gr)(r.type):l(a,r);break;case(0,h.$H)(r.type)||(0,h.Gw)(r.type):f(a,r);break;case(0,h.Fi)(r.type):p(a,r);break;case(0,h.ak)(r.type):u(a,r);break;case(0,h.G$)(r.type):y(a,r,i,s);break;case(0,h.wJ)(r.type,i):m(a,r,i);break;case(0,h.iO)(r.type,s):g(a,r);break;case(0,h.Zm)(r.type):v(a,r);break;default:throw new Error(`Validate Unhandled: argument ${r.name}, type ${r.type}, value ${a}`)}return e+1}),0)}},90178:(e,t,i)=>{i.d(t,{VO:()=>a,ow:()=>r,yw:()=>s});function s(e){return(new TextEncoder).encode(e)}function r(e){return e.replace(/^0x/i,"")}function a(e){return`0x${r(e)}`}},69491:(e,t,i)=>{i.d(t,{CL:()=>d,dl:()=>u,ez:()=>l,h$:()=>h,r4:()=>f});var s=i(33187),r=i(58325),a=i(46907),o=i(15307),n=i(11686);function d(e,t){return(0,s.NO)(BigInt(e),BigInt(t))}function h(e,t){return(0,n.nj)((0,s.Ef)(BigInt(e),BigInt(t)))}function c(e){return[...e,e.length].reduce(((e,t)=>(0,s.NO)(BigInt(e),BigInt(t))),0).toString()}const l=c;function u(e){return(0,n.nj)((0,s.pd)(e.map((e=>BigInt(e)))))}function f(e,t,i,s){const d=c(a.fP.compile(i)),h=c([(0,o.AB)("0x535441524b4e45545f434f4e54524143545f41444452455353"),s,e,t,d]);return(0,n.nj)(BigInt(h)%r.Vi)}},38354:(e,t,i)=>{i.d(t,{v:()=>r});var s=i(69491);class r{constructor(e,t=s.CL){this.branches=[],this.hashMethod=t,this.leaves=e,this.root=this.build(e)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const t=[];for(let i=0;i<e.length;i+=2)i+1===e.length?t.push(r.hash(e[i],"0x0",this.hashMethod)):t.push(r.hash(e[i],e[i+1],this.hashMethod));return this.build(t)}static hash(e,t,i=s.CL){const[r,a]=[BigInt(e),BigInt(t)].sort(((e,t)=>e>=t?1:-1));return i(r,a)}getProof(e,t=this.leaves,i=[]){const s=t.indexOf(e);if(-1===s)throw new Error("leaf not found");if(1===t.length)return i;const a=s%2==0,o=(a?t[s+1]:t[s-1])??"0x0",n=[...i,o],d=this.leaves.length===t.length?-1:this.branches.findIndex((e=>e.length===t.length)),h=this.branches[d+1]??[this.root];return this.getProof(r.hash(a?e:o,a?o:e,this.hashMethod),h,n)}}},11686:(e,t,i)=>{i.d(t,{A6:()=>d,Dg:()=>a,Et:()=>h,Lm:()=>c,nj:()=>n,qv:()=>r,sI:()=>o});var s=i(90178);function r(e){return/^0x[0-9a-f]*$/i.test(e)}function a(e){return BigInt(e)}function o(e){return"bigint"==typeof e}function n(e){return(0,s.VO)(a(e).toString(16))}const d=e=>/^\d+$/.test(e);function h(e){return"number"==typeof e}function c(e){return"boolean"==typeof e}},69793:(e,t,i)=>{i.d(t,{BK:()=>d});var s=i(33187),r=i(58325),a=i(90178),o=i(11686);function n(e){const t=BigInt(function(e){return(0,a.VO)((0,s.Dq)((0,a.yw)(e)).toString(16))}(e));return t&r.n$}function d(e){return(0,o.nj)(n(e))}},67925:(e,t,i)=>{i.d(t,{IN:()=>c,KH:()=>h,Kg:()=>d,Mu:()=>u,O4:()=>n,Wb:()=>f,mE:()=>l});var s=i(58325),r=i(90178),a=i(11686);function o(e){return/^[\x00-\x7F]*$/.test(e)}function n(e){return e.length<=s.p7}function d(e){return"string"==typeof e}function h(e){return d(e)&&!(0,a.qv)(e)&&!(0,a.A6)(e)}const c=e=>h(e)&&!n(e);function l(e){const t=RegExp(`[^]{1,${s.p7}}`,"g");return e.match(t)||[]}function u(e){if(!o(e))throw new Error(`${e} is not an ASCII string`);if(!n(e))throw new Error(`${e} is too long`);return(0,r.VO)(e.replace(/./g,(e=>e.charCodeAt(0).toString(16))))}function f(e){if(!o(e))throw new Error(`${e} is not an ASCII string`);if((0,a.qv)(e))return(0,r.ow)(e).replace(/.{2}/g,(e=>String.fromCharCode(parseInt(e,16))));if(function(e){return/^[0-9]*$/i.test(e)}(e))return f("0X".concat(BigInt(e).toString(16)));throw new Error(`${e} is not Hex or decimal`)}},21878:(e,t,i)=>{i.d(t,{E:()=>S});var s=i(58325),r=i(30162),a=i(79550),o=i(62256),n=i(69491),d=i(69793),h=i(38354),c=i(11686),l=i(67925);const u={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},f={[r.K.Active]:{domain:"StarknetDomain",hashMethod:n.dl,hashMerkleMethod:n.h$,escapeTypeString:e=>`"${e}"`,presetTypes:u},[r.K.Legacy]:{domain:"StarkNetDomain",hashMethod:n.ez,hashMerkleMethod:n.CL,escapeTypeString:e=>e,presetTypes:{}}};function p(e,t,{min:i,max:s}){const r=BigInt(e);(0,a.A)(r>=i&&r<=s,`${r} (${t}) is out of bounds [${i}, ${s}]`)}function m({types:e,domain:t}){return f[r.K.Active].domain in e&&t.revision===r.K.Active?r.K.Active:f[r.K.Legacy].domain in e&&(t.revision??r.K.Legacy)===r.K.Legacy?r.K.Legacy:void 0}function g(e){try{return(0,c.nj)(e)}catch(t){if((0,l.Kg)(e))return(0,c.nj)((0,l.Mu)(e));throw new Error(`Invalid BigNumberish: ${e}`)}}function v(e,t,i=[],s="",a=r.K.Legacy){return"*"===t[t.length-1]?t=t.slice(0,-1):a===r.K.Active&&("enum"===t?t=s:t.match(/^\(.*\)$/)&&(t=t.slice(1,-1))),i.includes(t)||!e[t]?i:[t,...e[t].reduce(((t,i)=>[...t,...v(e,i.type,t,i.contains,a).filter((e=>!t.includes(e)))]),[])]}function y(e,t,i=r.K.Legacy){const s=i===r.K.Active?{...e,...f[i].presetTypes}:e,[a,...o]=v(s,t,void 0,void 0,i),n=a?[a,...o.sort()]:[],d=f[i].escapeTypeString;return n.map((e=>{const t=s[e].map((e=>{const t="enum"===e.type&&i===r.K.Active?e.contains:e.type,s=t.match(/^\(.*\)$/)?`(${t.slice(1,-1).split(",").map((e=>e?d(e):e)).join(",")})`:d(t);return`${d(e.name)}:${s}`}));return`${d(e)}(${t})`})).join("")}function b(e,t,i=r.K.Legacy){return(0,d.BK)(y(e,t,i))}function w(e,t,i,n={},l=r.K.Legacy){if(e[t])return[t,k(e,t,i,l)];if(f[l].presetTypes[t])return[t,k(f[l].presetTypes,t,i,l)];if(t.endsWith("*")){const s=i.map((i=>w(e,t.slice(0,-1),i,void 0,l)[1]));return[t,f[l].hashMethod(s)]}switch(t){case"enum":if(l===r.K.Active){const[s,r]=Object.entries(i)[0],a=e[n.parent][0],o=e[a.contains],d=o.find((e=>e.name===s)),h=o.indexOf(d),c=d.type.slice(1,-1).split(",").map(((t,i)=>{if(!t)return t;const s=r[i];return w(e,t,s,void 0,l)[1]}));return[t,f[l].hashMethod([h,...c])]}return[t,g(i)];case"merkletree":{const t=function(e,t){if(t.parent&&t.key){const i=e[t.parent].find((e=>e.name===t.key));if("merkletree"!==i.type)throw new Error(`${t.key} is not a merkle tree`);if(i.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${t.key}`);return i.contains}return"raw"}(e,n),s=i.map((i=>w(e,t,i,void 0,l)[1])),{root:r}=new h.v(s,f[l].hashMerkleMethod);return["felt",r]}case"selector":return["felt",(u=i,(0,c.qv)(u)?u:(0,d.BK)(u))];case"string":if(l===r.K.Active){const e=(0,o.p)(i),s=[e.data.length,...e.data,e.pending_word,e.pending_word_len];return[t,f[l].hashMethod(s)]}return[t,g(i)];case"i128":if(l===r.K.Active){const e=BigInt(i);return p(e,t,s.He),[t,g(e<0n?s.s9+e:e)]}return[t,g(i)];case"timestamp":case"u128":return l===r.K.Active&&p(i,t,s.bE),[t,g(i)];case"felt":case"shortstring":return l===r.K.Active&&p(g(i),t,s.Kp),[t,g(i)];case"ClassHash":case"ContractAddress":return l===r.K.Active&&p(i,t,s.Kp),[t,g(i)];case"bool":return l===r.K.Active&&(0,a.A)("boolean"==typeof i,`Type mismatch for ${t} ${i}`),[t,g(i)];default:if(l===r.K.Active)throw new Error(`Unsupported type: ${t}`);return[t,g(i)]}var u}function k(e,t,i,s=r.K.Legacy){return f[s].hashMethod(function(e,t,i,s=r.K.Legacy){const a=e[t]??f[s].presetTypes[t],[o,n]=a.reduce((([r,a],o)=>{if(void 0===i[o.name]||null===i[o.name]&&"enum"!==o.type)throw new Error(`Cannot encode data: missing data for '${o.name}'`);const n=i[o.name],d={parent:t,key:o.name},[h,c]=w(e,o.type,n,d,s);return[[...r,h],[...a,c]]}),[["felt"],[b(e,t,s)]]);return[o,n]}(e,t,i,s)[1])}function S(e,t){if(!function(e){const t=e;return Boolean(t.message&&t.primaryType&&t.types&&m(t))}(e))throw new Error("Typed data does not match JSON schema");const i=m(e),{domain:s,hashMethod:r}=f[i];return r([(0,l.Mu)("StarkNet Message"),k(e.types,s,e.domain,i),t,k(e.types,e.primaryType,e.message,i)])}},22634:(e,t,i)=>{var s;i.d(t,{V:()=>o});const r=new WeakMap,a=()=>{};class o{constructor(e){this.subscribers=[],this.settlement=null,this[s]="Unpromise",this.promise="function"==typeof e?new Promise(e):e;const t=this.promise.then((e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:e},t?.forEach((({resolve:t})=>{t(e)}))}));"catch"in t&&t.catch((e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"rejected",reason:e},t?.forEach((({reject:t})=>{t(e)}))}))}subscribe(){let e,t;const{settlement:i}=this;if(null===i){if(null===this.subscribers)throw new Error("Unpromise settled but still has subscribers");const i=function(){let e,t;const i=new Promise(((i,s)=>{e=i,t=s}));return{promise:i,resolve:e,reject:t}}();this.subscribers=(s=this.subscribers,r=i,[...s,r]),e=i.promise,t=()=>{null!==this.subscribers&&(this.subscribers=function(e,t){const i=e.indexOf(t);if(-1!==i)return function(e,t){return[...e.slice(0,t),...e.slice(t+1)]}(e,i);return e}(this.subscribers,i))}}else{const{status:s}=i;e="fulfilled"===s?Promise.resolve(i.value):Promise.reject(i.reason),t=a}var s,r;return Object.assign(e,{unsubscribe:t})}then(e,t){const i=this.subscribe(),{unsubscribe:s}=i;return Object.assign(i.then(e,t),{unsubscribe:s})}catch(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.catch(e),{unsubscribe:i})}finally(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.finally(e),{unsubscribe:i})}static proxy(e){const t=o.getSubscribablePromise(e);return void 0!==t?t:o.createSubscribablePromise(e)}static createSubscribablePromise(e){const t=new o(e);return r.set(e,t),r.set(t,t),t}static getSubscribablePromise(e){return r.get(e)}static resolve(e){const t="object"==typeof e&&null!==e&&"then"in e&&"function"==typeof e.then?e:Promise.resolve(e);return o.proxy(t).subscribe()}static async any(e){const t=(Array.isArray(e)?e:[...e]).map(o.resolve);try{return await Promise.any(t)}finally{t.forEach((({unsubscribe:e})=>{e()}))}}static async race(e){const t=(Array.isArray(e)?e:[...e]).map(o.resolve);try{return await Promise.race(t)}finally{t.forEach((({unsubscribe:e})=>{e()}))}}static async raceReferences(e){const t=e.map(n);try{return await Promise.race(t)}finally{for(const e of t)e.unsubscribe()}}}function n(e){return o.proxy(e).then((()=>[e]))}s=Symbol.toStringTag},35619:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(5156);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tabdeal",name:"Tabdeal",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tabdeal/64x64.png",api:{public:"https://api.tabdeal.org"},www:"https://tabdeal.org",doc:["https://docs.tabdeal.org"]},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"1D","1w":"1W"},api:{public:{get:{"plots/market_information":1,"r/api/v1/depth":1,"r/plots/history/":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetPlotsMarketInformation(e),i=[];for(let e=0;e<t.length;e++){const s=this.parseMarket(t[e]);i.push(s)}return i}parseMarket(e){const t=this.safeString(e,"symbol");let[i,s]=t.split("_");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetPlotsMarketInformation(t),s={};for(let e=0;e<i.length;e++){const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"high",0),a=this.safeFloat(e,"low",0),o=this.safeFloat(e,"open",0),n=this.safeFloat(e,"price",0),d=this.safeFloat(e,"price",0),h=this.safeFloat(e,"price",0),c=this.safeFloat(e,"volume",0),l=c*h,u=this.safeString(e,"created");return this.safeTicker({symbol:s,timestamp:this.safeTimestamp(e,"created"),datetime:u,high:r,low:a,bid:n,bidVolume:void 0,ask:d,askVolume:void 0,vwap:void 0,open:o,close:h,last:h,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:c,quoteVolume:l,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.id,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetRPlotsHistory(n),h=this.safeList(d,"data"),c=[];for(let e=0;e<h.length;e++){const t=h[e],i=this.safeValue(t,"time"),s=this.safeFloat(t,"open"),r=this.safeFloat(t,"high"),a=this.safeFloat(t,"low"),o=this.safeFloat(t,"close"),n=this.safeFloat(t,"volume");c.push([i,s,r,a,o,n])}return this.parseOHLCVs(c,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={tabdealSymbol:this.market(e).id},r=await this.publicGetRApiV1Depth(s),a=this.milliseconds();return this.parseOrderBook(r,e,a)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"r/plots/history/"===e&&(n=n+"?"+this.urlencode(o)),"r/api/v1/depth"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},90200:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talaavan",name:"Talaavan",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://goldcore.talaavan.com"},www:"https://goldcore.talaavan.com",doc:"https://goldcore.talaavan.com/v1/price"},api:{public:{get:{"v1/price":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV1Price(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"status",!1),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1Price(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1Price(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"data",{});let s=this.safeNumber(i,"rate");return void 0!==s&&(s/=10),this.safeTicker({symbol:t.symbol,timestamp:this.parse8601(this.safeString(i,"date")),datetime:void 0,high:void 0,low:void 0,bid:s,bidVolume:void 0,ask:s,askVolume:void 0,vwap:void 0,open:void 0,close:s,last:s,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:i},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},30236:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talapp",name:"Talapp",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://talapp.ir"},www:"https://talapp.ir",doc:"https://talapp.ir/wp-json/talapp/v1/gold-prices"},api:{public:{get:{"wp-json/talapp/v1/gold-prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetWpJsonTalappV1GoldPrices(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:!this.safeBool(e,"stale",!1),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetWpJsonTalappV1GoldPrices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetWpJsonTalappV1GoldPrices(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeString(e,"fetched_at");let s;void 0!==i&&(s=this.parse8601(i.replace(" ","T")+"+03:30"));const r=this.safeNumber(e,"buy_gold"),a=this.safeNumber(e,"sell_gold");let o=r;return void 0!==a&&(void 0===o||a>o)&&(o=a),this.safeTicker({symbol:t.symbol,timestamp:s,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:a,askVolume:void 0,vwap:void 0,open:void 0,close:o,last:o,previousClose:void 0,change:void 0,percentage:this.safeNumber(e,"sell_diff"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},43829:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talasea",name:"Talasea",countries:["IR"],rateLimit:1e3,version:"api",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,otc:!0,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},options:{defaultType:"otc"},urls:{api:{public:"https://api.talasea.ir/api"},www:"https://talasea.ir",doc:"https://talasea.ir"},api:{public:{get:{"market/getGoldPrice":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.01"),taker:this.parseNumber("0.01")}}})}async fetchMarkets(e={}){const t=await this.publicGetMarketGetGoldPrice(e);return[this.parseMarket(t)]}parseMarket(e){const t=this.safeBool(e,"disableBuy",!1),i=this.safeBool(e,"disableSell",!1);let s=!0;(t||i)&&(s=!1);return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:s,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"minOrderValue"),max:this.safeNumber(e,"maxOrderValue")}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetMarketGetGoldPrice(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetMarketGetGoldPrice(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:1e3*this.safeNumber(e,"price"),last:1e3*this.safeNumber(e,"price"),previousClose:void 0,change:void 0,percentage:this.safeNumber(e,"change24h"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api[t]+"/"+this.implodeParams(e,s);return Object.keys(o).length&&(n+="?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},80501:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"technogold",name:"Techno Gold",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api2.technogold.gold"},www:"https://technogold.gold",doc:"https://technogold.gold"},api:{public:{get:{"customer/tradeables/only-price/1":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetCustomerTradeablesOnlyPrice1(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"succeed",!0),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetCustomerTradeablesOnlyPrice1(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=this.market("XAU18/IRT"),s=await this.publicGetCustomerTradeablesOnlyPrice1(t),r=this.parseTicker(s,i),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"results",{}),s=this.safeNumber(i,"buy_price"),r=this.safeNumber(i,"sell_price");let a=s;return void 0!==r&&(void 0===a||r>a)&&(a=r),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:s,bidVolume:void 0,ask:r,askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},67496:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(73835);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tehran_exchange",name:"Tehran Exchange",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tehran_exchange/64x64.png",api:{public:"https://otc-api.tehran.exchange"},www:"https://tehran.exchange",doc:["https://tehran.exchange"]},api:{public:{get:{"otc/v1/market/pair":1,"otc/v1/market/order/pair/price":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")}}})}async fetchMarkets(e={}){const t=await this.publicGetOtcV1MarketPair(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"pairs",[]),r=[];for(let e=0;e<s.length;e++){const t=this.parseMarket(s[e]);r.push(t)}return r}parseMarket(e){const t=this.safeString(e,"pair"),i=this.safeString(e,"baseSymbol"),s=this.safeString(e,"quoteSymbol"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s),o=this.safeString(e,"status"),n=this.safeBool(e,"tradable",!1),d="TRADABLE"===o&&n,h=this.safeInteger(e,"amountPrecision"),c=this.safeInteger(e,"pricePrecision"),l=this.safeString(e,"minBaseAmount"),u=this.safeString(e,"minQuoteAmount"),f=this.safeString(e,"maxQuoteAmount");return{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:d,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:h,price:c},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(l),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.parseNumber(u),max:this.parseNumber(f)}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetOtcV1MarketPair(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"pairs",[]),a=[];for(let t=0;t<r.length;t++){const i=r[t],s=this.safeString(i,"pair"),o=this.safeSymbol(s);e.includes(o)&&a.push(i)}const o={};for(let e=0;e<a.length;e++){const t=a[e],i={pair:this.safeString(t,"pair"),side:"BUY",basedOn:"BASE",amount:1},s=await this.publicGetOtcV1MarketOrderPairPrice(i),r=this.safeDict(s,"data",{}),n=this.safeFloat(r,"price",0);t.price=n;const d=this.parseTicker(t);o[d.symbol]=d}return this.filterByArrayTickers(o,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[this.safeSymbol(e)]}parseTicker(e,t=void 0){const i=this.safeString(e,"baseSymbol")+"/"+this.safeString(e,"quoteSymbol"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"price");return this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:r,askVolume:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return Object.keys(o).length&&(n+="?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},77497:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(29012);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tetherland",name:"TetherLand",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tetherland/64x64.png",api:{public:"https://service.tetherland.com"},www:"https://tetherland.org",doc:["https://docs.tetherland.com/docs/tetherland/71ca11f41704f-user-api"]},api:{public:{get:{"api/v5/currencies":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiV5Currencies(e),i=this.safeList(t,"data"),s=[],r=["USDT","IRT"];for(let e=0;e<i.length;e++)for(let t=0;t<r.length;t++){if("USDT"===i[e].symbol&&"USDT"===r[t])continue;i[e].quote=r[t];const a=this.parseMarket(i[e]);s.push(a)}return s}parseMarket(e){let[t,i]=[this.safeString(e,"symbol"),this.safeString(e,"quote")];const s=this.safeCurrencyCode(t),r=this.safeCurrencyCode(i),a=s+"/"+r;return t=t.toLowerCase(),i=i.toLowerCase(),{id:a,symbol:s+"/"+r,base:s,quote:r,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiV5Currencies(t),s=this.safeList(i,"data"),r={},a=["USDT","IRT"];for(let e=0;e<s.length;e++)for(let t=0;t<a.length;t++){if("USDT"===s[e].symbol&&"USDT"===a[t])continue;s[e].quote=a[t],s[e].id=s[e].symbol+"/"+s[e].quote;const i=this.parseTicker(s[e]);r[i.symbol]=i}return this.filterByArrayTickers(r,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeString(e,"quote"),r=this.safeSymbol(i,t,void 0,"spot");let a=parseFloat(this.safeString(e,"price","").replace(",",""));"IRT"===s&&(a=this.safeFloat(e,"toman_amount",0));const o=this.safeFloat(e,"changes_24h",0);return this.safeTicker({symbol:r,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:o,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){return{url:this.urls.api.public+"/"+e,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},66213:(e,t,i)=>{i.d(t,{A:()=>n});var s=i(90334),r=i(62079),a=i(85147),o=i(51579);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"timex",name:"TimeX",countries:["AU"],version:"v1",rateLimit:1500,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1},timeframes:{"1m":"I1","5m":"I5","15m":"I15","30m":"I30","1h":"H1","2h":"H2","4h":"H4","6h":"H6","12h":"H12","1d":"D1","1w":"W1"},urls:{logo:"https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg",api:{rest:"https://plasma-relay-backend.timex.io"},www:"https://timex.io",doc:"https://plasma-relay-backend.timex.io/swagger-ui/index.html",referral:"https://timex.io/?refcode=1x27vNkTbP1uwkCck"},api:{addressbook:{get:["me"],post:["","id/{id}","id/{id}/remove"]},custody:{get:["credentials","credentials/h/{hash}","credentials/k/{key}","credentials/me","credentials/me/address","deposit-addresses","deposit-addresses/h/{hash}"]},history:{get:["orders","orders/details","orders/export/csv","trades","trades/export/csv"]},currencies:{get:["a/{address}","i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},manager:{get:["deposits","transfers","withdrawals"]},markets:{get:["i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},public:{get:["candles","currencies","markets","orderbook","orderbook/raw","orderbook/v2","tickers","trades"]},statistics:{get:["address"]},trading:{get:["balances","fees","orders"],post:["orders","orders/json"],put:["orders","orders/json"],delete:["orders","orders/json"]},tradingview:{get:["config","history","symbol_info","time"]}},precisionMode:o.kb,exceptions:{exact:{0:r.ExchangeError,1:r.NotSupported,4e3:r.BadRequest,4001:r.BadRequest,4002:r.InsufficientFunds,4003:r.AuthenticationError,4004:r.AuthenticationError,4005:r.BadRequest,4006:r.BadRequest,4007:r.BadRequest,4300:r.PermissionDenied,4100:r.AuthenticationError,4400:r.OrderNotFound,5001:r.InvalidOrder,5002:r.ExchangeError,400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.OrderNotFound,429:r.RateLimitExceeded,500:r.ExchangeError,503:r.ExchangeNotAvailable},broad:{Insufficient:r.InsufficientFunds}},options:{expireIn:31536e3,fetchTickers:{period:"1d"},fetchTrades:{sort:"timestamp,asc"},fetchMyTrades:{sort:"timestamp,asc"},fetchOpenOrders:{sort:"createdAt,asc"},fetchClosedOrders:{sort:"createdAt,asc"},defaultSort:"timestamp,asc",defaultSortOrders:"createdAt,asc"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchTime(e={}){const t=await this.tradingviewGetTime(e);return 1e3*this.parseToInt(t)}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e);return this.parseMarkets(t)}async fetchCurrencies(e={}){const t=await this.publicGetCurrencies(e);return this.parseCurrencies(t)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){const a=this.safeString(s,"address");if(s=this.omit(s,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const o={address:a},n=await this.managerGetDeposits(this.extend(o,s)),d=this.safeCurrency(e);return this.parseTransactions(n,d,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const a=this.safeString(s,"address");if(s=this.omit(s,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const o={address:a},n=await this.managerGetWithdrawals(this.extend(o,s)),d=this.safeCurrency(e);return this.parseTransactions(n,d,t,i)}getCurrencyByAddress(e){const t=this.currencies;for(let i=0;i<t.length;i++){const s=t[i],r=this.safeValue(s,"info",{});if(this.safeString(r,"address")===e)return s}}parseTransaction(e,t=void 0){const i=this.safeString(e,"timestamp"),s=this.safeString(e,"token","");return t=this.getCurrencyByAddress(s),{info:e,id:this.safeString(e,"transferHash"),txid:this.safeString(e,"txid"),timestamp:this.parse8601(i),datetime:i,network:void 0,address:void 0,addressTo:this.safeString(e,"to"),addressFrom:this.safeString(e,"from"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:this.safeNumber(e,"value"),currency:this.safeCurrencyCode(void 0,t),status:"ok",updated:void 0,internal:void 0,comment:void 0,fee:void 0}}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=this.safeString(this.options.fetchTickers,"period","1d"),s={period:this.timeframes[i]},r=await this.publicGetTickers(this.extend(s,t));return this.parseTickers(r,e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=this.safeString(this.options.fetchTickers,"period","1d"),r={market:i.id,period:this.timeframes[s]},a=await this.publicGetTickers(this.extend(r,t)),o=this.safeDict(a,0);return this.parseTicker(o,i)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id};void 0!==t&&(s.limit=t);const r=await this.publicGetOrderbookV2(this.extend(s,i)),a=this.parse8601(this.safeString(r,"timestamp"));return this.parseOrderBook(r,e,a,"bid","ask","price","baseTokenAmount")}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a=this.safeValue(this.options,"fetchTrades",{}),o=this.safeValue(a,"sort","timestamp,asc"),n=this.safeString(s,"sort",o),d=this.omit(s,"sort"),h={market:r.id,sort:n};void 0!==t&&(h.from=this.iso8601(t)),void 0!==i&&(h.size=i);const c=await this.publicGetTrades(this.extend(h,d));return this.parseTrades(c,r,t,i)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,period:this.safeString(this.timeframes,t,t)},n=this.parseTimeframe(t),d=this.safeInteger(r,"until");if(void 0===s&&(s=1e3),void 0!==i)o.from=this.iso8601(i),o.till=void 0===d?this.iso8601(this.sum(i,this.sum(s,1)*n*1e3)):this.iso8601(d);else if(void 0!==d){o.till=this.iso8601(d);const e=d-this.sum(s,1)*n*1e3;o.from=this.iso8601(e)}else{const e=this.milliseconds();o.till=this.iso8601(e),o.from=this.iso8601(e-this.sum(s,1)*n*1e3-1)}r=this.omit(r,"until");const h=await this.publicGetCandles(this.extend(o,r));return this.parseOHLCVs(h,a,t,i,s)}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let i=0;i<e.length;i++){const s=e[i],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.total=this.safeString(s,"totalBalance"),o.used=this.safeString(s,"lockedBalance"),t[a]=o}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.tradingGetBalances(e);return this.parseBalance(t)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d=i.toUpperCase();let h=t.toUpperCase();this.safeBool(o,"postOnly",!1)&&(h="POST_ONLY",o=this.omit(o,["postOnly"]));const c={symbol:n.id,quantity:this.amountToPrecision(e,s),side:d,orderTypes:h};let l=o;if("LIMIT"===h||"POST_ONLY"===h){c.price=this.priceToPrecision(e,a);const i=this.safeInteger(this.options,"expireIn"),s=this.safeValue(o,"expireTime"),n=this.safeValue(o,"expireIn",i);if(void 0!==s)c.expireTime=s;else{if(void 0===n)throw new r.InvalidOrder(this.id+" createOrder() method requires a expireTime or expireIn param for a "+t+" order, you can also set the expireIn exchange-wide option");c.expireIn=n}l=this.omit(o,["expireTime","expireIn"])}else c.price=0;const u=await this.tradingPostOrders(this.extend(c,l)),f=this.safeValue(u,"orders",[]),p=this.safeDict(f,0,{});return this.parseOrder(p,n)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n=this.market(t),d={id:e};void 0!==r&&(d.quantity=this.amountToPrecision(t,r)),void 0!==a&&(d.price=this.priceToPrecision(t,a));const h=await this.tradingPutOrders(this.extend(d,o));if("unchangedOrders"in h){const e=this.safeValue(h,"unchangedOrders",[]),t=this.safeString(e,0);return this.safeOrder({id:t,info:h})}const c=this.safeValue(h,"changedOrders",[]),l=this.safeValue(c,0,{}),u=this.safeDict(l,"newOrder",{});return this.parseOrder(u,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s=await this.cancelOrders([e],t,i);return this.safeDict(s,0)}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s={id:e},r=await this.tradingDeleteOrders(this.extend(s,i)),a=this.safeList(r,"changedOrders",[]),o=this.safeList(r,"unchangedOrders",[]),n=[];for(let e=0;e<a.length;e++){const t=this.safeDict(a[e],"newOrder");n.push(this.parseOrder(t))}for(let e=0;e<o.length;e++)n.push(this.safeOrder({info:o[e],id:o[e],status:"unchanged"}));return n}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderHash:e},r=await this.historyGetOrdersDetails(s),a=this.safeValue(r,"order",{}),o=this.safeList(r,"trades",[]);return this.parseOrder(this.extend(a,{trades:o}))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchOpenOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==i&&(d.size=i);const c=await this.tradingGetOrders(this.extend(d,n)),l=this.safeList(c,"orders",[]);return this.parseOrders(l,h,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchClosedOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o,side:"BUY"};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==i&&(d.size=i);const c=await this.historyGetOrders(this.extend(d,n)),l=this.safeList(c,"orders",[]);return this.parseOrders(l,h,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchMyTrades",{}),a=this.safeValue(r,"sort","timestamp,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==i&&(d.size=i);const c=await this.historyGetTrades(this.extend(d,n)),l=this.safeList(c,"trades",[]);return this.parseTrades(l,h,t,i)}parseTradingFee(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeNumber(e,"fee");return{info:e,symbol:this.safeSymbol(i,t),maker:s,taker:s,percentage:void 0,tierBased:void 0}}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={markets:i.id},r=await this.tradingGetFees(this.extend(s,t)),a=this.safeValue(r,0,{});return this.parseTradingFee(a,i)}parseMarket(e){const t=this.safeValue(e,"locked"),i=this.safeString(e,"symbol"),s=this.safeString(e,"baseCurrency"),r=this.safeString(e,"quoteCurrency"),o=this.safeCurrencyCode(s),n=this.safeCurrencyCode(r),d=this.safeString(e,"quantityIncrement"),h=this.safeString(e,"baseMinSize"),c=a.Y.stringMax(d,h),l=this.safeString(e,"tickSize"),u=this.safeNumber(e,"quoteMinSize");return{id:i,symbol:o+"/"+n,base:o,quote:n,settle:void 0,baseId:s,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!t,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"quantityIncrement"),price:this.safeNumber(e,"tickSize")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(c),max:void 0},price:{min:this.parseNumber(l),max:void 0},cost:{min:u,max:void 0}},created:void 0,info:e}}parseCurrency(e){const t=this.safeString(e,"symbol"),i=this.safeCurrencyCode(t),s=this.safeString(e,"withdrawalFee"),r=this.safeInteger(e,"tradeDecimals");let a;if(void 0!==s&&void 0!==r){const e=s.length-r;if(e>0){const t=s.slice(0,e),i=s.slice(-e);a=this.parseNumber(t+"."+i)}else{let t=".";for(let i=0;i<-e;i++)t+="0";a=this.parseNumber(t+s)}}return this.safeCurrencyStructure({id:i,code:i,info:e,type:void 0,name:this.safeString(e,"name"),active:this.safeBool(e,"active"),deposit:this.safeBool(e,"depositEnabled"),withdraw:this.safeBool(e,"withdrawalEnabled"),fee:a,precision:this.parseNumber(this.parsePrecision(this.safeString(e,"decimals"))),limits:{withdraw:{min:void 0,max:void 0},amount:{min:void 0,max:void 0}},networks:{}})}parseTicker(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"/"),r=this.parse8601(this.safeString(e,"timestamp")),a=this.safeString(e,"last"),o=this.safeString(e,"open");return this.safeTicker({symbol:s,info:e,timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:o,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:this.safeString(e,"volumeQuote")},t)}parseTrade(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t),r=this.parse8601(this.safeString(e,"timestamp")),o=this.safeString(e,"price"),n=this.safeString(e,"quantity"),d=this.parseNumber(o),h=this.parseNumber(n),c=this.parseNumber(a.Y.stringMul(o,n)),l=this.safeString(e,"id"),u=this.safeStringLower2(e,"direction","side"),f=this.safeStringLower(e,"makerOrTaker");let p,m;void 0!==f&&(p=this.safeString(e,f+"OrderId"));const g=this.safeNumber(e,"fee"),v=this.safeCurrencyCode(this.safeString(e,"feeToken"));return void 0!==g&&(m={cost:g,currency:v}),this.safeTrade({info:e,id:l,timestamp:r,datetime:this.iso8601(r),symbol:s,order:p,type:void 0,side:u,price:d,amount:h,cost:c,takerOrMaker:f,fee:m})}parseOHLCV(e,t=void 0){return[this.parse8601(this.safeString(e,"timestamp")),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}parseOrder(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeStringLower(e,"type"),r=this.safeStringLower(e,"side"),o=this.safeString(e,"symbol"),n=this.safeSymbol(o,t),d=this.parse8601(this.safeString(e,"createdAt")),h=this.safeString(e,"price"),c=this.safeString(e,"quantity"),l=this.safeString(e,"filledQuantity"),u=this.omitZero(this.safeString(e,"cancelledQuantity"));let f;f=a.Y.stringEquals(l,c)?"closed":void 0!==u?"canceled":"open";const p=this.safeValue(e,"trades",[]),m=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,id:i,clientOrderId:m,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:n,type:s,timeInForce:void 0,postOnly:void 0,side:r,price:h,triggerPrice:void 0,amount:c,cost:void 0,average:void 0,filled:l,remaining:void 0,status:f,fee:void 0,trades:p},t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={symbol:i.code},r=await this.currenciesGetSSymbol(this.extend(s,t)),a=this.safeDict(r,"currency",{});return this.parseDepositAddress(a,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,currency:this.safeCurrencyCode(i,t),network:void 0,address:this.safeString(e,"address"),tag:void 0}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.extractParams(e);e=this.implodeParams(e,s),s=this.omit(s,o);let n=this.urls.api.rest+"/"+t+"/"+e;if(Object.keys(s).length&&(n+="?"+this.urlencodeWithArrayRepeat(s)),"public"!==t&&"tradingview"!==t){this.checkRequiredCredentials();r={authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)}}return{url:n,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n&&e>=400){const e=this.id+" "+o;let t=this.safeValue(n,"error");void 0===t&&(t=n);const i=this.safeString2(t,"code","status"),s=this.safeString2(t,"message","debugMessage");throw this.throwBroadlyMatchedException(this.exceptions.broad,s,e),this.throwExactlyMatchedException(this.exceptions.exact,i,e),this.throwExactlyMatchedException(this.exceptions.exact,s,e),new r.ExchangeError(e)}}}},42490:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(47999),r=i(51579),a=i(62079),o=i(85147),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tokocrypto",name:"Tokocrypto",countries:["ID"],certified:!1,pro:!1,version:"v1",has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:void 0,borrowMargin:void 0,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:void 0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createReduceOnlyOrder:void 0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:void 0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLedger:void 0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpg",api:{rest:{public:"https://www.tokocrypto.com",binance:"https://api.binance.com/api/v3",private:"https://www.tokocrypto.com"}},www:"https://tokocrypto.com",doc:"https://www.tokocrypto.com/apidocs/",fees:"https://www.tokocrypto.com/fees/newschedule"},api:{binance:{get:{ping:1,time:1,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},trades:1,aggTrades:1,historicalTrades:5,klines:1,"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:1,noSymbol:2},exchangeInfo:10},put:{userDataStream:1},post:{userDataStream:1},delete:{userDataStream:1}},public:{get:{"open/v1/common/time":1,"open/v1/common/symbols":1,"open/v1/market/depth":1,"open/v1/market/trades":1,"open/v1/market/agg-trades":1,"open/v1/market/klines":1}},private:{get:{"open/v1/orders/detail":1,"open/v1/orders":1,"open/v1/account/spot":1,"open/v1/account/spot/asset":1,"open/v1/orders/trades":1,"open/v1/withdraws":1,"open/v1/deposits":1,"open/v1/deposits/address":1},post:{"open/v1/orders":1,"open/v1/orders/cancel":1,"open/v1/orders/oco":1,"open/v1/withdraws":1,"open/v1/user-data-stream":1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0075"),maker:this.parseNumber("0.0075")}},precisionMode:r.kb,options:{createMarketBuyOrderRequiresPrice:!0,defaultTimeInForce:"GTC",hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,newOrderRespType:{market:"FULL",limit:"FULL"},quoteOrderQty:!1,networks:{ERC20:"ETH",TRC20:"TRX",BEP2:"BNB",BEP20:"BSC",OMNI:"OMNI",EOS:"EOS",SPL:"SOL"},reverseNetworks:{"tronscan.org":"TRC20","etherscan.io":"ERC20","bscscan.com":"BSC","explorer.binance.org":"BEP2","bithomp.com":"XRP","bloks.io":"EOS","stellar.expert":"XLM","blockchair.com/bitcoin":"BTC","blockchair.com/bitcoin-cash":"BCH","blockchair.com/ecash":"XEC","explorer.litecoin.net":"LTC","explorer.avax.network":"AVAX","solscan.io":"SOL","polkadot.subscan.io":"DOT","dashboard.internetcomputer.org":"ICP","explorer.chiliz.com":"CHZ","cardanoscan.io":"ADA","mainnet.theoan.com":"AION","algoexplorer.io":"ALGO","explorer.ambrosus.com":"AMB","viewblock.io/zilliqa":"ZIL","viewblock.io/arweave":"AR","explorer.ark.io":"ARK","atomscan.com":"ATOM","www.mintscan.io":"CTK","explorer.bitcoindiamond.org":"BCD","btgexplorer.com":"BTG","bts.ai":"BTS","explorer.celo.org":"CELO","explorer.nervos.org":"CKB","cerebro.cortexlabs.ai":"CTXC","chainz.cryptoid.info":"VIA","explorer.dcrdata.org":"DCR","digiexplorer.info":"DGB","dock.subscan.io":"DOCK","dogechain.info":"DOGE","explorer.elrond.com":"EGLD","blockscout.com":"ETC","explore-fetchhub.fetch.ai":"FET","filfox.info":"FIL","fio.bloks.io":"FIO","explorer.firo.org":"FIRO","neoscan.io":"NEO","ftmscan.com":"FTM","explorer.gochain.io":"GO","block.gxb.io":"GXS","hash-hash.info":"HBAR","www.hiveblockexplorer.com":"HIVE","explorer.helium.com":"HNT","tracker.icon.foundation":"ICX","www.iostabc.com":"IOST","explorer.iota.org":"IOTA","iotexscan.io":"IOTX","irishub.iobscan.io":"IRIS","kava.mintscan.io":"KAVA","scope.klaytn.com":"KLAY","kmdexplorer.io":"KMD","kusama.subscan.io":"KSM","explorer.lto.network":"LTO","polygonscan.com":"POLYGON","explorer.ont.io":"ONT","minaexplorer.com":"MINA","nanolooker.com":"NANO","explorer.nebulas.io":"NAS","explorer.nbs.plus":"NBS","explorer.nebl.io":"NEBL","nulscan.io":"NULS","nxscan.com":"NXS","explorer.harmony.one":"ONE","explorer.poa.network":"POA","qtum.info":"QTUM","explorer.rsk.co":"RSK","www.oasisscan.com":"ROSE","ravencoin.network":"RVN","sc.tokenview.com":"SC","secretnodes.com":"SCRT","explorer.skycoin.com":"SKY","steemscan.com":"STEEM","explorer.stacks.co":"STX","www.thetascan.io":"THETA","scan.tomochain.com":"TOMO","explore.vechain.org":"VET","explorer.vite.net":"VITE","www.wanscan.org":"WAN","wavesexplorer.com":"WAVES","wax.eosx.io":"WAXP","waltonchain.pro":"WTC","chain.nem.ninja":"XEM","verge-blockchain.info":"XVG","explorer.yoyow.org":"YOYOW","explorer.zcha.in":"ZEC","explorer.zensystem.io":"ZEN"},impliedNetworks:{ETH:{ERC20:"ETH"},TRX:{TRC20:"TRX"}},legalMoney:{MXN:!0,UGX:!0,SEK:!0,CHF:!0,VND:!0,AED:!0,DKK:!0,KZT:!0,HUF:!0,PEN:!0,PHP:!0,USD:!0,TRY:!0,EUR:!0,NGN:!0,PLN:!0,BRL:!0,ZAR:!0,KES:!0,ARS:!0,RUB:!0,AUD:!0,NOK:!0,CZK:!0,GBP:!0,UAH:!0,GHS:!0,HKD:!0,CAD:!0,INR:!0,JPY:!0,NZD:!0}},exceptions:{exact:{"System is under maintenance.":a.OnMaintenance,"System abnormality":a.ExchangeError,"You are not authorized to execute this request.":a.PermissionDenied,"API key does not exist":a.AuthenticationError,"Order would trigger immediately.":a.OrderImmediatelyFillable,"Stop price would trigger immediately.":a.OrderImmediatelyFillable,"Order would immediately match and take.":a.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":a.InsufficientFunds,"Rest API trading is not enabled.":a.ExchangeNotAvailable,"You don't have permission.":a.PermissionDenied,"Market is closed.":a.ExchangeNotAvailable,"Too many requests. Please try again later.":a.DDoSProtection,"This action disabled is on this account.":a.AccountSuspended,"-1000":a.ExchangeNotAvailable,"-1001":a.ExchangeNotAvailable,"-1002":a.AuthenticationError,"-1003":a.RateLimitExceeded,"-1004":a.DDoSProtection,"-1005":a.PermissionDenied,"-1006":a.BadResponse,"-1007":a.RequestTimeout,"-1010":a.BadResponse,"-1011":a.PermissionDenied,"-1013":a.InvalidOrder,"-1014":a.InvalidOrder,"-1015":a.RateLimitExceeded,"-1016":a.ExchangeNotAvailable,"-1020":a.BadRequest,"-1021":a.InvalidNonce,"-1022":a.AuthenticationError,"-1023":a.BadRequest,"-1099":a.AuthenticationError,"-1100":a.BadRequest,"-1101":a.BadRequest,"-1102":a.BadRequest,"-1103":a.BadRequest,"-1104":a.BadRequest,"-1105":a.BadRequest,"-1106":a.BadRequest,"-1108":a.BadRequest,"-1109":a.AuthenticationError,"-1110":a.BadRequest,"-1111":a.BadRequest,"-1112":a.InvalidOrder,"-1113":a.BadRequest,"-1114":a.BadRequest,"-1115":a.BadRequest,"-1116":a.BadRequest,"-1117":a.BadRequest,"-1118":a.BadRequest,"-1119":a.BadRequest,"-1120":a.BadRequest,"-1121":a.BadSymbol,"-1125":a.AuthenticationError,"-1127":a.BadRequest,"-1128":a.BadRequest,"-1130":a.BadRequest,"-1131":a.BadRequest,"-1136":a.BadRequest,"-2008":a.AuthenticationError,"-2010":a.ExchangeError,"-2011":a.OrderNotFound,"-2013":a.OrderNotFound,"-2014":a.AuthenticationError,"-2015":a.AuthenticationError,"-2016":a.BadRequest,"-2018":a.InsufficientFunds,"-2019":a.InsufficientFunds,"-2020":a.OrderNotFillable,"-2021":a.OrderImmediatelyFillable,"-2022":a.InvalidOrder,"-2023":a.InsufficientFunds,"-2024":a.InsufficientFunds,"-2025":a.InvalidOrder,"-2026":a.InvalidOrder,"-2027":a.InvalidOrder,"-2028":a.InsufficientFunds,"-3000":a.ExchangeError,"-3001":a.AuthenticationError,"-3002":a.BadSymbol,"-3003":a.BadRequest,"-3004":a.ExchangeError,"-3005":a.InsufficientFunds,"-3006":a.InsufficientFunds,"-3007":a.ExchangeError,"-3008":a.InsufficientFunds,"-3009":a.BadRequest,"-3010":a.ExchangeError,"-3011":a.BadRequest,"-3012":a.ExchangeError,"-3013":a.BadRequest,"-3014":a.AccountSuspended,"-3015":a.ExchangeError,"-3016":a.BadRequest,"-3017":a.ExchangeError,"-3018":a.AccountSuspended,"-3019":a.AccountSuspended,"-3020":a.InsufficientFunds,"-3021":a.BadRequest,"-3022":a.AccountSuspended,"-3023":a.BadRequest,"-3024":a.ExchangeError,"-3025":a.BadRequest,"-3026":a.BadRequest,"-3027":a.BadSymbol,"-3028":a.BadSymbol,"-3029":a.ExchangeError,"-3036":a.AccountSuspended,"-3037":a.ExchangeError,"-3038":a.BadRequest,"-3041":a.InsufficientFunds,"-3042":a.BadRequest,"-3043":a.BadRequest,"-3044":a.DDoSProtection,"-3045":a.ExchangeError,"-3999":a.ExchangeError,"-4001":a.BadRequest,"-4002":a.BadRequest,"-4003":a.BadRequest,"-4004":a.AuthenticationError,"-4005":a.RateLimitExceeded,"-4006":a.BadRequest,"-4007":a.BadRequest,"-4008":a.BadRequest,"-4010":a.BadRequest,"-4011":a.BadRequest,"-4012":a.BadRequest,"-4013":a.AuthenticationError,"-4014":a.PermissionDenied,"-4015":a.ExchangeError,"-4016":a.PermissionDenied,"-4017":a.PermissionDenied,"-4018":a.BadSymbol,"-4019":a.BadSymbol,"-4021":a.BadRequest,"-4022":a.BadRequest,"-4023":a.ExchangeError,"-4024":a.InsufficientFunds,"-4025":a.InsufficientFunds,"-4026":a.InsufficientFunds,"-4027":a.ExchangeError,"-4028":a.BadRequest,"-4029":a.BadRequest,"-4030":a.ExchangeError,"-4031":a.ExchangeError,"-4032":a.ExchangeError,"-4033":a.BadRequest,"-4034":a.ExchangeError,"-4035":a.PermissionDenied,"-4036":a.BadRequest,"-4037":a.ExchangeError,"-4038":a.ExchangeError,"-4039":a.BadRequest,"-4040":a.BadRequest,"-4041":a.ExchangeError,"-4042":a.ExchangeError,"-4043":a.BadRequest,"-4044":a.BadRequest,"-4045":a.ExchangeError,"-4046":a.AuthenticationError,"-4047":a.BadRequest,"-5001":a.BadRequest,"-5002":a.InsufficientFunds,"-5003":a.InsufficientFunds,"-5004":a.BadRequest,"-5005":a.InsufficientFunds,"-5006":a.BadRequest,"-5007":a.BadRequest,"-5008":a.InsufficientFunds,"-5009":a.BadRequest,"-5010":a.ExchangeError,"-5011":a.BadRequest,"-5012":a.ExchangeError,"-5013":a.InsufficientFunds,"-5021":a.BadRequest,"-6001":a.BadRequest,"-6003":a.BadRequest,"-6004":a.ExchangeError,"-6005":a.InvalidOrder,"-6006":a.BadRequest,"-6007":a.BadRequest,"-6008":a.BadRequest,"-6009":a.RateLimitExceeded,"-6011":a.BadRequest,"-6012":a.InsufficientFunds,"-6013":a.ExchangeError,"-6014":a.BadRequest,"-6015":a.BadRequest,"-6016":a.BadRequest,"-6017":a.BadRequest,"-6018":a.BadRequest,"-6019":a.AuthenticationError,"-6020":a.BadRequest,"-7001":a.BadRequest,"-7002":a.BadRequest,"-9000":a.InsufficientFunds,"-10017":a.BadRequest,"-11008":a.InsufficientFunds,"-12014":a.RateLimitExceeded,"-13000":a.BadRequest,"-13001":a.BadRequest,"-13002":a.BadRequest,"-13003":a.BadRequest,"-13004":a.BadRequest,"-13005":a.BadRequest,"-13006":a.InvalidOrder,"-13007":a.AuthenticationError,"-21001":a.BadRequest,"-21002":a.BadRequest,"-21003":a.BadRequest,100001003:a.BadRequest,2202:a.InsufficientFunds,3210:a.InvalidOrder,3203:a.InvalidOrder,3211:a.InvalidOrder,3207:a.InvalidOrder,3218:a.OrderNotFound},broad:{"has no operation privilege":a.PermissionDenied,MAX_POSITION:a.InvalidOrder}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!0,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetOpenV1CommonTime(e);return this.safeInteger(t,"timestamp")}async fetchMarkets(e={}){const t=await this.publicGetOpenV1CommonSymbols(e);this.options.adjustForTimeDifference&&await this.loadTimeDifference();const i=this.safeValue(t,"data",{}),s=this.safeValue(i,"list",[]),r=[];for(let e=0;e<s.length;e++){const t=s[e],i=this.safeString(t,"baseAsset"),a=this.safeString(t,"quoteAsset"),o=this.safeString(t,"symbol"),n=this.safeStringLower(t,"symbol"),d=this.safeString(t,"marginAsset"),h=this.safeCurrencyCode(i),c=this.safeCurrencyCode(a),l=this.safeCurrencyCode(d),u=h+"/"+c,f=this.safeValue(t,"filters",[]),p=this.indexBy(f,"filterType");let m="1"===this.safeString(t,"spotTradingEnable");const g=this.safeValue(t,"permissions",[]);for(let e=0;e<g.length;e++)if("TRD_GRP_003"===g[e]){m=!1;break}const v={id:o,lowercaseId:n,symbol:u,base:h,quote:c,settle:l,baseId:i,quoteId:a,settleId:d,type:"spot",spot:!0,margin:this.safeBool(t,"isMarginTradingAllowed",!1),swap:!1,future:!1,delivery:!1,option:!1,active:m,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(t,"quantityPrecision"))),price:this.parseNumber(this.parsePrecision(this.safeString(t,"pricePrecision"))),base:this.parseNumber(this.parsePrecision(this.safeString(t,"baseAssetPrecision"))),quote:this.parseNumber(this.parsePrecision(this.safeString(t,"quotePrecision")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t};if("PRICE_FILTER"in p){const e=this.safeValue(p,"PRICE_FILTER",{});v.precision.price=this.safeNumber(e,"tickSize"),v.limits.price={min:this.safeNumber(e,"minPrice"),max:this.safeNumber(e,"maxPrice")},v.precision.price=e.tickSize}if("LOT_SIZE"in p){const e=this.safeValue(p,"LOT_SIZE",{});v.precision.amount=this.safeNumber(e,"stepSize"),v.limits.amount={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MARKET_LOT_SIZE"in p){const e=this.safeValue(p,"MARKET_LOT_SIZE",{});v.limits.market={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MIN_NOTIONAL"in p){const e=this.safeValue(p,"MIN_NOTIONAL",{});v.limits.cost.min=this.safeNumber2(e,"minNotional","notional")}r.push(v)}return r}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={};let a;void 0!==t&&(r.limit=t),"USDT"===s.quote?(r.symbol=s.baseId+s.quoteId,a=await this.binanceGetDepth(this.extend(r,i))):(r.symbol=s.id,a=await this.publicGetOpenV1MarketDepth(this.extend(r,i)));const o=this.safeValue(a,"data",a),n=this.safeInteger2(a,"T","timestamp"),d=this.parseOrderBook(o,e,n);return d.nonce=this.safeInteger(o,"lastUpdateId"),d}parseTrade(e,t=void 0){const i=this.safeInteger2(e,"T","time"),s=this.safeString2(e,"p","price"),r=this.safeString2(e,"q","qty"),a=this.safeString2(e,"quoteQty","baseQty"),o=this.safeString(e,"symbol"),n=this.safeSymbol(o,t);let d,h=this.safeString2(e,"t","a");h=this.safeString2(e,"id","tradeId",h);const c=this.safeString(e,"orderId"),l=this.safeValue2(e,"m","isBuyerMaker");let u,f;return void 0!==l?(d=l?"sell":"buy",u="taker"):"side"in e?d=this.safeStringLower(e,"side"):"isBuyer"in e&&(d=e.isBuyer?"buy":"sell"),"commission"in e&&(f={cost:this.safeString(e,"commission"),currency:this.safeCurrencyCode(this.safeString(e,"commissionAsset"))}),"isMaker"in e&&(u=e.isMaker?"maker":"taker"),"maker"in e&&(u=e.maker?"maker":"taker"),this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:n,id:h,order:c,type:void 0,side:d,takerOrMaker:u,price:s,amount:r,cost:a,fee:f},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:this.getMarketIdByType(r)};if("USDT"!==r.quote){void 0!==i&&(a.limit=i);const e=this.publicGetOpenV1MarketTrades(this.extend(a,s)),o=this.safeDict(e,"data",{}),n=this.safeList(o,"list",[]);return this.parseTrades(n,r,t,i)}void 0!==i&&(a.limit=i);let o;return"binanceGetAggTrades"===this.safeString(this.options,"fetchTradesMethod","binanceGetTrades")&&void 0!==t?(a.startTime=t,a.endTime=this.sum(t,36e5),o=await this.binanceGetAggTrades(this.extend(a,s))):o=await this.binanceGetTrades(this.extend(a,s)),this.parseTrades(o,r,t,i)}parseTicker(e,t=void 0){const i=this.safeInteger(e,"closeTime"),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t),a=this.safeString(e,"lastPrice");let o,n;return"baseVolume"in e?(o=this.safeString(e,"baseVolume"),n=this.safeString(e,"volume")):(o=this.safeString(e,"volume"),n=this.safeString(e,"quoteVolume")),this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"highPrice"),low:this.safeString(e,"lowPrice"),bid:this.safeString(e,"bidPrice"),bidVolume:this.safeString(e,"bidQty"),ask:this.safeString(e,"askPrice"),askVolume:this.safeString(e,"askQty"),vwap:this.safeString(e,"weightedAvgPrice"),open:this.safeString(e,"openPrice"),close:a,last:a,previousClose:this.safeString(e,"prevClosePrice"),change:this.safeString(e,"priceChange"),percentage:this.safeString(e,"priceChangePercent"),average:void 0,baseVolume:o,quoteVolume:n,info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.binanceGetTicker24hr(t);return this.parseTickers(i,e)}getMarketIdByType(e){return"USDT"===e.quote?e.baseId+e.quoteId:e.id}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.baseId+i.quoteId},r=await this.binanceGetTicker24hr(this.extend(s,t));if(Array.isArray(r)){const e=this.safeDict(r,0,{});return this.parseTicker(e,i)}return this.parseTicker(r,i)}async fetchBidsAsks(e=void 0,t={}){await this.loadMarkets();const i=await this.binanceGetTickerBookTicker(t);return this.parseTickers(i,e)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.safeString(r,"price"),n=this.safeInteger(r,"until");r=this.omit(r,["price","until"]),s=void 0===s?500:Math.min(s,1500);const d={interval:this.safeString(this.timeframes,t,t),limit:s};let h;"index"===o?d.pair=a.id:d.symbol=this.getMarketIdByType(a),void 0!==i&&(d.startTime=i),void 0!==n&&(d.endTime=n),h="USDT"===a.quote?await this.binanceGetKlines(this.extend(d,r)):await this.publicGetOpenV1MarketKlines(this.extend(d,r));const c=this.safeList(h,"data",h);return this.parseOHLCVs(c,a,t,i,s)}async fetchBalance(e={}){await this.loadMarkets();const t=this.safeString2(this.options,"fetchBalance","defaultType","spot"),i=this.safeString(e,"type",t),s=this.safeString2(this.options,"marginMode","defaultMarginMode"),r=this.safeStringLower(e,"marginMode",s),a=await this.privateGetOpenV1AccountSpot(this.extend({},e));return this.parseBalanceCustom(a,i,r)}parseBalanceCustom(e,t=void 0,i=void 0){const s=this.safeInteger(e,"updateTime"),r={info:e,timestamp:s,datetime:this.iso8601(s)},a=this.safeValue(e,"data",{}),o=this.safeValue(a,"accountAssets",[]);for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"asset"),s=this.safeCurrencyCode(i),a=this.account();a.free=this.safeString(t,"free"),a.used=this.safeString(t,"locked"),r[s]=a}return this.safeBalance(r)}parseOrderStatus(e){return this.safeString({"-2":"open",0:"open",1:"open",2:"closed",3:"canceled",4:"canceling",5:"rejected",6:"expired",NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",PENDING_CANCEL:"canceling",REJECTED:"rejected",EXPIRED:"expired"},e,e)}parseOrder(e,t=void 0){const i=this.parseOrderStatus(this.safeString(e,"status")),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t),a=this.safeString(e,"executedQty","0"),o=this.safeInteger(e,"createTime"),n=this.safeString(e,"avgPrice"),d=this.safeString2(e,"price","executedPrice"),h=this.safeString(e,"origQty"),c=this.safeStringN(e,["cummulativeQuoteQty","cumQuote","executedQuoteQty","cumBase"]),l=this.safeString(e,"orderId"),u=this.parseOrderType(this.safeStringLower(e,"type"));let f=this.safeStringLower(e,"side");"0"===f?f="buy":"1"===f&&(f="sell");const p=this.safeValue(e,"fills",[]),m=this.safeString2(e,"clientOrderId","clientId");let g=this.safeString(e,"timeInForce");"GTX"===g&&(g="PO");const v="limit_maker"===u||"PO"===g;return this.safeOrder({info:e,id:l,clientOrderId:m,timestamp:o,datetime:this.iso8601(o),lastTradeTimestamp:void 0,symbol:r,type:u,timeInForce:g,postOnly:v,reduceOnly:this.safeValue(e,"reduceOnly"),side:f,price:d,triggerPrice:this.parseNumber(this.omitZero(this.safeString(e,"stopPrice"))),amount:h,cost:c,average:n,filled:a,remaining:void 0,status:i,fee:void 0,trades:p},t)}parseOrderType(e){return this.safeString({2:"market",1:"limit",4:"limit",7:"limit"},e,e)}async createOrder(e,t,i,s,n=void 0,d={}){await this.loadMarkets();const h=this.market(e),c=this.safeString2(d,"clientOrderId","clientId");this.safeBool(d,"postOnly",!1)&&(t="LIMIT_MAKER"),d=this.omit(d,["clientId","clientOrderId"]);const l=t.toUpperCase();let u=l;const f=this.safeValue2(d,"triggerPrice","stopPrice");void 0!==f&&(d=this.omit(d,["triggerPrice","stopPrice"]),"MARKET"===u?u="STOP_LOSS":"LIMIT"===u&&(u="STOP_LOSS_LIMIT"));const p=this.safeValue(h.info,"orderTypes");if(!this.inArray(u,p))throw l!==u?new a.InvalidOrder(this.id+" triggerPrice parameter is not allowed for "+e+" "+t+" orders"):new a.InvalidOrder(this.id+" "+t+" is not a valid order type for the "+e+" market");const m={symbol:h.baseId+"_"+h.quoteId,type:this.safeString({LIMIT:1,MARKET:2,STOP_LOSS:3,STOP_LOSS_LIMIT:4,TAKE_PROFIT:5,TAKE_PROFIT_LIMIT:6,LIMIT_MAKER:7},u)};if("buy"===i?m.side=0:"sell"===i&&(m.side=1),void 0===c){const e=this.safeValue(this.options,"broker");if(void 0!==e){const t=this.safeString(e,"marketType");void 0!==t&&(m.clientId=t+this.uuid22())}}else m.clientId=c;let g=!1,v=!1,y=!1;if("MARKET"===u)if("buy"===i){const e=h.precision.price;let t,i=!0;[i,d]=this.handleOptionAndParams(d,"createOrder","createMarketBuyOrderRequiresPrice",!0);const c=this.safeNumber2(d,"cost","quoteOrderQty");if(d=this.omit(d,["cost","quoteOrderQty"]),void 0!==c)t=c;else if(i){if(void 0===n)throw new a.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument");{const e=this.numberToString(s),i=this.numberToString(n);t=o.Y.stringMul(e,i)}}else t=s;m.quoteOrderQty=this.decimalToPrecision(t,r.R3,e,this.precisionMode)}else y=!0;else"LIMIT"===u?(g=!0,y=!0):"STOP_LOSS"===u||"TAKE_PROFIT"===u?(v=!0,y=!0,(h.linear||h.inverse)&&(g=!0)):"STOP_LOSS_LIMIT"===u||"TAKE_PROFIT_LIMIT"===u?(y=!0,v=!0,g=!0):"LIMIT_MAKER"===u&&(g=!0,y=!0);if(y&&(m.quantity=this.amountToPrecision(e,s)),g){if(void 0===n)throw new a.InvalidOrder(this.id+" createOrder() requires a price argument for a "+t+" order");m.price=this.priceToPrecision(e,n)}if(v){if(void 0===f)throw new a.InvalidOrder(this.id+" createOrder() requires a triggerPrice extra param for a "+t+" order");m.stopPrice=this.priceToPrecision(e,f)}const b=await this.privatePostOpenV1Orders(this.extend(m,d)),w=this.safeDict(b,"data",{});return this.parseOrder(w,h)}async fetchOrder(e,t=void 0,i={}){const s={orderId:e},r=await this.privateGetOpenV1Orders(this.extend(s,i)),a=this.safeValue(r,"data",{}),o=this.safeValue(a,"list",[]),n=this.safeDict(o,0,{});return this.parseOrder(n)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const r=this.market(e),o={symbol:r.id};void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i);const n=await this.privateGetOpenV1Orders(this.extend(o,s)),d=this.safeValue(n,"data",{}),h=this.safeList(d,"list",[]);return this.parseOrders(h,r,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({type:1},s))}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({type:2},s))}async cancelOrder(e,t=void 0,i={}){const s={orderId:e},r=await this.privatePostOpenV1OrdersCancel(this.extend(s,i)),a=this.safeDict(r,"data",{});return this.parseOrder(a)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const r=this.market(e),o={symbol:r.id},n=this.safeInteger2(s,"until","endTime");void 0!==t&&(o.startTime=t),void 0!==n&&(o.endTime=n,s=this.omit(s,["endTime","until"])),void 0!==i&&(o.limit=i);const d=await this.privateGetOpenV1OrdersTrades(this.extend(o,s)),h=this.safeValue(d,"data",{}),c=this.safeList(h,"list",[]);return this.parseTrades(c,r,t,i)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i={asset:this.currency(e).id},s=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(s,r,r),void 0!==r&&(i.network=r,t=this.omit(t,"network"));const a=await this.privateGetOpenV1DepositsAddress(this.extend(i,t)),o=this.safeValue(a,"data",{}),n=this.safeString(o,"address");let d=this.safeString(o,"addressTag","");return 0===d.length&&(d=void 0),this.checkAddress(n),{info:a,currency:e,network:this.safeString(o,"network"),address:n,tag:d}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={},o=this.safeInteger(s,"until");if(void 0!==e&&(r=this.currency(e),a.coin=r.id),void 0!==t){a.startTime=t;let e=this.sum(t,7776e6);void 0!==o&&(e=Math.min(e,o)),a.endTime=e}void 0!==i&&(a.limit=i);const n=await this.privateGetOpenV1Deposits(this.extend(a,s)),d=this.safeValue(n,"data",{}),h=this.safeList(d,"list",[]);return this.parseTransactions(h,r,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t,r.endTime=this.sum(t,7776e6)),void 0!==i&&(r.limit=i);const o=await this.privateGetOpenV1Withdraws(this.extend(r,s)),n=this.safeValue(o,"data",{}),d=this.safeList(n,"list",[]);return this.parseTransactions(d,a,t,i)}parseTransactionStatusByType(e,t=void 0){const i=this.safeValue({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",1:"canceled",2:"pending",3:"failed",4:"pending",5:"failed",10:"ok"}},t,{});return this.safeString(i,e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"address");let s=this.safeString(e,"addressTag");void 0!==s&&s.length<1&&(s=void 0);let r=this.safeString(e,"txId");void 0!==r&&r.indexOf("Internal transfer ")>=0&&(r=r.slice(18));const a=this.safeString2(e,"coin","fiatCurrency"),o=this.safeCurrencyCode(a,t);let n;const d=this.safeInteger(e,"insertTime"),h=this.safeInteger2(e,"createTime","timestamp");let c=this.safeString(e,"type");void 0===c&&(void 0!==d&&void 0===h?(c="deposit",n=d):void 0===d&&void 0!==h&&(c="withdrawal",n=h));const l=this.safeNumber2(e,"transactionFee","totalFee"),u={currency:void 0,cost:void 0,rate:void 0};void 0!==l&&(u.currency=o,u.cost=l);let f=!1;void 0!==this.safeInteger(e,"transferType")&&(f=!0);let p=this.safeString(e,"id");if(void 0===p){const t=this.safeValue(e,"data",{});p=this.safeString(t,"withdrawId"),c="withdrawal"}return{info:e,id:p,txid:r,type:c,currency:o,network:this.safeString(e,"network"),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatusByType(this.safeString(e,"status"),c),timestamp:n,datetime:this.iso8601(n),address:i,addressFrom:void 0,addressTo:i,tag:s,tagFrom:void 0,tagTo:s,updated:this.safeInteger2(e,"successTime","updateTime"),comment:void 0,internal:f,fee:u}}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a=this.currency(e),o={asset:a.id,address:i,amount:this.numberToString(t)};void 0!==s&&(o.addressTag=s);const[n,d]=this.handleNetworkCodeAndParams(r),h=this.networkCodeToId(n);void 0!==h&&(o.network=h.toUpperCase());const c=await this.privatePostOpenV1Withdraws(this.extend(o,d));return this.parseTransaction(c,a)}sign(e,t="public",i="GET",s={},r=void 0,o=void 0){if(!(t in this.urls.api.rest))throw new a.NotSupported(this.id+" does not have a testnet/sandbox URL for "+t+" endpoints");let d=this.urls.api.rest[t];d+="/"+e,"wapi"===t&&(d+=".html");if("userDataStream"===e||"listenKey"===e){if(!this.apiKey)throw new a.AuthenticationError(this.id+" userDataStream endpoint requires `apiKey` credential");r={"X-MBX-APIKEY":this.apiKey,"Content-Type":"application/x-www-form-urlencoded"},"GET"!==i&&(o=this.urlencode(s))}else if("private"===t||"sapi"===t&&"system/status"!==e||"sapiV3"===t||"wapi"===t&&"systemStatus"!==e||"dapiPrivate"===t||"dapiPrivateV2"===t||"fapiPrivate"===t||"fapiPrivateV2"===t){let a;this.checkRequiredCredentials();const h=this.safeInteger(this.options,"recvWindow"),c=this.extend({timestamp:this.nonce()},s);void 0!==h&&(c.recvWindow=h);const l=this.safeInteger(s,"recvWindow");void 0!==l&&(c.recvWindow=l),a="sapi"===t&&"asset/dust"===e?this.urlencodeWithArrayRepeat(c):"batchOrders"===e||e.indexOf("sub-account")>=0||"capital/withdraw/apply"===e||e.indexOf("staking")>=0?this.rawencode(c):this.urlencode(c);a+="&signature="+this.hmac(this.encode(a),this.encode(this.secret),n.s),r={"X-MBX-APIKEY":this.apiKey},"GET"===i||"DELETE"===i||"wapi"===t?d+="?"+a:(o=a,r["Content-Type"]="application/x-www-form-urlencoded")}else Object.keys(s).length&&(d+="?"+this.urlencode(s));return{url:d,method:i,body:o,headers:r}}handleErrors(e,t,i,s,r,n,d,h,c){if(418===e||429===e)throw new a.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(e>=400){if(n.indexOf("Price * QTY is zero or less")>=0)throw new a.InvalidOrder(this.id+" order cost = amount * price is zero or less "+n);if(n.indexOf("LOT_SIZE")>=0)throw new a.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+n);if(n.indexOf("PRICE_FILTER")>=0)throw new a.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) "+n)}if(void 0===d)return;const l=this.safeBool(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const f=this.safeString(d,"code");if(void 0!==f){if("200"===f||o.Y.stringEquals(f,"0"))return;if("-2015"===f&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new a.DDoSProtection(this.id+" "+n);const e=this.id+" "+n;if("No need to change margin type."===u)throw new a.MarginModeAlreadySet(e);throw this.throwExactlyMatchedException(this.exceptions.exact,f,e),new a.ExchangeError(e)}if(!l)throw new a.ExchangeError(this.id+" "+n)}calculateRateLimiterCost(e,t,i,s,r={}){if("noCoin"in r&&!("coin"in s))return r.noCoin;if("noSymbol"in r&&!("symbol"in s))return r.noSymbol;if("noPoolId"in r&&!("poolId"in s))return r.noPoolId;if("byLimit"in r&&"limit"in s){const e=s.limit,t=r.byLimit;for(let i=0;i<t.length;i++){const s=t[i];if(e<=s[0])return s[1]}}return this.safeInteger(r,"cost",1)}}},90237:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(53016);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"toobit",name:"Toobit",countries:["KY"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://toobit-docs.github.io/apidocs/spot/v1/en/images/logo.svg",api:{public:"https://api.toobit.com"},www:"https://www.toobit.com/",doc:["https://toobit-docs.github.io/apidocs/spot/v1/en/#change-log"]},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},api:{public:{get:{"quote/v1/ticker/24hr":1,"quote/v1/klines":1,"/api/v1/exchangeInfo":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiV1ExchangeInfo(),i=this.safeValue(t,"symbols",[]),s=[];for(let e=0;e<i.length;e++){const t=i[e],r=this.safeValue(t,"status"),a=this.safeValue(t,"symbol");if("TRADING"!==r||"TESTA1S3TESTX8Z9"===a)continue;const o=this.parseMarket(t);s.push(o)}return s}parseMarket(e){const t=this.safeValue(e,"symbol"),i=this.safeValue(e,"baseAsset"),s=this.safeValue(e,"quoteAsset"),r=this.safeValue(e,"baseAssetPrecision"),a=this.safeValue(e,"quotePrecision"),o=this.safeValue(e,"allowMargin",!1),n=this.safeValue(e,"filters",[]);let d,h,c,l,u,f,p,m,g;for(let e=0;e<n.length;e++){const t=n[e],i=this.safeValue(t,"filterType");"PRICE_FILTER"===i?(d=this.safeNumber(t,"minPrice"),h=this.safeNumber(t,"maxPrice"),c=this.safeString(t,"tickSize")):"LOT_SIZE"===i?(l=this.safeNumber(t,"minQty"),u=this.safeNumber(t,"maxQty"),f=this.safeString(t,"stepSize")):"MIN_NOTIONAL"===i?p=this.safeNumber(t,"minNotional"):"TRADE_AMOUNT"===i&&(m=this.safeNumber(t,"minAmount"),g=this.safeNumber(t,"maxAmount"))}const v=t,y=this.safeCurrencyCode(i),b=this.safeCurrencyCode(s);return{id:v,symbol:y+"/"+b,base:y,quote:b,settle:void 0,baseId:i.toLowerCase(),quoteId:s.toLowerCase(),settleId:void 0,type:"spot",spot:!0,margin:o,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:f?this.precisionFromString(f.toString()):this.precisionFromString(r),price:c?this.precisionFromString(c.toString()):this.precisionFromString(a)},limits:{leverage:{min:void 0,max:void 0},amount:{min:l,max:u},price:{min:d,max:h},cost:{min:p||m,max:g}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetQuoteV1Ticker24hr(),s={};for(let e=0;e<i.length;e++){if(0===this.safeFloat(i[e],"v"))continue;const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i={symbol:this.market(e).id},s=await this.publicGetQuoteV1Ticker24hr(i);return this.parseTicker(s[0])}parseTicker(e,t=void 0){let i=this.safeValue(e,"s");const s=i;i=this.safeSymbol(s,t,void 0,"spot");const r=this.safeFloat(e,"h"),a=this.safeFloat(e,"l"),o=this.safeFloat(e,"o"),n=this.safeFloat(e,"c"),d=this.safeFloat(e,"c"),h=this.safeFloat(e,"pcp"),c=this.safeFloat(e,"pc"),l=this.safeFloat(e,"v"),u=this.safeFloat(e,"qv"),f=this.safeString(e,"t"),p=this.safeFloat(e,"b",0),m=this.safeFloat(e,"a",0);return this.safeTicker({symbol:i,timestamp:f,datetime:this.parse8601(f),high:r,low:a,bid:p,bidVolume:void 0,ask:m,askVolume:void 0,vwap:void 0,open:o,close:n,last:d,previousClose:void 0,change:c,percentage:h,average:void 0,baseVolume:l,quoteVolume:u,info:e},t)}async fetchOHLCV(e,t="1h",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=Date.now(),n={symbol:a.id,from:o-864e5,to:o,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i),void 0!==t&&(n.interval=this.safeString(this.timeframes,t,t));const d=await this.publicGetQuoteV1Klines(n),h=[];for(let e=0;e<d.length;e++){const t=d[e],i=this.safeTimestamp(t,0),s=this.safeFloat(t,1),r=this.safeFloat(t,2),a=this.safeFloat(t,3),o=this.safeFloat(t,4),n=this.safeFloat(t,5);h.push([i,s,r,a,o,n])}return this.parseOHLCVs(h,a,t,i,s)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"quote/v1/ticker/24hr"===e&&(n=n+"?"+this.urlencode(o)),"quote/v1/klines"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},45887:(e,t,i)=>{i.d(t,{A:()=>o});var s=i(94352),r=i(62079),a=i(51579);class o extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tradeogre",name:"tradeogre",countries:[],rateLimit:100,version:"v2",pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createMarketOrder:!1,createOrder:!0,createOrders:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAccounts:!1,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!1},urls:{referral:"",logo:"https://github.com/ccxt/ccxt/assets/43336371/3aa748b7-ea44-45e9-a9e7-b1d207a2578a",api:{rest:"https://tradeogre.com/api/v1"},www:"https://tradeogre.com",doc:"https://tradeogre.com/help/api",fees:"https://tradeogre.com/help/fees"},fees:{trading:{maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},api:{public:{get:{markets:1,"orders/{market}":1,"ticker/{market}":1,"history/{market}":1,"chart/{interval}/{market}/{timestamp}":1,"chart/{interval}/{market}":1}},private:{get:{"account/balances":1,"account/order/{uuid}":1},post:{"order/buy":1,"order/sell":1,"order/cancel":1,orders:1,"account/orders":1,"account/balance":1}}},commonCurrencies:{},precisionMode:a.kb,exceptions:{exact:{"Must be authorized":r.AuthenticationError,"Market not found":r.BadRequest,"Insufficient funds":r.InsufficientFunds,"Order not found":r.BadRequest}},timeframes:{"1m":"1m","15m":"15m","1h":"1h","4h":"4h","1d":"1d","1w":"1w"},options:{},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e),i=[];for(let e=0;e<t.length;e++){const s=t[e],r=Object.keys(s),a=this.safeString(r,0),o=a.split("-"),n=this.safeString(o,0),d=this.safeString(o,1),h=this.safeCurrencyCode(n),c=this.safeCurrencyCode(d),l=this.safeMarketStructure({id:a,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:n,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,taker:this.fees.trading.taker,maker:this.fees.trading.maker,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision("8")),price:this.parseNumber(this.parsePrecision("8"))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:s});i.push(l)}return i}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={market:i.id},r=await this.publicGetTickerMarket(this.extend(s,t));return this.parseTicker(r,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.publicGetMarkets(this.extend({},t)),s={};for(let e=0;e<i.length;e++){const t=i[e],r=Object.keys(t),a=this.safeString(r,0),o=this.safeMarket(a),n=t[a],d=this.parseTicker(n,o);s[d.symbol]=d}return this.filterByArrayTickers(s,"symbol",e)}parseTicker(e,t=void 0){return this.safeTicker({symbol:this.safeString(t,"symbol"),timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"initialprice"),close:this.safeString(e,"price"),last:this.safeString(e,"price"),previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:void 0,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,interval:this.safeString(this.timeframes,t,t)};let n;const d=this.safeInteger(r,"until");return void 0!==d?(r=this.omit(r,"until"),o.timestamp=this.parseToInt(d/1e3),n=await this.publicGetChartIntervalMarketTimestamp(this.extend(o,r))):n=await this.publicGetChartIntervalMarket(this.extend(o,r)),this.parseOHLCVs(n,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id},r=await this.publicGetOrdersMarket(this.extend(s,i)),a={bids:this.safeDict(r,"buy",{}),asks:this.safeDict(r,"sell",{})},o=this.parseOrderBook(a,e);return o.nonce=this.safeInteger(r,"s"),o}parseBidsAsks(e,t=0,i=1,s=2){const r=Object.keys(e),a=[];for(let t=0;t<r.length;t++){const i=this.safeString(r,t),s=this.safeNumber(r,t),o=this.safeNumber(e,i);a.push([s,o])}return a}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},o=await this.publicGetHistoryMarket(this.extend(a,s));return this.parseTrades(o,r,t,i)}parseTrade(e,t=void 0){const i=this.safeIntegerProduct(e,"date",1e3);return this.safeTrade({info:e,id:void 0,timestamp:i,datetime:this.iso8601(i),symbol:this.safeString(t,"symbol"),order:void 0,type:void 0,side:this.safeString(e,"type"),takerOrMaker:void 0,price:this.safeString(e,"price"),amount:this.safeString(e,"quantity"),cost:void 0,fee:{currency:void 0,cost:void 0}},t)}async fetchBalance(e={}){let t;await this.loadMarkets();const i=this.safeString(e,"currency");if(void 0!==i){t=await this.privatePostAccountBalance(e);const s={info:t},r=this.safeCurrencyCode(i),a={total:this.safeNumber(t,"balance"),free:this.safeNumber(t,"available")};return s[r]=a,this.safeBalance(s)}t=await this.privateGetAccountBalances(e);const s=this.safeDict(t,"balances",{});return this.parseBalance(s)}parseBalance(e){const t={info:e},i=Object.keys(e);for(let s=0;s<i.length;s++){const r=i[s],a={total:e[r]};t[this.safeCurrencyCode(r)]=a}return this.safeBalance(t)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e);if("market"===t)throw new r.BadRequest(this.id+" createOrder does not support market orders");if(void 0===a)throw new r.ArgumentsRequired(this.id+" createOrder requires a price parameter");const d={market:n.id,quantity:this.amountToPrecision(e,s),price:this.priceToPrecision(e,a)};let h;return h="buy"===i?await this.privatePostOrderBuy(this.extend(d,o)):await this.privatePostOrderSell(this.extend(d,o)),this.parseOrder(h,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privatePostOrderCancel(this.extend(s,i));return this.parseOrder(r)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();return[await this.cancelOrder("all",e,t)]}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a={};void 0!==e&&(a.market=r.id);const o=await this.privatePostAccountOrders(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateGetAccountOrderUuid(this.extend(s,i));return this.parseOrder(r,void 0)}parseOrder(e,t=void 0){const i=this.safeIntegerProduct(e,"date",1e3),s=this.safeString(e,"market");return t=this.safeMarket(s,t),this.safeOrder({info:e,id:this.safeString(e,"uuid"),clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,symbol:t.symbol,type:void 0,timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"type"),price:this.safeString(e,"price"),triggerPrice:void 0,amount:void 0,cost:void 0,average:void 0,filled:this.safeString(e,"fulfilled"),remaining:this.safeString(e,"quantity"),status:void 0,fee:{currency:void 0,cost:void 0},trades:void 0},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api.rest+"/"+this.implodeParams(e,s);return s=this.omit(s,this.extractParams(e)),"GET"===i&&Object.keys(s).length&&(o+="?"+this.urlencode(s)),"private"===t&&(r={"Content-Type":"application/x-www-form-urlencoded",Referer:"CCXT",authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)},"GET"!==i&&(a=this.urlencode(s))),{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;if(!("success"in n))return;if(this.safeBool(n,"success"))return;if("true"===this.safeString(n,"success"))return;const c=this.safeValue(n,"error"),l=this.safeString(c,"code"),u=this.id+" "+this.json(n);throw this.throwExactlyMatchedException(this.exceptions.exact,l,u),new r.ExchangeError(u)}}},58586:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(51419);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"twox",name:"Twox",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,otc:!0,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/twox/64x64.png",api:{public:"https://api.twox.ir"},www:"https://twox.ir",doc:["https://twox.ir"]},api:{public:{get:{"api/currencies":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiCurrencies(e),i=[],s=["IRT","USDT"];for(let e=0;e<t.length;e++){const r=this.extend({},t[e]),a=this.safeString(r,"symbol");for(let e=0;e<s.length;e++){const t=s[e];if(a===t||0===r.sellPrice||"IRT"===a)break;r.base=a,r.quote=t;const o=this.parseMarket(r);i.push(o)}}return i}parseMarket(e){let t=this.safeString(e,"base"),i=this.safeString(e,"quote");const s=this.safeCurrencyCode(t),r=this.safeCurrencyCode(i),a=s+r;return t=t.toLowerCase(),i=i.toLowerCase(),{id:a,symbol:s+"/"+r,base:s,quote:r,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiCurrencies(t),s={},r=["IRT","USDT"];for(let e=0;e<i.length;e++){const t=this.safeString(i[e],"symbol");for(let a=0;a<r.length;a++){const o=r[a];if(t===o||0===i[e].sellPrice||"IRT"===t)continue;i[e].base=t,i[e].quote=o,i[e].symbol=t+o;const n=this.parseTicker(i[e]);s[n.symbol]=n}}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,void 0,"otc"),r=this.safeFloat(e,"sellPrice"),a=this.safeFloat(e,"buyPrice"),o=this.safeFloat(e,"latestPrice");let n,d,h;"IRT"===e.quote?(n=r,d=a,h=r):(n=o,d=a,h=r);const c=this.safeFloat(e,"priceChangePercent"),l=this.safeFloat(e,"sellPriceChange"),u=this.safeFloat(e,"buyPriceChange");let f;return f="IRT"===e.quote?l:u,this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:d,bidVolume:void 0,ask:h,askVolume:void 0,vwap:void 0,open:void 0,close:n,last:n,previousClose:void 0,change:f,percentage:c,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){return{url:this.urls.api.public+"/"+e,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},73551:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(70786);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"ubitex",name:"Ubitex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://ubitex.io/_next/image?url=https%3A%2F%2Fipfs.ubitex.io%2Fipfs%2FQmNqYsDFS1GoEeVYsPHkp8lFkodFeKo5cXLQlt1suO3T&w=256&q=75",api:{public:"https://appapi.ubitex.io"},www:"https://ubitex.io/",doc:["https://ubitex.io/"]},timeframes:{"1m":"1","1h":"60","1d":"1D"},api:{public:{get:{"api/dashboard/PairList":1,"api/chart/history":1,"api/dashboard":1}}},commonCurrencies:{TMN:"IRT"},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiDashboardPairList(e),i=[];for(let e=0;e<t.length;e++){const s=this.parseMarket(t[e]);i.push(s)}return i}parseMarket(e){const t=this.safeString(e,"id");let i=this.safeString(e,"destinationCoinSymbol"),s=this.safeString(e,"sourceCoinSymbol");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiDashboardPairList(t),s={};for(let e=0;e<i.length;e++){const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={src:this.safeStringUpper(i,"quoteId"),dest:this.safeStringUpper(i,"baseId")},r=await this.publicGetApiDashboardPairList(s),a=this.safeDict(r,0);return this.parseTicker(a)}parseTicker(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"highestRecentOrder",0),a=this.safeFloat(e,"lowestRecentOrder",0),o=this.safeFloat(e,"bestBuy",0),n=this.safeFloat(e,"bestSell",0),d=this.safeFloat(e,"lastOrderPrice",0),h=this.safeFloat(e,"change",0),c=this.safeFloat(e,"todayTradeAmount",0);return this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:r,low:a,bid:o,bidVolume:void 0,ask:n,askVolume:void 0,vwap:void 0,open:d,close:d,last:d,previousClose:void 0,change:h,percentage:void 0,average:void 0,baseVolume:c,quoteVolume:void 0,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=100,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.base+a.quote,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t),countback:s};"IRT"===a.quote&&(n.symbol=a.base+"TMN"),void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetApiChartHistory(n),h=this.safeValue(d,"o",[]),c=this.safeList(d,"h",[]),l=this.safeList(d,"l",[]),u=this.safeList(d,"c",[]),f=this.safeList(d,"v",[]),p=this.safeList(d,"t",[]),m=[];for(let e=0;e<h.length;e++)m.push([p[e],h[e],c[e],l[e],u[e],f[e]]);return this.parseOHLCVs(m,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={id:this.market(e).id},r=await this.publicGetApiDashboard(s),a=this.milliseconds();return this.parseOrderBook(r,e,a,"buyers","sellers","price","totalAmount")}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return void 0!==this.safeString(s,"src")&&void 0!==this.safeString(s,"dest")&&(n=n+"?"+this.urlencode(o)),"api/dashboard"===e&&(n=n+"/"+s.id+"/market"),"api/chart/history"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},90930:(e,t,i)=>{i.d(t,{A:()=>c});var s=i(76405),r=i(62079),a=i(85147),o=i(51579),n=i(37481),d=i(54852),h=i(75354);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"upbit",name:"Upbit",countries:["KR"],version:"v1",rateLimit:50,pro:!0,has:{CORS:!0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,editOrder:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!1,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,transfer:!1,withdraw:!0},timeframes:{"1s":"seconds","1m":"minutes","3m":"minutes","5m":"minutes","10m":"minutes","15m":"minutes","30m":"minutes","1h":"minutes","4h":"minutes","1d":"days","1w":"weeks","1M":"months","1y":"years"},hostname:"api.upbit.com",urls:{logo:"https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg",api:{public:"https://{hostname}",private:"https://{hostname}"},www:"https://upbit.com",doc:"https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C",fees:"https://upbit.com/service_center/guide"},api:{public:{get:{"market/all":2,"candles/{timeframe}":2,"candles/{timeframe}/{unit}":2,"candles/seconds":2,"candles/minutes/{unit}":2,"candles/minutes/1":2,"candles/minutes/3":2,"candles/minutes/5":2,"candles/minutes/10":2,"candles/minutes/15":2,"candles/minutes/30":2,"candles/minutes/60":2,"candles/minutes/240":2,"candles/days":2,"candles/weeks":2,"candles/months":2,"candles/years":2,"trades/ticks":2,ticker:2,"ticker/all":2,orderbook:2,"orderbook/supported_levels":2}},private:{get:{accounts:.67,"orders/chance":.67,order:.67,"orders/closed":.67,"orders/open":.67,"orders/uuids":.67,withdraws:.67,withdraw:.67,"withdraws/chance":.67,"withdraws/coin_addresses":.67,deposits:.67,"deposits/chance/coin":.67,deposit:.67,"deposits/coin_addresses":.67,"deposits/coin_address":.67,"travel_rule/vasps":.67,"status/wallet":.67,api_keys:.67},post:{orders:2.5,"orders/cancel_and_new":2.5,"withdraws/coin":.67,"withdraws/krw":.67,"deposits/krw":.67,"deposits/generate_coin_address":.67,"travel_rule/deposit/uuid":.67,"travel_rule/deposit/txid":.67},delete:{order:.67,"orders/open":40,"orders/uuids":.67}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!1},hedged:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:200}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"This key has expired.":r.AuthenticationError,"Missing request parameter error. Check the required parameters!":r.BadRequest,"side is missing, side does not have a valid value":r.InvalidOrder},broad:{thirdparty_agreement_required:r.PermissionDenied,out_of_scope:r.PermissionDenied,order_not_found:r.OrderNotFound,insufficient_funds:r.InsufficientFunds,invalid_access_key:r.AuthenticationError,jwt_verification:r.AuthenticationError,create_ask_error:r.ExchangeError,create_bid_error:r.ExchangeError,volume_too_large:r.InvalidOrder,invalid_funds:r.InvalidOrder}},options:{createMarketBuyOrderRequiresPrice:!0,tradingFeesByQuoteCurrency:{KRW:5e-4}},commonCurrencies:{TON:"Tokamak Network"}})}async fetchCurrency(e,t={}){await this.loadMarkets();const i=this.currency(e);return await this.fetchCurrencyById(i.id,t)}async fetchCurrencyById(e,t={}){const i={currency:e},s=await this.privateGetWithdrawsChance(this.extend(i,t)),r=this.safeValue(s,"member_level",{}),o=this.safeValue(s,"currency",{}),n=this.safeValue(s,"withdraw_limit",{}),d=this.safeValue(n,"can_withdraw"),h=this.safeString(o,"wallet_state"),c=this.safeValue(r,"wallet_locked"),l=this.safeValue(r,"locked");let u=!0;void 0===d||d?("working"!==h||void 0!==c&&c||void 0!==l&&l)&&(u=!1):u=!1;const f=this.safeString(n,"onetime"),p=this.safeString(n,"daily",f),m=this.safeString(n,"remaining_daily",p);let g;g=a.Y.stringGt(m,"0")?m:p;const v=this.safeString(o,"code"),y=this.safeCurrencyCode(v);return{info:s,id:v,code:y,name:y,active:u,fee:this.safeNumber(o,"withdraw_fee"),precision:void 0,limits:{withdraw:{min:this.safeNumber(n,"minimum"),max:this.parseNumber(g)}}}}async fetchMarket(e,t={}){await this.loadMarkets();const i=this.market(e);return await this.fetchMarketById(i.id,t)}async fetchMarketById(e,t={}){const i={market:e},s=await this.privateGetOrdersChance(this.extend(i,t)),r=this.safeValue(s,"market"),o=this.safeValue(r,"bid"),n=this.safeValue(r,"ask"),d=this.safeString(r,"id"),h=this.safeString(n,"currency"),c=this.safeString(o,"currency"),l=this.safeCurrencyCode(h),u=this.safeCurrencyCode(c),f=this.safeString(r,"state"),p=this.safeString(s,"bid_fee"),m=this.safeString(s,"ask_fee"),g=this.parseNumber(a.Y.stringMax(p,m));return this.safeMarketStructure({id:d,symbol:l+"/"+u,base:l,quote:u,settle:void 0,baseId:h,quoteId:c,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:"active"===f,contract:!1,linear:void 0,inverse:void 0,taker:g,maker:g,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber("1e-8"),price:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_total"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(o,"min_total"),max:this.safeNumber(r,"max_total")},info:s}})}async fetchMarkets(e={}){const t=await this.publicGetMarketAll(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"market"),[i,s]=t.split("-"),r=this.safeCurrencyCode(s),a=this.safeCurrencyCode(i);return this.safeMarketStructure({id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:s,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,a,this.fees.trading.taker),maker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,a,this.fees.trading.maker),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{price:this.parseNumber("1e-8"),amount:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e})}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let i=0;i<e.length;i++){const s=e[i],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.free=this.safeString(s,"balance"),o.used=this.safeString(s,"locked"),t[a]=o}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetAccounts(e);return this.parseBalance(t)}async fetchOrderBooks(e=void 0,t=void 0,i={}){let s;await this.loadMarkets(),void 0===e?s=this.ids.join(","):(s=this.marketIds(e),s=s.join(","));const r={markets:s},a=await this.publicGetOrderbook(this.extend(r,i)),o={};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"market"),s=this.safeSymbol(i,void 0,"-"),r=this.safeInteger(t,"timestamp");o[s]={symbol:s,bids:this.sortBy(this.parseBidsAsks(t.orderbook_units,"bid_price","bid_size"),0,!0),asks:this.sortBy(this.parseBidsAsks(t.orderbook_units,"ask_price","ask_size"),0),timestamp:r,datetime:this.iso8601(r),nonce:void 0}}return o}async fetchOrderBook(e,t=void 0,i={}){const s=await this.fetchOrderBooks([e],t,i);return this.safeValue(s,e)}parseTicker(e,t=void 0){const i=this.safeInteger(e,"trade_timestamp"),s=this.safeString2(e,"market","code");t=this.safeMarket(s,t,"-");const r=this.safeString(e,"trade_price");return this.safeTicker({symbol:t.symbol,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high_price"),low:this.safeString(e,"low_price"),bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:this.safeString(e,"opening_price"),close:r,last:r,previousClose:this.safeString(e,"prev_closing_price"),change:this.safeString(e,"signed_change_price"),percentage:this.safeString(e,"signed_change_rate"),average:void 0,baseVolume:this.safeString(e,"acc_trade_volume_24h"),quoteVolume:this.safeString(e,"acc_trade_price_24h"),info:e},t)}async fetchTickers(e=void 0,t={}){let i;await this.loadMarkets(),void 0===(e=this.marketSymbols(e))?i=this.ids.join(","):(i=this.marketIds(e),i=i.join(","));const s={markets:i},r=await this.publicGetTicker(this.extend(s,t)),a={};for(let e=0;e<r.length;e++){const t=this.parseTicker(r[e]);a[t.symbol]=t}return this.filterByArrayTickers(a,"symbol",e)}async fetchTicker(e,t={}){const i=await this.fetchTickers([e],t);return this.safeValue(i,e)}parseTrade(e,t=void 0){const i=this.safeString2(e,"sequential_id","uuid");let s,r=this.safeInteger(e,"timestamp");void 0===r&&(r=this.parse8601(this.safeString(e,"created_at")));const a=this.safeStringLower2(e,"ask_bid","side");"ask"===a?s="sell":"bid"===a&&(s="buy");const o=this.safeString(e,"funds"),n=this.safeString2(e,"trade_price","price"),d=this.safeString2(e,"trade_volume","volume"),h=this.safeString2(e,"market","code");let c;t=this.safeMarket(h,t,"-");const l=this.safeString(e,a+"_fee");return void 0!==l&&(c={currency:t.quote,cost:l}),this.safeTrade({id:i,info:e,order:undefined,timestamp:r,datetime:this.iso8601(r),symbol:t.symbol,type:void 0,side:s,takerOrMaker:void 0,price:n,amount:d,cost:o,fee:c},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e);void 0===i&&(i=200);const a={market:r.id,count:i},o=await this.publicGetTradesTicks(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchTradingFee(e,t={}){await this.loadMarkets();const i={market:this.market(e).id},s=await this.privateGetOrdersChance(this.extend(i,t)),r=this.safeString(s,"ask_fee"),o=this.safeString(s,"bid_fee"),n=a.Y.stringMax(r,o),d=this.safeString(s,"maker_ask_fee"),h=this.safeString(s,"maker_bid_fee"),c=a.Y.stringMax(d,h);return{info:s,symbol:e,maker:this.parseNumber(c),taker:this.parseNumber(n),percentage:!0,tierBased:!1}}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.fetchMarkets(e),i={};for(let e=0;e<t.length;e++){const s={};s.maker=this.safeNumber(t[e],"maker"),s.taker=this.safeNumber(t[e],"taker"),s.symbol=this.safeString(t[e],"symbol"),s.percentage=!0,s.tierBased=!1,s.info=t[e],i[this.safeString(t[e],"symbol")]=s}return i}parseOHLCV(e,t=void 0){return[this.parse8601(this.safeString(e,"candle_date_time_utc")),this.safeNumber(e,"opening_price"),this.safeNumber(e,"high_price"),this.safeNumber(e,"low_price"),this.safeNumber(e,"trade_price"),this.safeNumber(e,"candle_acc_trade_volume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.parseTimeframe(t),n=this.safeString(this.timeframes,t,t);void 0===s&&(s=200);const d={market:a.id,timeframe:n,count:s};let h;if(void 0!==i&&(d.to=this.iso8601(this.sum(i,o*s*1e3))),"minutes"===n){const e=Math.round(o/60);d.unit=e,h=await this.publicGetCandlesTimeframeUnit(this.extend(d,r))}else h=await this.publicGetCandlesTimeframe(this.extend(d,r));return this.parseOHLCVs(h,a,t,i,s)}calcOrderPrice(e,t,i=void 0,s={}){let o;const n=this.safeValue(this.options,"createMarketBuyOrderRequiresPrice"),d=this.safeString(s,"cost");if(void 0!==d)o=this.costToPrecision(e,d);else if(n){if(void 0===i||void 0===t)throw new r.InvalidOrder(this.id+" createOrder() requires the price and amount argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument");const s=this.numberToString(t),n=this.numberToString(i),d=a.Y.stringMul(s,n);o=this.costToPrecision(e,d)}else{if(void 0===t)throw new r.ArgumentsRequired(this.id+' When createMarketBuyOrderRequiresPrice is false, "amount" is required and should be the total quote amount to spend.');o=this.costToPrecision(e,t)}return o}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e);let d;if("buy"===i)d="bid";else{if("sell"!==i)throw new r.InvalidOrder(this.id+" createOrder() supports only buy or sell in the side argument.");d="ask"}const h={market:n.id,side:d};if("limit"===t){if(void 0===a||void 0===s)throw new r.ArgumentsRequired(this.id+" the limit type order in createOrder() is required price and amount.");h.ord_type="limit",h.price=this.priceToPrecision(e,a),h.volume=this.amountToPrecision(e,s)}else{if("market"!==t)throw new r.InvalidOrder(this.id+" createOrder() supports only limit or market types in the type argument.");if("buy"===i){h.ord_type="price";const t=this.calcOrderPrice(e,s,a,o);h.price=t}else{if(void 0===s)throw new r.ArgumentsRequired(this.id+" the market sell type order in createOrder() is required amount.");h.ord_type="market",h.volume=this.amountToPrecision(e,s)}}if("best"===this.safeString2(o,"ordType","ord_type"))if(o=this.omit(o,["ordType","ord_type"]),h.ord_type="best","buy"===i){const t=this.calcOrderPrice(e,s,a,o);h.price=t}else{if(void 0===s)throw new r.ArgumentsRequired(this.id+" the best sell type order in createOrder() is required amount.");h.volume=this.amountToPrecision(e,s)}const c=this.safeString(o,"clientOrderId");if(void 0!==c&&(h.identifier=c),"market"!==h.ord_type&&"price"!==h.ord_type){const e=this.safeStringLower2(o,"timeInForce","time_in_force");if(o=this.omit(o,["timeInForce"]),void 0!==e)h.time_in_force=e;else if("best"===h.ord_type)throw new r.ArgumentsRequired(this.id+" the best type order in createOrder() is required timeInForce.")}o=this.omit(o,["clientOrderId","cost"]);const l=await this.privatePostOrders(this.extend(h,o));return this.parseOrder(l)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateDeleteOrder(this.extend(s,i));return this.parseOrder(r)}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){await this.loadMarkets();const d={},h=this.safeString(n,"clientOrderId");if(n=this.omit(n,"clientOrderId"),void 0!==e)d.prev_order_uuid=e;else{if(void 0===h)throw new r.ArgumentsRequired(this.id+" editOrder() is required id or clientOrderId.");d.prev_order_identifier=h}if("limit"===i){if(void 0===o||void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required price and amount to create limit type order.");d.new_ord_type="limit",d.new_price=this.priceToPrecision(t,o),d.new_volume=this.amountToPrecision(t,a)}else{if("market"!==i)throw new r.InvalidOrder(this.id+" editOrder() supports only limit or market types in the type argument.");if("buy"===s){d.new_ord_type="price";const e=this.calcOrderPrice(t,a,o,n);d.new_price=e}else{if(void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required amount to create market sell type order.");d.new_ord_type="market",d.new_volume=this.amountToPrecision(t,a)}}if("best"===this.safeString2(n,"newOrdType","new_ord_type"))if(n=this.omit(n,["newOrdType","new_ord_type"]),d.new_ord_type="best","buy"===s){const e=this.calcOrderPrice(t,a,o,n);d.new_price=e}else{if(void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required amount to create best sell order.");d.new_volume=this.amountToPrecision(t,a)}const c=this.safeString(n,"newClientOrderId");if(void 0!==c&&(d.new_identifier=c),"market"!==d.new_ord_type&&"price"!==d.new_ord_type){const e=this.safeStringLower2(n,"newTimeInForce","new_time_in_force");if(n=this.omit(n,["newTimeInForce","new_time_in_force"]),void 0!==e)d.new_time_in_force=e;else if("best"===d.new_ord_type)throw new r.ArgumentsRequired(this.id+" the best type order is required timeInForce.")}n=this.omit(n,["newClientOrderId","cost"]);const l=await this.privatePostOrdersCancelAndNew(this.extend(d,n)),u={};return u.uuid=this.safeString(l,"new_order_uuid"),u.identifier=this.safeString(l,"new_order_identifier"),u.side=this.safeString(l,"side"),u.market=this.safeString(l,"market"),this.parseOrder(u)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetDeposits(this.extend(r,s));return this.parseTransactions(o,a,t,i)}async fetchDeposit(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e};let r;void 0!==t&&(r=this.currency(t),s.currency=r.id);const a=await this.privateGetDeposit(this.extend(s,i));return this.parseTransaction(a,r)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetWithdraws(this.extend(r,s));return this.parseTransactions(o,a,t,i)}async fetchWithdrawal(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e};let r;void 0!==t&&(r=this.currency(t),s.currency=r.id);const a=await this.privateGetWithdraw(this.extend(s,i));return this.parseTransaction(a,r)}parseTransactionStatus(e){return this.safeString({submitting:"pending",submitted:"pending",almost_accepted:"pending",rejected:"failed",accepted:"ok",processing:"pending",done:"ok",canceled:"canceled"},e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"done_at"),s=this.parse8601(this.safeString(e,"created_at",i));let r=this.safeString(e,"type");"withdraw"===r&&(r="withdrawal");const a=this.safeString(e,"currency"),o=this.safeCurrencyCode(a,t);return{info:e,id:this.safeString(e,"uuid"),currency:o,amount:this.safeNumber(e,"amount"),network:void 0,address:undefined,addressTo:void 0,addressFrom:void 0,tag:undefined,tagTo:void 0,tagFrom:void 0,status:this.parseTransactionStatus(this.safeStringLower(e,"state")),type:r,updated:this.parse8601(i),txid:this.safeString(e,"txid"),timestamp:s,datetime:this.iso8601(s),internal:void 0,comment:void 0,fee:{currency:o,cost:this.safeNumber(e,"fee")}}}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"uuid");let s=this.safeString(e,"side");s="bid"===s?"buy":"sell";const r=this.safeString(e,"identifier");let o=this.safeString(e,"ord_type");const n=this.parse8601(this.safeString(e,"created_at")),d=this.parseOrderStatus(this.safeString(e,"state"));let h,c=this.safeString(e,"price");const l=this.safeString(e,"volume"),u=this.safeString(e,"remaining_volume"),f=this.safeString(e,"executed_volume");let p,m,g;"price"===o&&(o="market",p=c,c=void 0);let v=this.safeString(e,"paid_fee");const y=this.safeString(e,"market");t=this.safeMarket(y,t);let b=this.safeValue(e,"trades",[]);b=this.parseTrades(b,t,void 0,void 0,{order:i,type:o});const w=b.length;if(w>0){h=b[w-1].timestamp;let e=!1;void 0===v&&(e=!0,v="0"),p="0";for(let t=0;t<w;t++){const i=b[t];if(p=a.Y.stringAdd(p,this.safeString(i,"cost")),e){const e=this.safeValue(b[t],"fee",{}),i=this.safeString(e,"cost");void 0!==i&&(v=a.Y.stringAdd(v,i))}}m=a.Y.stringDiv(p,f)}return void 0!==v&&(g={currency:t.quote,cost:v}),this.safeOrder({info:e,id:i,clientOrderId:r,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:h,symbol:t.symbol,type:o,timeInForce:this.safeStringUpper(e,"time_in_force"),postOnly:void 0,side:s,price:c,triggerPrice:void 0,cost:this.parseNumber(p),average:this.parseNumber(m),amount:l,filled:f,remaining:u,status:d,fee:g,trades:b})}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.market=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetOrdersOpen(this.extend(r,s));return this.parseOrders(o,a,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a={state:"done"};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==t&&(a.start_time=t),void 0!==i&&(a.limit=i),[a,s]=this.handleUntilOption("end_time",a,s);const o=await this.privateGetOrdersClosed(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a={state:"cancel"};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==t&&(a.start_time=t),void 0!==i&&(a.limit=i),[a,s]=this.handleUntilOption("end_time",a,s);const o=await this.privateGetOrdersClosed(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateGetOrder(this.extend(s,i));return this.parseOrder(r)}async fetchDepositAddresses(e=void 0,t={}){await this.loadMarkets();const i=await this.privateGetDepositsCoinAddresses(t);return this.parseDepositAddresses(i,e)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"deposit_address"),s=this.safeString(e,"secondary_address"),r=this.safeString(e,"currency"),a=this.safeCurrencyCode(r),o=this.safeString(e,"net_type");return this.checkAddress(i),{info:e,currency:a,network:this.networkIdToCode(o),address:i,tag:s}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e);let s;if([s,t]=this.handleNetworkCodeAndParams(t),void 0===s)throw new r.ArgumentsRequired(this.id+' fetchDepositAddress requires params["network"]');const a=await this.privateGetDepositsCoinAddress(this.extend({currency:i.id,net_type:this.networkCodeToId(s,i.code)},t));return this.parseDepositAddress(a)}async createDepositAddress(e,t={}){await this.loadMarkets();const i={currency:this.currency(e).id},s=await this.privatePostDepositsGenerateCoinAddress(this.extend(i,t));if(void 0!==this.safeString(s,"message"))throw new r.AddressPending(this.id+" is generating "+e+" deposit address, call fetchDepositAddress or createDepositAddress one more time later to retrieve the generated address");return this.parseDepositAddress(s)}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),await this.loadMarkets();const o=this.currency(e),n={amount:t};let d;if("KRW"!==e){this.checkAddress(i);const e=this.safeStringUpper2(a,"network","net_type");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a network argument");a=this.omit(a,["network"]),n.net_type=e,n.currency=o.id,n.address=i,void 0!==s&&(n.secondary_address=s),a=this.omit(a,"network"),d=await this.privatePostWithdrawsCoin(this.extend(n,a))}else d=await this.privatePostWithdrawsKrw(this.extend(n,a));return this.parseTransaction(d)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.implodeParams(this.urls.api[t],{hostname:this.hostname});o+="/"+this.version+"/"+this.implodeParams(e,s);const c=this.omit(s,this.extractParams(e));if("POST"!==i&&Object.keys(c).length&&(o+="?"+this.urlencode(c)),"private"===t){this.checkRequiredCredentials(),r={};const e=this.uuid(),t={access_key:this.apiKey,nonce:e},o=Object.keys(c).length;let l;if("GET"!==i&&"DELETE"!==i&&(a=this.json(s),r["Content-Type"]="application/json"),o&&(l=this.rawencode(c)),void 0!==l){const e=this.hash(this.encode(l),n.Zf);t.query_hash=e,t.query_hash_alg="SHA512"}const u=(0,h.a)(t,this.encode(this.secret),d.s);r.Authorization="Bearer "+u}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.safeValue(n,"error");if(void 0!==c){const e=this.safeString(c,"message"),t=this.safeString(c,"name"),i=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,i),this.throwExactlyMatchedException(this.exceptions.exact,t,i),this.throwBroadlyMatchedException(this.exceptions.broad,e,i),this.throwBroadlyMatchedException(this.exceptions.broad,t,i),new r.ExchangeError(i)}}}},84910:(e,t,i)=>{i.d(t,{A:()=>c});var s=i(38139),r=i(62079),a=i(85147),o=i(51579),n=i(38432),d=i(40987),h=i(88283);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"vertex",name:"Vertex",countries:[],version:"v1",rateLimit:50,certified:!1,pro:!0,dex:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!0,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!1,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:void 0,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":60,"5m":300,"15m":900,"1h":3600,"2h":7200,"4h":14400,"1d":86400,"1w":604800,"1M":604800},hostname:"vertexprotocol.com",urls:{logo:"https://github.com/ccxt/ccxt/assets/43336371/bd04a0fa-3b48-47b6-9d8b-124954d520a8",api:{v1:{archive:"https://archive.prod.{hostname}/v1",gateway:"https://gateway.prod.{hostname}/v1",trigger:"https://trigger.prod.{hostname}/v1"},v2:{archive:"https://archive.prod.{hostname}/v2",gateway:"https://gateway.prod.{hostname}/v2"}},test:{v1:{archive:"https://archive.sepolia-test.{hostname}/v1",gateway:"https://gateway.sepolia-test.{hostname}/v1",trigger:"https://trigger.sepolia-test.{hostname}/v1"},v2:{archive:"https://archive.sepolia-test.{hostname}/v2",gateway:"https://gateway.sepolia-test.{hostname}/v2"}},www:"https://vertexprotocol.com/",doc:"https://docs.vertexprotocol.com/",fees:"https://docs.vertexprotocol.com/basics/fees",referral:"https://app.vertexprotocol.com?referrer=0xCfC9BaB96a2eA3d3c3F031c005e82E1D9F295aC1"},api:{v1:{archive:{post:{"":1}},gateway:{get:{query:1,symbols:1,time:1},post:{query:1,execute:1}},trigger:{post:{execute:1,query:1}}},v2:{archive:{get:{tickers:1,contracts:1,trades:1,vrtx:1}},gateway:{get:{assets:.6667,pairs:1,orderbook:1}}}},fees:{swap:{taker:this.parseNumber("0.0002"),maker:this.parseNumber("0.0002")},spot:{taker:this.parseNumber("0.0002"),maker:this.parseNumber("0.0002")}},requiredCredentials:{apiKey:!1,secret:!1,walletAddress:!0,privateKey:!0},exceptions:{exact:{1e3:r.RateLimitExceeded,1015:r.RateLimitExceeded,1001:r.PermissionDenied,1002:r.PermissionDenied,1003:r.PermissionDenied,2e3:r.InvalidOrder,2001:r.InvalidOrder,2002:r.InvalidOrder,2003:r.InvalidOrder,2004:r.InvalidOrder,2005:r.InvalidOrder,2006:r.InvalidOrder,2007:r.InvalidOrder,2008:r.InvalidOrder,2009:r.InvalidOrder,2010:r.InvalidOrder,2011:r.BadRequest,2012:r.BadRequest,2013:r.InvalidOrder,2014:r.PermissionDenied,2015:r.InvalidOrder,2016:r.InvalidOrder,2017:r.InvalidOrder,2019:r.InvalidOrder,2020:r.InvalidOrder,2021:r.InvalidOrder,2022:r.InvalidOrder,2023:r.InvalidOrder,2024:r.InsufficientFunds,2025:r.InsufficientFunds,2026:r.BadRequest,2027:r.AuthenticationError,2028:r.AuthenticationError,2029:r.AuthenticationError,2030:r.BadRequest,2031:r.InvalidOrder,2033:r.InvalidOrder,2034:r.InvalidOrder,2035:r.InvalidOrder,2036:r.InvalidOrder,2037:r.InvalidOrder,2038:r.InvalidOrder,2039:r.InvalidOrder,2040:r.InvalidOrder,2041:r.InvalidOrder,2042:r.InvalidOrder,2043:r.InvalidOrder,2044:r.InvalidOrder,2045:r.InvalidOrder,2046:r.InvalidOrder,2047:r.InvalidOrder,2048:r.InvalidOrder,2049:r.ExchangeError,2050:r.PermissionDenied,2051:r.InvalidOrder,2052:r.InvalidOrder,2053:r.InvalidOrder,2054:r.InvalidOrder,2055:r.InvalidOrder,2056:r.InvalidOrder,2057:r.InvalidOrder,2058:r.InvalidOrder,2059:r.InvalidOrder,2060:r.InvalidOrder,2061:r.InvalidOrder,2062:r.InvalidOrder,2063:r.InvalidOrder,2064:r.InvalidOrder,2065:r.InvalidOrder,2066:r.InvalidOrder,2067:r.InvalidOrder,2068:r.InvalidOrder,2069:r.InvalidOrder,2070:r.InvalidOrder,2071:r.InvalidOrder,2072:r.InvalidOrder,2073:r.InvalidOrder,2074:r.InvalidOrder,2075:r.InvalidOrder,2076:r.InvalidOrder,3e3:r.BadRequest,3001:r.BadRequest,3002:r.BadRequest,3003:r.BadRequest,4e3:r.BadRequest,4001:r.ExchangeError,4002:r.ExchangeError,4003:r.ExchangeError,4004:r.InvalidOrder,5e3:r.ExchangeError},broad:{}},precisionMode:o.kb,commonCurrencies:{},options:{defaultType:"swap",sandboxMode:!1,timeDifference:0,brokerId:5930043274845996},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:1e5,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:void 0,inverse:void 0}}})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}convertToX18(e){if("string"==typeof e)return a.Y.stringMul(e,"1000000000000000000");const t=this.numberToString(e);return a.Y.stringMul(t,"1000000000000000000")}convertFromX18(e){if("string"==typeof e)return a.Y.stringDiv(e,"1000000000000000000");const t=this.numberToString(e);return a.Y.stringDiv(t,"1000000000000000000")}async fetchCurrencies(e={}){const t=await this.v2GatewayGetAssets(this.extend({},e)),i={};for(let e=0;e<t.length;e++){const s=this.safeDict(t,e,{}),r=this.safeString(s,"ticker_id");if(void 0!==r&&r.indexOf("PERP")>0)continue;const a=this.safeString(s,"symbol"),o=this.safeCurrencyCode(a);i[o]=this.safeCurrencyStructure({id:this.safeString(s,"product_id"),name:a,code:o,precision:void 0,info:s,active:void 0,deposit:this.safeBool(s,"can_deposit"),withdraw:this.safeBool(s,"can_withdraw"),networks:void 0,fee:void 0,limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}}})}return i}parseMarket(e){const t=this.safeString(e,"type"),i="USDC",s=this.safeCurrencyCode(i),r=this.safeString(e,"symbol"),a=this.safeCurrencyCode(r),o=i,n=this.safeCurrencyCode(o);let d=a+"/"+s;const h="spot"===t,c=!h,l=!h;if(l){d=a.split("-")[0]+"/"+s+":"+n}const u=this.safeString(e,"price_increment_x18"),f=this.safeString(e,"size_increment"),p=this.safeString(e,"min_size"),m=this.safeNumber(e,"taker_fee_rate_x18"),g=this.safeNumber(e,"maker_fee_rate_x18"),v=!!h&&void 0,y=!h||void 0,b=h?void 0:this.parseNumber("1");return{id:this.safeString(e,"product_id"),symbol:d,base:a,quote:s,settle:h?void 0:n,baseId:r,quoteId:i,settleId:h?void 0:o,type:h?"spot":"swap",spot:h,margin:void 0,swap:l,future:!1,option:!1,active:!0,contract:c,linear:y,inverse:v,taker:this.parseNumber(this.convertFromX18(m)),maker:this.parseNumber(this.convertFromX18(g)),contractSize:b,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.convertFromX18(f)),price:this.parseNumber(this.convertFromX18(u))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(this.convertFromX18(p)),max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchMarkets(e={}){const t=await this.v1GatewayGetQuery(this.extend({type:"symbols"},e)),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"symbols",{}),r=Object.keys(s),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeDict(s,t,{});a.push(this.parseMarket(i))}return a}async fetchTime(e={}){const t=await this.v1GatewayGetTime(e);return this.parseToInt(t)}async fetchStatus(e={}){const t=await this.v1GatewayGetQuery(this.extend({type:"status"},e));let i=this.safeString(t,"data");return i="active"===i?"ok":"error",{status:i,updated:void 0,eta:void 0,url:void 0,info:t}}parseTrade(e,t=void 0){let i,s,r,o;const n=this.convertFromX18(this.safeString(e,"fee"));void 0!==n&&(o={cost:n,currency:void 0});const d=this.safeString2(e,"trade_id","submission_idx"),h=this.safeString(e,"digest"),c=this.safeTimestamp(e,"timestamp");if(void 0===c){const o=this.safeDict(this.safeDict(e,"pre_balance",{}),"base",{});let n;n="perp"in o?this.safeString(this.safeDict(o,"perp",{}),"product_id"):this.safeString(this.safeDict(o,"spot",{}),"product_id"),t=this.safeMarket(n);const d=this.safeDict(e,"order",{});i=this.convertFromX18(this.safeString(d,"priceX18")),s=this.convertFromX18(this.safeString(e,"base_filled")),r=a.Y.stringLt(s,"0")?"sell":"buy"}else{const a=this.safeString(e,"ticker_id").split("_"),o=a[0].split("-")[0]+a[1];t=this.safeMarket(o,t),i=this.safeString(e,"price"),s=this.safeString(e,"base_filled"),r=this.safeStringLower(e,"trade_type")}s=a.Y.stringAbs(s);const l=t.symbol;return this.safeTrade({id:d,timestamp:c,datetime:this.iso8601(c),symbol:l,side:r,price:i,amount:s,cost:void 0,order:h,takerOrMaker:void 0,type:void 0,fee:o,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={ticker_id:r.baseId+"_USDC"};void 0!==i&&(a.limit=i);const o=await this.v2ArchiveGetTrades(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r,a;await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchMyTrades",s);const o={subaccount:this.convertAddressToSender(r)};void 0!==e&&(a=this.market(e),o.product_ids=[this.parseToNumeric(a.id)]);const n=this.safeInteger(s,"until");void 0!==n&&(s=this.omit(s,"until"),o.max_time=n),void 0!==i&&(o.limit=i);const d={matches:o},h=await this.v1ArchivePost(this.extend(d,s)),c=this.safeList(h,"matches",[]);return this.parseTrades(c,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();void 0===t&&(t=100);const s={ticker_id:this.market(e).baseId+"_USDC",depth:t},r=await this.v2GatewayGetOrderbook(this.extend(s,i)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a,"bids","asks")}async fetchTradingFees(e={}){let t;await this.loadMarkets(),[t,e]=this.handlePublicAddress("fetchTradingFees",e);const i={type:"fee_rates",sender:this.convertAddressToSender(t)},s=await this.v1GatewayGetQuery(this.extend(i,e)),r=this.safeDict(s,"data",{}),a=this.safeList(r,"maker_fee_rates_x18",[]),o=this.safeList(r,"taker_fee_rates_x18",[]),n={};for(let e=0;e<o.length;e++){const t=this.safeMarket(this.numberToString(e));if(void 0===t.id)continue;const i=t.symbol;n[i]={info:s,symbol:i,maker:this.parseNumber(this.convertFromX18(a[e])),taker:this.parseNumber(this.convertFromX18(o[e])),percentage:!0,tierBased:!1}}return n}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,"timestamp"),this.parseNumber(this.convertFromX18(this.safeString(e,"open_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"high_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"low_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"close_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"volume")))]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={product_id:this.parseToInt(a.id),granularity:this.safeInteger(this.timeframes,t)},n=this.safeInteger(r,"until");void 0!==n&&(r=this.omit(r,"until"),o.max_time=n),void 0!==s&&(o.limit=Math.min(s,1e3));const d={candlesticks:o},h=await this.v1ArchivePost(this.extend(d,r)),c=this.safeList(h,"candlesticks",[]);return this.parseOHLCVs(c,a,t,i,s)}parseFundingRate(e,t=void 0){let i=this.safeNumber(e,"funding_rate");if(void 0===i){const t=this.safeString(e,"funding_rate_x18");i=this.parseNumber(this.convertFromX18(t))}const s=this.safeTimestamp2(e,"update_time","next_funding_rate_timestamp"),r=this.safeNumber(e,"mark_price"),a=this.safeNumber(e,"index_price");return{info:e,symbol:t.symbol,markPrice:r,indexPrice:a,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:void 0,datetime:void 0,fundingRate:i,fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={funding_rate:{product_id:this.parseToInt(i.id)}},r=await this.v1ArchivePost(this.extend(s,t));return this.parseFundingRate(r,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets();void 0!==e&&(e=this.marketSymbols(e));const i=await this.v2ArchiveGetContracts(this.extend({},t)),s=Object.keys(i),r={};for(let e=0;e<s.length;e++){const t=s[e],a=t.split("-"),o=i[t],n=a[0]+"/USDC:USDC",d=this.market(n),h=this.parseFundingRate(o,d);r[h.symbol]=h}return this.filterByArray(r,"symbol",e)}parseOpenInterest(e,t=void 0){const i=this.safeString(e,"ticker_id");return this.safeOpenInterest({symbol:this.safeSymbol(i,t),openInterestAmount:this.safeNumber(e,"open_interest"),openInterestValue:this.safeNumber(e,"open_interest_usd"),timestamp:void 0,datetime:void 0,info:e},t)}async fetchOpenInterests(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v2ArchiveGetContracts(t),s=[],r=[],a=Object.keys(i);if(void 0===e){e=[];for(let t=0;t<a.length;t++){const i=a[t].split("-")[0]+"/USDC:USDC";this.inArray(i,e)||e.push(i)}}for(let t=0;t<a.length;t++){const o=a[t],n=this.safeMarket(o),d=this.safeDict(i,o,{});for(let t=0;t<e.length;t++){const i=this.market(e[t]),a=i.base+"_USDC";n.marketId===a&&(s.push(i.symbol),r.push(this.parseOpenInterest(d,i)))}}return this.filterByArray(r,"symbol",s)}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new r.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");const s=await this.v2ArchiveGetContracts(this.extend({},t)),a=i.base+"_USDC",o=this.safeDict(s,a,{});return this.parseOpenInterest(o,i)}parseTicker(e,t=void 0){const i=this.safeString(e,"base_currency");let s=i+"/"+this.safeString(e,"quote_currency");i.indexOf("PERP")>0&&(s=s.replace("-PERP","")+":USDC"),t=this.safeMarket(s,t);const r=this.safeString(e,"last_price");return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:this.safeString(e,"price_change_percent_24h"),average:void 0,baseVolume:this.safeString(e,"base_volume"),quoteVolume:this.safeString(e,"quote_volume"),info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!0,!0,!0);const i=await this.v2ArchiveGetTickers(this.extend({},t)),s=Object.values(i);return this.parseTickers(s,e)}async queryContracts(e={}){const t=this.safeDict(this.options,"v1contracts");if(void 0!==t)return t;const i=await this.v1GatewayGetQuery(this.extend({type:"contracts"},e)),s=this.safeDict(i,"data",{});return this.options.v1contracts=s,s}nonce(){return this.milliseconds()-this.options.timeDifference}hashMessage(e){return"0x"+this.hash(e,n.lY,"hex")}signHash(e,t){const i=(0,h.h1)(e.slice(-64),t.slice(-64),d.bI,void 0),s=i.r,r=i.s,a=this.intToBase16(this.sum(27,i.v));return"0x"+s.padStart(64,"0")+r.padStart(64,"0")+a}signMessage(e,t){return this.signHash(this.hashMessage(e),t.slice(-64))}buildSig(e,t,i,s=""){const r={chainId:e,name:"Vertex",verifyingContract:s,version:"0.0.1"},a=this.ethEncodeStructuredData(r,t,i);return this.signMessage(a,this.privateKey)}buildCreateOrderSig(e,t,i){return this.buildSig(t,{Order:[{name:"sender",type:"bytes32"},{name:"priceX18",type:"int128"},{name:"amount",type:"int128"},{name:"expiration",type:"uint64"},{name:"nonce",type:"uint64"}]},e,i)}buildListTriggerTxSig(e,t,i){return this.buildSig(t,{ListTriggerOrders:[{name:"sender",type:"bytes32"},{name:"recvTime",type:"uint64"}]},e,i)}buildCancelAllOrdersSig(e,t,i){return this.buildSig(t,{CancellationProducts:[{name:"sender",type:"bytes32"},{name:"productIds",type:"uint32[]"},{name:"nonce",type:"uint64"}]},e,i)}buildCancelOrdersSig(e,t,i){return this.buildSig(t,{Cancellation:[{name:"sender",type:"bytes32"},{name:"productIds",type:"uint32[]"},{name:"digests",type:"bytes32[]"},{name:"nonce",type:"uint64"}]},e,i)}buildWithdrawSig(e,t,i){return this.buildSig(t,{WithdrawCollateral:[{name:"sender",type:"bytes32"},{name:"productId",type:"uint32"},{name:"amount",type:"uint128"},{name:"nonce",type:"uint64"}]},e,i)}convertAddressToSender(e){return(e+"64656661756c74").padEnd(66,"0")}getNonce(e,t){return void 0===e&&(e=this.nonce()),a.Y.stringAdd(a.Y.stringMul(a.Y.stringAdd(this.numberToString(e),this.numberToString(t)),"1048576"),"1000")}getExpiration(e,t,i,s){let r=a.Y.stringAdd(this.numberToString(e),"86400");return"ioc"===t?r=a.Y.stringOr(r,"4611686018427387904"):"fok"===t?r=a.Y.stringOr(r,"9223372036854775808"):i&&(r=a.Y.stringOr(r,"13835058055282163712")),s&&(r=a.Y.stringOr(r,"2305843009213693952")),r}getAmount(e,t){let i=this.numberToString(e);return"sell"===t?e>0&&(i=a.Y.stringMul(i,"-1")):e<0&&(i=a.Y.stringMul(i,"-1")),i}async createOrder(e,t,i,s,o=void 0,n={}){this.checkRequiredCredentials();const d="market"===t.toLowerCase();if(d&&void 0===o)throw new r.ArgumentsRequired(this.id+" createOrder() requires a price argument for market order");await this.loadMarkets();const h=this.market(e),c=this.parseToInt(h.id),l=await this.queryContracts(),u=this.safeString(l,"chain_id"),f=this.safeList(l,"book_addrs",[]),p=this.safeString(f,c),m=d?"fok":void 0,g=this.safeStringLower(n,"timeInForce",m),v=this.safeBool(n,"postOnly",!1),y=this.safeBool(n,"reduceOnly",!1),b=this.safeString2(n,"triggerPrice","stopPrice"),w=this.safeString(n,"stopLossPrice",b),k=this.safeString(n,"takeProfitPrice"),S=w||k,O=this.nonce();let T=this.getNonce(O,9e4);if(v&&y)throw new r.NotSupported(this.id+" reduceOnly not supported when postOnly is enabled");const P=this.getExpiration(O,g,v,y);S&&(T=a.Y.stringOr(T,"9223372036854775808"));const M=this.getAmount(s,i),I={sender:this.convertAddressToSender(this.walletAddress),priceX18:this.convertToX18(this.priceToPrecision(e,o)),amount:this.convertToX18(this.amountToPrecision(e,M)),expiration:P,nonce:T},x={place_order:{product_id:c,order:{sender:I.sender,priceX18:I.priceX18,amount:I.amount,expiration:this.numberToString(I.expiration),nonce:I.nonce},signature:this.buildCreateOrderSig(I,u,p),id:this.safeInteger(this.options,"brokerId",5930043274845996)}};let A;if(n=this.omit(n,["timeInForce","reduceOnly","postOnly","triggerPrice","stopPrice","stopLossPrice","takeProfitPrice"]),S){const e={};void 0!==w?e.last_price_below=this.convertToX18(w):void 0!==k&&(e.last_price_above=this.convertToX18(k)),x.place_order.trigger=e,A=await this.v1TriggerPostExecute(this.extend(x,n))}else A=await this.v1GatewayPostExecute(this.extend(x,n));const C=this.safeDict(A,"data",{});return this.safeOrder({id:this.safeString(C,"digest")})}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){this.checkRequiredCredentials();const d="market"===i.toLowerCase();if(d&&void 0===o)throw new r.ArgumentsRequired(this.id+" editOrder() requires a price argument for market order");await this.loadMarkets();const h=this.market(t),c=this.parseToInt(h.id),l=d?"fok":void 0,u=this.safeStringLower(n,"timeInForce",l),f=this.safeBool(n,"postOnly",!1),p=this.safeBool(n,"reduceOnly",!1),m=this.safeString2(n,"triggerPrice","stopPrice"),g=this.safeString(n,"stopLossPrice",m),v=this.safeString(n,"takeProfitPrice"),y=g||v,b=await this.queryContracts(),w=this.safeString(b,"chain_id"),k=this.safeList(b,"book_addrs",[]),S=this.safeString(k,c),O=this.safeString(b,"endpoint_addr"),T=this.nonce(),P=this.getNonce(T,9e4),M=this.convertAddressToSender(this.walletAddress);if(f&&p)throw new r.NotSupported(this.id+" reduceOnly not supported when postOnly is enabled");if(y)throw new r.NotSupported(this.id+" editOrder() not supported for trigger order");const I=this.getExpiration(T,u,f,p),x=this.getAmount(a,s),A={sender:M,priceX18:this.convertToX18(this.priceToPrecision(t,o)),amount:this.convertToX18(this.amountToPrecision(t,x)),expiration:I,nonce:P},C={sender:M,productIds:[c],digests:[e],nonce:P},_={cancel_and_place:{cancel_tx:{sender:C.sender,productIds:C.productIds,digests:C.digests,nonce:this.numberToString(C.nonce)},cancel_signature:this.buildCancelOrdersSig(C,w,O),place_order:{product_id:c,order:{sender:A.sender,priceX18:A.priceX18,amount:A.amount,expiration:this.numberToString(A.expiration),nonce:A.nonce},signature:this.buildCreateOrderSig(A,w,S),id:this.safeInteger(this.options,"brokerId",5930043274845996)}}};n=this.omit(n,["timeInForce","reduceOnly","postOnly","triggerPrice","stopPrice","stopLossPrice","takeProfitPrice"]);const B=await this.v1GatewayPostExecute(this.extend(_,n)),E=this.safeDict(B,"data",{});return this.safeOrder({id:this.safeString(E,"digest")})}parseOrderStatus(e){if(void 0!==e){const t={pending:"open"};if("string"==typeof e)return this.safeString(t,e,e);if(void 0!==this.safeDict(e,"cancelled"))return"canceled";const i=this.safeDict(e,"triggered",{});return"success"===this.safeString(i,"status","failure")?"closed":"canceled"}return e}parseOrder(e,t=void 0){let i=this.safeString(e,"product_id"),s=this.safeTimestamp(e,"placed_at"),r=this.safeString(e,"amount"),a=this.safeString(e,"price_x18");const o=this.safeString(e,"unfilled_amount");let n;const d=this.safeValue(e,"status");if(void 0!==d){const t=this.safeDict(e,"order",{}),o=this.safeDict(t,"order",{});i=this.safeString(t,"product_id"),r=this.safeString(o,"amount"),a=this.safeString(o,"priceX18"),s=this.safeTimestamp(e,"updated_at");const d=this.safeDict(t,"trigger",{}),h=this.safeStringN(d,["price_above","price_below","last_price_above","last_price_below"]);void 0!==h&&(n=this.parseToNumeric(this.convertFromX18(h)))}const h=(t=this.safeMarket(i,t)).symbol;let c,l,u,f;void 0!==a&&(c=this.parseToNumeric(this.convertFromX18(a))),void 0!==r&&(l=this.parseToNumeric(this.convertFromX18(r))),void 0!==o&&(u=this.parseToNumeric(this.convertFromX18(o))),void 0!==l&&void 0!==u&&(f=l<0||u<0?"sell":"buy");const p=this.parseTimeInForce(this.safeString(e,"order_type")),m="PO"===p;return this.safeOrder({info:e,id:this.safeString(e,"digest"),clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:void 0,symbol:h,type:void 0,timeInForce:p,postOnly:m,reduceOnly:void 0,side:f,price:c,triggerPrice:n,amount:l,cost:void 0,average:void 0,filled:void 0,remaining:u,status:this.parseOrderStatus(d),fee:void 0,trades:void 0},t)}parseTimeInForce(e){return this.safeStringUpper({POST_ONLY:"PO"},e,e)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(t),r={type:"order",product_id:this.parseToInt(s.id),digest:e},a=await this.v1GatewayGetQuery(this.extend(r,i)),o=this.safeDict(a,"data");return this.parseOrder(o,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;this.checkRequiredCredentials(),await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchOpenOrders",s);const a={};let o;const n=this.safeBool2(s,"stop","trigger");let d;if(s=this.omit(s,["stop","trigger"]),void 0!==e&&(o=this.market(e),a.product_id=this.parseToNumeric(o.id)),n){const e=await this.queryContracts(),t=this.safeString(e,"chain_id"),o=this.safeString(e,"endpoint_addr"),n={sender:this.convertAddressToSender(r),recvTime:this.nonce()+9e4};a.signature=this.buildListTriggerTxSig(n,t,o),a.tx={sender:n.sender,recvTime:this.numberToString(n.recvTime)},a.type="list_trigger_orders",a.pending=!0;const h=this.safeInteger(s,"until");s=this.omit(s,"until"),void 0!==h&&(a.max_update_time=h),void 0!==i&&(a.limit=i),d=await this.v1TriggerPostQuery(this.extend(a,s))}else this.checkRequiredArgument("fetchOpenOrders",e,"symbol"),a.type="subaccount_orders",a.sender=this.convertAddressToSender(r),d=await this.v1GatewayPostQuery(this.extend(a,s));const h=this.safeDict(d,"data",{}),c=this.safeList(h,"orders");return this.parseOrders(c,o,t,i)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){this.checkRequiredCredentials();const a=this.safeBool2(s,"stop","trigger");if(s=this.omit(s,["stop","trigger"]),!a)throw new r.NotSupported(this.id+" fetchOrders only support trigger orders");let o,n;[o,s]=this.handlePublicAddress("fetchOrders",s),await this.loadMarkets();const d={type:"list_trigger_orders",pending:!1};void 0!==e&&(n=this.market(e),d.product_id=this.parseToNumeric(n.id));const h=await this.queryContracts(),c=this.safeString(h,"chain_id"),l=this.safeString(h,"endpoint_addr"),u={sender:this.convertAddressToSender(o),recvTime:this.nonce()+9e4};d.signature=this.buildListTriggerTxSig(u,c,l),d.tx={sender:u.sender,recvTime:this.numberToString(u.recvTime)};const f=this.safeInteger(s,"until");s=this.omit(s,"until"),void 0!==f&&(d.max_update_time=f),void 0!==i&&(d.limit=i);const p=await this.v1TriggerPostQuery(this.extend(d,s)),m=this.safeDict(p,"data",{}),g=this.safeList(m,"orders");return this.parseOrders(g,n,t,i)}async cancelAllOrders(e=void 0,t={}){if(this.checkRequiredCredentials(),await this.loadMarkets(),void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a symbol argument");const i=this.market(e).id,s=await this.queryContracts(),a=this.safeString(s,"chain_id"),o=this.safeString(s,"endpoint_addr"),n=this.nonce(),d=this.getNonce(n,9e4),h={sender:this.convertAddressToSender(this.walletAddress),productIds:[this.parseToNumeric(i)],nonce:d},c={cancel_product_orders:{tx:{sender:h.sender,productIds:h.productIds,nonce:this.numberToString(h.nonce)},signature:this.buildCancelAllOrdersSig(h,a,o)}},l=this.safeBool2(t,"stop","trigger");let u;return t=this.omit(t,["stop","trigger"]),u=l?await this.v1TriggerPostExecute(this.extend(c,t)):await this.v1GatewayPostExecute(this.extend(c,t)),[this.safeOrder({info:u})]}async cancelOrder(e,t=void 0,i={}){const s=await this.cancelOrders([e],t,i);return this.safeOrder({info:s})}async cancelOrders(e,t=void 0,i={}){if(this.checkRequiredCredentials(),void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrders() requires a symbol argument");await this.loadMarkets();const s=this.market(t).id,a=await this.queryContracts(),o=this.safeString(a,"chain_id"),n=this.safeString(a,"endpoint_addr"),d=this.nonce(),h=this.getNonce(d,9e4),c={sender:this.convertAddressToSender(this.walletAddress),productIds:[],digests:e,nonce:h},l=c.productIds,u=this.parseToNumeric(s);for(let t=0;t<e.length;t++)l.push(u);const f={cancel_orders:{tx:{sender:c.sender,productIds:l,digests:c.digests,nonce:this.numberToString(c.nonce)},signature:this.buildCancelOrdersSig(c,o,n)}},p=this.safeBool2(i,"stop","trigger");let m;return i=this.omit(i,["stop","trigger"]),m=p?await this.v1TriggerPostExecute(this.extend(f,i)):await this.v1GatewayPostExecute(this.extend(f,i)),m}async fetchBalance(e={}){let t;[t,e]=this.handlePublicAddress("fetchBalance",e);const i={type:"subaccount_info",subaccount:this.convertAddressToSender(t)},s=await this.v1GatewayGetQuery(this.extend(i,e)),r=this.safeDict(s,"data",{}),a=this.safeList(r,"spot_balances",[]),o={info:s};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"product_id"),s=this.safeMarket(i),r="0"===i;if(void 0===s.id&&!r)continue;const n=r?"USDC":this.safeString(s,"baseId"),d=this.safeCurrencyCode(n),h=this.account(),c=this.safeDict(t,"balance",{}),l=this.convertFromX18(this.safeString(c,"amount"));h.total=l,o[d]=h}return this.safeBalance(o)}parsePosition(e,t=void 0){const i=this.safeString(e,"product_id");t=this.safeMarket(i);const s=this.safeDict(e,"balance",{}),r=this.convertFromX18(this.safeString(s,"amount"));let o="buy";return a.Y.stringLt(r,"1")&&(o="sell"),this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:void 0,datetime:void 0,lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:void 0,notional:void 0,leverage:void 0,unrealizedPnl:void 0,contracts:void 0,contractSize:this.parseToNumeric(r),marginRatio:void 0,liquidationPrice:void 0,markPrice:void 0,lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:o,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchPositions(e=void 0,t={}){let i;[i,t]=this.handlePublicAddress("fetchPositions",t);const s={type:"subaccount_info",subaccount:this.convertAddressToSender(i)},r=await this.v1GatewayGetQuery(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"perp_balances",[]);e=this.marketSymbols(e);const n=[];for(let e=0;e<o.length;e++){const i=this.extend(this.parsePosition(o[e],void 0),t);0!==i.contractSize&&n.push(i)}return this.filterByArrayPositions(n,"symbol",e,!1)}async queryNonces(){const e={type:"nonces",address:this.walletAddress},t=await this.v1GatewayGetQuery(e);return this.safeDict(t,"data",{})}async withdraw(e,t,i,s=void 0,r={}){this.checkRequiredCredentials(),await this.loadMarkets();const a=this.currency(e),o=await this.queryContracts(),n=this.safeString(o,"chain_id"),d=this.safeString(o,"endpoint_addr"),h=await this.queryNonces(),c=this.safeNumber(h,"tx_nonce"),l={sender:this.convertAddressToSender(this.walletAddress),productId:this.parseToNumeric(a.id),amount:t.toString(),nonce:c},u={withdraw_collateral:{tx:{sender:l.sender,productId:l.productId,amount:l.amount,nonce:this.numberToString(l.nonce)},signature:this.buildWithdrawSig(l,n,d)}},f=await this.v1GatewayPostExecute(this.extend(u,r)),p=this.parseTransaction(f,a);return this.extend(p,{amount:t,address:i})}parseTransaction(e,t=void 0){let i;return void 0!==t&&(i=t.code),{info:e,id:void 0,txid:void 0,timestamp:void 0,datetime:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,type:"withdrawal",amount:void 0,currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:void 0,network:void 0,comment:void 0,internal:void 0,fee:void 0}}parseTransactionStatus(e){return this.safeString({success:"ok"},e,e)}handlePublicAddress(e,t){let i;[i,t]=this.handleOptionAndParams(t,e,"user");let s=i;if([s,t]=this.handleOptionAndParams(t,e,"address",i),void 0!==s&&""!==s)return[s,t];if(void 0!==this.walletAddress&&""!==this.walletAddress)return[this.walletAddress,t];throw new r.ArgumentsRequired(this.id+" "+e+"() requires a user parameter inside 'params' or the wallet address set")}handleErrors(e,t,i,s,a,o,n,d,h){if(!n)return;if("failure"===this.safeString(n,"status","")){const e=this.safeString(n,"error"),t=this.id+" "+o,i=this.safeString(n,"error_code");throw this.throwExactlyMatchedException(this.exceptions.exact,i,t),this.throwBroadlyMatchedException(this.exceptions.broad,e,t),new r.ExchangeError(t)}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.safeString(t,0),n=this.safeString(t,1);let d=this.implodeHostname(this.urls.api[o][n]);return"v1"===o&&"archive"===n||(d=d+"/"+e),"POST"===i?(r={"Content-Type":"application/json"},a=this.json(s)):Object.keys(s).length&&(d+="?"+this.urlencode(s)),"execute"!==e&&(void 0!==r?r["Accept-Encoding"]="gzip":r={"Accept-Encoding":"gzip"}),{url:d,method:i,body:a,headers:r}}}},88633:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(16140);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wallex",name:"Wallex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/wallex/64x64.png",api:{public:"https://api.wallex.ir"},www:"https://wallex.ir",doc:["https://api-docs.wallex.ir"]},timeframes:{"1m":"1","1h":"60","3h":"180","6h":"360","12h":"720","1d":"1D"},api:{public:{get:{"v1/markets":1,"v1/currencies/stats":1,"v1/depth":1,"v1/udf/history":1}}},commonCurrencies:{TMN:"IRT"},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetV1Markets(e),i=this.safeDict(t,"result"),s=this.safeDict(i,"symbols"),r=Object.keys(s),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.parseMarket(s[t]);a.push(i)}return a}parseMarket(e){const t=this.safeString(e,"symbol");let i=this.safeString(e,"baseAsset"),s=this.safeString(e,"quoteAsset");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1Markets(t),s=this.safeDict(i,"result"),r=this.safeDict(s,"symbols"),a=Object.keys(r),o={};for(let e=0;e<a.length;e++){const t=a[e],i=this.parseTicker(r[t]);o[i.symbol]=i}return this.filterByArrayTickers(o,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1Markets(t),r=this.safeDict(s,"result"),a=this.safeDict(r,"symbols");return this.parseTicker(a[i.id])}parseTicker(e,t=void 0){const i=this.safeValue(e,"stats"),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t,void 0,"spot"),a=this.safeFloat(i,"24h_highPrice",0),o=this.safeFloat(i,"24h_lowPrice",0),n=this.safeFloat(i,"bidPrice",0),d=this.safeFloat(i,"askPrice",0),h=this.safeFloat(i,"lastPrice",0),c=this.safeFloat(i,"24h_quoteVolume",0),l=this.safeFloat(i,"24h_volume",0);return this.safeTicker({symbol:r,timestamp:void 0,datetime:void 0,high:a,low:o,bid:n,bidVolume:void 0,ask:d,askVolume:void 0,vwap:void 0,open:void 0,close:h,last:h,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:l,quoteVolume:c,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.id,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetV1UdfHistory(n),h=this.safeValue(d,"o",[]),c=this.safeList(d,"h",[]),l=this.safeList(d,"l",[]),u=this.safeList(d,"c",[]),f=this.safeList(d,"v",[]),p=this.safeList(d,"t",[]),m=[];for(let e=0;e<h.length;e++)m.push([p[e],h[e],c[e],l[e],u[e],f[e]]);return this.parseOHLCVs(m,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id},r=await this.publicGetV1Depth(s),a=this.safeDict(r,"result",{}),o=this.milliseconds();return this.parseOrderBook(a,e,o,"bid","ask","price","quantity")}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"v1/udf/history"===e&&(n=n+"?"+this.urlencode(o)),"v1/depth"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},56314:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wallgold",name:"WallGold",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.wallgold.ir"},www:"https://wallgold.ir",doc:"https://wallgold.ir"},api:{public:{get:{"api/v1/price":1}}}})}async fetchMarkets(e={}){const t=await this.fetchPrice("buy",e);return[this.parseMarket(t)]}fetchPrice(e,t={}){return this.publicGetApiV1Price(this.extend({side:e,symbol:"GLD_18C_750TMN"},t))}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"success",!0),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.fetchPrice("buy",t),r=await this.fetchPrice("sell",t);return this.parseTicker(s,i,r)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=this.market("XAU18/IRT"),s=await this.fetchPrice("buy",t),r=await this.fetchPrice("sell",t),a=this.parseTicker(s,i,r),o={};return o[a.symbol]=a,this.filterByArrayTickers(o,"symbol",e)}parseTicker(e,t=void 0,i=void 0){const s=this.safeDict(e,"result",{}),r=this.safeDict(i,"result",s),a=this.safeNumber(s,"price"),o=this.safeNumber(r,"price");let n=a;void 0!==o&&(void 0===n||o>n)&&(n=o);const d=this.safeString(s,"currentTime"),h=d?this.parse8601(d):void 0;return this.safeTicker({symbol:t.symbol,timestamp:h,datetime:void 0,high:void 0,low:void 0,bid:a,bidVolume:void 0,ask:o,askVolume:void 0,vwap:void 0,open:void 0,close:n,last:n,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:{buy:e,sell:i}},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},57073:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(47698),r=i(62079),a=i(85147),o=i(6414),n=i(51579);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wavesexchange",name:"Waves.Exchange",countries:["CH"],certified:!1,pro:!1,dex:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:void 0,fetchDepositAddressesByNetwork:void 0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,reduceMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,signIn:!0,transfer:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","3h":"3h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg",test:{matcher:"https://matcher-testnet.wx.network",node:"https://nodes-testnet.wavesnodes.com",public:"https://api-testnet.wavesplatform.com/v0",private:"https://api-testnet.wx.network/v1",forward:"https://testnet.wx.network/api/v1/forward/matcher",market:"https://testnet.wx.network/api/v1/forward/marketdata/api/v1"},api:{matcher:"https://matcher.wx.network",node:"https://nodes.wx.network",public:"https://api.wavesplatform.com/v0",private:"https://api.wx.network/v1",forward:"https://wx.network/api/v1/forward/matcher",market:"https://wx.network/api/v1/forward/marketdata/api/v1"},doc:["https://docs.wx.network","https://docs.waves.tech","https://api.wavesplatform.com/v0/docs/","https://nodes.wavesnodes.com/api-docs/index.html","https://matcher.waves.exchange/api-docs/index.html"],www:"https://wx.network"},api:{matcher:{get:["matcher","matcher/settings","matcher/settings/rates","matcher/balance/reserved/{publicKey}","matcher/debug/allSnashotOffsets","matcher/debug/currentOffset","matcher/debug/lastOffset","matcher/debug/oldestSnapshotOffset","matcher/debug/config","matcher/debug/address/{address}","matcher/debug/status","matcher/debug/address/{address}/check","matcher/orderbook","matcher/orderbook/{baseId}/{quoteId}","matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}","matcher/orderbook/{baseId}/{quoteId}/{orderId}","matcher/orderbook/{baseId}/{quoteId}/info","matcher/orderbook/{baseId}/{quoteId}/status","matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}","matcher/orderbook/{publicKey}","matcher/orderbook/{publicKey}/{orderId}","matcher/orders/{address}","matcher/orders/{address}/{orderId}","matcher/transactions/{orderId}","api/v1/orderbook/{baseId}/{quoteId}"],post:["matcher/orderbook","matcher/orderbook/market","matcher/orderbook/cancel","matcher/orderbook/{baseId}/{quoteId}/cancel","matcher/orderbook/{baseId}/{quoteId}/calculateFee","matcher/orderbook/{baseId}/{quoteId}/delete","matcher/orderbook/{baseId}/{quoteId}/cancelAll","matcher/debug/saveSnapshots","matcher/orders/{address}/cancel","matcher/orders/cancel/{orderId}","matcher/orders/serialize"],delete:["matcher/orderbook/{baseId}/{quoteId}","matcher/settings/rates/{assetId}"],put:["matcher/settings/rates/{assetId}"]},node:{get:["addresses","addresses/balance/{address}","addresses/balance/{address}/{confirmations}","addresses/balance/details/{address}","addresses/data/{address}","addresses/data/{address}/{key}","addresses/effectiveBalance/{address}","addresses/effectiveBalance/{address}/{confirmations}","addresses/publicKey/{publicKey}","addresses/scriptInfo/{address}","addresses/scriptInfo/{address}/meta","addresses/seed/{address}","addresses/seq/{from}/{to}","addresses/validate/{address}","alias/by-address/{address}","alias/by-alias/{alias}","assets/{assetId}/distribution/{height}/{limit}","assets/balance/{address}","assets/balance/{address}/{assetId}","assets/details/{assetId}","assets/nft/{address}/limit/{limit}","blockchain/rewards","blockchain/rewards/height","blocks/address/{address}/{from}/{to}/","blocks/at/{height}","blocks/delay/{signature}/{blockNum}","blocks/first","blocks/headers/last","blocks/headers/seq/{from}/{to}","blocks/height","blocks/height/{signature}","blocks/last","blocks/seq/{from}/{to}","blocks/signature/{signature}","consensus/algo","consensus/basetarget","consensus/basetarget/{blockId}","consensus/{generatingbalance}/address","consensus/generationsignature","consensus/generationsignature/{blockId}","debug/balances/history/{address}","debug/blocks/{howMany}","debug/configInfo","debug/historyInfo","debug/info","debug/minerInfo","debug/portfolios/{address}","debug/state","debug/stateChanges/address/{address}","debug/stateChanges/info/{id}","debug/stateWaves/{height}","leasing/active/{address}","node/state","node/version","peers/all","peers/blacklisted","peers/connected","peers/suspended","transactions/address/{address}/limit/{limit}","transactions/info/{id}","transactions/status","transactions/unconfirmed","transactions/unconfirmed/info/{id}","transactions/unconfirmed/size","utils/seed","utils/seed/{length}","utils/time","wallet/seed"],post:["addresses","addresses/data/{address}","addresses/sign/{address}","addresses/signText/{address}","addresses/verify/{address}","addresses/verifyText/{address}","debug/blacklist","debug/print","debug/rollback","debug/validate","node/stop","peers/clearblacklist","peers/connect","transactions/broadcast","transactions/calculateFee","tranasctions/sign","transactions/sign/{signerAddress}","tranasctions/status","utils/hash/fast","utils/hash/secure","utils/script/compileCode","utils/script/compileWithImports","utils/script/decompile","utils/script/estimate","utils/sign/{privateKey}","utils/transactionsSerialize"],delete:["addresses/{address}","debug/rollback-to/{signature}"]},public:{get:["assets","pairs","candles/{baseId}/{quoteId}","transactions/exchange"]},private:{get:["deposit/addresses/{currency}","deposit/addresses/{currency}/{platform}","platforms","deposit/currencies","withdraw/currencies","withdraw/addresses/{currency}/{address}"],post:["oauth2/token"]},forward:{get:["matcher/orders/{address}","matcher/orders/{address}/{orderId}"],post:["matcher/orders/{wavesAddress}/cancel"]},market:{get:["tickers"]}},currencies:{WX:this.safeCurrencyStructure({id:"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",numericId:void 0,code:"WX",precision:this.parseNumber("1e-8")})},precisionMode:n.kb,options:{allowedCandles:1440,accessToken:void 0,createMarketBuyOrderRequiresPrice:!0,matcherPublicKey:void 0,quotes:void 0,createOrderDefaultExpiry:24192e5,wavesAddress:void 0,withdrawFeeUSDN:7420,withdrawFeeWAVES:1e5,wavesPrecision:1e-8,messagePrefix:"W",networks:{ERC20:"ETH",BEP20:"BSC"}},features:{spot:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{EGG:"Waves Ducks"},requiresEddsa:!0,exceptions:{3147270:r.InsufficientFunds,112:r.InsufficientFunds,4:r.ExchangeError,13:r.ExchangeNotAvailable,14:r.ExchangeNotAvailable,3145733:r.AccountSuspended,3148040:r.DuplicateOrderId,3148801:r.AuthenticationError,9440512:r.AuthenticationError,9440771:r.BadSymbol,9441026:r.InvalidOrder,9441282:r.InvalidOrder,9441286:r.InvalidOrder,9441295:r.InvalidOrder,9441540:r.InvalidOrder,9441542:r.InvalidOrder,106954752:r.AuthenticationError,106954769:r.AuthenticationError,106957828:r.AuthenticationError,106960131:r.AuthenticationError,106981137:r.AuthenticationError,9437184:r.BadRequest,9437193:r.OrderNotFound,1048577:r.BadRequest,1051904:r.AuthenticationError}})}setSandboxMode(e){this.options.messagePrefix=e?"T":"W",this.options.sandboxMode=e,super.setSandboxMode(e)}async getFeesForAsset(e,t,i,s,r={}){await this.loadMarkets();const a=this.market(e);i=this.toRealSymbolAmount(e,i),s=this.toRealSymbolPrice(e,s);const o=this.extend({baseId:a.baseId,quoteId:a.quoteId,orderType:t,amount:i,price:s},r);return await this.matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee(o)}async customCalculateFee(e,t,i,s,r,o="taker",n={}){const d=await this.getFeesForAsset(e,i,s,r);let h;h=this.safeBool(n,"isDiscountFee",!1)?this.safeValue(d,"discount"):this.safeValue(d,"base");const c=this.safeString(h,"matcherFee"),l=this.safeString(h,"feeAssetId"),u=this.safeCurrencyCode(l),f=this.fromRealCurrencyAmount(u,c),p=this.numberToString(s),m=this.numberToString(r),g=this.feeToPrecision(e,this.parseNumber(f)),v=a.Y.stringDiv(f,a.Y.stringMul(p,m));return{type:o,currency:u,rate:this.parseNumber(v),cost:this.parseNumber(g)}}async getQuotes(){let e=this.safeValue(this.options,"quotes");if(e)return e;{const t=await this.matcherGetMatcherSettings();e={};const i=this.safeValue(t,"priceAssets");for(let t=0;t<i.length;t++)e[i[t]]=!0;return this.options.quotes=e,e}}async fetchMarkets(e={}){const t=await this.marketGetTickers(),i=[];for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"amountAssetID"),a=this.safeString(s,"priceAssetID"),o=r+"/"+a,n=this.safeString(s,"symbol");let[d,h]=n.split("/");d=this.safeCurrencyCode(d),h=this.safeCurrencyCode(h);const c=d+"/"+h;i.push({id:o,symbol:c,base:d,quote:h,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(s,"amountAssetDecimals"))),price:this.parseNumber(this.parsePrecision(this.safeString(s,"priceAssetDecimals")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:s})}return i}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r=this.extend({baseId:s.baseId,quoteId:s.quoteId},i),a=await this.matcherGetMatcherOrderbookBaseIdQuoteId(r),o=this.safeInteger(a,"timestamp");return{symbol:e,bids:this.parseOrderBookSide(this.safeValue(a,"bids"),s,t),asks:this.parseOrderBookSide(this.safeValue(a,"asks"),s,t),timestamp:o,datetime:this.iso8601(o),nonce:void 0}}parseOrderBookSide(e,t=void 0,i=void 0){const s=t.precision,r=this.safeString(this.options,"wavesPrecision","1e-8"),o=this.safeString(s,"amount"),n=this.safeString(s,"price"),d=a.Y.stringDiv(o,n),h=a.Y.stringDiv(r,d),c=[];for(let t=0;t<e.length;t++){const s=e[t],r=this.safeString(s,"price","0"),n=this.safeString(s,"amount","0");let d,l;if(void 0!==h&&void 0!==r&&(d=a.Y.stringMul(r,h)),void 0!==o&&void 0!==n&&(l=a.Y.stringMul(n,o)),void 0!==i&&t>i)break;c.push([this.parseNumber(d),this.parseNumber(l)])}return c}checkRequiredKeys(){if(void 0===this.apiKey)throw new r.AuthenticationError(this.id+" requires apiKey credential");if(void 0===this.secret)throw new r.AuthenticationError(this.id+" requires secret credential");let e,t;try{e=this.base58ToBinary(this.apiKey)}catch(e){throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key")}try{t=this.base58ToBinary(this.secret)}catch(e){throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}const i=this.binaryToBase16(e),s=this.binaryToBase16(t);if(64!==i.length)throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key");if(64!==s.length)throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key");return!0}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e)),n="matcher/orders/{wavesAddress}/cancel"===e;e=this.implodeParams(e,s);let d=this.urls.api[t]+"/"+e,h=this.urlencodeWithArrayRepeat(o);if("private"===t||"forward"===t){r={Accept:"application/json"};const e=this.safeString(this.options,"accessToken");e&&(r.Authorization="Bearer "+e),r["content-type"]="POST"===i?"application/json":"application/x-www-form-urlencoded",n&&(a=this.json([o.orderId]),h=""),h.length>0&&(d+="?"+h)}else"matcher"===t?"POST"===i?(r={Accept:"application/json","Content-Type":"application/json"},a=this.json(o)):r=o:"POST"===i?(r={"content-type":"application/json"},a=this.json(o)):(r={"content-type":"application/x-www-form-urlencoded"},h.length>0&&(d+="?"+h));return{url:d,method:i,body:a,headers:r}}async signIn(e={}){if(!this.safeString(this.options,"accessToken")){const e="ffffff01",t=604800;let i=this.sum(this.seconds(),t);i=i.toString();const s="wx.network",r=this.safeString(this.options,"messagePrefix","W")+":"+s+":"+i,a=e+this.binaryToBase16(this.encode(r)),n=this.binaryToBase16(this.base58ToBinary(this.secret)),d=this.axolotl(a,n,o.ev),h={grant_type:"password",scope:"general",username:this.apiKey,password:i+":"+d,client_id:s},c=await this.privatePostOauth2Token(h);return this.options.accessToken=this.safeString(c,"access_token"),this.options.accessToken}}parseTicker(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString(e,"symbol"),r=(t=this.safeMarket(s,t,"/")).symbol,a=this.safeString2(e,"24h_close","lastPrice"),o=this.safeString2(e,"24h_low","low"),n=this.safeString2(e,"24h_high","high"),d=this.safeString2(e,"24h_vwap","weightedAveragePrice"),h=this.safeString2(e,"24h_volume","volume"),c=this.safeString2(e,"24h_priceVolume","quoteVolume"),l=this.safeString2(e,"24h_open","firstPrice");return this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:n,low:o,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:d,open:l,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:h,quoteVolume:c,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pairs:i.id},r=await this.publicGetPairs(this.extend(s,t)),a=this.safeValue(r,"data",[]),o=this.safeValue(a,0,{}),n=this.safeDict(o,"data",{});return this.parseTicker(n,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.marketGetTickers(t);return this.parseTickers(i,e)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={baseId:a.baseId,quoteId:a.quoteId,interval:this.safeString(this.timeframes,t,t)},n=this.safeInteger(this.options,"allowedCandles",1440),d=this.safeInteger(r,"until"),h=void 0!==d;void 0===s&&(s=n),s=Math.min(n,s);const c=1e3*this.parseTimeframe(t);if(void 0===i){const e=this.milliseconds(),t=h?d:e,i=this.parseToInt(t/c)*c-(s-1)*c;o.timeStart=i.toString(),h&&(o.timeEnd=d.toString())}else if(o.timeStart=i.toString(),h)o.timeEnd=d.toString();else{const e=this.sum(i,c*s);o.timeEnd=e.toString()}r=this.omit(r,"until");const l=await this.publicGetCandlesBaseIdQuoteId(this.extend(o,r)),u=this.safeValue(l,"data",[]);let f,p=this.parseOHLCVs(u,a,t,i,s);p=this.filterFutureCandles(p);const m=p.length;for(let e=0;e<p.length;e++){const t=m-e-1,i=p[t];void 0===i[1]&&(i[1]=f,i[2]=f,i[3]=f,i[4]=f,p[t]=i),f=i[4]}return p}filterFutureCandles(e){const t=[],i=this.milliseconds();for(let s=0;s<e.length&&!(e[s][0]>i);s++)t.push(e[s]);return t}parseOHLCV(e,t=void 0){const i=this.safeValue(e,"data",{});return[this.parse8601(this.safeString(i,"time")),this.safeNumber(i,"open"),this.safeNumber(i,"high"),this.safeNumber(i,"low"),this.safeNumber(i,"close"),this.safeNumber(i,"volume",0)]}async fetchDepositAddress(e,t={}){await this.signIn();const i=this.safeValue(this.options,"networks",{}),s=this.safeStringUpper(t,"network"),a=this.safeString(i,s,s);t=this.omit(t,["network"]);const o=await this.privateGetPlatforms(),n={},d={},h=this.safeValue(o,"items",[]);for(let e=0;e<h.length;e++){const t=h[e],i=this.safeString(t,"id"),s=this.safeValue(t,"currencies",[]);for(let e=0;e<s.length;e++){const t=this.safeString(s,e);n[t]=!0,t in d||(d[t]={}),d[t][i]=!0}}if(!(e in n)){const t=Object.keys(n);throw new r.ExchangeError(this.id+" fetchDepositAddress() "+e+" not supported. Currency code must be one of "+t.join(", "))}let c;if(void 0===a){const i={currency:e};c=await this.privateGetDepositAddressesCurrency(this.extend(i,t))}else{const i=d[e];if(!(a in i)){const t=Object.keys(i);throw new r.ExchangeError(this.id+" "+a+" network "+e+" deposit address not supported. Network must be one of "+t.join(", "))}if("WAVES"===a){const t={publicKey:this.apiKey};return{info:await this.nodeGetAddressesPublicKeyPublicKey(this.extend(t,t)),currency:e,network:a,address:this.safeString(c,"address"),tag:void 0}}{const i={currency:e,platform:a};c=await this.privateGetDepositAddressesCurrencyPlatform(this.extend(i,t))}}const l=this.safeValue(c,"currency"),u=this.safeString(l,"platform_id"),f=this.safeValue(this.options,"networkByIds",{}),p=this.safeString(f,u,u),m=this.safeValue(c,"deposit_addresses");return{info:c,currency:e,network:p,address:this.safeString(m,0),tag:void 0}}async getMatcherPublicKey(){const e=this.safeString(this.options,"matcherPublicKey");if(e)return e;{const e=await this.matcherGetMatcher();return this.options.matcherPublicKey=e.slice(1,e.length-1),this.options.matcherPublicKey}}getAssetBytes(e){return"WAVES"===e?this.numberToBE(0,1):this.binaryConcat(this.numberToBE(1,1),this.base58ToBinary(e))}getAssetId(e){return"WAVES"===e?"":e}toRealCurrencyAmount(e,t,i=void 0){const s=this.currency(e),r=a.Y.stringDiv(this.numberToString(t),this.safeString(s,"precision"));return parseInt(r)}fromRealCurrencyAmount(e,t){if(!(e in this.currencies))return t;const i=this.currency(e),s=this.safeString(i,"precision");return a.Y.stringMul(t,s)}toRealSymbolPrice(e,t){const i=this.market(e),s=a.Y.stringDiv(this.numberToString(t),this.safeString(i.precision,"price"));return parseInt(s)}fromRealSymbolPrice(e,t){const i=this.markets[e];return a.Y.stringMul(t,this.safeString(i.precision,"price"))}toRealSymbolAmount(e,t){const i=this.market(e),s=a.Y.stringDiv(this.numberToString(t),this.safeString(i.precision,"amount"));return parseInt(s)}fromRealSymbolAmount(e,t){const i=this.markets[e];return a.Y.stringMul(t,i.precision.amount)}safeGetDynamic(e){const t=this.safeValue(e,"orderFee");return"dynamic"in t?this.safeValue(t,"dynamic"):this.safeValue(t.composite.default,"dynamic")}safeGetRates(e){const t=this.safeValue(e,"rates");return void 0===t?{WAVES:1}:t}async createOrder(e,t,i,s,a=void 0,n={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const d=this.market(e),h=await this.getMatcherPublicKey(),c=this.getAssetId(d.baseId),l=this.getAssetId(d.quoteId),u="market"===t,f=this.safeFloat2(n,"triggerPrice","stopPrice"),p=void 0!==f;if(u&&void 0===a)throw new r.InvalidOrder(this.id+" createOrder() requires a price argument for "+t+" orders to determine the max price for buy and the min price for sell");const m=this.milliseconds();let g;[g,n]=this.handleOptionAndParams(n,"createOrder","defaultExpiry",this.safeInteger(this.options,"createOrderDefaultExpiry",24192e5));const v=this.sum(m,g),y=await this.getFeesForAsset(e,i,s,a),b=this.safeValue2(y,"base","discount"),w=this.safeString(b,"feeAssetId"),k=this.safeCurrencyCode(w),S=this.safeString(b,"matcherFee"),O=this.safeValue(y,"discount"),T=this.safeString(O,"feeAssetId"),P=this.safeCurrencyCode(T),M=this.safeString(O,"matcherFee");let I,x;if("feeAsset"in n||"feeAsset"in this.options){const e=this.safeString(n,"feeAsset",this.safeString(this.options,"feeAsset")),t=this.currency(e);I=this.safeString(t,"id")}const A=await this.fetchBalance();if(void 0!==I){if(w!==I&&T!==I)throw new r.InvalidOrder(this.id+" asset fee must be "+k+" or "+P);const e=this.safeCurrencyCode(I),t=I===w?S:M,i=parseFloat(this.fromRealCurrencyAmount(e,t));if(!(e in A&&A[e].free>=i))throw new r.InsufficientFunds(this.id+" not enough funds of the selected asset fee");x=parseInt(t)}const C=this.fromRealCurrencyAmount(k,S),_=this.fromRealCurrencyAmount(P,M);if(void 0===I&&(k in A&&A[k].free>=parseFloat(C)?(I=w,x=parseInt(S)):P in A&&A[P].free>=parseFloat(_)&&(I=T,x=parseInt(M))),void 0===I)throw new r.InsufficientFunds(this.id+" not enough funds on none of the eligible asset fees: "+k+" "+C+" or "+P+" "+_);s=this.toRealSymbolAmount(e,s),a=this.toRealSymbolPrice(e,a);const B={amountAsset:c,priceAsset:l},E=this.safeBool(this.options,"sandboxMode",!1)?84:87,L={senderPublicKey:this.apiKey,matcherPublicKey:h,assetPair:B,orderType:i,price:a,amount:s,timestamp:m,expiration:v,matcherFee:parseInt(x),priceMode:"assetDecimals",version:4,chainId:E};if(p){const t={v:1,c:{t:"sp",v:{p:this.toRealSymbolPrice(e,f)}}};L.attachment=this.binaryToBase58(this.encode(JSON.stringify(t)))}"WAVES"!==I&&(L.matcherFeeAssetId=I);let R=await this.matcherPostMatcherOrdersSerialize(L);'"'===R[0]&&'"'===R[R.length-1]&&(R=R.slice(1,R.length-1));const N=this.axolotl(this.binaryToBase16(this.base58ToBinary(R)),this.binaryToBase16(this.base58ToBinary(this.secret)),o.ev);if(L.signature=N,u){const e=await this.matcherPostMatcherOrderbookMarket(this.extend(L,n)),t=this.safeDict(e,"message");return this.parseOrder(t,d)}{const e=await this.matcherPostMatcherOrderbook(this.extend(L,n)),t=this.safeDict(e,"message");return this.parseOrder(t,d)}}async cancelOrder(e,t=void 0,i={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.signIn();const s=await this.getWavesAddress(),r=await this.forwardPostMatcherOrdersWavesAddressCancel({wavesAddress:s,orderId:e}),a=this.safeValue(r,"message"),o=this.safeValue(a,0),n=this.safeValue(o,0),d=this.safeString(n,"orderId");return this.safeOrder({info:r,id:d,clientOrderId:void 0,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,symbol:t,type:void 0,side:void 0,price:void 0,amount:void 0,cost:void 0,average:void 0,filled:void 0,remaining:void 0,status:void 0,fee:void 0,trades:void 0})}async fetchOrder(e,t=void 0,i={}){let s;this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.milliseconds(),a=[this.base58ToBinary(this.apiKey),this.numberToBE(r,8)],n=this.binaryConcatArray(a),d=this.binaryToBase16(this.base58ToBinary(this.secret)),h=this.axolotl(this.binaryToBase16(n),d,o.ev),c={Timestamp:r.toString(),Signature:h,publicKey:this.apiKey,orderId:e},l=await this.matcherGetMatcherOrderbookPublicKeyOrderId(this.extend(c,i));return this.parseOrder(l,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){if(this.checkRequiredDependencies(),this.checkRequiredKeys(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n=this.milliseconds(),d=[this.base58ToBinary(this.apiKey),this.numberToBE(n,8)],h=this.binaryConcatArray(d),c=this.binaryToBase16(this.base58ToBinary(this.secret)),l=this.axolotl(this.binaryToBase16(h),c,o.ev),u={Accept:"application/json",Timestamp:n.toString(),Signature:l,publicKey:this.apiKey,baseId:a.baseId,quoteId:a.quoteId},f=await this.matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKey(this.extend(u,s));return this.parseOrders(f,a,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),activeOnly:!0},o=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(o,r,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),closedOnly:!0},o=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(o,r,t,i)}parseOrderStatus(e){return this.safeString({Cancelled:"canceled",Accepted:"open",Filled:"closed",PartiallyFilled:"open"},e,e)}getSymbolFromAssetPair(e){const t=this.safeString(e,"amountAsset","WAVES"),i=this.safeString(e,"priceAsset","WAVES");return this.safeCurrencyCode(t)+"/"+this.safeCurrencyCode(i)}parseOrder(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString2(e,"type","orderType");let r="limit";"type"in e&&(r=this.safeString(e,"orderType",r));const a=this.safeString(e,"id"),o=this.safeString(e,"filled"),n=this.safeString(e,"price"),d=this.safeString(e,"amount"),h=this.safeValue(e,"assetPair");let c;void 0!==h?c=this.getSymbolFromAssetPair(h):void 0!==t&&(c=t.symbol);const l=this.safeCurrencyCode(this.safeString(h,"amountAsset","WAVES")),u=this.fromRealSymbolPrice(c,n),f=this.fromRealCurrencyAmount(l,d),p=this.fromRealCurrencyAmount(l,o),m=this.fromRealSymbolPrice(c,this.safeString(e,"avgWeighedPrice")),g=this.parseOrderStatus(this.safeString(e,"status"));let v,y;if("type"in e){const t=this.safeCurrencyCode(this.safeString(e,"feeAsset"));v={currency:t,fee:this.parseNumber(this.fromRealCurrencyAmount(t,this.safeString(e,"filledFee")))}}else{const t=this.safeCurrencyCode(this.safeString(e,"matcherFeeAssetId","WAVES"));v={currency:t,fee:this.parseNumber(this.fromRealCurrencyAmount(t,this.safeString(e,"matcherFee")))}}const b=this.safeString(e,"attachment");if(void 0!==b){const e=this.parseJson(this.decode(this.base58ToBinary(b)));if(void 0!==e){const t=this.safeValue(e,"c");if(void 0!==t){const e=this.safeValue(t,"v");void 0!==e&&(y=this.safeString(e,"p"))}}}return this.safeOrder({info:e,id:a,clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,symbol:c,type:r,timeInForce:void 0,postOnly:void 0,side:s,price:u,triggerPrice:y,amount:f,cost:void 0,average:m,filled:p,remaining:void 0,status:g,fee:v,trades:void 0},t)}async getWavesAddress(){const e=this.safeString(this.options,"wavesAddress");if(void 0===e){const e={publicKey:this.apiKey},t=await this.nodeGetAddressesPublicKeyPublicKey(e);return this.options.wavesAddress=this.safeString(t,"address"),this.options.wavesAddress}return e}async fetchBalance(e={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const t=await this.getWavesAddress(),i={address:t},s=await this.nodeGetAssetsBalanceAddress(i),r=this.safeValue(s,"balances",[]);let n,d={};const h=[],c=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeInteger(t,"timestamp");n=void 0===n?i:Math.max(n,i);const s=this.safeValue(t,"issueTransaction"),a=this.safeString(t,"assetId"),o=this.safeString(t,"balance");if(a in this.currencies_by_id){const e=this.safeCurrencyCode(a);d[e]=this.account(),d[e].total=this.fromRealCurrencyAmount(e,o)}else void 0===s&&(h.push(a),c.push(o))}if(h.length){const e={ids:h},t=await this.publicGetAssets(e),i=this.safeValue(t,"data",[]);for(let e=0;e<i.length;e++){const t=i[e],s=c[e],r=this.safeValue(t,"data"),o=this.parsePrecision(this.safeString(r,"precision")),n=this.safeString(r,"ticker"),h=this.safeCurrencyCode(n);d[h]=this.account(),d[h].total=a.Y.stringMul(s,o)}}const l=this.milliseconds(),u=[this.base58ToBinary(this.apiKey),this.numberToBE(l,8)],f=this.binaryConcatArray(u),p=this.binaryToBase16(this.base58ToBinary(this.secret)),m=this.axolotl(this.binaryToBase16(f),p,o.ev),g={publicKey:this.apiKey,signature:m,timestamp:l.toString()},v=await this.matcherGetMatcherBalanceReservedPublicKey(g),y=Object.keys(v);for(let e=0;e<y.length;e++){const t=y[e],i=this.safeCurrencyCode(t);i in d||(d[i]=this.account());const s=this.safeString(v,t);d[i].used=this.fromRealCurrencyAmount(i,s)}const b={address:t},w=await this.nodeGetAddressesBalanceAddress(b);return d.WAVES=this.safeValue(d,"WAVES",this.account()),d.WAVES.total=this.fromRealCurrencyAmount("WAVES",this.safeString(w,"balance")),d=this.setUndefinedBalancesToZero(d),d.timestamp=n,d.datetime=this.iso8601(n),this.safeBalance(d)}setUndefinedBalancesToZero(e,t="used"){const i=Object.keys(e);for(let s=0;s<i.length;s++){const r=i[s];void 0===this.safeValue(e[r],"used")&&(e[r][t]="0")}return e}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={sender:await this.getWavesAddress()};let a;void 0!==e&&(a=this.market(e),r.amountAsset=a.baseId,r.priceAsset=a.quoteId);const o=await this.publicGetTransactionsExchange(r),n=this.safeValue(o,"data");return this.parseTrades(n,a,t,i)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={amountAsset:r.baseId,priceAsset:r.quoteId};void 0!==i&&(a.limit=Math.min(i,100)),void 0!==t&&(a.timeStart=t);const o=await this.publicGetTransactionsExchange(a),n=this.safeValue(o,"data");return this.parseTrades(n,r,t,i)}parseTrade(e,t=void 0){const i=this.safeValue(e,"data"),s=this.safeString(i,"timestamp"),r=this.parse8601(s),a=this.safeString(i,"id"),o=this.safeString(i,"price"),n=this.safeString(i,"amount"),d=this.safeValue(i,"order1"),h=this.safeValue(i,"order2");let c,l;if(this.safeString(d,"senderPublicKey")===this.apiKey)c=d;else if(this.safeString(h,"senderPublicKey")===this.apiKey)c=h;else{const e=this.safeString(d,"timestamp"),t=this.safeString(h,"timestamp");c=this.parse8601(e)>this.parse8601(t)?d:h}const u=this.safeValue(c,"assetPair");void 0!==u?l=this.getSymbolFromAssetPair(u):void 0!==t&&(l=t.symbol);const f=this.safeString(c,"orderType"),p=this.safeString(c,"id"),m={cost:this.safeString(c,"matcherFee"),currency:this.safeCurrencyCode(this.safeString(c,"matcherFeeAssetId","WAVES"))};return this.safeTrade({info:e,timestamp:r,datetime:s,symbol:l,id:a,order:p,type:void 0,side:f,takerOrMaker:void 0,price:o,amount:n,cost:void 0,fee:m},t)}parseDepositWithdrawFees(e,t=void 0,i=void 0){const s={};t=this.marketCodes(t);for(let r=0;r<e.length;r++){const a=e[r],o=this.safeString(a,i),n=this.safeValue(this.currencies_by_id,o),d=this.safeString(n,"code",o);if(void 0===t||this.inArray(d,t)){let e=this.safeValue(s,d);void 0===e?e={info:[a],withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}}:(e=s[d],e.info=this.arrayConcat(e.info,[a]));const t=this.safeString(a,"platform_id"),i=this.safeString(n,"code"),r=this.networkIdToCode(t,i);let o=this.safeValue(e.networks,r);void 0===o&&(o={withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0}});const h=this.safeString(a,"type"),c=this.safeValue(a,"fees");let l="deposit";"withdrawal_currency"===h&&(l="withdraw"),o[l]={fee:this.safeNumber(c,"flat"),percentage:!1},e.networks[r]=o,s[d]=e}}const r=Object.keys(s);for(let e=0;e<r.length;e++){const t=r[e],i=s[t],a=this.safeValue(i,"networks"),o=Object.keys(a);if(1===o.length){const e=this.safeValue(a,o[0]);s[t].withdraw=this.safeValue(e,"withdraw"),s[t].deposit=this.safeValue(e,"deposit")}}return s}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();let i=[],s=[];s.push(this.privateGetDepositCurrencies(t)),s.push(this.privateGetWithdrawCurrencies(t)),s=await Promise.all(s);for(let e=0;e<s.length;e++){const t=this.safeValue(s[e],"items");i=this.arrayConcat(i,t)}return this.parseDepositWithdrawFees(i,e,"id")}handleErrors(e,t,i,s,a,o,n,d,h){const c=this.safeString(n,"error"),l=this.safeBool(n,"success",!0),u=this.safeValue(this.exceptions,c);if(void 0!==u){const e=this.safeString(n,"message");throw new u(this.id+" "+e)}if("Validation Error"===this.safeString(n,"message"))throw new r.BadRequest(this.id+" "+o);if(!l)throw new r.ExchangeError(this.id+" "+o)}async withdraw(e,t,i,s=void 0,a={}){if([s,a]=this.handleWithdrawTagAndParams(s,a),"WAVES"!==e){const t=await this.privateGetWithdrawCurrencies(),i={},s=this.safeValue(t,"items",[]);for(let e=0;e<s.length;e++){const t=s[e];i[this.safeString(t,"id")]=!0}if(!(e in i)){const t=Object.keys(i);throw new r.ExchangeError(this.id+" withdraw() "+e+" not supported. Currency code must be one of "+t.toString())}}await this.loadMarkets();const n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],d={};for(let e=0;e<n.length;e++){d[n[e]]=!0}let h=!0;const c=this.remove0xPrefix(i).toLowerCase(),l=1*c.length;for(let e=0;e<l;e++){if(!(c[e]in d)){h=!1;break}}let u;if(await this.signIn(),"WAVES"!==e||h){const s={address:i,currency:e},a=await this.privateGetWithdrawAddressesCurrencyAddress(s),o=this.safeValue(a,"currency"),n=this.safeValue(o,"allowed_amount"),d=this.safeNumber(n,"min");if(t<=d)throw new r.BadRequest(this.id+" "+e+" withdraw failed, amount "+t.toString()+" must be greater than the minimum allowed amount of "+d.toString());const h=this.safeValue(a,"proxy_addresses",[]);u=this.safeString(h,0)}else u=i;const f=this.safeInteger(this.options,"withdrawFeeWAVES",1e5),p="WAVES",m=this.toRealCurrencyAmount(e,t),g=this.currency(e),v=this.milliseconds(),y=[this.numberToBE(4,1),this.numberToBE(2,1),this.base58ToBinary(this.apiKey),this.getAssetBytes(g.id),this.getAssetBytes(p),this.numberToBE(v,8),this.numberToBE(m,8),this.numberToBE(f,8),this.base58ToBinary(u),this.numberToBE(0,2)],b=this.binaryConcatArray(y),w=this.binaryToBase16(this.base58ToBinary(this.secret)),k=this.axolotl(this.binaryToBase16(b),w,o.ev),S={senderPublicKey:this.apiKey,amount:m,fee:f,type:4,version:2,attachment:"",feeAssetId:this.getAssetId(p),proofs:[k],assetId:this.getAssetId(g.id),recipient:u,timestamp:v,signature:k},O=await this.nodePostTransactionsBroadcast(S);return this.parseTransaction(O,g)}parseTransaction(e,t=void 0){const i=(t=this.safeCurrency(void 0,t)).code,s="4"===this.safeString(e,"type")?"withdraw":"deposit",r=this.parseNumber(this.fromRealCurrencyAmount(i,this.safeString(e,"amount"))),a=this.safeString(e,"fee"),o=this.safeString(e,"feeAssetId","WAVES"),n=this.safeCurrencyCode(o),d=this.parseNumber(this.fromRealCurrencyAmount(n,a)),h=this.safeInteger(e,"timestamp");return{id:this.safeString(e,"id"),txid:void 0,timestamp:h,datetime:this.iso8601(h),network:void 0,addressFrom:this.safeString(e,"sender"),address:void 0,addressTo:this.safeString(e,"recipient"),amount:r,type:s,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:{currency:n,cost:d},info:e}}}},75336:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(33965),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"whitebit",name:"WhiteBit",version:"v4",countries:["EE"],rateLimit:50,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!1,createConvertTrade:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchConvertQuote:!0,fetchConvertTrade:!1,fetchConvertTradeHistory:!0,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg",api:{v1:{public:"https://whitebit.com/api/v1/public",private:"https://whitebit.com/api/v1"},v2:{public:"https://whitebit.com/api/v2/public"},v4:{public:"https://whitebit.com/api/v4/public",private:"https://whitebit.com/api/v4"}},www:"https://www.whitebit.com",doc:"https://github.com/whitebit-exchange/api-docs",fees:"https://whitebit.com/fee-schedule",referral:"https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963"},api:{web:{get:["v1/healthcheck"]},v1:{public:{get:["markets","tickers","ticker","symbols","depth/result","history","kline"]},private:{post:["account/balance","order/new","order/cancel","orders","account/order_history","account/executed_history","account/executed_history/all","account/order"]}},v2:{public:{get:["markets","ticker","assets","fee","depth/{market}","trades/{market}"]}},v4:{public:{get:["assets","collateral/markets","fee","orderbook/depth/{market}","orderbook/{market}","ticker","trades/{market}","time","ping","markets","futures","platform/status","mining-pool"]},private:{post:["collateral-account/balance","collateral-account/balance-summary","collateral-account/positions/history","collateral-account/leverage","collateral-account/positions/open","collateral-account/summary","collateral-account/funding-history","main-account/address","main-account/balance","main-account/create-new-address","main-account/codes","main-account/codes/apply","main-account/codes/my","main-account/codes/history","main-account/fiat-deposit-url","main-account/history","main-account/withdraw","main-account/withdraw-pay","main-account/transfer","main-account/smart/plans","main-account/smart/investment","main-account/smart/investment/close","main-account/smart/investments","main-account/fee","main-account/smart/interest-payment-history","trade-account/balance","trade-account/executed-history","trade-account/order","trade-account/order/history","order/collateral/limit","order/collateral/market","order/collateral/stop-limit","order/collateral/trigger-market","order/collateral/bulk","order/new","order/market","order/stock_market","order/stop_limit","order/stop_market","order/cancel","order/cancel/all","order/kill-switch","order/kill-switch/status","order/bulk","order/modify","order/conditional-cancel","orders","oco-orders","order/collateral/oco","order/oco-cancel","order/oto-cancel","profile/websocket_token","convert/estimate","convert/confirm","convert/history","sub-account/create","sub-account/delete","sub-account/edit","sub-account/list","sub-account/transfer","sub-account/block","sub-account/unblock","sub-account/balances","sub-account/transfer/history","sub-account/api-key/create","sub-account/api-key/edit","sub-account/api-key/delete","sub-account/api-key/list","sub-account/api-key/reset","sub-account/api-key/ip-address/list","sub-account/api-key/ip-address/create","sub-account/api-key/ip-address/delete","mining/rewards","market/fee","conditional-orders"]}}},fees:{trading:{tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},options:{timeDifference:0,adjustForTimeDifference:!1,fiatCurrencies:["EUR","USD","RUB","UAH"],fetchBalance:{account:"spot"},accountsByType:{funding:"main",main:"main",spot:"spot",margin:"collateral",trade:"spot"},networksById:{BEP20:"BSC"},defaultType:"spot",brokerId:"ccxt"},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1440}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"Unauthorized request.":r.AuthenticationError,"The market format is invalid.":r.BadSymbol,"Market is not available":r.BadSymbol,"Invalid payload.":r.BadRequest,"Amount must be greater than 0":r.InvalidOrder,"Not enough balance.":r.InsufficientFunds,"The order id field is required.":r.InvalidOrder,"Not enough balance":r.InsufficientFunds,"This action is unauthorized.":r.PermissionDenied,"This API Key is not authorized to perform this action.":r.PermissionDenied,"Unexecuted order was not found.":r.OrderNotFound,"The selected from is invalid.":r.BadRequest,503:r.ExchangeNotAvailable,422:r.OrderNotFound},broad:{"This action is unauthorized":r.PermissionDenied,"Given amount is less than min amount":r.InvalidOrder,"Min amount step":r.InvalidOrder,"Total is less than":r.InvalidOrder,"fee must be no less than":r.InvalidOrder,"Enable your key in API settings":r.PermissionDenied,"You don't have such amount for transfer":r.InsufficientFunds}}})}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=await this.v4PublicGetMarkets();return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeString(e,"stock");let s=this.safeString(e,"money");s="PERP"===s?"USDT":s;const r=this.safeCurrencyCode(i),o=this.safeCurrencyCode(s),n=this.safeValue(e,"tradesEnabled"),d=this.safeValue(e,"isCollateral");let h,c,l,u=r+"/"+o;const f="futures"===this.safeString(e,"type"),p=d&&!f;let m=!1;const g=this.parseNumber(this.parsePrecision(this.safeString(e,"stockPrec"))),v=g;let y,b;f?(l=s,c=this.safeCurrencyCode(l),u=u+":"+c,h="swap",m=!0,y=!0,b=!1):h="spot";const w=this.safeString(e,"takerFee"),k=a.Y.stringDiv(w,"100"),S=this.safeString(e,"makerFee"),O=a.Y.stringDiv(S,"100");return{id:t,symbol:u,base:r,quote:o,settle:c,baseId:i,quoteId:s,settleId:l,type:h,spot:!f,margin:p,swap:f,future:!1,option:!1,active:n,contract:m,linear:y,inverse:b,taker:this.parseNumber(k),maker:this.parseNumber(O),contractSize:v,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:g,price:this.parseNumber(this.parsePrecision(this.safeString(e,"moneyPrec")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"minAmount"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"minTotal"),max:this.safeNumber(e,"maxTotal")}},created:void 0,info:e}}async fetchCurrencies(e={}){const t=await this.v4PublicGetAssets(e),i=Object.keys(t),s={};for(let e=0;e<i.length;e++){const r=i[e],a=t[r],o=this.safeCurrencyCode(r),n="providers"in a,d={},h=this.safeDict(a,"networks",{}),c=this.safeList(h,"deposits",[]),l=this.safeList(h,"withdraws",[]),u=this.safeDict(a,"limits",{}),f=this.safeDict(u,"deposit",{}),p=this.safeDict(u,"withdraw",{}),m=this.arrayConcat(c,l);for(let e=0;e<m.length;e++){const t=m[e],i=this.networkIdToCode(t);d[i]={id:t,network:i,active:void 0,deposit:this.inArray(t,c),withdraw:this.inArray(t,l),fee:void 0,precision:void 0,limits:{deposit:{min:this.safeNumber(f,"min",void 0),max:this.safeNumber(f,"max",void 0)},withdraw:{min:this.safeNumber(p,"min",void 0),max:this.safeNumber(p,"max",void 0)}}}}s[o]=this.safeCurrencyStructure({id:r,code:o,info:a,name:void 0,active:void 0,deposit:this.safeBool(a,"can_deposit"),withdraw:this.safeBool(a,"can_withdraw"),fee:void 0,networks:void 0,type:n?"fiat":"crypto",precision:this.parseNumber(this.parsePrecision(this.safeString(a,"currency_precision"))),limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(a,"min_withdraw"),max:this.safeNumber(a,"max_withdraw")},deposit:{min:this.safeNumber(a,"min_deposit"),max:this.safeNumber(a,"max_deposit")}}})}return s}async fetchTransactionFees(e=void 0,t={}){await this.loadMarkets();const i=await this.v4PublicGetFee(t),s=Object.keys(i),r={},a={};for(let e=0;e<s.length;e++){const t=s[e],o=i[t],n=this.safeCurrencyCode(t),d=this.safeValue(o,"withdraw",{});r[n]=this.safeString(d,"fixed");const h=this.safeValue(o,"deposit",{});a[n]=this.safeString(h,"fixed")}return{withdraw:r,deposit:a,info:i}}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();const i=await this.v4PublicGetFee(t);return this.parseDepositWithdrawFees(i,e)}parseDepositWithdrawFees(e,t=void 0,i=void 0){const s={};t=this.marketCodes(t);const r=Object.keys(e);for(let i=0;i<r.length;i++){const a=r[i],o=a.split(" "),n=o[0],d=e[a],h=this.safeCurrencyCode(n);if(void 0===t||this.inArray(h,t)){void 0===this.safeValue(s,h)&&(s[h]=this.depositWithdrawFee({})),s[h].info[a]=d;let e=this.safeString(o,1);const t=this.safeValue(d,"withdraw"),i=this.safeValue(d,"deposit"),r=this.safeNumber(t,"fixed"),n=this.safeNumber(i,"fixed"),c={fee:r,percentage:void 0===r&&void 0},l={fee:n,percentage:void 0===n&&void 0};if(void 0!==e){const t=e.length;e=e.slice(1,t-1);const i=this.networkIdToCode(e);s[h].networks[i]={withdraw:c,deposit:l}}else s[h].withdraw=c,s[h].deposit=l}}const a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e],i=this.currency(t);s[t]=this.assignDefaultDepositWithdrawFees(s[t],i)}return s}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v4PublicGetAssets(e),i={};for(let e=0;e<this.symbols.length;e++){const s=this.symbols[e],r=this.market(s),o=this.safeValue(t,r.baseId,{});let n=this.safeString(o,"maker_fee"),d=this.safeString(o,"taker_fee");n=a.Y.stringDiv(n,"100"),d=a.Y.stringDiv(d,"100"),i[s]={info:o,symbol:r.symbol,percentage:!0,tierBased:!1,maker:this.parseNumber(n),taker:this.parseNumber(d)}}return i}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={market:i.id},r=await this.v1PublicGetTicker(this.extend(s,t)),a=this.safeDict(r,"result",{});return this.parseTicker(a,i)}parseTicker(e,t=void 0){const i=this.safeString(e,"tradingPairs");t=this.safeMarket(i,t);const s=this.safeStringN(e,["last","last_price","lastPrice"]),r=this.safeString(e,"close",s);return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString2(e,"bid","highestBid"),bidVolume:void 0,ask:this.safeString2(e,"ask","lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"open"),close:r,last:s,previousClose:void 0,change:void 0,percentage:this.safeString(e,"change"),average:void 0,baseVolume:this.safeStringN(e,["base_volume","volume","baseVolume24h"]),quoteVolume:this.safeStringN(e,["quote_volume","deal","quoteVolume24h"]),info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);let i,s="v4PublicGetTicker";[s,t]=this.handleOptionAndParams(t,"fetchTickers","method",s),i="v4PublicGetTicker"===s?await this.v4PublicGetTicker(t):await this.v2PublicGetTicker(t);const r=this.safeList(i,"result");if(void 0!==r)return this.parseTickers(r,e);const a=Object.keys(i),o={};for(let e=0;e<a.length;e++){const t=a[e],s=this.safeMarket(t),r=this.parseTicker(i[t],s);o[r.symbol]=r}return this.filterByArrayTickers(o,"symbol",e)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id};void 0!==t&&(s.limit=t);const r=await this.v4PublicGetOrderbookMarket(this.extend(s,i)),a=this.safeTimestamp(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},o=await this.v4PublicGetTradesMarket(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id);const o=await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(a,s));if(Array.isArray(o))return this.parseTrades(o,r,t,i);{let e=[];const s=Object.keys(o);for(let r=0;r<s.length;r++){const a=s[r],n=this.safeMarket(a,void 0,"_"),d=this.safeValue(o,a,[]),h=this.parseTrades(d,n,t,i);e=this.arrayConcat(e,h)}return e=this.sortBy2(e,"timestamp","id"),this.filterBySinceLimit(e,t,i,"timestamp")}}parseTrade(e,t=void 0){t=this.safeMarket(void 0,t);const i=this.safeTimestamp2(e,"time","trade_timestamp"),s=this.safeString2(e,"dealOrderId","orderId"),r=this.safeString(e,"deal"),a=this.safeString(e,"price"),o=this.safeString2(e,"amount","quote_volume"),n=this.safeString2(e,"id","tradeID"),d=this.safeString2(e,"type","side"),h=t.symbol,c=this.safeInteger(e,"role");let l,u;void 0!==c&&(l=1===c?"maker":"taker");const f=this.safeString(e,"fee");return void 0!==f&&(u={cost:f,currency:this.safeCurrencyCode(this.safeString(e,"feeAsset"))}),this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:h,id:n,order:s,type:void 0,takerOrMaker:l,side:d,price:a,amount:o,cost:r,fee:u},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,interval:this.safeString(this.timeframes,t,t)};if(void 0!==i){const e=1440;void 0===s&&(s=e),s=Math.min(s,e);const t=this.parseToInt(i/1e3);o.start=t}void 0!==s&&(o.limit=Math.min(s,1440));const n=await this.v1PublicGetKline(this.extend(o,r)),d=this.safeList(n,"result",[]);return this.parseOHLCVs(d,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,2),this.safeNumber(e,5)]}async fetchStatus(e={}){const t=await this.v4PublicGetPing(e),i=this.safeString(t,0);return{status:"pong"===i?"ok":i,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v4PublicGetTime(e);return this.safeInteger(t,"time")}async createMarketOrderWithCost(e,t,i,s={}){const r={cost:i};return await this.createOrder(e,"market",t,0,void 0,this.extend(r,s))}async createMarketBuyOrderWithCost(e,t,i={}){return await this.createMarketOrderWithCost(e,"buy",t,i)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d={market:n.id,side:i};let h;if([h,o]=this.handleParamString(o,"cost"),void 0!==h){if("buy"!==i||"market"!==t)throw new r.InvalidOrder(this.id+" createOrder() cost is only supported for market buy orders");d.amount=this.costToPrecision(e,h)}else d.amount=this.amountToPrecision(e,s);const c=this.safeString2(o,"clOrdId","clientOrderId");if(void 0===c){const e=this.safeString(this.options,"brokerId");void 0!==e&&(d.clientOrderId=e+this.uuid16())}else d.clientOrderId=c,o=this.omit(o,["clientOrderId"]);const l=this.safeString(n,"type"),u="limit"===t,f="market"===t,p=this.safeNumberN(o,["triggerPrice","stopPrice","activation_price"]),m=void 0!==p,g=this.isPostOnly(f,!1,o),[v,y]=this.handleMarginModeAndParams("createOrder",o);if(g&&(d.postOnly=!0),void 0!==v&&"cross"!==v)throw new r.NotSupported(this.id+" createOrder() is only available for cross margin");o=this.omit(y,["postOnly","triggerPrice","stopPrice"]);const b=void 0!==v||"swap"===l;let w;return m?(d.activation_price=this.priceToPrecision(e,p),u?(d.price=this.priceToPrecision(e,a),w=await this.v4PrivatePostOrderStopLimit(this.extend(d,o))):w=b?await this.v4PrivatePostOrderCollateralTriggerMarket(this.extend(d,o)):await this.v4PrivatePostOrderStopMarket(this.extend(d,o))):u?(d.price=this.priceToPrecision(e,a),w=b?await this.v4PrivatePostOrderCollateralLimit(this.extend(d,o)):await this.v4PrivatePostOrderNew(this.extend(d,o))):w=b?await this.v4PrivatePostOrderCollateralMarket(this.extend(d,o)):void 0!==h?await this.v4PrivatePostOrderMarket(this.extend(d,o)):await this.v4PrivatePostOrderStockMarket(this.extend(d,o)),this.parseOrder(w)}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" editOrder() requires a id argument");if(void 0===t)throw new r.ArgumentsRequired(this.id+" editOrder() requires a symbol argument");await this.loadMarkets();const d={orderId:e,market:this.market(t).id},h=this.safeString2(n,"clOrdId","clientOrderId");void 0!==h&&(d.clientOrderId=h);const c="limit"===i,l=this.safeNumberN(n,["triggerPrice","stopPrice","activation_price"]),u=void 0!==l;n=this.omit(n,["clOrdId","clientOrderId","triggerPrice","stopPrice"]),u?(d.activation_price=this.priceToPrecision(t,l),c?(d.amount=this.amountToPrecision(t,a),d.price=this.priceToPrecision(t,o)):"buy"===s?d.total=this.amountToPrecision(t,a):d.amount=this.amountToPrecision(t,a)):(d.amount=this.amountToPrecision(t,a),c&&(d.price=this.priceToPrecision(t,o)));const f=await this.v4PrivatePostOrderModify(this.extend(d,n));return this.parseOrder(f)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const s={market:this.market(t).id,orderId:parseInt(e)},a=await this.v4PrivatePostOrderCancel(this.extend(s,i));return this.parseOrder(a)}async cancelAllOrders(e=void 0,t={}){let i;await this.loadMarkets();const s={};let a;void 0!==e&&(i=this.market(e),s.market=i.id),[a,t]=this.handleMarketTypeAndParams("cancelAllOrders",i,t);const o=[];if("spot"===a){let e;[e,t]=this.handleOptionAndParams(t,"cancelAllOrders","isMargin",!1),e?o.push("margin"):o.push("spot")}else{if("swap"!==a)throw new r.NotSupported(this.id+" cancelAllOrders() does not support "+a+" type");o.push("futures")}s.type=o;const n=await this.v4PrivatePostOrderCancelAll(this.extend(s,t));return this.parseOrders(n,i)}async cancelAllOrdersAfter(e,t={}){await this.loadMarkets();const i=this.safeString(t,"symbol");if(void 0===i)throw new r.ArgumentsRequired(this.id+" cancelAllOrdersAfter() requires a symbol argument in params");const s=this.market(i);t=this.omit(t,"symbol");const a=e>0,o={market:s.id};o.timeout=a?this.numberToString(e/1e3):"null";return await this.v4PrivatePostOrderKillSwitch(this.extend(o,t))}parseBalance(e){const t=Object.keys(e),i={};for(let s=0;s<t.length;s++){const r=t[s],a=this.safeCurrencyCode(r),o=e[r];if("object"==typeof o&&void 0!==o){const e=this.account();e.free=this.safeString2(o,"available","main_balance"),e.used=this.safeString(o,"freeze"),e.total=this.safeString(o,"main_balance"),i[a]=e}else{const e=this.account();e.total=o,i[a]=e}}return this.safeBalance(i)}async fetchBalance(e={}){let t,i;if(await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),"swap"===t)i=await this.v4PrivatePostCollateralAccountBalance(e);else{const t=this.safeValue(this.options,"fetchBalance",{}),s=this.safeString(t,"account"),r=this.safeString2(e,"account","type",s);e=this.omit(e,["account","type"]),i="main"===r||"funding"===r?await this.v4PrivatePostMainAccountBalance(e):await this.v4PrivatePostTradeAccountBalance(e)}return this.parseBalance(i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostOrders(this.extend(a,s));return this.parseOrders(o,r,t,i,{status:"open"})}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),e=a.symbol,r.market=a.id),void 0!==i&&(r.limit=Math.min(i,100));const o=await this.v4PrivatePostTradeAccountOrderHistory(this.extend(r,s)),n=Object.keys(o);let d=[];for(let e=0;e<n.length;e++){const t=n[e],i=this.safeMarket(t,void 0,"_"),s=o[t];for(let e=0;e<s.length;e++){const t=this.parseOrder(s[e],i);d.push(this.extend(t,{status:"closed"}))}}return d=this.sortBy(d,"timestamp"),d=this.filterBySymbolSinceLimit(d,e,t,i),d}parseOrderType(e){return this.safeString({limit:"limit",market:"market","stop market":"market","stop limit":"limit","stock market":"market","margin limit":"limit","margin market":"market"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"market"),s=(t=this.safeMarket(i,t,"_")).symbol,r=this.safeString(e,"side"),a=this.safeString(e,"dealStock");let o=this.safeString(e,"left"),n=this.safeString(e,"clientOrderId");""===n&&(n=void 0);const d=this.safeString(e,"price"),h=this.safeNumber(e,"activation_price"),c=this.safeString2(e,"orderId","id"),l=this.safeString(e,"type"),u=this.parseOrderType(l);"market"===u&&(o=void 0);let f=this.safeString(e,"amount");const p=this.safeString(e,"dealMoney");"buy"!==r||"market"!==l&&"stop market"!==l||(f=a);const m=this.safeString(e,"dealFee");let g;void 0!==m&&(g={cost:this.parseNumber(m),currency:t.quote});const v=this.safeTimestamp2(e,"ctime","timestamp"),y=this.safeTimestamp(e,"ftime");return this.safeOrder({info:e,id:c,symbol:s,clientOrderId:n,timestamp:v,datetime:this.iso8601(v),lastTradeTimestamp:y,timeInForce:void 0,postOnly:void 0,status:void 0,side:r,price:d,type:u,triggerPrice:h,amount:f,filled:a,remaining:o,average:void 0,cost:p,fee:g,trades:void 0},t)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={orderId:parseInt(e)};let o;void 0!==t&&(o=this.market(t),a.market=o.id),void 0!==s&&(a.limit=Math.min(s,100));const n=await this.v4PrivatePostTradeAccountOrder(this.extend(a,r)),d=this.safeList(n,"records",[]);return this.parseTrades(d,o)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i={ticker:this.currency(e).id};let s;if(this.isFiat(e)){const e=this.safeString(t,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires a provider when the ticker is fiat");i.provider=e;const a=this.safeNumber(t,"amount");if(void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an amount when the ticker is fiat");i.amount=a;if(void 0===this.safeValue(t,"uniqueId"))throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an uniqueId when the ticker is fiat");s=await this.v4PrivatePostMainAccountFiatDepositUrl(this.extend(i,t))}else s=await this.v4PrivatePostMainAccountAddress(this.extend(i,t));const a=this.safeString(s,"url"),o=this.safeValue(s,"account",{}),n=this.safeString(o,"address",a),d=this.safeString(o,"memo");return this.checkAddress(n),{info:s,currency:e,network:void 0,address:n,tag:d}}async createDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={ticker:i.id},r=await this.v4PrivatePostMainAccountCreateNewAddress(this.extend(s,t)),a=this.safeDict(r,"account",{});return this.parseDepositAddress(a,i)}parseDepositAddress(e,t=void 0){return{info:e,currency:this.safeCurrencyCode(void 0,t),network:void 0,address:this.safeString(e,"address"),tag:this.safeString(e,"memo")}}async setLeverage(e,t=void 0,i={}){if(await this.loadMarkets(),void 0!==t)throw new r.NotSupported(this.id+" setLeverage() does not allow to set per symbol");if(e<1||e>20)throw new r.BadRequest(this.id+" setLeverage() leverage should be between 1 and 20");const s={leverage:e};return await this.v4PrivatePostCollateralAccountLeverage(this.extend(s,i))}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeValue(this.options,"accountsByType"),n=this.safeString(o,i,i),d=this.safeString(o,s,s),h=this.currencyToPrecision(e,t),c={ticker:a.id,amount:h,from:n,to:d},l=await this.v4PrivatePostMainAccountTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=void 0){return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async withdraw(e,t,i,s=void 0,a={}){await this.loadMarkets();const o=this.currency(e),n={ticker:o.id,amount:this.currencyToPrecision(e,t),address:i};let d=this.safeValue(a,"uniqueId");if(void 0===d&&(d=this.uuid22()),n.uniqueId=d,void 0!==s&&(n.memo=s),this.isFiat(e)){const e=this.safeValue(a,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a provider when the ticker is fiat");n.provider=e}const h=await this.v4PrivatePostMainAccountWithdraw(this.extend(n,a));return this.extend({id:d},this.parseTransaction(h,o))}parseTransaction(e,t=void 0){t=this.safeCurrency(void 0,t);const i=this.safeString(e,"address"),s=this.safeTimestamp(e,"createdAt"),r=this.safeString(e,"ticker"),a=this.safeString(e,"status"),o=this.safeString(e,"method");return{id:this.safeString(e,"uniqueId"),txid:this.safeString(e,"transactionId"),timestamp:s,datetime:this.iso8601(s),network:this.safeString(e,"network"),addressFrom:"1"===o?i:void 0,address:i,addressTo:"2"===o?i:void 0,amount:this.safeNumber(e,"amount"),type:"1"===o?"deposit":"withdrawal",currency:this.safeCurrencyCode(r,t),status:this.parseTransactionStatus(a),updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:this.safeString(e,"description"),internal:void 0,fee:{cost:this.safeNumber(e,"fee"),currency:this.safeCurrencyCode(r,t)},info:e}}parseTransactionStatus(e){return this.safeString({1:"pending",2:"pending",3:"ok",4:"canceled",5:"pending",6:"pending",7:"ok",9:"canceled",10:"pending",11:"pending",12:"pending",13:"pending",14:"pending",15:"pending",16:"pending",17:"pending"},e,e)}async fetchDeposit(e,t=void 0,i={}){let s;await this.loadMarkets();const r={transactionMethod:1,uniqueId:e,limit:1,offset:0};void 0!==t&&(s=this.currency(t),r.ticker=s.id);const a=await this.v4PrivatePostMainAccountHistory(this.extend(r,i)),o=this.safeValue(a,"records",[]),n=this.safeDict(o,0,{});return this.parseTransaction(n,s)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={transactionMethod:1,limit:100,offset:0};void 0!==e&&(r=this.currency(e),a.ticker=r.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostMainAccountHistory(this.extend(a,s)),n=this.safeList(o,"records",[]);return this.parseTransactions(n,r,t,i)}async fetchBorrowInterest(e=void 0,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={};let o;void 0!==t&&(o=this.market(t),a.market=o.id);const n=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(a,r)),d=this.parseBorrowInterests(n,o);return this.filterByCurrencySinceLimit(d,e,i,s)}parseBorrowInterest(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"_"),r=this.safeTimestamp(e,"modifyDate");return{info:e,symbol:s,currency:"USDT",interest:this.safeNumber(e,"unrealizedFunding"),interestRate:98e-5,amountBorrowed:this.safeNumber(e,"amount"),marginMode:"cross",timestamp:r,datetime:this.iso8601(r)}}async fetchFundingRate(e,t={}){await this.loadMarkets(),e=this.symbol(e);const i=await this.fetchFundingRates([e],t);return this.safeValue(i,e)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v4PublicGetFutures(t),s=this.safeList(i,"result",[]);return this.parseFundingRates(s,e)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"ticker_id"),s=this.safeSymbol(i,t),r=this.safeNumber(e,"markPrice"),a=this.safeNumber(e,"indexPrice"),o=this.safeNumber(e,"interestRate"),n=this.safeNumber(e,"funding_rate"),d=this.safeInteger(e,"next_funding_rate_timestamp");return{info:e,symbol:s,markPrice:r,indexPrice:a,interestRate:o,timestamp:void 0,datetime:void 0,fundingRate:n,fundingTimestamp:d,fundingDatetime:this.iso8601(d),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){if(await this.loadMarkets(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingHistory() requires a symbol argument");const a=this.market(e);let o={market:a.id};void 0!==t&&(o.startDate=t),void 0!==i&&(o.limit=t),[o,s]=this.handleUntilOption("endDate",o,s);const n=await this.v4PrivatePostCollateralAccountFundingHistory(o),d=this.safeList(n,"records",[]);return this.parseFundingHistories(d,a,t,i)}parseFundingHistory(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeInteger(e,"fundingTime");return{info:e,symbol:this.safeSymbol(i,t,void 0,"swap"),code:void 0,timestamp:s,datetime:this.iso8601(s),id:void 0,amount:this.safeNumber(e,"fundingAmount")}}parseFundingHistories(e,t=void 0,i=void 0,s=void 0){const r=[];for(let i=0;i<e.length;i++){const s=e[i];r.push(this.parseFundingHistory(s,t))}const a=this.sortBy(r,"timestamp");return this.filterBySinceLimit(a,i,s)}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.ticker=a.id),void 0!==i&&(r.limit=i);const o=await this.v4PrivatePostMainAccountHistory(this.extend(r,s)),n=this.safeList(o,"records");return this.parseTransactions(n,a,t,i)}async fetchConvertQuote(e,t,i=void 0,s={}){await this.loadMarkets();const r=this.currency(e),a=this.currency(t),o={from:e,to:t,amount:this.numberToString(i),direction:"from"},n=await this.v4PrivatePostConvertEstimate(this.extend(o,s));return this.parseConversion(n,r,a)}async createConvertTrade(e,t,i,s=void 0,r={}){await this.loadMarkets();const a=this.currency(t),o=this.currency(i),n={quoteId:e},d=await this.v4PrivatePostConvertConfirm(this.extend(n,r));return this.parseConversion(d,a,o)}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={};if(void 0!==e&&(r.fromTicker=e),void 0!==t){const e=this.parseToInt(t/1e3);r.from=this.numberToString(e)}void 0!==i&&(r.limit=i),[r,s]=this.handleUntilOption("to",r,s,.001);const a=await this.v4PrivatePostConvertHistory(this.extend(r,s)),o=this.safeList(a,"records",[]);return this.parseConversions(o,e,"fromCurrency","toCurrency",t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeList(e,"path",[]),r=this.safeDict(s,0,{}),a=this.safeString(r,"from"),o=this.safeString(r,"to"),n=this.safeTimestamp2(e,"date","expireAt"),d=this.safeString(e,"from",a),h=this.safeCurrencyCode(d,t),c=this.safeString(e,"to",o),l=this.safeCurrencyCode(c,i);return{info:e,timestamp:n,datetime:this.iso8601(n),id:this.safeString(e,"id"),fromCurrency:h,fromAmount:this.safeNumber2(e,"give","finalGive"),toCurrency:l,toAmount:this.safeNumber2(e,"receive","finalReceive"),price:this.safeNumber(e,"rate"),fee:void 0}}async fetchPositionHistory(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={market:this.market(e).id};void 0!==t&&(r.startDate=t),void 0!==i&&(r.limit=t),[r,s]=this.handleUntilOption("endDate",r,s);const a=await this.v4PrivatePostCollateralAccountPositionsHistory(this.extend(r,s)),o=this.parsePositions(a);return this.filterBySymbolSinceLimit(o,e,t,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v4PrivatePostCollateralAccountPositionsOpen(t);return this.parsePositions(i,e)}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(s,t)),a=this.safeDict(r,0,{});return this.parsePosition(a,i)}parsePosition(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeTimestamp(e,"openDate"),r=this.safeDict(e,"tpsl",{}),a=this.safeDict(e,"orderDetail",{});return this.safePosition({info:e,id:this.safeString(e,"positionId"),symbol:this.safeSymbol(i,t),notional:void 0,marginMode:void 0,liquidationPrice:this.safeNumber(e,"liquidationPrice"),entryPrice:this.safeNumber(e,"basePrice"),unrealizedPnl:this.safeNumber(e,"pnl"),realizedPnl:this.safeNumber(a,"realizedPnl"),percentage:this.safeNumber(e,"pnlPercent"),contracts:void 0,contractSize:void 0,markPrice:void 0,lastPrice:void 0,side:void 0,hedged:void 0,timestamp:s,datetime:this.iso8601(s),lastUpdateTimestamp:this.safeTimestamp(e,"modifyDate"),maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,collateral:this.safeNumber(e,"margin"),initialMargin:void 0,initialMarginPercentage:void 0,leverage:void 0,marginRatio:void 0,stopLossPrice:this.safeNumber(r,"stopLoss"),takeProfitPrice:this.safeNumber(r,"takeProfit")})}async fetchCrossBorrowRate(e,t={}){await this.loadMarkets();const i=this.currency(e),s={ticker:i.id},r=await this.v4PrivatePostMainAccountSmartPlans(this.extend(s,t)),a=this.safeList(r,0,[]);return this.parseBorrowRate(a,i)}parseBorrowRate(e,t=void 0){const i=this.safeString(e,"ticker"),s=this.safeString(e,"percent");return{currency:this.safeCurrencyCode(i,t),rate:this.parseNumber(a.Y.stringDiv(s,"100")),period:this.safeInteger(e,"duration"),timestamp:void 0,datetime:void 0,info:e}}isFiat(e){const t=this.safeValue(this.options,"fiatCurrencies",[]);return this.inArray(e,t)}nonce(){return this.milliseconds()-this.options.timeDifference}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e)),d=this.safeValue(t,0),h=this.safeValue(t,1),c="/"+this.implodeParams(e,s);let l=this.urls.api[d][h]+c;if("public"===h&&Object.keys(o).length&&(l+="?"+this.urlencode(o)),"private"===h){this.checkRequiredCredentials();const e=this.nonce().toString(),t=this.encode(this.secret),i="/api/"+d+c;a=this.json(this.extend({request:i,nonce:e},s));const o=this.stringToBase64(a),h=this.hmac(this.encode(o),t,n.Zf);r={"Content-Type":"application/json","X-TXC-APIKEY":this.apiKey,"X-TXC-PAYLOAD":o,"X-TXC-SIGNATURE":h}}return{url:l,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+o);if(404===e)throw new r.ExchangeError(this.id+" "+e.toString()+" endpoint not found");if(void 0!==n){const e=this.safeString(n,"status"),t=this.safeValue(n,"errors"),i=this.safeString(n,"message"),s=this.safeInteger(n,"code"),a=void 0!==e&&"200"!==e&&void 0!==t;if(a||void 0!==s){const t=this.id+" "+o;let s=i;if(a)s=e;else{const e=this.safeDict(n,"errors",{}),t=Object.keys(e);if(t.length>0){const i=t[0],r=this.safeValue(e,i,[]);s=r.length>0?r[0]:o}}throw this.throwExactlyMatchedException(this.exceptions.exact,s,t),this.throwBroadlyMatchedException(this.exceptions.broad,o,t),new r.ExchangeError(t)}}}}},40669:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(17246),r=i(62079),a=i(85147),o=i(51579),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"woo",name:"WOO X",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,hostname:"woox.io",has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!0,createTrailingPercentOrder:!0,createTriggerOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!0,setLeverage:!0,setMargin:!1,setPositionMode:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg",api:{pub:"https://api-pub.woox.io",public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{pub:"https://api-pub.staging.woox.io",public:"https://api.staging.woox.io",private:"https://api.staging.woox.io"},www:"https://woox.io/",doc:["https://docs.woox.io/"],fees:["https://support.woox.io/hc/en-001/articles/4404611795353--Trading-Fees"],referral:{url:"https://woox.io/register?ref=DIJT0CNL",discount:.35}},api:{v1:{pub:{get:{"hist/kline":10,"hist/trades":10}},public:{get:{info:1,"info/{symbol}":1,system_info:1,market_trades:1,token:1,token_network:1,funding_rates:1,"funding_rate/{symbol}":1,funding_rate_history:1,futures:1,"futures/{symbol}":1,"orderbook/{symbol}":1,kline:1}},private:{get:{"client/token":1,"order/{oid}":1,"client/order/{client_order_id}":1,orders:1,"client/trade/{tid}":1,"order/{oid}/trades":1,"client/trades":1,"client/hist_trades":1,"staking/yield_history":1,"client/holding":1,"asset/deposit":10,"asset/history":60,"sub_account/all":60,"sub_account/assets":60,"sub_account/asset_detail":60,"sub_account/ip_restriction":10,"asset/main_sub_transfer_history":30,token_interest:60,"token_interest/{token}":60,"interest/history":60,"interest/repay":60,"funding_fee/history":30,positions:3.33,"position/{symbol}":3.33,"client/transaction_history":60,"client/futures_leverage":60},post:{order:1,"order/cancel_all_after":1,"asset/main_sub_transfer":30,"asset/ltv":30,"asset/withdraw":30,"asset/internal_withdraw":30,"interest/repay":60,"client/account_mode":120,"client/position_mode":5,"client/leverage":120,"client/futures_leverage":30,"client/isolated_margin":30},delete:{order:1,"client/order":1,orders:1,"asset/withdraw":120}}},v2:{private:{get:{"client/holding":1}}},v3:{public:{get:{systemInfo:1,instruments:1,token:1,tokenNetwork:1,tokenInfo:1,marketTrades:1,marketTradesHistory:1,orderbook:1,kline:1,klineHistory:1,futures:1,fundingRate:1,fundingRateHistory:1,insuranceFund:1}},private:{get:{"trade/order":2,"trade/orders":1,"trade/algoOrder":1,"trade/algoOrders":1,"trade/transaction":1,"trade/transactionHistory":5,"trade/tradingFee":5,"account/info":60,"account/tokenConfig":1,"account/symbolConfig":1,"account/subAccounts/all":60,"account/referral/summary":60,"account/referral/rewardHistory":60,"account/credentials":60,"asset/balances":1,"asset/token/history":60,"asset/transfer/history":30,"asset/wallet/history":60,"asset/wallet/deposit":60,"asset/staking/yieldHistory":60,"futures/positions":3.33,"futures/leverage":60,"futures/defaultMarginMode":60,"futures/fundingFee/history":30,"spotMargin/interestRate":60,"spotMargin/interestHistory":60,"spotMargin/maxMargin":60,"algo/order/{oid}":1,"algo/orders":1,balances:1,positions:3.33,buypower:1,"convert/exchangeInfo":1,"convert/assetInfo":1,"convert/rfq":60,"convert/trade":1,"convert/trades":1},post:{"trade/order":2,"trade/algoOrder":5,"trade/cancelAllAfter":1,"account/tradingMode":120,"account/listenKey":20,"asset/transfer":30,"asset/wallet/withdraw":60,"spotMargin/leverage":120,"spotMargin/interestRepay":60,"algo/order":5,"convert/rft":60},put:{"trade/order":2,"trade/algoOrder":2,"futures/leverage":60,"futures/positionMode":120,"order/{oid}":2,"order/client/{client_order_id}":2,"algo/order/{oid}":2,"algo/order/client/{client_order_id}":2},delete:{"trade/order":1,"trade/orders":1,"trade/algoOrder":1,"trade/algoOrders":1,"trade/allOrders":1,"algo/order/{order_id}":1,"algo/orders/pending":1,"algo/orders/pending/{symbol}":1,"orders/pending":1}}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{timeDifference:0,adjustForTimeDifference:!1,sandboxMode:!1,createMarketBuyOrderRequiresPrice:!0,"network-aliases-for-tokens":{HT:"ERC20",OMG:"ERC20",UATOM:"ATOM",ZRX:"ZRX"},networks:{TRX:"TRON",TRC20:"TRON",ERC20:"ETH",BEP20:"BSC",ARB:"Arbitrum"},networksById:{TRX:"TRC20",TRON:"TRC20"},defaultNetworkCodeForCurrencies:{},transfer:{fillResponseFromRequest:!0},brokerId:"bc830de7-50f3-460b-9ee0-f430f83f9dad"},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:90,untilDays:1e4,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!0,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forSwap:{extends:"default",createOrder:{hedged:!0}},swap:{linear:{extends:"forSwap"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{"-1000":r.OperationFailed,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.BadRequest,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.BadRequest,"-1012":r.BadRequest,"-1101":r.InvalidOrder,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder},broad:{"Can not place":r.ExchangeError,maintenance:r.OnMaintenance,"symbol must not be blank":r.BadRequest,"The token is not supported":r.BadRequest,"Your order and symbol are not valid or already canceled":r.BadRequest,"Insufficient WOO. Please enable margin trading for leverage trading":r.BadRequest}},precisionMode:o.kb})}async fetchStatus(e={}){const t=await this.v3PublicGetSystemInfo(e),i=this.safeDict(t,"data",{});let s=this.safeString(i,"status");return s=void 0===s?"error":"0"===s?"ok":"maintenance",{status:s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v3PublicGetSystemInfo(e);return this.safeInteger(t,"timestamp")}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=await this.v3PublicGetInstruments(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"rows",[]);return this.parseMarkets(s)}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("_"),s=this.safeString(i,0);let r,a=!1,o=!1;"SPOT"===s?(a=!0,r="spot"):"PERP"===s&&(o=!0,r="swap");const n=this.safeString(i,1),d=this.safeString(i,2),h=this.safeCurrencyCode(n),c=this.safeCurrencyCode(d);let l,u,f,p,m,g=h+"/"+c,v=!0;const y=o;y&&(v=!1,l=this.safeString(i,2),u=this.safeCurrencyCode(l),g=h+"/"+c+":"+u,f=this.parseNumber("1"),p=!0,m=!1);return{id:t,symbol:g,base:h,quote:c,settle:u,baseId:n,quoteId:d,settleId:l,type:r,spot:a,margin:v,swap:o,future:!1,option:!1,active:"TRADING"===this.safeString(e,"status"),contract:y,linear:p,inverse:m,contractSize:f,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"baseTick"),price:this.safeNumber(e,"quoteTick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"baseMin"),max:this.safeNumber(e,"baseMax")},price:{min:this.safeNumber(e,"quoteMin"),max:this.safeNumber(e,"quoteMax")},cost:{min:this.safeNumber(e,"minNotional"),max:void 0}},created:void 0,info:e}}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==i&&(a.limit=i);const o=await this.v3PublicGetMarketTrades(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]);return this.parseTrades(d,r,t,i)}parseTrade(e,t=void 0){const i="id"in e,s=this.safeString2(e,"executed_timestamp","executedTimestamp");let r;void 0!==s&&(r=s.indexOf(".")>-1?this.safeTimestamp2(e,"executed_timestamp","executedTimestamp"):this.safeInteger(e,"executedTimestamp"));const o=this.safeString(e,"symbol"),n=(t=this.safeMarket(o,t)).symbol,d=this.safeString2(e,"executed_price","executedPrice"),h=this.safeString2(e,"executed_quantity","executedQuantity"),c=this.safeString2(e,"order_id","orderId"),l=this.parseTokenAndFeeTemp(e,["fee_asset","feeAsset"],["fee"]),u=this.safeString(l,"cost");void 0!==u&&(l.cost=u);const f=a.Y.stringMul(d,h),p=this.safeStringLower(e,"side"),m=this.safeString(e,"id");let g;if(i){g="1"===this.safeString2(e,"is_maker","isMaker")?"maker":"taker"}return this.safeTrade({id:m,timestamp:r,datetime:this.iso8601(r),symbol:n,side:p,price:d,amount:h,cost:f,order:c,takerOrMaker:g,type:void 0,fee:l,info:e},t)}parseTokenAndFeeTemp(e,t,i){const s=this.safeStringN(e,i);let r;if(void 0!==s){const i=this.safeStringN(e,t);r={cost:s,currency:this.safeCurrencyCode(i)}}return r}parseTradingFee(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),maker:this.parseNumber(a.Y.stringDiv(this.safeString(e,"makerFee"),"100")),taker:this.parseNumber(a.Y.stringDiv(this.safeString(e,"takerFee"),"100")),percentage:void 0,tierBased:void 0}}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PrivateGetTradeTradingFee(this.extend(s,t)),a=this.safeDict(r,"data",{});return this.parseTradingFee(a,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v3PrivateGetAccountInfo(e),i=this.safeDict(t,"data",{}),s=this.safeString(i,"makerFeeRate"),r=this.safeString(i,"takerFeeRate"),o={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e];o[i]={info:t,symbol:i,maker:this.parseNumber(a.Y.stringDiv(s,"10000")),taker:this.parseNumber(a.Y.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return o}async fetchCurrencies(e={}){const t={},i=this.v1PublicGetToken(e),s=this.v1PublicGetTokenNetwork(e),[r,a]=await Promise.all([i,s]),o=this.safeList(r,"rows",[]),n=this.safeList(a,"rows",[]),d=this.groupBy(n,"token"),h=this.groupBy(o,"balance_token"),c=Object.keys(h);for(let e=0;e<c.length;e++){const i=c[e],s=this.safeCurrencyCode(i),r=this.indexBy(h[i],"network"),a=this.indexBy(d[i],"network"),o=Object.keys(a),n={};for(let e=0;e<o.length;e++){const t=o[e],i=this.safeDict(r,t,{}),d=this.safeDict(a,t,{}),h=this.networkIdToCode(t,s),c=this.safeString(i,"token");n[h]={id:t,currencyNetworkId:c,network:h,active:void 0,deposit:"1"===this.safeString(d,"allow_deposit"),withdraw:"1"===this.safeString(d,"allow_withdraw"),fee:this.safeNumber(d,"withdrawal_fee"),precision:this.parseNumber(this.parsePrecision(this.safeString(i,"decimals"))),limits:{withdraw:{min:this.safeNumber(d,"minimum_withdrawal"),max:void 0},deposit:{min:void 0,max:void 0}},info:[d,i]}}t[s]=this.safeCurrencyStructure({id:i,name:void 0,code:s,precision:void 0,active:void 0,fee:void 0,networks:n,deposit:void 0,withdraw:void 0,type:"crypto",limits:{deposit:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},info:[r,a]})}return t}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","buy",t,1,i)}async createMarketSellOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketSellOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","sell",t,1,i)}async createTrailingAmountOrder(e,t,i,s,a=void 0,o=void 0,n=void 0,d={}){if(void 0===o)throw new r.ArgumentsRequired(this.id+" createTrailingAmountOrder() requires a trailingAmount argument");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createTrailingAmountOrder() requires a trailingTriggerPrice argument");return d.trailingAmount=o,d.trailingTriggerPrice=n,await this.createOrder(e,t,i,s,a,d)}async createTrailingPercentOrder(e,t,i,s,a=void 0,o=void 0,n=void 0,d={}){if(void 0===o)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingPercent argument");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingTriggerPrice argument");return d.trailingPercent=o,d.trailingTriggerPrice=n,await this.createOrder(e,t,i,s,a,d)}async createOrder(e,t,i,s,o=void 0,n={}){const d=this.safeBool2(n,"reduceOnly","reduce_only");n=this.omit(n,["reduceOnly","reduce_only"]);const h=t.toUpperCase();await this.loadMarkets();const c=this.market(e),l=i.toUpperCase(),u={symbol:c.id,side:l};let f;[f,n]=this.handleMarginModeAndParams("createOrder",n),void 0!==f&&(u.marginMode=this.encodeMarginMode(f));const p=this.safeString2(n,"triggerPrice","stopPrice"),m=this.safeValue(n,"stopLoss"),g=this.safeValue(n,"takeProfit"),v=this.safeString(n,"algoType"),y=this.safeString2(n,"trailingTriggerPrice","activatedPrice",this.numberToString(o)),b=this.safeString2(n,"trailingAmount","callbackValue"),w=this.safeString2(n,"trailingPercent","callbackRate"),k=void 0!==b,S=void 0!==w,O=k||S,T=O||void 0!==p||void 0!==m||void 0!==g||void 0!==this.safeValue(n,"childOrders"),P="MARKET"===h,M=this.safeStringLower(n,"timeInForce"),I=this.isPostOnly(P,void 0,n),x=T?"clientAlgoOrderId":"clientOrderId";if(u.type=h,T||(I?u.type="POST_ONLY":"fok"===M?u.type="FOK":"ioc"===M&&(u.type="IOC")),d&&(u.reduceOnly=d),P||void 0===o||(u.price=this.priceToPrecision(e,o)),P&&!T){const t=this.safeStringN(n,["cost","order_amount","orderAmount"]);n=this.omit(n,["cost","order_amount","orderAmount"]);const i=void 0!==o;if(c.spot&&(i||void 0!==t)){let i;if(void 0!==t)i=this.costToPrecision(e,t);else{const t=this.numberToString(s),r=this.numberToString(o),n=a.Y.stringMul(t,r);i=this.costToPrecision(e,n)}u.amount=i}else u.quantity=this.amountToPrecision(e,s)}else"POSITIONAL_TP_SL"!==v&&(u.quantity=this.amountToPrecision(e,s));const A=this.safeStringN(n,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==A&&(u[x]=A),O){if(void 0===y)throw new r.ArgumentsRequired(this.id+" createOrder() requires a trailingTriggerPrice parameter for trailing orders");if(u.activatedPrice=this.priceToPrecision(e,y),u.algoType="TRAILING_STOP",k)u.callbackValue=b;else if(S){const e=a.Y.stringDiv(w,"100");u.callbackRate=e}}else if(void 0!==p)"TRAILING_STOP"!==v&&(u.triggerPrice=this.priceToPrecision(e,p),u.algoType="STOP");else if(void 0!==m||void 0!==g){u.algoType="BRACKET";const t={symbol:c.id,reduceOnly:!1,algoType:"POSITIONAL_TP_SL",childOrders:[]},i=t.childOrders,s="BUY"===l?"SELL":"BUY";if(void 0!==m){const t=this.safeString(m,"triggerPrice",m),r={side:s,algoType:"STOP_LOSS",triggerPrice:this.priceToPrecision(e,t),type:"CLOSE_POSITION",reduceOnly:!0};i.push(r)}if(void 0!==g){const t=this.safeString(g,"triggerPrice",g),r={side:s,algoType:"TAKE_PROFIT",triggerPrice:this.priceToPrecision(e,t),type:"CLOSE_POSITION",reduceOnly:!0};i.push(r)}u.childOrders=[t]}let C;n=this.omit(n,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit","trailingPercent","trailingAmount","trailingTriggerPrice"]),C=T?await this.v3PrivatePostTradeAlgoOrder(this.extend(u,n)):await this.v3PrivatePostTradeOrder(this.extend(u,n));let _=this.safeDict(C,"data",{});return _=this.safeDict(this.safeList(_,"rows"),0,_),_.timestamp=this.safeString(C,"timestamp"),this.parseOrder(_,c)}encodeMarginMode(e){return this.safeString({cross:"CROSS",isolated:"ISOLATED"},e,e)}async editOrder(e,t,i,s,r=void 0,o=void 0,n={}){await this.loadMarkets();const d=this.market(t),h={};void 0!==o&&(h.price=this.priceToPrecision(t,o)),void 0!==r&&(h.quantity=this.amountToPrecision(t,r));const c=this.safeString2(n,"clOrdID","clientOrderId"),l=this.safeString(n,"client_order_id",c),u=void 0!==l,f=this.safeNumberN(n,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==f&&(h.triggerPrice=this.priceToPrecision(t,f));const p=this.safeString2(n,"trailingTriggerPrice","activatedPrice",this.numberToString(o)),m=this.safeString2(n,"trailingAmount","callbackValue"),g=this.safeString2(n,"trailingPercent","callbackRate"),v=void 0!==m,y=void 0!==g,b=v||y;if(b)if(void 0!==p&&(h.activatedPrice=this.priceToPrecision(t,p)),v)h.callbackValue=m;else if(y){const e=a.Y.stringDiv(g,"100");h.callbackRate=e}n=this.omit(n,["clOrdID","clientOrderId","client_order_id","stopPrice","triggerPrice","takeProfitPrice","stopLossPrice","trailingTriggerPrice","trailingAmount","trailingPercent"]);const w=b||void 0!==f||void 0!==this.safeValue(n,"childOrders");let k;u?(h.client_order_id=l,k=w?await this.v3PrivatePutAlgoOrderClientClientOrderId(this.extend(h,n)):await this.v3PrivatePutOrderClientClientOrderId(this.extend(h,n))):(h.oid=e,k=w?await this.v3PrivatePutAlgoOrderOid(this.extend(h,n)):await this.v3PrivatePutOrderOid(this.extend(h,n)));const S=this.safeDict(k,"data",{});return this.parseOrder(S,d)}async cancelOrder(e,t=void 0,i={}){const s=this.safeBool2(i,"trigger","stop",!1);if(i=this.omit(i,["trigger","stop"]),!s&&void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={},n=this.safeString2(i,"clOrdID","clientOrderId"),d=this.safeString(i,"client_order_id",n);i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]);const h=void 0!==d;let c;s?(h?o.clientAlgoOrderId=d:o.algoOrderId=e,c=await this.v3PrivateDeleteTradeAlgoOrder(this.extend(o,i))):(o.symbol=a.id,h?o.clientOrderId=d:o.orderId=e,c=await this.v3PrivateDeleteTradeOrder(this.extend(o,i)));const l=this.safeDict(c,"data",{});return l.timestamp=this.safeString(c,"timestamp"),h?l.clientOrderId=d:l.orderId=e,this.parseOrder(l,a)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=this.safeBool2(t,"stop","trigger");t=this.omit(t,["stop","trigger"]);const s={};if(void 0!==e){const t=this.market(e);s.symbol=t.id}let r;r=i?await this.v3PrivateDeleteTradeAlgoOrders(t):await this.v3PrivateDeleteTradeOrders(this.extend(s,t));const a=this.safeDict(r,"data",{});return[this.safeOrder({info:a})]}async cancelAllOrdersAfter(e,t={}){await this.loadMarkets();const i={triggerAfter:e>0?Math.min(e,9e5):0};return await this.v3PrivatePostTradeCancelAllAfter(this.extend(i,t))}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.safeBool2(i,"stop","trigger");i=this.omit(i,["stop","trigger"]);const a={},o=this.safeString2(i,"clOrdID","clientOrderId");let n;r?(void 0!==o?a.clientAlgoOrderId=e:a.algoOrderId=e,n=await this.v3PrivateGetTradeAlgoOrder(this.extend(a,i))):(void 0!==o?a.clientOrderId=o:a.orderId=e,n=await this.v3PrivateGetTradeOrder(this.extend(a,i)));const d=this.safeDict(n,"data",{});return this.parseOrder(d,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchOrders",e,t,i,s,"page",500);const a={};let o;const n=this.safeBool2(s,"stop","trigger");s=this.omit(s,["stop","trigger"]),void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const d=this.safeInteger(s,"until");let h;s=this.omit(s,["until"]),void 0!==d&&(a.endTime=d),void 0!==i&&(a.size=Math.min(i,500)),h=n?await this.v3PrivateGetTradeAlgoOrders(this.extend(a,s)):await this.v3PrivateGetTradeOrders(this.extend(a,s));const c=this.safeValue(h,"data",{}),l=this.safeList(c,"rows",[]);return this.parseOrders(l,o,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"INCOMPLETE"});return await this.fetchOrders(e,t,i,r)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"COMPLETED"});return await this.fetchOrders(e,t,i,r)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrder(e,t=void 0){let i=this.safeTimestamp(e,"createdTime");void 0===i&&(i=this.safeInteger(e,"timestamp"));const s=this.safeString2(e,"orderId","algoOrderId"),r=this.omitZero(this.safeString2(e,"clientOrderId","clientAlgoOrderId")),a=this.safeString(e,"symbol"),o=(t=this.safeMarket(a,t)).symbol,n=this.safeString(e,"price"),d=this.safeString(e,"quantity"),h=this.safeString(e,"amount"),c=this.safeStringLower(e,"type"),l=this.safeValue2(e,"status","algoStatus"),u=this.safeStringLower(e,"side"),f=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),p=this.omitZero(this.safeString(e,"averageExecutedPrice")),m=this.safeNumber(e,"totalFee"),g=this.safeString(e,"feeAsset"),v=this.safeNumber(e,"triggerPrice"),y=this.safeTimestamp(e,"updatedTime");return this.safeOrder({id:s,clientOrderId:r,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,lastUpdateTimestamp:y,status:this.parseOrderStatus(l),symbol:o,type:c,timeInForce:this.parseTimeInForce(c),postOnly:void 0,reduceOnly:this.safeBool(e,"reduceOnly"),side:u,price:n,triggerPrice:v,takeProfitPrice:void 0,stopLossPrice:void 0,average:p,amount:d,filled:f,remaining:void 0,cost:h,trades:void 0,fee:{cost:m,currency:g},info:e},t)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id};void 0!==t&&(s.maxLevel=t);const r=await this.v3PublicGetOrderbook(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeInteger(r,"timestamp");return this.parseOrderBook(a,e,o,"bids","asks","price","quantity")}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==s&&(o.limit=Math.min(s,1e3)),void 0!==i&&(o.after=i);const n=this.safeInteger(r,"until");r=this.omit(r,"until"),void 0!==n&&(o.before=n);const d=await this.v3PublicGetKlineHistory(this.extend(o,r)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseOHLCVs(c,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"startTimestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={oid:e},n=await this.v1PrivateGetOrderOidTrades(this.extend(o,r)),d=this.safeList(n,"rows",[]);return this.parseTrades(d,a,i,s,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.endTime=n),void 0!==i&&(a.limit=i);const d=await this.v3PrivateGetTradeTransactionHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseTrades(c,o,t,i,s)}async fetchAccounts(e={}){const t=this.v3PrivateGetAccountInfo(e),i=this.v3PrivateGetAccountSubAccountsAll(e),[s,r]=await Promise.all([t,i]),a=[this.safeDict(s,"data",{})],o=this.safeDict(r,"data",{}),n=this.safeList(o,"rows",[]),d=this.arrayConcat(a,n);return this.parseAccounts(d,e)}parseAccount(e){return{info:e,id:this.safeString(e,"applicationId"),name:this.safeStringN(e,["name","account","alias"]),code:void 0,type:this.safeStringLower(e,"accountType","subaccount")}}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v3PrivateGetBalances(e),i=this.safeDict(t,"data");return this.parseBalance(i)}parseBalance(e){const t={info:e},i=this.safeList(e,"holding",[]);for(let e=0;e<i.length;e++){const s=i[e],r=this.safeCurrencyCode(this.safeString(s,"token")),a=this.account();a.total=this.safeString(s,"holding"),a.free=this.safeString(s,"availableBalance"),t[r]=a}return this.safeBalance(t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e);let s;[s,t]=this.handleNetworkCodeAndParams(t);const r={token:i.id,network:this.networkCodeToId(s)},a=await this.v3PrivateGetAssetWalletDeposit(this.extend(r,t)),o=this.safeDict(a,"data",{});return this.parseDepositAddress(o,i)}getDedicatedNetworkId(e,t){let i;[i,t]=this.handleNetworkCodeAndParams(t),i=this.networkIdToCode(i,e.code);const s=this.safeDict(e.networks,i);if(void 0===s){const t=Object.keys(e.networks);throw new r.BadRequest(this.id+' can not determine a network code, please provide unified "network" param, one from the following: '+this.json(t))}return[this.safeString(s,"currencyNetworkId"),t]}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address");return this.checkAddress(i),{info:e,currency:this.safeString(t,"code"),network:void 0,address:i,tag:this.safeString(e,"extra")}}async getAssetHistoryRows(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o;void 0!==e&&(a=this.currency(e),r.token=a.id),[o,s]=this.handleNetworkCodeAndParams(s),void 0!==o&&(r.network=this.networkCodeToId(o)),void 0!==t&&(r.startTime=t),void 0!==i&&(r.size=Math.min(i,1e3));const n=this.safeString(s,"type");s=this.omit(s,"type"),void 0!==n&&(r.type=n);const d=await this.v3PrivateGetAssetWalletHistory(this.extend(r,s)),h=this.safeDict(d,"data",{});return[a,this.safeList(h,"rows",[])]}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,s),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseLedger(o,a,t,i,s)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"token"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(s,t);const r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"tokenSide")?"in":"out",o=this.safeTimestamp(e,"createdTime"),n=this.parseTokenAndFeeTemp(e,["feeToken"],["feeAmount"]);return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),currency:s,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"txId"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,direction:a,timestamp:o,datetime:this.iso8601(o),type:this.parseLedgerEntryType(this.safeString(e,"type")),fee:n},t)}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}getCurrencyFromChaincode(e,t){if(void 0!==t)return t;{const i=e.split("_"),s=i.length,r=this.safeString(i,0);let a=this.safeString(i,1,r);s>2&&(a+="_"+this.safeString(i,2)),t=this.safeCurrency(a)}return t}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({tokenSide:"DEPOSIT"},s))}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({tokenSide:"WITHDRAW"},s))}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,this.extend({type:"BALANCE"},s)),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseTransactions(o,a,t,i,s)}parseTransaction(e,t=void 0){const i=this.safeString(e,"token"),s=this.getCurrencyFromChaincode(i,t).code;let r=this.safeStringLower2(e,"token_side","tokenSide");"withdraw"===r&&(r="withdrawal");const a=this.parseTokenAndFeeTemp(e,["fee_token","feeToken"],["fee_amount","feeAmount"]),o=this.safeString2(e,"target_address","targetAddress"),n=this.safeString2(e,"source_address","sourceAddress"),d=this.safeTimestamp2(e,"created_time","createdTime");return{info:e,id:this.safeStringN(e,["id","withdraw_id","withdrawId"]),txid:this.safeString2(e,"tx_id","txId"),timestamp:d,datetime:this.iso8601(d),address:void 0,addressFrom:n,addressTo:o,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:s,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeTimestamp2(e,"updated_time","updatedTime"),comment:void 0,internal:void 0,fee:a,network:void 0}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o={token:a.id,amount:this.parseToNumeric(t),from_application_id:i,to_application_id:s},n=await this.v1PrivatePostAssetMainSubTransfer(this.extend(o,r)),d=this.parseTransfer(n,a),h=this.safeDict(this.options,"transfer",{});return this.safeBool(h,"fillResponseFromRequest",!0)&&(d.amount=t,d.fromAccount=i,d.toAccount=s),d}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){const r={};let a;void 0!==e&&(a=this.currency(e)),void 0!==i&&(r.size=i),void 0!==t&&(r.startTime=t);const o=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==o&&(r.endTime=o);const n=await this.v3PrivateGetAssetTransferHistory(this.extend(r,s)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTransfers(h,a,t,i,s)}parseTransfer(e,t=void 0){const i=this.safeCurrencyCode(this.safeString(e,"token"),t),s=this.safeTimestamp(e,"createdTime"),r=this.safeBool(e,"success");let a;void 0!==r&&(a=r?"ok":"failed");const o=this.safeDict(e,"from",{}),n=this.safeDict(e,"to",{});return{id:this.safeString(e,"id"),timestamp:s,datetime:this.iso8601(s),currency:i,amount:this.safeNumber(e,"amount"),fromAccount:this.safeString(o,"applicationId"),toAccount:this.safeString(n,"applicationId"),status:this.parseTransferStatus(this.safeString(e,"status",a)),info:e}}parseTransferStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a=this.currency(e),o={amount:t,address:i};let n;void 0!==s&&(o.extra=s),[n,r]=this.getDedicatedNetworkId(a,r),o.token=n;const d=await this.v1PrivatePostAssetWithdraw(this.extend(o,r));return this.parseTransaction(d,a)}async repayMargin(e,t,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==i&&(r=this.market(i),i=r.symbol);const a=this.currency(e),o={token:a.id,amount:this.currencyToPrecision(e,t)},n=await this.v1PrivatePostInterestRepay(this.extend(o,s)),d=this.parseMarginLoan(n,a);return this.extend(d,{amount:t,symbol:i})}parseMarginLoan(e,t=void 0){return{id:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,symbol:void 0,timestamp:void 0,datetime:void 0,info:e}}nonce(){return this.milliseconds()-this.options.timeDifference}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=t[0],d=t[1],h=this.implodeParams(e,s);let c=this.implodeHostname(this.urls.api[d]);if(c+="/"+o+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===d)c+=d+"/"+h,Object.keys(s).length&&(c+="?"+this.urlencode(s));else if("pub"===d)c+=h,Object.keys(s).length&&(c+="?"+this.urlencode(s));else{if(this.checkRequiredCredentials(),"POST"===i&&("trade/algoOrder"===e||"trade/order"===e)){if(!this.safeBool(this.options,"sandboxMode",!1)){const t="bc830de7-50f3-460b-9ee0-f430f83f9dad",i=this.safeString(this.options,"brokerId",t);e.indexOf("algo")>-1?s.brokerId=i:s.broker_id=i}s=this.keysort(s)}let t="";const d=this.nonce().toString();if(c+=h,r={"x-api-key":this.apiKey,"x-api-timestamp":d},"v3"===o){if(t=d+i+"/"+o+"/"+h,"POST"===i||"PUT"===i)t+=a=this.json(s),r["content-type"]="application/json";else if(Object.keys(s).length){const e=this.urlencode(s);c+="?"+e,t+="?"+e}}else t=this.urlencode(s),"POST"===i||"PUT"===i||"DELETE"===i?a=t:Object.keys(s).length&&(c+="?"+t),t+="|"+d,r["content-type"]="application/x-www-form-urlencoded";r["x-api-signature"]=this.hmac(this.encode(t),this.encode(this.secret),n.s)}return{url:c,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,a,o,n,d){if(!o)return;const h=this.safeBool(o,"success"),c=this.safeString(o,"code");if(!h){const e=this.id+" "+this.json(o);this.throwBroadlyMatchedException(this.exceptions.broad,a,e),this.throwExactlyMatchedException(this.exceptions.exact,c,e)}}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t);let r=this.safeString(e,"fundingFee");const o=this.safeCurrencyCode("USD"),n=this.safeString(e,"id"),d=this.safeInteger(e,"updatedTime"),h=this.safeNumber(e,"fundingRate");return r="Pay"===this.safeString(e,"paymentType")?a.Y.stringNeg(r):r,{info:e,symbol:s,code:o,timestamp:d,datetime:this.iso8601(d),id:n,amount:this.parseNumber(r),rate:h}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingHistory",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.endTime=n),void 0!==i&&(a.size=Math.min(i,500));const d=await this.v3PrivateGetFuturesFundingFeeHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseIncomes(c,o,t,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.market(i);const s=this.safeInteger(e,"nextFundingTime"),r=this.safeInteger(e,"estFundingRateTimestamp"),a=this.safeInteger(e,"lastFundingRateTimestamp"),o=this.safeString(e,"estFundingIntervalHours");return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"estFundingRate"),fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"lastFundingRate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a),interval:o+"h"}}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PublicGetFundingRate(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"rows",[]),n=this.safeDict(o,0,{});return this.parseFundingRate(n,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v3PublicGetFundingRate(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parseFundingRates(r,e)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,i,s,"page",25);if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");const o=this.market(e);e=o.symbol;let n={symbol:o.id};void 0!==t&&(n.startTime=t),[n,s]=this.handleUntilOption("endTime",n,s);const d=await this.v3PublicGetFundingRateHistory(this.extend(n,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e],i=this.safeString(t,"symbol"),s=this.safeInteger(t,"fundingRateTimestamp");l.push({info:t,symbol:this.safeSymbol(i),fundingRate:this.safeNumber(t,"fundingRate"),timestamp:s,datetime:this.iso8601(s)})}const u=this.sortBy(l,"timestamp");return this.filterBySymbolSinceLimit(u,e,t,i)}async setPositionMode(e,t=void 0,i={}){let s;s=e?"HEDGE_MODE":"ONE_WAY";const r={positionMode:s};return await this.v3PrivatePutFuturesPositionMode(this.extend(r,i))}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e);let s;if(i.spot)s=await this.v3PrivateGetAccountInfo(t);else{if(!i.swap)throw new r.NotSupported(this.id+" fetchLeverage() is not supported for "+i.type+" markets");{const e={symbol:i.id};let r;[r,t]=this.handleMarginModeAndParams("fetchLeverage",t,"cross"),e.marginMode=this.encodeMarginMode(r),s=await this.v3PrivateGetFuturesLeverage(this.extend(e,t))}}const a=this.safeDict(s,"data",{});return this.parseLeverage(a,i)}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=this.safeStringLower(e,"marginMode");let r=this.safeInteger(e,"leverage");0===r&&(r=null);let a=r,o=r;const n=this.safeList(e,"details",[]);for(let e=0;e<n.length;e++){const t=this.safeDict(n,e,{}),i=this.safeInteger(t,"leverage"),s=this.safeString(t,"positionSide");"BOTH"===s?(a=i,o=i):"LONG"===s?a=i:"SHORT"===s&&(o=i)}return{info:e,symbol:t.symbol,marginMode:s,longLeverage:a,shortLeverage:o}}async setLeverage(e,t=void 0,i={}){await this.loadMarkets();const s={leverage:e};let a;if(void 0!==t&&(a=this.market(t)),void 0===t||a.spot)return await this.v3PrivatePostSpotMarginLeverage(this.extend(s,i));if(a.swap){let e;return s.symbol=a.id,[e,i]=this.handleMarginModeAndParams("fetchLeverage",i,"cross"),s.marginMode=this.encodeMarginMode(e),await this.v3PrivatePutFuturesLeverage(this.extend(s,i))}throw new r.NotSupported(this.id+" fetchLeverage() is not supported for "+a.type+" markets")}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"ADD",i)}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"REDUCE",i)}async modifyMarginHelper(e,t,i,s={}){await this.loadMarkets();const r={symbol:this.market(e).id,adjust_token:"USDT",adjust_amount:t,action:i};return await this.v1PrivatePostClientIsolatedMargin(this.extend(r,s))}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PrivateGetFuturesPositions(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"positions",[]),n=this.safeDict(o,0,{});return this.parsePosition(n,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.v3PrivateGetFuturesPositions(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"positions",[]);return this.parsePositions(r,e)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);let s,r=this.safeString(e,"holding");s=a.Y.stringGt(r,"0")?"long":"short";const o=this.safeString(t,"contractSize"),n=this.safeString2(e,"markPrice","mark_price"),d=this.safeString(e,"timestamp");let h;void 0!==d&&(h=d.indexOf(".")>-1?this.safeTimestamp(e,"timestamp"):this.safeInteger(e,"timestamp"));const c=this.safeString2(e,"averageOpenPrice","average_open_price"),l=a.Y.stringSub(n,c),u=a.Y.stringMul(l,r);r=a.Y.stringAbs(r);const f=a.Y.stringMul(r,n),p=this.safeString(e,"positionSide");return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:h,datetime:this.iso8601(h),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(c),notional:this.parseNumber(f),leverage:this.safeNumber(e,"leverage"),unrealizedPnl:this.parseNumber(u),contracts:this.parseNumber(r),contractSize:this.parseNumber(o),marginRatio:void 0,liquidationPrice:this.safeNumber2(e,"estLiqPrice","est_liq_price"),markPrice:this.parseNumber(n),lastPrice:void 0,collateral:void 0,marginMode:this.safeStringLower2(e,"marginMode","margin_mode"),side:s,percentage:void 0,hedged:"BOTH"!==p,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchConvertQuote(e,t,i=void 0,s={}){await this.loadMarkets();const r={sellToken:e.toUpperCase(),buyToken:t.toUpperCase(),sellQuantity:this.numberToString(i)},a=await this.v3PrivateGetConvertRfq(this.extend(r,s)),o=this.safeDict(a,"data",{}),n=this.safeString(o,"sellToken",e),d=this.currency(n),h=this.safeString(o,"buyToken",t),c=this.currency(h);return this.parseConversion(o,d,c)}async createConvertTrade(e,t,i,s=void 0,r={}){await this.loadMarkets();const a={quoteId:e},o=await this.v3PrivatePostConvertRft(this.extend(a,r)),n=this.safeDict(o,"data",{});return this.parseConversion(n)}async fetchConvertTrade(e,t=void 0,i={}){await this.loadMarkets();const s={quoteId:e},r=await this.v3PrivateGetConvertTrade(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeString(a,"sellAsset"),n=this.safeString(a,"buyAsset");let d,h;return void 0!==o&&(d=this.currency(o)),void 0!==n&&(h=this.currency(n)),this.parseConversion(a,d,h)}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={};[r,s]=this.handleUntilOption("endTime",r,s),void 0!==t&&(r.startTime=t),void 0!==i&&(r.size=i);const a=await this.v3PrivateGetConvertTrades(this.extend(r,s)),o=this.safeDict(a,"data",{}),n=this.safeList(o,"tradeVos",[]);return this.parseConversions(n,e,"sellAsset","buyAsset",t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeInteger2(e,"expireTimestamp","createdTime"),r=this.safeString2(e,"sellToken","buyAsset"),a=this.safeCurrencyCode(r,t),o=this.safeString2(e,"buyToken","sellAsset"),n=this.safeCurrencyCode(o,i);return{info:e,timestamp:s,datetime:this.iso8601(s),id:this.safeString(e,"quoteId"),fromCurrency:a,fromAmount:this.safeNumber2(e,"sellQuantity","sellAmount"),toCurrency:n,toAmount:this.safeNumber2(e,"buyQuantity","buyAmount"),price:this.safeNumber(e,"buyPrice"),fee:void 0}}async fetchConvertCurrencies(e={}){await this.loadMarkets();const t=await this.v3PrivateGetConvertAssetInfo(e),i={},s=this.safeList(t,"rows",[]);for(let e=0;e<s.length;e++){const t=s[e],r=this.safeString(t,"token"),a=this.safeCurrencyCode(r);i[a]={info:t,id:r,code:a,networks:void 0,type:void 0,name:void 0,active:void 0,deposit:void 0,withdraw:void 0,fee:void 0,precision:this.safeNumber(t,"tick"),limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},created:this.safeTimestamp(t,"createdTime")}}return i}defaultNetworkCodeForCurrency(e){const t=this.currency(e).networks,i=Object.keys(t);for(let e=0;e<i.length;e++){const t=i[e];if("ETH"===t)return t}return this.safeValue(i,0)}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}}},99641:(e,t,i)=>{i.d(t,{A:()=>l});var s=i(55308),r=i(62079),a=i(51579),o=i(85147),n=i(88283),d=i(6414),h=i(38432),c=i(40987);class l extends s.A{describe(){return this.deepExtend(super.describe(),{id:"woofipro",name:"WOOFI PRO",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,dex:!0,hostname:"dex.woo.org",has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!0,setMargin:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1",api:{public:"https://api-evm.orderly.org",private:"https://api-evm.orderly.org"},test:{public:"https://testnet-api-evm.orderly.org",private:"https://testnet-api-evm.orderly.org"},www:"https://dex.woo.org",doc:["https://orderly.network/docs/build-on-evm/building-on-evm"],fees:["https://dex.woo.org/en/orderly"],referral:{url:"https://dex.woo.org/en/trade?ref=CCXT",discount:.05}},api:{v1:{public:{get:{"public/volume/stats":1,"public/broker/name":1,"public/chain_info/{broker_id}":1,"public/system_info":1,"public/vault_balance":1,"public/insurancefund":1,"public/chain_info":1,"faucet/usdc":1,"public/account":1,get_account:1,registration_nonce:1,get_orderly_key:1,"public/liquidation":1,"public/liquidated_positions":1,"public/config":1,"public/campaign/ranking":10,"public/campaign/stats":10,"public/campaign/user":10,"public/campaign/stats/details":10,"public/campaigns":10,"public/points/leaderboard":1,"client/points":1,"public/points/epoch":1,"public/points/epoch_dates":1,"public/referral/check_ref_code":1,"public/referral/verify_ref_code":1,"referral/admin_info":1,"referral/info":1,"referral/referee_info":1,"referral/referee_rebate_summary":1,"referral/referee_history":1,"referral/referral_history":1,"referral/rebate_summary":1,"client/distribution_history":1,"tv/config":1,"tv/history":1,"tv/symbol_info":1,"public/funding_rate_history":1,"public/funding_rate/{symbol}":.33,"public/funding_rates":1,"public/info":1,"public/info/{symbol}":1,"public/market_trades":1,"public/token":1,"public/futures":1,"public/futures/{symbol}":1},post:{register_account:1}},private:{get:{"client/key_info":6,"client/orderly_key_ip_restriction":6,"order/{oid}":1,"client/order/{client_order_id}":1,"algo/order/{oid}":1,"algo/client/order/{client_order_id}":1,orders:1,"algo/orders":1,"trade/{tid}":1,trades:1,"order/{oid}/trades":1,"client/liquidator_liquidations":1,liquidations:1,"asset/history":60,"client/holding":1,withdraw_nonce:1,settle_nonce:1,"pnl_settlement/history":1,"volume/user/daily":60,"volume/user/stats":60,"client/statistics":60,"client/info":60,"client/statistics/daily":60,positions:3.33,"position/{symbol}":3.33,"funding_fee/history":30,"notification/inbox/notifications":60,"notification/inbox/unread":60,"volume/broker/daily":60,"broker/fee_rate/default":10,"broker/user_info":10,"orderbook/{symbol}":1,kline:1},post:{orderly_key:1,"client/set_orderly_key_ip_restriction":6,"client/reset_orderly_key_ip_restriction":6,order:1,"batch-order":10,"algo/order":1,liquidation:1,claim_insurance_fund:1,withdraw_request:1,settle_pnl:1,"notification/inbox/mark_read":60,"notification/inbox/mark_read_all":60,"client/leverage":120,"client/maintenance_config":60,delegate_signer:10,delegate_orderly_key:10,delegate_settle_pnl:10,delegate_withdraw_request:10,"broker/fee_rate/set":10,"broker/fee_rate/set_default":10,"broker/fee_rate/default":10,"referral/create":10,"referral/update":10,"referral/bind":10,"referral/edit_split":10},put:{order:1,"algo/order":1},delete:{order:1,"algo/order":1,"client/order":1,"algo/client/order":1,"algo/orders":1,orders:1,"batch-order":1,"client/batch-order":1}}}},requiredCredentials:{apiKey:!0,secret:!0,accountId:!0,privateKey:!1},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{sandboxMode:!1,brokerId:"CCXT",verifyingContractAddress:"0x6F7a338F2aA472838dEFD3283eB360d4Dff5D203"},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!0,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPriceType:void 0,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!1}}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{"-1000":r.ExchangeError,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.InvalidOrder,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.InsufficientFunds,"-1011":r.NetworkError,"-1012":r.BadRequest,"-1101":r.InsufficientFunds,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder,"-1201":r.BadRequest,"-1202":r.BadRequest,29:r.BadRequest,9:r.AuthenticationError,3:r.AuthenticationError,2:r.BadRequest,15:r.BadRequest},broad:{}},precisionMode:a.kb})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}async fetchStatus(e={}){const t=await this.v1PublicGetPublicSystemInfo(e),i=this.safeDict(t,"data",{});let s=this.safeString(i,"status");return s=void 0===s?"error":"0"===s?"ok":"maintenance",{status:s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v1PublicGetPublicSystemInfo(e);return this.safeInteger(t,"timestamp")}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("_"),s=this.safeString(i,1),r=this.safeString(i,2),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r),n=this.safeString(i,2),d=this.safeCurrencyCode(n);return{id:t,symbol:a+"/"+o+":"+d,base:a,quote:o,settle:d,baseId:s,quoteId:r,settleId:n,type:"swap",spot:!1,margin:!1,swap:!0,future:!1,option:!1,active:void 0,contract:!0,linear:!0,inverse:!1,contractSize:this.parseNumber("1"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"base_tick"),price:this.safeNumber(e,"quote_tick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"base_min"),max:this.safeNumber(e,"base_max")},price:{min:this.safeNumber(e,"quote_min"),max:this.safeNumber(e,"quote_max")},cost:{min:this.safeNumber(e,"min_notional"),max:void 0}},created:this.safeInteger(e,"created_time"),info:e}}async fetchMarkets(e={}){const t=await this.v1PublicGetPublicInfo(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"rows",[]);return this.parseMarkets(s)}async fetchCurrencies(e={}){const t={},i=this.v1PublicGetPublicToken(e),s=this.v1PublicGetPublicChainInfo(e),[r,a]=await Promise.all([i,s]),o=this.safeDict(r,"data",{}),n=this.safeList(o,"rows",[]),d=this.safeDict(a,"data",{}),h=this.safeList(d,"rows",[]),c=this.indexBy(h,"chain_id");for(let e=0;e<n.length;e++){const i=n[e],s=this.safeString(i,"token"),r=this.safeList(i,"chain_details"),a=this.safeCurrencyCode(s),o={};for(let e=0;e<r.length;e++){const t=r[e],i=this.safeString(t,"chain_id"),s=this.safeDict(c,i),n=this.safeString(s,"name"),d=this.networkIdToCode(n,a);o[d]={id:i,network:d,limits:{withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},active:void 0,deposit:void 0,withdraw:void 0,fee:this.safeNumber(t,"withdrawal_fee"),precision:this.parseNumber(this.parsePrecision(this.safeString(t,"decimals"))),info:[t,s]}}t[a]=this.safeCurrencyStructure({id:s,name:void 0,code:a,precision:void 0,active:void 0,fee:void 0,networks:o,deposit:void 0,withdraw:void 0,limits:{deposit:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(i,"minimum_withdraw_amount"),max:void 0}},info:i})}return t}parseTokenAndFeeTemp(e,t,i){const s=this.safeString(e,i);let r;if(void 0!==s){const i=this.safeString(e,t);r={cost:s,currency:this.safeCurrencyCode(i)}}return r}parseTrade(e,t=void 0){const i="id"in e,s=this.safeInteger(e,"executed_timestamp"),r=this.safeString(e,"symbol"),a=(t=this.safeMarket(r,t)).symbol,n=this.safeString(e,"executed_price"),d=this.safeString(e,"executed_quantity"),h=this.safeString(e,"order_id"),c=this.parseTokenAndFeeTemp(e,"fee_asset","fee"),l=this.safeString(c,"cost");void 0!==l&&(c.cost=l);const u=o.Y.stringMul(n,d),f=this.safeStringLower(e,"side"),p=this.safeString(e,"id");let m;if(i){m="1"===this.safeString(e,"is_maker")?"maker":"taker"}return this.safeTrade({id:p,timestamp:s,datetime:this.iso8601(s),symbol:a,side:f,price:n,amount:d,cost:u,order:h,takerOrMaker:m,type:void 0,fee:c,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==i&&(a.limit=i);const o=await this.v1PublicGetPublicMarketTrades(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]);return this.parseTrades(d,r,t,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.market(i);const s=this.safeInteger(e,"next_funding_time"),r=this.safeInteger(e,"est_funding_rate_timestamp"),a=this.safeInteger(e,"last_funding_rate_timestamp"),n=this.safeString(e,"last_funding_rate_timestamp"),d=this.safeString(e,"next_funding_time"),h=o.Y.stringSub(d,n);return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"est_funding_rate"),fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"last_funding_rate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a),interval:this.parseFundingInterval(h)}}parseFundingInterval(e){return this.safeString({36e5:"1h",144e5:"4h",288e5:"8h",576e5:"16h",864e5:"24h"},e,e)}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v1PublicGetPublicFundingRateSymbol(this.extend(s,t)),a=this.safeDict(r,"data",{});return this.parseFundingRate(a,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v1PublicGetPublicFundingRates(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parseFundingRates(r,e)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,i,s,"page",25);let a={};if(void 0!==e){const t=this.market(e);e=t.symbol,a.symbol=t.id}void 0!==t&&(a.start_t=t),[a,s]=this.handleUntilOption("end_t",a,s,.001);const o=await this.v1PublicGetPublicFundingRateHistory(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]),h=[];for(let e=0;e<d.length;e++){const t=d[e],i=this.safeString(t,"symbol"),s=this.safeInteger(t,"funding_rate_timestamp");h.push({info:t,symbol:this.safeSymbol(i),fundingRate:this.safeNumber(t,"funding_rate"),timestamp:s,datetime:this.iso8601(s)})}const c=this.sortBy(h,"timestamp");return this.filterBySymbolSinceLimit(c,e,t,i)}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t);let r=this.safeString(e,"funding_fee");const a=this.safeCurrencyCode("USDC"),n=this.safeInteger(e,"updated_time"),d=this.safeNumber(e,"funding_rate");return r="Pay"===this.safeString(e,"payment_type")?o.Y.stringNeg(r):r,{info:e,symbol:s,code:a,timestamp:n,datetime:this.iso8601(n),id:void 0,amount:this.parseNumber(r),rate:d}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingHistory",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.start_t=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.end_t=n),void 0!==i&&(a.size=Math.min(i,500));const d=await this.v1PrivateGetFundingFeeHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseIncomes(c,o,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v1PrivateGetClientInfo(e),i=this.safeDict(t,"data",{}),s=this.safeString(i,"futures_maker_fee_rate"),r=this.safeString(i,"futures_taker_fee_rate"),a={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e];a[i]={info:t,symbol:i,maker:this.parseNumber(o.Y.stringDiv(s,"10000")),taker:this.parseNumber(o.Y.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return a}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id};void 0!==t&&(t=Math.min(t,1e3),s.max_level=t);const r=await this.v1PrivateGetOrderbookSymbol(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeInteger(a,"timestamp");return this.parseOrderBook(a,e,o,"bids","asks","price","quantity")}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"start_timestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==s&&(o.limit=Math.min(s,1e3));const n=await this.v1PrivateGetKline(this.extend(o,r)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseOHLCVs(h,a,t,i,s)}parseOrder(e,t=void 0){const i=this.safeIntegerN(e,["timestamp","created_time","createdTime"]),s=this.safeStringN(e,["order_id","orderId","algoOrderId"]),r=this.omitZero(this.safeString2(e,"client_order_id","clientOrderId")),a=this.safeString(e,"symbol"),n=(t=this.safeMarket(a,t)).symbol,d=this.safeString2(e,"order_price","price"),h=this.safeString2(e,"order_quantity","quantity"),c=this.safeString2(e,"order_amount","amount"),l=this.safeStringLower2(e,"order_type","type");let u=this.safeValue2(e,"status","algoStatus");const f=this.safeBool(e,"success");void 0!==f&&(u=f?"NEW":"REJECTED");const p=this.safeStringLower(e,"side"),m=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),g=this.omitZero(this.safeString2(e,"average_executed_price","averageExecutedPrice")),v=o.Y.stringSub(c,m),y=this.safeValue2(e,"total_fee","totalFee"),b=this.safeString2(e,"fee_asset","feeAsset"),w=this.safeValue(e,"Transactions"),k=this.safeNumber(e,"triggerPrice");let S,O;const T=this.safeValue(e,"childOrders");if(void 0!==T){const e=this.safeValue(T,0),t=this.safeValue(e,"childOrders",[]);if(t.length>0){const e=this.safeValue(t,0),i=this.safeValue(t,1);S=this.safeNumber(e,"triggerPrice"),O=this.safeNumber(i,"triggerPrice")}}const P=this.safeInteger2(e,"updatedTime","updated_time");return this.safeOrder({id:s,clientOrderId:r,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,lastUpdateTimestamp:P,status:this.parseOrderStatus(u),symbol:n,type:this.parseOrderType(l),timeInForce:this.parseTimeInForce(l),postOnly:void 0,reduceOnly:this.safeBool(e,"reduce_only"),side:p,price:d,triggerPrice:k,takeProfitPrice:S,stopLossPrice:O,average:g,amount:h,filled:m,remaining:v,cost:c,trades:w,fee:{cost:y,currency:b},info:e},t)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}parseOrderType(e){return this.safeStringLower({LIMIT:"limit",MARKET:"market",POST_ONLY:"limit"},e,e)}createOrderRequest(e,t,i,s,r=void 0,a={}){const o=this.safeBool2(a,"reduceOnly","reduce_only"),n=t.toUpperCase(),d=this.market(e),h=i.toUpperCase(),c={symbol:d.id,side:h},l=this.safeString2(a,"triggerPrice","stopPrice"),u=this.safeValue(a,"stopLoss"),f=this.safeValue(a,"takeProfit"),p=this.safeString(a,"algoType"),m=void 0!==l||void 0!==u||void 0!==f||void 0!==this.safeValue(a,"childOrders"),g="MARKET"===n,v=this.safeStringLower(a,"timeInForce"),y=this.isPostOnly(g,void 0,a),b=m?"quantity":"order_quantity",w=m?"price":"order_price";c[m?"type":"order_type"]=n,m||(y?c.order_type="POST_ONLY":"fok"===v?c.order_type="FOK":"ioc"===v&&(c.order_type="IOC")),o&&(c.reduce_only=o),void 0!==r&&(c[w]=this.priceToPrecision(e,r)),(g&&!m||"POSITIONAL_TP_SL"!==p)&&(c[b]=this.amountToPrecision(e,s));const k=this.safeStringN(a,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==k&&(c.client_order_id=k),void 0!==l)c.trigger_price=this.priceToPrecision(e,l),c.algo_type="STOP";else if(void 0!==u||void 0!==f){c.algo_type="TP_SL";const t={symbol:d.id,reduce_only:!1,algo_type:"POSITIONAL_TP_SL",child_orders:[]},i=t.child_orders,s="BUY"===h?"SELL":"BUY";if(void 0!==u){const t=this.safeNumber2(u,"triggerPrice","price",u),r={side:s,algo_type:"TP_SL",trigger_price:this.priceToPrecision(e,t),type:"LIMIT",reduce_only:!0};i.push(r)}if(void 0!==f){const i=this.safeNumber2(f,"triggerPrice","price",f),r={side:s,algo_type:"TP_SL",trigger_price:this.priceToPrecision(e,i),type:"LIMIT",reduce_only:!0};t.push(r)}c.child_orders=[t]}return a=this.omit(a,["reduceOnly","reduce_only","clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit"]),this.extend(c,a)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.createOrderRequest(e,t,i,s,r,a),d=this.safeString2(a,"triggerPrice","stopPrice"),h=this.safeValue(a,"stopLoss"),c=this.safeValue(a,"takeProfit");let l;l=void 0!==d||void 0!==h||void 0!==c||void 0!==this.safeValue(a,"childOrders")?await this.v1PrivatePostAlgoOrder(n):await this.v1PrivatePostOrder(n);const u=this.safeDict(l,"data");u.timestamp=this.safeInteger(l,"timestamp");const f=this.parseOrder(u,o);return f.type=t,f}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t<e.length;t++){const s=e[t],a=this.safeString(s,"symbol"),o=this.safeString(s,"type"),n=this.safeString(s,"side"),d=this.safeValue(s,"amount"),h=this.safeValue(s,"price"),c=this.safeDict(s,"params",{}),l=this.safeString2(c,"triggerPrice","stopPrice"),u=this.safeValue(c,"stopLoss"),f=this.safeValue(c,"takeProfit");if(void 0!==l||void 0!==u||void 0!==f||void 0!==this.safeValue(c,"childOrders"))throw new r.NotSupported(this.id+" createOrders() only support non-stop order");const p=this.createOrderRequest(a,o,n,d,h,c);i.push(p)}const s={orders:i},a=await this.v1PrivatePostBatchOrder(this.extend(s,t)),o=this.safeDict(a,"data",{}),n=this.safeList(o,"rows",[]);return this.parseOrders(n)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n=this.market(t),d={order_id:e},h=this.safeStringN(o,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==h&&(d.triggerPrice=this.priceToPrecision(t,h));const c=void 0!==h||void 0!==this.safeValue(o,"childOrders"),l=c?"quantity":"order_quantity";let u;if(void 0!==a&&(d[c?"price":"order_price"]=this.priceToPrecision(t,a)),void 0!==r&&(d[l]=this.amountToPrecision(t,r)),o=this.omit(o,["stopPrice","triggerPrice","takeProfitPrice","stopLossPrice","trailingTriggerPrice","trailingAmount","trailingPercent"]),c)u=await this.v1PrivatePutAlgoOrder(this.extend(d,o));else{d.symbol=n.id,d.side=s.toUpperCase();const e=i.toUpperCase(),t=this.safeStringLower(o,"timeInForce"),r="MARKET"===e,a=this.isPostOnly(r,void 0,o);d.order_type=a?"POST_ONLY":"fok"===t?"FOK":"ioc"===t?"IOC":e;const h=this.safeStringN(o,["clOrdID","clientOrderId","client_order_id"]);o=this.omit(o,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce"]),void 0!==h&&(d.client_order_id=h),u=await this.v1PrivatePutOrder(this.extend(d,o))}const f=this.safeDict(u,"data",{});return f.timestamp=this.safeInteger(u,"timestamp"),this.parseOrder(f,n)}async cancelOrder(e,t=void 0,i={}){const s=this.safeBool2(i,"stop","trigger",!1);if(i=this.omit(i,["stop","trigger"]),!s&&void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={symbol:a.id},n=this.safeString2(i,"clOrdID","clientOrderId"),d=this.safeString(i,"client_order_id",n),h=void 0!==d;let c;s?h?(o.client_order_id=d,i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]),c=await this.v1PrivateDeleteAlgoClientOrder(this.extend(o,i))):(o.order_id=e,c=await this.v1PrivateDeleteAlgoOrder(this.extend(o,i))):h?(o.client_order_id=d,i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]),c=await this.v1PrivateDeleteClientOrder(this.extend(o,i))):(o.order_id=e,c=await this.v1PrivateDeleteOrder(this.extend(o,i)));const l={symbol:t};if(h?l.client_order_id=d:l.id=e,s)return this.extend(this.parseOrder(c),l);const u=this.safeDict(c,"data",{});return this.extend(this.parseOrder(u),l)}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeListN(i,["clOrdIDs","clientOrderIds","client_order_ids"]);i=this.omit(i,["clOrdIDs","clientOrderIds","client_order_ids"]);const r={};let a;return s?(r.client_order_ids=s.join(","),a=await this.v1PrivateDeleteClientBatchOrder(this.extend(r,i))):(r.order_ids=e.join(","),a=await this.v1PrivateDeleteBatchOrder(this.extend(r,i))),[this.safeOrder({info:a})]}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=this.safeBool2(t,"stop","trigger");t=this.omit(t,["stop","trigger"]);const s={};if(void 0!==e){const t=this.market(e);s.symbol=t.id}let r;return r=i?await this.v1PrivateDeleteAlgoOrders(this.extend(s,t)):await this.v1PrivateDeleteOrders(this.extend(s,t)),[this.safeOrder({info:r})]}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.safeBool2(i,"stop","trigger",!1),a={},o=this.safeStringN(i,["clOrdID","clientOrderId","client_order_id"]);let n;i=this.omit(i,["stop","trigger","clOrdID","clientOrderId","client_order_id"]),r?o?(a.client_order_id=o,n=await this.v1PrivateGetAlgoClientOrderClientOrderId(this.extend(a,i))):(a.oid=e,n=await this.v1PrivateGetAlgoOrderOid(this.extend(a,i))):o?(a.client_order_id=o,n=await this.v1PrivateGetClientOrderClientOrderId(this.extend(a,i))):(a.oid=e,n=await this.v1PrivateGetOrderOid(this.extend(a,i)));const d=this.safeDict(n,"data",n);return this.parseOrder(d,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;const a=this.safeBool2(s,"stop","trigger",!1),o=a?100:500;if([r,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchOrders",e,t,i,s,"page",o);let n,d,h={};s=this.omit(s,["stop","trigger"]),void 0!==e&&(n=this.market(e),h.symbol=n.id),void 0!==t&&(h.start_t=t),h.size=void 0!==i?i:o,a&&(h.algo_type="STOP"),[h,s]=this.handleUntilOption("end_t",h,s),d=a?await this.v1PrivateGetAlgoOrders(this.extend(h,s)):await this.v1PrivateGetOrders(this.extend(h,s));const c=this.safeValue(d,"data",d),l=this.safeList(c,"rows");return this.parseOrders(l,n,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"INCOMPLETE"});return await this.fetchOrders(e,t,i,r)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"COMPLETED"});return await this.fetchOrders(e,t,i,r)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={oid:e},n=await this.v1PrivateGetOrderOidTrades(this.extend(o,r)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTrades(h,a,i,s,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,"page",500);let a,o={};void 0!==e&&(a=this.market(e),o.symbol=a.id),void 0!==t&&(o.start_t=t),o.size=void 0!==i?i:500,[o,s]=this.handleUntilOption("end_t",o,s);const n=await this.v1PrivateGetTrades(this.extend(o,s)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTrades(h,a,t,i,s)}parseBalance(e){const t={info:e},i=this.safeList(e,"holding",[]);for(let e=0;e<i.length;e++){const s=i[e],r=this.safeCurrencyCode(this.safeString(s,"token")),a=this.account();a.total=this.safeString(s,"holding"),a.frozen=this.safeString(s,"frozen"),t[r]=a}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1PrivateGetClientHolding(e),i=this.safeDict(t,"data");return this.parseBalance(i)}async getAssetHistoryRows(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.balance_token=a.id),void 0!==t&&(r.start_t=t),void 0!==i&&(r.pageSize=i);const o=this.safeString(s,"type");s=this.omit(s,"type"),void 0!==o&&(r.type=o);const n=await this.v1PrivateGetAssetHistory(this.extend(r,s)),d=this.safeDict(n,"data",{});return[a,this.safeList(d,"rows",[])]}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"token"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(i,t);const r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"token_side")?"in":"out",o=this.safeInteger(e,"created_time"),n=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount");return this.safeLedgerEntry({id:this.safeString(e,"id"),currency:s,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"tx_id"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,fee:n,direction:a,timestamp:o,datetime:this.iso8601(o),type:this.parseLedgerEntryType(this.safeString(e,"type")),info:e},t)}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,s),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseLedger(o,a,t,i,s)}parseTransaction(e,t=void 0){const i=this.safeString(e,"token");let s=this.safeStringLower(e,"token_side");"withdraw"===s&&(s="withdrawal");const r=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount"),a=this.safeString(e,"target_address"),o=this.safeString(e,"source_address"),n=this.safeInteger(e,"created_time");return{info:e,id:this.safeString2(e,"id","withdraw_id"),txid:this.safeString(e,"tx_id"),timestamp:n,datetime:this.iso8601(n),address:void 0,addressFrom:o,addressTo:a,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:s,amount:this.safeNumber(e,"amount"),currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeInteger(e,"updated_time"),comment:void 0,internal:void 0,fee:r,network:void 0}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({side:"DEPOSIT"},s))}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({side:"WITHDRAW"},s))}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,this.extend({},s)),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseTransactions(o,a,t,i,s)}async getWithdrawNonce(e={}){const t=await this.v1PrivateGetWithdrawNonce(e),i=this.safeDict(t,"data",{});return this.safeNumber(i,"withdraw_nonce")}hashMessage(e){return"0x"+this.hash(e,h.lY,"hex")}signHash(e,t){const i=(0,n.h1)(e.slice(-64),t.slice(-64),c.bI,void 0),s=i.r,r=i.s,a=this.intToBase16(this.sum(27,i.v));return"0x"+s.padStart(64,"0")+r.padStart(64,"0")+a}signMessage(e,t){return this.signHash(this.hashMessage(e),t.slice(-64))}async withdraw(e,t,i,s=void 0,a={}){if(await this.loadMarkets(),this.checkAddress(i),void 0!==e&&"USDC"!==(e=e.toUpperCase()))throw new r.NotSupported(this.id+" withdraw() only support USDC");const o=this.currency(e),n=this.safeString(this.options,"verifyingContractAddress"),d=this.safeString(a,"chainId"),h=this.safeDict(o,"networks",{}),c=this.safeDict(h,d,{});if(void 0===this.safeNumber(c,"id"))throw new r.BadRequest(this.id+" withdraw() require chainId parameter");const l=await this.getWithdrawNonce(a),u=this.nonce(),f={chainId:d,name:"Orderly",verifyingContract:n,version:"1"},p={brokerId:this.safeString(this.options,"keyBrokerId","woofi_pro"),chainId:this.parseToInt(d),receiver:i,token:e,amount:t.toString(),withdrawNonce:l,timestamp:u},m=this.ethEncodeStructuredData(f,{Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},p),g={signature:this.signMessage(m,this.privateKey),userAddress:i,verifyingContract:n,message:p};a=this.omit(a,"chainId");const v=await this.v1PrivatePostWithdrawRequest(this.extend(g,a)),y=this.safeDict(v,"data",{});return this.parseTransaction(y,o)}parseLeverage(e,t=void 0){const i=this.safeInteger(e,"max_leverage");return{info:e,symbol:t.symbol,marginMode:void 0,longLeverage:i,shortLeverage:i}}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.v1PrivateGetClientInfo(t),r=this.safeDict(s,"data",{});return this.parseLeverage(r,i)}async setLeverage(e,t=void 0,i={}){if(await this.loadMarkets(),e<1||e>50)throw new r.BadRequest(this.id+" leverage should be between 1 and 50");const s={leverage:e};return await this.v1PrivatePostClientLeverage(this.extend(s,i))}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);let s,r=this.safeString(e,"position_qty");s=o.Y.stringGt(r,"0")?"long":"short";const a=this.safeString(t,"contractSize"),n=this.safeString(e,"mark_price"),d=this.safeInteger(e,"timestamp"),h=this.safeString(e,"average_open_price"),c=this.safeString(e,"unsettled_pnl");r=o.Y.stringAbs(r);const l=o.Y.stringMul(r,n);return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:d,datetime:this.iso8601(d),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(h),notional:this.parseNumber(l),leverage:void 0,unrealizedPnl:this.parseNumber(c),contracts:this.parseNumber(r),contractSize:this.parseNumber(a),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"est_liq_price"),markPrice:this.parseNumber(n),lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:s,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v1PrivateGetPositionSymbol(this.extend(s,t)),a=this.safeDict(r,"data");return this.parsePosition(a,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.v1PrivateGetPositions(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parsePositions(r,e)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=t[0],h=t[1],c=this.implodeParams(e,s);let l=this.implodeHostname(this.urls.api[h]);if(l+="/"+o+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===h)l+=c,Object.keys(s).length&&(l+="?"+this.urlencode(s));else{if(this.checkRequiredCredentials(),!("POST"!==i&&"PUT"!==i||"algo/order"!==e&&"order"!==e&&"batch-order"!==e)){if(!this.safeBool(this.options,"sandboxMode",!1)){const t=this.safeString(this.options,"brokerId","CCXT");if("batch-order"===e){const e=this.safeList(s,"orders",[]);for(let i=0;i<e.length;i++)s.orders[i].order_tag=t}else s.order_tag=t}s=this.keysort(s)}let t="";const h=this.nonce().toString();l+=c;let u=this.apiKey;u.indexOf("ed25519:")<0&&(u="ed25519:"+u),r={"orderly-account-id":this.accountId,"orderly-key":u,"orderly-timestamp":h},t=h+i+"/"+o+"/"+c,"POST"===i||"PUT"===i?(t+=a=this.json(s),r["content-type"]="application/json"):(Object.keys(s).length&&(l+="?"+this.urlencode(s),t+="?"+this.rawencode(s)),r["content-type"]="application/x-www-form-urlencoded","DELETE"===i&&(a=""));let f=this.secret;if(f.indexOf("ed25519:")>=0){const e=f.split("ed25519:");f=e[1]}const p=(0,n.q4)(this.encode(t),this.base58ToBinary(f),d.ev);r["orderly-signature"]=this.urlencodeBase64(this.base64ToBinary(p))}return{url:l,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(!n)return;const c=this.safeBool(n,"success"),l=this.safeString(n,"code");if(!c){const e=this.id+" "+this.json(n);throw this.throwBroadlyMatchedException(this.exceptions.broad,o,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),new r.ExchangeError(e)}}}},55344:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(43521),r=i(85147),a=i(51579),o=i(62079),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"xt",name:"XT",countries:["SC"],rateLimit:100,version:"v4",certified:!1,pro:!0,has:{CORS:!1,spot:!0,margin:!0,swap:!0,future:!0,option:!1,addMargin:!0,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!1,createReduceOnlyOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawals:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchL3OrderBook:!1,fetchLedger:!0,fetchLedgerEntry:!1,fetchLeverage:!1,fetchLeverageTiers:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrdersByStatus:!0,fetchOrderTrades:!1,fetchPosition:!0,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!0,repayMargin:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!1,signIn:!1,transfer:!0,withdraw:!0},precisionMode:a.kb,urls:{logo:"https://user-images.githubusercontent.com/14319357/232636712-466df2fc-560a-4ca4-aab2-b1d954a58e24.jpg",api:{spot:"https://sapi.xt.com",linear:"https://fapi.xt.com",inverse:"https://dapi.xt.com",user:"https://api.xt.com"},www:"https://xt.com",referral:"https://www.xt.com/en/accounts/register?ref=9PTM9VW",doc:["https://doc.xt.com/","https://github.com/xtpub/api-doc"],fees:"https://www.xt.com/en/rate"},api:{public:{spot:{get:{currencies:1,depth:10,kline:1,symbol:1,ticker:1,"ticker/book":1,"ticker/price":1,"ticker/24h":1,time:1,"trade/history":1,"trade/recent":1,"wallet/support/currency":1}},linear:{get:{"future/market/v1/public/contract/risk-balance":1,"future/market/v1/public/contract/open-interest":1,"future/market/v1/public/leverage/bracket/detail":1,"future/market/v1/public/leverage/bracket/list":1,"future/market/v1/public/q/agg-ticker":1,"future/market/v1/public/q/agg-tickers":1,"future/market/v1/public/q/deal":1,"future/market/v1/public/q/depth":1,"future/market/v1/public/q/funding-rate":1,"future/market/v1/public/q/funding-rate-record":1,"future/market/v1/public/q/index-price":1,"future/market/v1/public/q/kline":1,"future/market/v1/public/q/mark-price":1,"future/market/v1/public/q/symbol-index-price":1,"future/market/v1/public/q/symbol-mark-price":1,"future/market/v1/public/q/ticker":1,"future/market/v1/public/q/tickers":1,"future/market/v1/public/symbol/coins":3.33,"future/market/v1/public/symbol/detail":3.33,"future/market/v1/public/symbol/list":1}},inverse:{get:{"future/market/v1/public/contract/risk-balance":1,"future/market/v1/public/contract/open-interest":1,"future/market/v1/public/leverage/bracket/detail":1,"future/market/v1/public/leverage/bracket/list":1,"future/market/v1/public/q/agg-ticker":1,"future/market/v1/public/q/agg-tickers":1,"future/market/v1/public/q/deal":1,"future/market/v1/public/q/depth":1,"future/market/v1/public/q/funding-rate":1,"future/market/v1/public/q/funding-rate-record":1,"future/market/v1/public/q/index-price":1,"future/market/v1/public/q/kline":1,"future/market/v1/public/q/mark-price":1,"future/market/v1/public/q/symbol-index-price":1,"future/market/v1/public/q/symbol-mark-price":1,"future/market/v1/public/q/ticker":1,"future/market/v1/public/q/tickers":1,"future/market/v1/public/symbol/coins":3.33,"future/market/v1/public/symbol/detail":3.33,"future/market/v1/public/symbol/list":1}}},private:{spot:{get:{balance:1,balances:1,"batch-order":1,"deposit/address":1,"deposit/history":1,"history-order":1,"open-order":1,order:1,"order/{orderId}":1,trade:1,"withdraw/history":1},post:{order:.2,withdraw:10,"balance/transfer":1,"balance/account/transfer":1,"ws-token":1},delete:{"batch-order":1,"open-order":1,"order/{orderId}":1},put:{"order/{orderId}":1}},linear:{get:{"future/trade/v1/entrust/plan-detail":1,"future/trade/v1/entrust/plan-list":1,"future/trade/v1/entrust/plan-list-history":1,"future/trade/v1/entrust/profit-detail":1,"future/trade/v1/entrust/profit-list":1,"future/trade/v1/order/detail":1,"future/trade/v1/order/list":1,"future/trade/v1/order/list-history":1,"future/trade/v1/order/trade-list":1,"future/user/v1/account/info":1,"future/user/v1/balance/bills":1,"future/user/v1/balance/detail":1,"future/user/v1/balance/funding-rate-list":1,"future/user/v1/balance/list":1,"future/user/v1/position/adl":1,"future/user/v1/position/list":1,"future/user/v1/user/collection/list":1,"future/user/v1/user/listen-key":1},post:{"future/trade/v1/entrust/cancel-all-plan":1,"future/trade/v1/entrust/cancel-all-profit-stop":1,"future/trade/v1/entrust/cancel-plan":1,"future/trade/v1/entrust/cancel-profit-stop":1,"future/trade/v1/entrust/create-plan":1,"future/trade/v1/entrust/create-profit":1,"future/trade/v1/entrust/update-profit-stop":1,"future/trade/v1/order/cancel":1,"future/trade/v1/order/cancel-all":1,"future/trade/v1/order/create":1,"future/trade/v1/order/create-batch":1,"future/trade/v1/order/update":1,"future/user/v1/account/open":1,"future/user/v1/position/adjust-leverage":1,"future/user/v1/position/auto-margin":1,"future/user/v1/position/close-all":1,"future/user/v1/position/margin":1,"future/user/v1/user/collection/add":1,"future/user/v1/user/collection/cancel":1,"future/user/v1/position/change-type":1}},inverse:{get:{"future/trade/v1/entrust/plan-detail":1,"future/trade/v1/entrust/plan-list":1,"future/trade/v1/entrust/plan-list-history":1,"future/trade/v1/entrust/profit-detail":1,"future/trade/v1/entrust/profit-list":1,"future/trade/v1/order/detail":1,"future/trade/v1/order/list":1,"future/trade/v1/order/list-history":1,"future/trade/v1/order/trade-list":1,"future/user/v1/account/info":1,"future/user/v1/balance/bills":1,"future/user/v1/balance/detail":1,"future/user/v1/balance/funding-rate-list":1,"future/user/v1/balance/list":1,"future/user/v1/position/adl":1,"future/user/v1/position/list":1,"future/user/v1/user/collection/list":1,"future/user/v1/user/listen-key":1},post:{"future/trade/v1/entrust/cancel-all-plan":1,"future/trade/v1/entrust/cancel-all-profit-stop":1,"future/trade/v1/entrust/cancel-plan":1,"future/trade/v1/entrust/cancel-profit-stop":1,"future/trade/v1/entrust/create-plan":1,"future/trade/v1/entrust/create-profit":1,"future/trade/v1/entrust/update-profit-stop":1,"future/trade/v1/order/cancel":1,"future/trade/v1/order/cancel-all":1,"future/trade/v1/order/create":1,"future/trade/v1/order/create-batch":1,"future/trade/v1/order/update":1,"future/user/v1/account/open":1,"future/user/v1/position/adjust-leverage":1,"future/user/v1/position/auto-margin":1,"future/user/v1/position/close-all":1,"future/user/v1/position/margin":1,"future/user/v1/user/collection/add":1,"future/user/v1/user/collection/cancel":1}},user:{get:{"user/account":1,"user/account/api-key":1},post:{"user/account":1,"user/account/api-key":1},put:{"user/account/api-key":1},delete:{"user/account/{apikeyId}":1}}}},fees:{spot:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("5000"),this.parseNumber("0.0018")],[this.parseNumber("10000"),this.parseNumber("0.0016")],[this.parseNumber("20000"),this.parseNumber("0.0014")],[this.parseNumber("50000"),this.parseNumber("0.0012")],[this.parseNumber("150000"),this.parseNumber("0.0010")],[this.parseNumber("300000"),this.parseNumber("0.0008")],[this.parseNumber("600000"),this.parseNumber("0.0007")],[this.parseNumber("1200000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0005")],[this.parseNumber("6000000"),this.parseNumber("0.0004")],[this.parseNumber("15000000"),this.parseNumber("0.0003")],[this.parseNumber("30000000"),this.parseNumber("0.0002")]],taker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("5000"),this.parseNumber("0.0018")],[this.parseNumber("10000"),this.parseNumber("0.0016")],[this.parseNumber("20000"),this.parseNumber("0.0014")],[this.parseNumber("50000"),this.parseNumber("0.0012")],[this.parseNumber("150000"),this.parseNumber("0.0010")],[this.parseNumber("300000"),this.parseNumber("0.0008")],[this.parseNumber("600000"),this.parseNumber("0.0007")],[this.parseNumber("1200000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0005")],[this.parseNumber("6000000"),this.parseNumber("0.0004")],[this.parseNumber("15000000"),this.parseNumber("0.0003")],[this.parseNumber("30000000"),this.parseNumber("0.0002")]]}},contract:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0004"),taker:this.parseNumber("0.0006"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0004")],[this.parseNumber("200000"),this.parseNumber("0.00038")],[this.parseNumber("1000000"),this.parseNumber("0.00036")],[this.parseNumber("5000000"),this.parseNumber("0.00034")],[this.parseNumber("10000000"),this.parseNumber("0.00032")],[this.parseNumber("15000000"),this.parseNumber("0.00028")],[this.parseNumber("30000000"),this.parseNumber("0.00024")],[this.parseNumber("50000000"),this.parseNumber("0.0002")],[this.parseNumber("100000000"),this.parseNumber("0.00016")],[this.parseNumber("300000000"),this.parseNumber("0.00012")],[this.parseNumber("500000000"),this.parseNumber("0.00008")]],taker:[[this.parseNumber("0"),this.parseNumber("0.0006")],[this.parseNumber("200000"),this.parseNumber("0.000588")],[this.parseNumber("1000000"),this.parseNumber("0.00057")],[this.parseNumber("5000000"),this.parseNumber("0.00054")],[this.parseNumber("10000000"),this.parseNumber("0.00051")],[this.parseNumber("15000000"),this.parseNumber("0.00048")],[this.parseNumber("30000000"),this.parseNumber("0.00045")],[this.parseNumber("50000000"),this.parseNumber("0.00045")],[this.parseNumber("100000000"),this.parseNumber("0.00036")],[this.parseNumber("300000000"),this.parseNumber("0.00033")],[this.parseNumber("500000000"),this.parseNumber("0.0003")]]}}},exceptions:{exact:{400:o.NetworkError,404:o.ExchangeError,429:o.RateLimitExceeded,500:o.ExchangeError,502:o.ExchangeError,503:o.OnMaintenance,AUTH_001:o.AuthenticationError,AUTH_002:o.AuthenticationError,AUTH_003:o.AuthenticationError,AUTH_004:o.AuthenticationError,AUTH_005:o.AuthenticationError,AUTH_006:o.AuthenticationError,AUTH_007:o.AuthenticationError,AUTH_101:o.AuthenticationError,AUTH_102:o.AuthenticationError,AUTH_103:o.AuthenticationError,AUTH_104:o.AuthenticationError,AUTH_105:o.AuthenticationError,AUTH_106:o.PermissionDenied,SYMBOL_001:o.BadSymbol,SYMBOL_002:o.BadSymbol,SYMBOL_003:o.BadSymbol,SYMBOL_004:o.BadSymbol,SYMBOL_005:o.BadSymbol,ORDER_001:o.InvalidOrder,ORDER_002:o.InsufficientFunds,ORDER_003:o.InvalidOrder,ORDER_004:o.InvalidOrder,ORDER_005:o.InvalidOrder,ORDER_006:o.InvalidOrder,ORDER_007:o.PermissionDenied,ORDER_F0101:o.InvalidOrder,ORDER_F0102:o.InvalidOrder,ORDER_F0103:o.InvalidOrder,ORDER_F0201:o.InvalidOrder,ORDER_F0202:o.InvalidOrder,ORDER_F0203:o.InvalidOrder,ORDER_F0301:o.InvalidOrder,ORDER_F0401:o.InvalidOrder,ORDER_F0501:o.InvalidOrder,ORDER_F0502:o.InvalidOrder,ORDER_F0601:o.InvalidOrder,COMMON_001:o.ExchangeError,COMMON_002:o.ExchangeError,COMMON_003:o.BadRequest,CURRENCY_001:o.BadRequest,DEPOSIT_001:o.BadRequest,DEPOSIT_002:o.PermissionDenied,DEPOSIT_003:o.BadRequest,DEPOSIT_004:o.BadRequest,DEPOSIT_005:o.BadRequest,DEPOSIT_006:o.BadRequest,DEPOSIT_007:o.BadRequest,DEPOSIT_008:o.BadRequest,WITHDRAW_001:o.BadRequest,WITHDRAW_002:o.BadRequest,WITHDRAW_003:o.PermissionDenied,WITHDRAW_004:o.BadRequest,WITHDRAW_005:o.BadRequest,WITHDRAW_006:o.BadRequest,WITHDRAW_008:o.PermissionDenied,WITHDRAW_009:o.PermissionDenied,WITHDRAW_010:o.BadRequest,WITHDRAW_011:o.InsufficientFunds,WITHDRAW_012:o.PermissionDenied,WITHDRAW_013:o.PermissionDenied,WITHDRAW_014:o.BadRequest,WITHDRAW_015:o.BadRequest,WITHDRAW_016:o.BadRequest,WITHDRAW_017:o.BadRequest,WITHDRAW_018:o.BadRequest,WITHDRAW_019:o.BadRequest,WITHDRAW_020:o.PermissionDenied,WITHDRAW_021:o.PermissionDenied,WITHDRAW_022:o.BadRequest,WITHDRAW_023:o.BadRequest,WITHDRAW_024:o.BadRequest,WITHDRAW_025:o.BadRequest,FUND_001:o.BadRequest,FUND_002:o.InsufficientFunds,FUND_003:o.BadRequest,FUND_004:o.ExchangeError,FUND_005:o.PermissionDenied,FUND_014:o.BadRequest,FUND_015:o.BadRequest,FUND_016:o.BadRequest,FUND_017:o.BadRequest,FUND_018:o.BadRequest,FUND_019:o.BadRequest,FUND_020:o.BadRequest,FUND_021:o.BadRequest,FUND_022:o.BadRequest,FUND_044:o.BadRequest,TRANSFER_001:o.BadRequest,TRANSFER_002:o.InsufficientFunds,TRANSFER_003:o.BadRequest,TRANSFER_004:o.PermissionDenied,TRANSFER_005:o.PermissionDenied,TRANSFER_006:o.PermissionDenied,TRANSFER_007:o.RequestTimeout,TRANSFER_008:o.BadRequest,TRANSFER_009:o.BadRequest,TRANSFER_010:o.PermissionDenied,TRANSFER_011:o.PermissionDenied,TRANSFER_012:o.PermissionDenied,symbol_not_support_trading_via_api:o.BadSymbol,open_order_min_nominal_value_limit:o.InvalidOrder,insufficient_balance:o.InsufficientFunds},broad:{"The symbol does not support trading via API":o.BadSymbol,"Exceeds the minimum notional value of a single order":o.InvalidOrder,"insufficient balance":o.InsufficientFunds}},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},commonCurrencies:{},options:{adjustForTimeDifference:!1,timeDifference:0,accountsById:{spot:"SPOT",leverage:"LEVER",finance:"FINANCE",swap:"FUTURES_U",future:"FUTURES_U",linear:"FUTURES_U",inverse:"FUTURES_C"},networks:{ERC20:"Ethereum",TRC20:"Tron",BEP20:"BNB Smart Chain",BEP2:"BNB-BEP2",ETH:"Ethereum",TRON:"Tron",BNB:"BNB Smart Chain",AVAX:"AVAX C-Chain",GAL:"GAL(FT)",ALEO:"ALEO(IOU)",BTC:"Bitcoin",XT:"XT Smart Chain",ETC:"Ethereum Classic",MATIC:"Polygon",LTC:"Litecoin",BTS:"BitShares",XRP:"Ripple",XLM:"Stellar Network",ADA:"Cardano",XWC:"XWC-XWC",DOGE:"dogecoin",DCR:"Decred",SC:"Siacoin",XTZ:"Tezos",ZEC:"Zcash",XMR:"Monero",LSK:"Lisk",ATOM:"Cosmos",ONT:"Ontology",ALGO:"Algorand",SOL:"SOL-SOL",DOT:"Polkadot",ZEN:"Horizen",FIL:"Filecoin",CHZ:"chz",ICP:"Internet Computer",KSM:"Kusama",LUNA:"Terra",THETA:"Theta Token",FTM:"Fantom",VET:"VeChain",NEAR:"NEAR Protocol",ONE:"Harmony",KLAY:"Klaytn",AR:"Arweave",CELT:"OKT",EGLD:"Elrond eGold",CRO:"CRO-CRONOS",BCH:"Bitcoin Cash",GLMR:"Moonbeam",LOOP:"LOOP-LRC",REI:"REI Network",ASTR:"Astar Network",OP:"OPT",MMT:"MMT-MMT",TBC:"TBC-TBC",OMAX:"OMAX-OMAX CHAIN",GMMT:"GMMT chain",ZIL:"Zilliqa"},networksById:{Ethereum:"ERC20",Tron:"TRC20","BNB Smart Chain":"BEP20","BNB-BEP2":"BEP2",Bitcoin:"BTC","XT Smart Chain":"XT","Ethereum Classic":"ETC",Polygon:"MATIC",Litecoin:"LTC",BitShares:"BTS",Ripple:"XRP","Stellar Network":"XLM",Cardano:"ADA","XWC-XWC":"XWC",dogecoin:"DOGE",Decred:"DCR",Siacoin:"SC",Tezos:"XTZ",Zcash:"ZEC",Monero:"XMR",Lisk:"LSK",Cosmos:"ATOM",Ontology:"ONT",Algorand:"ALGO","SOL-SOL":"SOL",Polkadot:"DOT",Horizen:"ZEN",Filecoin:"FIL",chz:"CHZ","Internet Computer":"ICP",Kusama:"KSM",Terra:"LUNA","Theta Token":"THETA",Fantom:"FTM",VeChain:"VET","AVAX C-Chain":"AVAX","NEAR Protocol":"NEAR",Harmony:"ONE",Klaytn:"KLAY",Arweave:"AR",OKT:"CELT","Elrond eGold":"EGLD","CRO-CRONOS":"CRO","Bitcoin Cash":"BCH",Moonbeam:"GLMR","LOOP-LRC":"LOOP","REI Network":"REI","Astar Network":"ASTR","GAL(FT)":"GAL","ALEO(IOU)":"ALEO",OPT:"OP","MMT-MMT":"MMT","TBC-TBC":"TBC","OMAX-OMAX CHAIN":"OMAX","GMMT chain":"GMMT",Zilliqa:"ZIL"},createMarketBuyOrderRequiresPrice:!0,recvWindow:"5000"},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!0,limit:100,daysBack:1e5,untilDays:1e5,marketType:!0,subType:!0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:100,daysBack:1e5,untilDays:1e5,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchClosedOrders:{marginMode:!0,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},stopLossPrice:!0,takeProfitPrice:!0},fetchMyTrades:{daysBack:void 0,untilDays:void 0}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicSpotGetTime(e),i=this.safeValue(t,"result");return this.safeInteger(i,"serverTime")}async fetchCurrencies(e={}){const t=[this.publicSpotGetWalletSupportCurrency(e),this.publicSpotGetCurrencies(e)],[i,s]=await Promise.all(t),r=this.safeValue(i,"result",[]),a=this.safeValue(s,"result",[]),o=this.safeValue(a,"currencies",[]),n=this.indexBy(r,"currency"),d={};for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"currency"),s=this.safeCurrencyCode(i),r=this.safeValue(n,i,{}),a=this.safeValue(r,"supportChains",[]),h={};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"chain"),r=this.networkIdToCode(i,s);h[r]={info:t,id:i,network:r,name:void 0,active:void 0,fee:this.safeNumber(t,"withdrawFeeAmount"),precision:void 0,deposit:this.safeBool(t,"depositEnabled"),withdraw:this.safeBool(t,"withdrawEnabled"),limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(t,"withdrawMinAmount"),max:void 0},deposit:{min:void 0,max:void 0}}}}let c;c="FT"===this.safeString(t,"type")?"crypto":"other",d[s]=this.safeCurrencyStructure({info:t,id:i,code:s,name:this.safeString(t,"fullName"),active:void 0,fee:void 0,precision:this.parseNumber(this.parsePrecision(this.safeString(t,"maxPrecision"))),deposit:"1"===this.safeString(t,"depositStatus"),withdraw:"1"===this.safeString(t,"withdrawStatus"),networks:h,type:c,limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}}})}return d}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=[this.fetchSpotMarkets(e),this.fetchSwapAndFutureMarkets(e)],i=await Promise.all(t),s=i[0],r=i[1];return this.arrayConcat(s,r)}async fetchSpotMarkets(e={}){const t=await this.publicSpotGetSymbol(e),i=this.safeValue(t,"result",{}),s=this.safeValue(i,"symbols",[]);return this.parseMarkets(s)}async fetchSwapAndFutureMarkets(e={}){const t=await Promise.all([this.publicLinearGetFutureMarketV1PublicSymbolList(e),this.publicInverseGetFutureMarketV1PublicSymbolList(e)]),i=this.arrayConcat(this.safeValue(t[0],"result",[]),this.safeValue(t[1],"result",[]));return this.parseMarkets(i)}parseMarkets(e){const t=[];for(let i=0;i<e.length;i++)t.push(this.parseMarket(e[i]));return t}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeString2(e,"baseCurrency","baseCoin"),s=this.safeString2(e,"quoteCurrency","quoteCoin"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s),o=this.safeString(e,"state");let n=r+"/"+a;const d=this.safeValue(e,"filters",[]);let h,c,l,u,f,p,m;for(let e=0;e<d.length;e++){const t=d[e],i=this.safeString(t,"filter");"QUANTITY"===i&&(h=this.safeNumber(t,"min"),c=this.safeNumber(t,"max"),m=this.safeNumber(t,"tickSize")),"QUOTE_QTY"===i&&(l=this.safeNumber(t,"min")),"PRICE"===i&&(f=this.safeNumber(t,"min"),p=this.safeNumber(t,"max"))}void 0===m&&(m=this.parseNumber(this.parsePrecision(this.safeString(e,"quantityPrecision"))));const g=this.safeString(e,"underlyingType");let v,y,b,w,k,S=!1,O=!1,T=!1,P=!0,M="spot";if("U_BASED"===g?(n=n+":"+a,b=i,w=a,v=!0,y=!1):"COIN_BASED"===g&&(n=n+":"+r,b=i,w=r,v=!1,y=!0),void 0!==g){k=this.safeInteger(e,"deliveryDate");"perpetual"!==this.safeString(e,"productType")?(n=n+"-"+this.yymmdd(k),M="future",S=!0):(M="swap",O=!0),h=this.safeNumber(e,"minQty"),l=this.safeNumber(e,"minNotional"),u=this.safeNumber(e,"maxNotional"),f=this.safeNumber(e,"minPrice"),p=this.safeNumber(e,"maxPrice"),T=!0,P=!1}let I=!1;return T?I=this.safeValue(e,"isOpenApi",!1):"ONLINE"===o&&this.safeValue(e,"tradingEnabled")&&this.safeValue(e,"openapiEnabled")&&(I=!0),this.safeMarketStructure({id:t,symbol:n,base:r,quote:a,settle:w,baseId:i,quoteId:s,settleId:b,type:M,spot:P,margin:void 0,swap:O,future:S,option:!1,active:I,contract:T,linear:v,inverse:y,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:this.safeNumber(e,"contractSize"),expiry:k,expiryDatetime:this.iso8601(k),strike:void 0,optionType:void 0,precision:{price:this.parseNumber(this.parsePrecision(this.safeString(e,"pricePrecision"))),amount:m,base:this.parseNumber(this.parsePrecision(this.safeString(e,"baseCoinPrecision"))),quote:this.parseNumber(this.parsePrecision(this.safeString(e,"quoteCoinPrecision")))},limits:{leverage:{min:this.parseNumber("1"),max:void 0},amount:{min:h,max:c},price:{min:f,max:p},cost:{min:l,max:u}},info:e})}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();let a=!1;if([a,r]=this.handleOptionAndParams(r,"fetchOHLCV","paginate",!1),a)return await this.fetchPaginatedCallDeterministic("fetchOHLCV",e,i,s,t,r,1e3);const o=this.market(e),n={symbol:o.id,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.startTime=i),n.limit=void 0!==s?s:1e3;const d=this.safeInteger(r,"until");let h;r=this.omit(r,["until"]),void 0!==d&&(n.endTime=d),h=o.linear?await this.publicLinearGetFutureMarketV1PublicQKline(this.extend(n,r)):o.inverse?await this.publicInverseGetFutureMarketV1PublicQKline(this.extend(n,r)):await this.publicSpotGetKline(this.extend(n,r));const c=this.safeValue(h,"result",[]);return this.parseOHLCVs(c,o,t,i,s)}parseOHLCV(e,t=void 0){const i=t.inverse?"v":"a";return[this.safeInteger(e,"t"),this.safeNumber(e,"o"),this.safeNumber(e,"h"),this.safeNumber(e,"l"),this.safeNumber(e,"c"),this.safeNumber2(e,"q",i)]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={symbol:s.id};let a;s.spot?(void 0!==t&&(r.limit=Math.min(t,500)),a=await this.publicSpotGetDepth(this.extend(r,i))):(r.level=void 0!==t?Math.min(t,50):50,s.linear?a=await this.publicLinearGetFutureMarketV1PublicQDepth(this.extend(r,i)):s.inverse&&(a=await this.publicInverseGetFutureMarketV1PublicQDepth(this.extend(r,i))));const o=this.safeValue(a,"result",{}),n=this.safeInteger2(o,"timestamp","t");if(s.spot){const t=this.parseOrderBook(o,e,n);return t.nonce=this.safeInteger(o,"lastUpdateId"),t}const d=this.parseOrderBook(o,e,n,"b","a");return d.nonce=this.safeInteger2(o,"u","lastUpdateId"),d}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r;r=i.linear?await this.publicLinearGetFutureMarketV1PublicQAggTicker(this.extend(s,t)):i.inverse?await this.publicInverseGetFutureMarketV1PublicQAggTicker(this.extend(s,t)):await this.publicSpotGetTicker(this.extend(s,t));const a=this.safeValue(r,"result");return i.spot?this.parseTicker(a[0],i):this.parseTicker(a,i)}async fetchTickers(e=void 0,t={}){let i;await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e),i=this.market(e[0]));const s={};let r,a,o;[r,t]=this.handleMarketTypeAndParams("fetchTickers",i,t),[a,t]=this.handleSubTypeAndParams("fetchTickers",i,t),o="inverse"===a?await this.publicInverseGetFutureMarketV1PublicQAggTickers(this.extend(s,t)):"linear"===a||"swap"===r||"future"===r?await this.publicLinearGetFutureMarketV1PublicQAggTickers(this.extend(s,t)):await this.publicSpotGetTicker24h(this.extend(s,t));const n=this.safeValue(o,"result",[]),d={};for(let e=0;e<n.length;e++){const t=this.parseTicker(n[e],i);d[t.symbol]=t}return this.filterByArray(d,"symbol",e)}async fetchBidsAsks(e=void 0,t={}){await this.loadMarkets();let i,s;if(void 0!==(e=this.marketSymbols(e))&&(i=this.market(e[0])),[s,t]=this.handleSubTypeAndParams("fetchBidsAsks",i,t),void 0!==s)throw new o.NotSupported(this.id+" fetchBidsAsks() is not available for swap and future markets, only spot markets are supported");const r=await this.publicSpotGetTickerBook(this.extend({},t)),a=this.safeValue(r,"result",[]);return this.parseTickers(a,e)}parseTicker(e,t=void 0){const i=this.safeString(e,"s");let s=void 0!==t?t.type:void 0;void 0===s&&(s="cv"in e||"aq"in e?"spot":"contract");const a=(t=this.safeMarket(i,t,"_",s)).symbol,o=this.safeInteger(e,"t");let n=this.safeString2(e,"cr","r");return void 0!==n&&(n=r.Y.stringMul(n,"100")),this.safeTicker({symbol:a,timestamp:o,datetime:this.iso8601(o),high:this.safeNumber(e,"h"),low:this.safeNumber(e,"l"),bid:this.safeNumber(e,"bp"),bidVolume:this.safeNumber(e,"bq"),ask:this.safeNumber(e,"ap"),askVolume:this.safeNumber(e,"aq"),vwap:void 0,open:this.safeString(e,"o"),close:this.safeString(e,"c"),last:this.safeString(e,"c"),previousClose:void 0,change:this.safeNumber(e,"cv"),percentage:this.parseNumber(n),average:void 0,baseVolume:this.safeNumber2(e,"a","q"),quoteVolume:this.safeNumber2(e,"a","v"),info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};let o;r.spot?(void 0!==i&&(a.limit=i),o=await this.publicSpotGetTradeRecent(this.extend(a,s))):(void 0!==i&&(a.num=i),r.linear?o=await this.publicLinearGetFutureMarketV1PublicQDeal(this.extend(a,s)):r.inverse&&(o=await this.publicInverseGetFutureMarketV1PublicQDeal(this.extend(a,s))));const n=this.safeValue(o,"result",[]);return this.parseTrades(n,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o,n,d;if(void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.startTime=t),[o,s]=this.handleMarketTypeAndParams("fetchMyTrades",a,s),[n,s]=this.handleSubTypeAndParams("fetchMyTrades",a,s),void 0!==n||"swap"===o||"future"===o)void 0!==i&&(r.size=i),d="inverse"===n?await this.privateInverseGetFutureTradeV1OrderTradeList(this.extend(r,s)):await this.privateLinearGetFutureTradeV1OrderTradeList(this.extend(r,s));else{let e;[e,s]=this.handleMarginModeAndParams("fetchMyTrades",s);const t=void 0!==e?"LEVER":"SPOT";r.bizType=t,void 0!==i&&(r.limit=i),d=await this.privateSpotGetTrade(this.extend(r,s))}const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]);return this.parseTrades(c,a,t,i)}parseTrade(e,t=void 0){const i=this.safeString2(e,"s","symbol");let s=void 0!==t?t.type:void 0;let a,o;void 0===s&&(s="b"in e||"bizType"in e||"oi"in e?"spot":"contract"),t=this.safeMarket(i,t,"_",s);const n=this.safeBool(e,"b");if(void 0!==n)a=n?"sell":"buy",o="taker";else{const t=this.safeStringLower(e,"takerMaker");if(void 0!==t)o=t;else{const t=this.safeBool(e,"isMaker");void 0!==t&&(o=t?"maker":"taker")}const i=this.safeStringLower(e,"orderSide");if(void 0!==i)a=i;else{const t=this.safeString(e,"m");void 0!==t&&(a="BID"===t?"buy":"sell")}}const d=this.safeIntegerN(e,["t","time","timestamp"]),h=this.safeString2(e,"q","quantity");let c;return c="spot"===s?h:void 0===h?r.Y.stringMul(this.safeString(e,"a"),this.numberToString(t.contractSize)):r.Y.stringMul(h,this.numberToString(t.contractSize)),this.safeTrade({info:e,id:this.safeStringN(e,["i","tradeId","execId"]),timestamp:d,datetime:this.iso8601(d),symbol:t.symbol,order:this.safeString2(e,"orderId","oi"),type:this.safeStringLower(e,"orderType"),side:a,takerOrMaker:o,price:this.safeString2(e,"p","price"),amount:c,cost:void 0,fee:{currency:this.safeCurrencyCode(this.safeString2(e,"feeCurrency","feeCoin")),cost:this.safeString(e,"fee")}},t)}async fetchBalance(e={}){let t,i,s;await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),[i,e]=this.handleSubTypeAndParams("fetchBalance",void 0,e);const r="swap"===t||"future"===t;let a;if(s="inverse"===i?await this.privateInverseGetFutureUserV1BalanceList(e):"linear"===i||r?await this.privateLinearGetFutureUserV1BalanceList(e):await this.privateSpotGetBalances(e),void 0!==i||r)a=this.safeValue(s,"result",[]);else{const e=this.safeValue(s,"result",{});a=this.safeValue(e,"assets",[])}return this.parseBalance(a)}parseBalance(e){const t={info:e};for(let i=0;i<e.length;i++){const s=e[i],a=this.safeString2(s,"currency","coin"),o=this.safeCurrencyCode(a),n=this.account(),d=this.safeString2(s,"availableAmount","availableBalance");let h=this.safeString(s,"frozenAmount");const c=this.safeString2(s,"totalAmount","walletBalance");if(void 0===h){const e=r.Y.stringAdd(this.safeString(s,"crossedMargin"),this.safeString(s,"isolatedMargin"));h=r.Y.stringAdd(this.safeString(s,"openOrderMarginFrozen"),e)}n.free=d,n.used=h,n.total=c,t[o]=n}return this.safeBalance(t)}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new o.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","buy",t,1,i)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e);return e=o.symbol,o.spot?await this.createSpotOrder(e,t,i,s,r,a):await this.createContractOrder(e,t,i,s,r,a)}async createSpotOrder(e,t,i,s,a=void 0,n={}){await this.loadMarkets();const d=this.market(e),h={symbol:d.id,side:i.toUpperCase(),type:t.toUpperCase()};let c,l;[l,n]=this.handleMarginModeAndParams("createOrder",n);const u=void 0!==l?"LEVER":"SPOT";if(h.bizType=u,"market"===t){if(c=this.safeStringUpper(n,"timeInForce","FOK"),"buy"===i){const t=this.safeString(n,"cost");n=this.omit(n,"cost");if(this.safeBool(this.options,"createMarketBuyOrderRequiresPrice",!0)){if(void 0===a&&void 0===t)throw new o.InvalidOrder(this.id+" createOrder() requires a price argument or cost in params for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter");{const i=this.numberToString(s),o=this.numberToString(a);let n;n=void 0!==a?r.Y.stringMul(i,o):t,h.quoteQty=this.costToPrecision(e,n)}}else{const i=void 0!==t?t:s;h.quoteQty=this.costToPrecision(e,i)}}}else c=this.safeStringUpper(n,"timeInForce","GTC"),h.price=this.priceToPrecision(e,a);"sell"!==i&&"limit"!==t||(h.quantity=this.amountToPrecision(e,s)),h.timeInForce=c;const f=await this.privateSpotPostOrder(this.extend(h,n)),p=this.safeValue(f,"result",{});return this.parseOrder(p,d)}async createContractOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n={symbol:o.id,origQty:this.amountToPrecision(e,s)},d=this.safeStringUpper(a,"timeInForce");void 0!==d&&(n.timeInForce=d);const h=this.safeValue(a,"reduceOnly",!1);if("buy"===i){const e=h?"SHORT":"LONG";n.positionSide=e}else{const e=h?"LONG":"SHORT";n.positionSide=e}let c;const l=this.safeNumber2(a,"triggerPrice","stopPrice"),u=this.safeNumber2(a,"stopLoss","triggerStopPrice"),f=this.safeNumber2(a,"takeProfit","triggerProfitPrice"),p=void 0!==l,m=void 0!==u,g=void 0!==f;if(void 0!==r&&(m||g||(n.price=this.priceToPrecision(e,r))),p){n.timeInForce=this.safeStringUpper(a,"timeInForce","GTC"),n.triggerPriceType=this.safeString(a,"triggerPriceType","LATEST_PRICE"),n.orderSide=i.toUpperCase(),n.stopPrice=this.priceToPrecision(e,l);const s="market"===t?"STOP_MARKET":"STOP";n.entrustType=s,a=this.omit(a,"triggerPrice"),o.linear?c=await this.privateLinearPostFutureTradeV1EntrustCreatePlan(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1EntrustCreatePlan(this.extend(n,a)))}else m||g?(m?n.triggerStopPrice=this.priceToPrecision(e,u):n.triggerProfitPrice=this.priceToPrecision(e,f),a=this.omit(a,["stopLoss","takeProfit"]),o.linear?c=await this.privateLinearPostFutureTradeV1EntrustCreateProfit(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1EntrustCreateProfit(this.extend(n,a)))):(n.orderSide=i.toUpperCase(),n.orderType=t.toUpperCase(),o.linear?c=await this.privateLinearPostFutureTradeV1OrderCreate(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1OrderCreate(this.extend(n,a))));return this.parseOrder(c,o)}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={};let a,o,n;[a,i]=this.handleMarketTypeAndParams("fetchOrder",s,i),[o,i]=this.handleSubTypeAndParams("fetchOrder",s,i);const d=this.safeValue(i,"stop"),h=this.safeValue(i,"stopLossTakeProfit");d?r.entrustId=e:h?r.profitId=e:r.orderId=e,d?(i=this.omit(i,"stop"),n="inverse"===o?await this.privateInverseGetFutureTradeV1EntrustPlanDetail(this.extend(r,i)):await this.privateLinearGetFutureTradeV1EntrustPlanDetail(this.extend(r,i))):h?(i=this.omit(i,"stopLossTakeProfit"),n="inverse"===o?await this.privateInverseGetFutureTradeV1EntrustProfitDetail(this.extend(r,i)):await this.privateLinearGetFutureTradeV1EntrustProfitDetail(this.extend(r,i))):n="inverse"===o?await this.privateInverseGetFutureTradeV1OrderDetail(this.extend(r,i)):"linear"===o||"swap"===a||"future"===a?await this.privateLinearGetFutureTradeV1OrderDetail(this.extend(r,i)):await this.privateSpotGetOrderOrderId(this.extend(r,i));const c=this.safeValue(n,"result",{});return this.parseOrder(c,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o,n,d;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i),[o,s]=this.handleMarketTypeAndParams("fetchOrders",a,s),[n,s]=this.handleSubTypeAndParams("fetchOrders",a,s);if(this.safeValue2(s,"trigger","stop"))s=this.omit(s,["trigger","stop"]),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustPlanListHistory(this.extend(r,s)):await this.privateLinearGetFutureTradeV1EntrustPlanListHistory(this.extend(r,s));else if("inverse"===n)d=await this.privateInverseGetFutureTradeV1OrderListHistory(this.extend(r,s));else if("linear"===n||"swap"===o||"future"===o)d=await this.privateLinearGetFutureTradeV1OrderListHistory(this.extend(r,s));else{let e;[e,s]=this.handleMarginModeAndParams("fetchOrders",s);const t=void 0!==e?"LEVER":"SPOT";r.bizType=t,d=await this.privateSpotGetHistoryOrder(this.extend(r,s))}const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]);return this.parseOrders(c,a,t,i)}async fetchOrdersByStatus(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();let a,o,n,d,h={};void 0!==t&&(a=this.market(t),h.symbol=a.id),void 0!==s&&(h.size=s),void 0!==i&&(h.startTime=i),[o,r]=this.handleMarketTypeAndParams("fetchOrdersByStatus",a,r),[n,r]=this.handleSubTypeAndParams("fetchOrdersByStatus",a,r);const c=this.safeBool2(r,"stop","trigger"),l=this.safeValue(r,"stopLossTakeProfit");if("open"===e?c||l?h.state="NOT_TRIGGERED":"swap"===o&&(h.state="UNFINISHED"):h.state="closed"===e?c||l?"TRIGGERED":"FILLED":"canceled"===e?c||l?"USER_REVOCATION":"CANCELED":e,(c||l||void 0!==n||"swap"===o||"future"===o)&&(void 0!==i&&(h.startTime=i),void 0!==s&&(h.size=s)),c)r=this.omit(r,["stop","trigger"]),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustPlanList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1EntrustPlanList(this.extend(h,r));else if(l)r=this.omit(r,"stopLossTakeProfit"),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustProfitList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1EntrustProfitList(this.extend(h,r));else if(void 0!==n||"swap"===o||"future"===o)d="inverse"===n?await this.privateInverseGetFutureTradeV1OrderList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1OrderList(this.extend(h,r));else{let t;[t,r]=this.handleMarginModeAndParams("fetchOrdersByStatus",r);const a=void 0!==t?"LEVER":"SPOT";h.bizType=a,"open"!==e?(void 0!==i&&(h.startTime=i),void 0!==s&&(h=this.omit(h,"size"),h.limit=s),d=await this.privateSpotGetHistoryOrder(this.extend(h,r))):d=await this.privateSpotGetOpenOrder(this.extend(h,r))}let u=[];const f=this.safeDict(d,"result");return u=void 0!==f?this.safeList(f,"items",[]):this.safeList(d,"result"),this.parseOrders(u,a,i,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("open",e,t,i,s)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("closed",e,t,i,s)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("canceled",e,t,i,s)}async cancelOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={};let a,o,n;[a,i]=this.handleMarketTypeAndParams("cancelOrder",s,i),[o,i]=this.handleSubTypeAndParams("cancelOrder",s,i);const d=this.safeValue2(i,"trigger","stop"),h=this.safeValue(i,"stopLossTakeProfit");d?r.entrustId=e:h?r.profitId=e:r.orderId=e,d?(i=this.omit(i,["trigger","stop"]),n="inverse"===o?await this.privateInversePostFutureTradeV1EntrustCancelPlan(this.extend(r,i)):await this.privateLinearPostFutureTradeV1EntrustCancelPlan(this.extend(r,i))):h?(i=this.omit(i,"stopLossTakeProfit"),n="inverse"===o?await this.privateInversePostFutureTradeV1EntrustCancelProfitStop(this.extend(r,i)):await this.privateLinearPostFutureTradeV1EntrustCancelProfitStop(this.extend(r,i))):n="inverse"===o?await this.privateInversePostFutureTradeV1OrderCancel(this.extend(r,i)):"linear"===o||"swap"===a||"future"===a?await this.privateLinearPostFutureTradeV1OrderCancel(this.extend(r,i)):await this.privateSpotDeleteOrderOrderId(this.extend(r,i));const c=void 0!==o||"swap"===a||"future"===a?n:this.safeValue(n,"result",{});return this.parseOrder(c,s)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i={};let s,r,a,o;void 0!==e&&(s=this.market(e),i.symbol=s.id),[r,t]=this.handleMarketTypeAndParams("cancelAllOrders",s,t),[a,t]=this.handleSubTypeAndParams("cancelAllOrders",s,t);const n=this.safeValue2(t,"trigger","stop"),d=this.safeValue(t,"stopLossTakeProfit");if(n)t=this.omit(t,["trigger","stop"]),o="inverse"===a?await this.privateInversePostFutureTradeV1EntrustCancelAllPlan(this.extend(i,t)):await this.privateLinearPostFutureTradeV1EntrustCancelAllPlan(this.extend(i,t));else if(d)t=this.omit(t,"stopLossTakeProfit"),o="inverse"===a?await this.privateInversePostFutureTradeV1EntrustCancelAllProfitStop(this.extend(i,t)):await this.privateLinearPostFutureTradeV1EntrustCancelAllProfitStop(this.extend(i,t));else if("inverse"===a)o=await this.privateInversePostFutureTradeV1OrderCancelAll(this.extend(i,t));else if("linear"===a||"swap"===r||"future"===r)o=await this.privateLinearPostFutureTradeV1OrderCancelAll(this.extend(i,t));else{let e;[e,t]=this.handleMarginModeAndParams("cancelAllOrders",t);const s=void 0!==e?"LEVER":"SPOT";i.bizType=s,o=await this.privateSpotDeleteOpenOrder(this.extend(i,t))}return[this.safeOrder(o)]}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s={orderIds:e};let r,a;if(void 0!==t&&(r=this.market(t)),[a,i]=this.handleSubTypeAndParams("cancelOrders",r,i),void 0!==a)throw new o.NotSupported(this.id+" cancelOrders() does not support swap and future orders, only spot orders are accepted");const n=await this.privateSpotDeleteBatchOrder(this.extend(s,i));return[this.safeOrder(n)]}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol"),s="result"in e||"positionSide"in e?"contract":"spot";t=this.safeMarket(i,t,void 0,s);const a=this.safeSymbol(i,t,void 0,s),o=this.safeInteger2(e,"time","createdTime"),n=this.safeNumber(e,"origQty"),d="spot"===s?n:r.Y.stringMul(this.numberToString(n),this.numberToString(t.contractSize)),h=this.safeNumber(e,"executedQty"),c="spot"===s?h:r.Y.stringMul(this.numberToString(h),this.numberToString(t.contractSize)),l=this.safeInteger(e,"updatedTime");return this.safeOrder({info:e,id:this.safeStringN(e,["orderId","result","cancelId","entrustId","profitId"]),clientOrderId:this.safeString2(e,"clientOrderId","clientModifyId"),timestamp:o,datetime:this.iso8601(o),lastTradeTimestamp:l,lastUpdateTimestamp:l,symbol:a,type:this.safeStringLower2(e,"type","orderType"),timeInForce:this.safeString(e,"timeInForce"),postOnly:void 0,side:this.safeStringLower2(e,"side","orderSide"),price:this.safeNumber(e,"price"),triggerPrice:this.safeNumber(e,"stopPrice"),stopLoss:this.safeNumber(e,"triggerStopPrice"),takeProfit:this.safeNumber(e,"triggerProfitPrice"),amount:d,filled:c,remaining:this.safeNumber(e,"leavingQty"),cost:void 0,average:this.safeNumber(e,"avgPrice"),status:this.parseOrderStatus(this.safeString(e,"state")),fee:{currency:this.safeCurrencyCode(this.safeString(e,"feeCurrency")),cost:this.safeNumber(e,"fee")},trades:void 0},t)}parseOrderStatus(e){return this.safeString({NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",REJECTED:"rejected",EXPIRED:"expired",UNFINISHED:"open",NOT_TRIGGERED:"open",TRIGGERING:"open",TRIGGERED:"closed",USER_REVOCATION:"canceled",PLATFORM_REVOCATION:"rejected",HISTORY:"expired"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,n,d,h;if(void 0!==e&&(a=this.currency(e)),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i),[n,s]=this.handleMarketTypeAndParams("fetchLedger",void 0,s),[d,s]=this.handleSubTypeAndParams("fetchLedger",void 0,s),"inverse"===d)h=await this.privateInverseGetFutureUserV1BalanceBills(this.extend(r,s));else{if("linear"!==d&&"swap"!==n&&"future"!==n)throw new o.NotSupported(this.id+" fetchLedger() does not support spot transactions, only swap and future wallet transactions are supported");h=await this.privateLinearGetFutureUserV1BalanceBills(this.extend(r,s))}const c=this.safeValue(h,"result",{}),l=this.safeValue(c,"items",[]);return this.parseLedger(l,a,t,i)}parseLedgerEntry(e,t=void 0){const i="ADD"===this.safeString(e,"side")?"in":"out",s=this.safeString(e,"coin");t=this.safeCurrency(s,t);const r=this.safeInteger(e,"createdTime");return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:i,account:void 0,referenceId:void 0,referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(s,t),amount:this.safeNumber(e,"amount"),timestamp:r,datetime:this.iso8601(r),before:void 0,after:this.safeNumber(e,"afterAmount"),status:void 0,fee:{currency:void 0,cost:void 0}},t)}parseLedgerEntryType(e){return this.safeString({EXCHANGE:"transfer",CLOSE_POSITION:"trade",TAKE_OVER:"trade",MERGE:"trade",QIANG_PING_MANAGER:"fee",FUND:"fee",FEE:"fee",ADL:"auto-deleveraging"},e,e)}async fetchDepositAddress(e,t={}){let i;await this.loadMarkets(),[i,t]=this.handleNetworkCodeAndParams(t);const s=this.currency(e),r=this.networkCodeToId(i,e);this.checkRequiredArgument("fetchDepositAddress",r,"network");const a={currency:s.id,chain:r},o=await this.privateSpotGetDepositAddress(this.extend(a,t)),n=this.safeValue(o,"result",{});return this.parseDepositAddress(n,s)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address");return this.checkAddress(i),{info:e,currency:this.safeCurrencyCode(void 0,t),network:void 0,address:i,tag:this.safeString(e,"memo")}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.privateSpotGetDepositHistory(this.extend(r,s)),n=this.safeValue(o,"result",{}),d=this.safeValue(n,"items",[]);return this.parseTransactions(d,a,t,i,s)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.privateSpotGetWithdrawHistory(this.extend(r,s)),n=this.safeValue(o,"result",{}),d=this.safeValue(n,"items",[]);return this.parseTransactions(d,a,t,i,s)}async withdraw(e,t,i,s=void 0,r={}){this.checkAddress(i),await this.loadMarkets();const a=this.currency(e);let o;[s,r]=this.handleWithdrawTagAndParams(s,r),[o,r]=this.handleNetworkCodeAndParams(r);const n=this.safeValue(this.options,"networks",{}),d=this.safeString2(n,o,e,e),h={currency:a.id,chain:d,amount:this.currencyToPrecision(e,t),address:i};void 0!==s&&(h.memo=s);const c=await this.privateSpotPostWithdraw(this.extend(h,r)),l=this.safeValue(c,"result",{});return this.parseTransaction(l,a)}parseTransaction(e,t=void 0){const i="fromAddr"in e?"deposit":"withdraw",s=this.safeInteger(e,"createdTime"),r=this.safeString(e,"address"),a=this.safeString(e,"memo"),o=this.safeCurrencyCode(this.safeString(e,"currency"),t),n=this.safeNumber(e,"fee"),d=void 0!==n?o:void 0,h=this.safeString(e,"chain");return{info:e,id:this.safeString(e,"id"),txid:this.safeString(e,"transactionId"),timestamp:s,datetime:this.iso8601(s),updated:void 0,addressFrom:this.safeString(e,"fromAddr"),addressTo:r,address:r,tagFrom:void 0,tagTo:void 0,tag:a,type:i,amount:this.safeNumber(e,"amount"),currency:o,network:this.networkIdToCode(h,o),status:this.parseTransactionStatus(this.safeString(e,"status")),comment:a,fee:{currency:d,cost:n,rate:void 0},internal:void 0}}parseTransactionStatus(e){return this.safeString({SUBMIT:"pending",REVIEW:"pending",AUDITED:"pending",PENDING:"pending",CANCEL:"canceled",FAIL:"failed",SUCCESS:"ok"},e,e)}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new o.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");const s=this.safeString(i,"positionSide");if(this.checkRequiredArgument("setLeverage",s,"positionSide",["LONG","SHORT"]),e<1||e>125)throw new o.BadRequest(this.id+" setLeverage() leverage should be between 1 and 125");await this.loadMarkets();const r=this.market(t);if(!r.contract)throw new o.BadSymbol(this.id+" setLeverage() supports contract markets only");const a={symbol:r.id,positionSide:s,leverage:e};let n,d;return[n,i]=this.handleSubTypeAndParams("setLeverage",r,i),d="inverse"===n?await this.privateInversePostFutureUserV1PositionAdjustLeverage(this.extend(a,i)):await this.privateLinearPostFutureUserV1PositionAdjustLeverage(this.extend(a,i)),d}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"ADD",i)}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"SUB",i)}async modifyMarginHelper(e,t,i,s={}){const r=this.safeString(s,"positionSide");this.checkRequiredArgument("setLeverage",r,"positionSide",["LONG","SHORT"]),await this.loadMarkets();const a=this.market(e),o={symbol:a.id,margin:t,type:i,positionSide:r};let n,d;return[n,s]=this.handleSubTypeAndParams("modifyMarginHelper",a,s),d="inverse"===n?await this.privateInversePostFutureUserV1PositionMargin(this.extend(o,s)):await this.privateLinearPostFutureUserV1PositionMargin(this.extend(o,s)),this.parseMarginModification(d,a)}parseMarginModification(e,t=void 0){return{info:e,type:void 0,amount:void 0,code:void 0,symbol:this.safeSymbol(void 0,t),status:void 0,marginMode:void 0,total:void 0,timestamp:void 0,datetime:void 0}}async fetchLeverageTiers(e=void 0,t={}){let i,s;await this.loadMarkets(),[i,t]=this.handleSubTypeAndParams("fetchLeverageTiers",void 0,t),s="inverse"===i?await this.publicInverseGetFutureMarketV1PublicLeverageBracketList(t):await this.publicLinearGetFutureMarketV1PublicLeverageBracketList(t);const r=this.safeValue(s,"result",[]);return e=this.marketSymbols(e),this.parseLeverageTiers(r,e,"symbol")}parseLeverageTiers(e,t=void 0,i=void 0){const s={};for(let i=0;i<e.length;i++){const r=e[i],a=this.safeString(r,"symbol"),o=this.safeMarket(a,void 0,"_","contract"),n=this.safeSymbol(a,o);void 0!==t?this.inArray(n,t)&&(s[n]=this.parseMarketLeverageTiers(r,o)):s[n]=this.parseMarketLeverageTiers(e[i],o)}return s}async fetchMarketLeverageTiers(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchMarketLeverageTiers",i,t),a="inverse"===r?await this.publicInverseGetFutureMarketV1PublicLeverageBracketDetail(this.extend(s,t)):await this.publicLinearGetFutureMarketV1PublicLeverageBracketDetail(this.extend(s,t));const o=this.safeValue(a,"result",{});return this.parseMarketLeverageTiers(o,i)}parseMarketLeverageTiers(e,t=void 0){const i=[],s=this.safeValue(e,"leverageBrackets",[]);for(let r=0;r<s.length;r++){const a=s[r],o=this.safeString(e,"symbol");t=this.safeMarket(o,t,"_","contract"),i.push({tier:this.safeInteger(a,"bracket"),symbol:this.safeSymbol(o,t,"_","contract"),currency:t.settle,minNotional:this.safeNumber(s[r-1],"maxNominalValue",0),maxNotional:this.safeNumber(a,"maxNominalValue"),maintenanceMarginRate:this.safeNumber(a,"maintMarginRate"),maxLeverage:this.safeNumber(a,"maxLeverage"),info:a})}return i}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new o.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const r=this.market(e);if(!r.swap)throw new o.BadSymbol(this.id+" fetchFundingRateHistory() supports swap contracts only");const a={symbol:r.id};let n,d;void 0!==i&&(a.limit=i),[n,s]=this.handleSubTypeAndParams("fetchFundingRateHistory",r,s),d="inverse"===n?await this.publicInverseGetFutureMarketV1PublicQFundingRateRecord(this.extend(a,s)):await this.publicLinearGetFutureMarketV1PublicQFundingRateRecord(this.extend(a,s));const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e],i=this.safeString(t,"symbol"),s=this.safeSymbol(i,r),a=this.safeInteger(t,"createdTime");l.push({info:t,symbol:s,fundingRate:this.safeNumber(t,"fundingRate"),timestamp:a,datetime:this.iso8601(a)})}const u=this.sortBy(l,"timestamp");return this.filterBySymbolSinceLimit(u,r.symbol,t,i)}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.swap)throw new o.BadSymbol(this.id+" fetchFundingRate() supports swap contracts only");const s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchFundingRate",i,t),a="inverse"===r?await this.publicInverseGetFutureMarketV1PublicQFundingRate(this.extend(s,t)):await this.publicLinearGetFutureMarketV1PublicQFundingRate(this.extend(s,t));const n=this.safeValue(a,"result",{});return this.parseFundingRate(n,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,"_","swap"),r=this.safeInteger(e,"nextCollectionTime");let a=this.safeString(e,"collectionInternal");return void 0!==a&&(a+="h"),{info:e,symbol:s,markPrice:void 0,indexPrice:void 0,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:void 0,datetime:void 0,fundingRate:this.safeNumber(e,"fundingRate"),fundingTimestamp:r,fundingDatetime:this.iso8601(r),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:a}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e);if(!r.swap)throw new o.BadSymbol(this.id+" fetchFundingHistory() supports swap contracts only");const a={symbol:r.id};let n,d;void 0!==t&&(a.startTime=t),void 0!==i&&(a.limit=i),[n,s]=this.handleSubTypeAndParams("fetchFundingHistory",r,s),d="inverse"===n?await this.privateInverseGetFutureUserV1BalanceFundingRateList(this.extend(a,s)):await this.privateLinearGetFutureUserV1BalanceFundingRateList(this.extend(a,s));const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e];l.push(this.parseFundingHistory(t,r))}const u=this.sortBy(l,"timestamp");return this.filterBySinceLimit(u,t,i)}parseFundingHistory(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,"_","swap"),r=this.safeString(e,"coin"),a=this.safeCurrencyCode(r),o=this.safeInteger(e,"createdTime");return{info:e,symbol:s,code:a,timestamp:o,datetime:this.iso8601(o),id:this.safeString(e,"id"),amount:this.safeNumber(e,"cast")}}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchPosition",i,t),a="inverse"===r?await this.privateInverseGetFutureUserV1PositionList(this.extend(s,t)):await this.privateLinearGetFutureUserV1PositionList(this.extend(s,t));const o=this.safeValue(a,"result",[]);for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"symbol"),s=this.safeMarket(i,void 0,void 0,"contract");if("0"!==this.safeString(t,"positionSize"))return this.parsePosition(t,s)}}async fetchPositions(e=void 0,t={}){let i,s;await this.loadMarkets(),[i,t]=this.handleSubTypeAndParams("fetchPositions",void 0,t),s="inverse"===i?await this.privateInverseGetFutureUserV1PositionList(t):await this.privateLinearGetFutureUserV1PositionList(t);const r=this.safeValue(s,"result",[]),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeString(t,"symbol"),s=this.safeMarket(i,void 0,void 0,"contract");a.push(this.parsePosition(t,s))}return this.filterByArrayPositions(a,"symbol",e,!1)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t,void 0,"contract");const s=this.safeSymbol(i,t,void 0,"contract"),r="CROSSED"===this.safeString(e,"positionType")?"cross":"isolated",a=this.safeNumber(e,"isolatedMargin");return this.safePosition({info:e,id:void 0,symbol:s,timestamp:void 0,datetime:void 0,hedged:void 0,side:this.safeStringLower(e,"positionSide"),contracts:this.safeNumber(e,"positionSize"),contractSize:t.contractSize,entryPrice:this.safeNumber(e,"entryPrice"),markPrice:void 0,notional:void 0,leverage:this.safeInteger(e,"leverage"),collateral:a,initialMargin:a,maintenanceMargin:void 0,initialMarginPercentage:void 0,maintenanceMarginPercentage:void 0,unrealizedPnl:void 0,liquidationPrice:void 0,marginMode:r,percentage:void 0,marginRatio:void 0})}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeValue(this.options,"accountsById"),n=this.safeString(o,i,i),d=this.safeString(o,s,s),h=this.currencyToPrecision(e,t),c={bizId:this.uuid(),currency:a.id,amount:h,from:n,to:d},l=await this.privateSpotPostBalanceTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=void 0){return{info:e,id:this.safeString(e,"result"),timestamp:void 0,datetime:void 0,currency:void 0,amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new o.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");await this.loadMarkets();const s=this.market(t);if(s.spot)throw new o.BadSymbol(this.id+" setMarginMode() supports contract markets only");if("isolated"!==(e=e.toLowerCase())&&"cross"!==e)throw new o.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");e="cross"===e?"CROSSED":"ISOLATED";const r=this.safeStringUpper(i,"positionSide");if(void 0===r)throw new o.ArgumentsRequired(this.id+' setMarginMode() requires a positionSide parameter, either "LONG" or "SHORT"');const a={positionType:e,positionSide:r,symbol:s.id};return await this.privateLinearPostFutureUserV1PositionChangeType(this.extend(a,i))}async editOrder(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===r)throw new o.ArgumentsRequired(this.id+" editOrder() requires an amount argument");await this.loadMarkets();const d=this.market(t),h={},c=this.safeNumber2(n,"stopLoss","triggerStopPrice"),l=this.safeNumber2(n,"takeProfit","triggerProfitPrice");n=this.omit(n,["stopLoss","takeProfit"]);const u=void 0!==c,f=void 0!==l;let p;if(u||f?h.profitId=e:(h.orderId=e,h.price=this.priceToPrecision(t,a)),d.swap){let e;u?h.triggerStopPrice=this.priceToPrecision(t,c):void 0!==l?h.triggerProfitPrice=this.priceToPrecision(t,l):h.origQty=this.amountToPrecision(t,r),[e,n]=this.handleSubTypeAndParams("editOrder",d,n),p="inverse"===e?u||f?await this.privateInversePostFutureTradeV1EntrustUpdateProfitStop(this.extend(h,n)):await this.privateInversePostFutureTradeV1OrderUpdate(this.extend(h,n)):u||f?await this.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(this.extend(h,n)):await this.privateLinearPostFutureTradeV1OrderUpdate(this.extend(h,n))}else h.quantity=this.amountToPrecision(t,r),p=await this.privateSpotPutOrderOrderId(this.extend(h,n));const m=d.swap?p:this.safeDict(p,"result",{});return this.parseOrder(m,d)}handleErrors(e,t,i,s,r,a,n,d,h){const c=this.safeStringUpper2(n,"msgInfo","mc");if(void 0!==c&&"SUCCESS"!==c){const e=this.id+" "+a,t=this.safeValue(n,"error",{}),i=this.safeString(n,"mc"),s=this.safeString(t,"code",i),r=this.safeString(n,"msgInfo"),d=this.safeString(t,"msg",r);throw this.throwExactlyMatchedException(this.exceptions.exact,s,e),this.throwBroadlyMatchedException(this.exceptions.broad,d,e),new o.ExchangeError(e)}}sign(e,t=[],i="GET",s={},r=void 0,a=void 0){const o="private"===t[0],d=t[1],h="/"+this.implodeParams(e,s);let c;c="spot"===d||"user"===d?o?"/"+this.version+h:"/"+this.version+"/public"+h:h;let l=this.urls.api[d]+c;const u=this.omit(s,this.extractParams(e)),f=this.urlencode(this.keysort(u));if(r={"Content-Type":"application/json"},o){this.checkRequiredCredentials();const t=this.safeString(this.options,"recvWindow"),s=this.safeString(u,"recvWindow",t),o=this.numberToString(this.nonce());if(a=u,"/v4/order"===c||"/future/trade/v1/order/create"===c||"/future/trade/v1/entrust/create-plan"===c||"/future/trade/v1/entrust/create-profit"===c||"/future/trade/v1/order/create-batch"===c){const e="CCXT";c.indexOf("future")>-1?a.clientMedia=e:a.media=e}let h,p="GET"===i||"order/{orderId}"===e||"ws-token"===e;"PUT"===i&&"spot"===d&&(p=!1),a=p?void 0:this.json(a),"spot"===d||"user"===d?(h="xt-validate-algorithms=HmacSHA256&xt-validate-appkey="+this.apiKey+"&xt-validate-recvwindow="+s+"&xt-validate-timestamp="+o,p?f?(l+="?"+f,h+="#"+i+"#"+c+"#"+this.rawencode(this.keysort(u))):h+="#"+i+"#"+c:h+="#"+i+"#"+c+"#"+a,r["xt-validate-algorithms"]="HmacSHA256",r["xt-validate-recvwindow"]=s):(h="xt-validate-appkey="+this.apiKey+"&xt-validate-timestamp="+o,"GET"===i?f?(l+="?"+f,h+="#"+c+"#"+f):h+="#"+c:h+="#"+c+"#"+a);const m=this.hmac(this.encode(h),this.encode(this.secret),n.s);r["xt-validate-appkey"]=this.apiKey,r["xt-validate-timestamp"]=o,r["xt-validate-signature"]=m}else f&&(l+="?"+f);return{url:l,method:i,body:a,headers:r}}}},87469:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(13578),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"yobit",name:"YoBit",countries:["RU"],rateLimit:2e3,version:"3",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0,ws:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpg",api:{public:"https://yobit.net/api",private:"https://yobit.net/tapi"},www:"https://www.yobit.net",doc:"https://www.yobit.net/en/api/",fees:"https://www.yobit.net/en/fees/"},api:{public:{get:{"depth/{pair}":1,info:1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{ActiveOrders:1,CancelOrder:1,GetDepositAddress:1,getInfo:1,OrderInfo:1,Trade:1,TradeHistory:1,WithdrawCoinsToAddress:1}}},fees:{trading:{maker:.002,taker:.002},funding:{withdraw:{}}},commonCurrencies:{AIR:"AirCoin",ANI:"ANICoin",ANT:"AntsCoin",ATMCHA:"ATM",ASN:"Ascension",AST:"Astral",ATM:"Autumncoin",AUR:"AuroraCoin",BAB:"Babel",BAN:"BANcoin",BCC:"BCH",BCS:"BitcoinStake",BITS:"Bitstar",BLN:"Bulleon",BNS:"Benefit Bonus Coin",BOT:"BOTcoin",BON:"BONES",BPC:"BitcoinPremium",BST:"BitStone",BTS:"Bitshares2",CAT:"BitClave",CBC:"CryptoBossCoin",CMT:"CometCoin",COIN:"Coin.com",COV:"Coven Coin",COVX:"COV",CPC:"Capricoin",CREDIT:"Creditbit",CS:"CryptoSpots",DCT:"Discount",DFT:"DraftCoin",DGD:"DarkGoldCoin",DIRT:"DIRTY",DROP:"FaucetCoin",DSH:"DASH",EGC:"EverGreenCoin",EGG:"EggCoin",EKO:"EkoCoin",ENTER:"ENTRC",EPC:"ExperienceCoin",ESC:"EdwardSnowden",EUROPE:"EUROP",EXT:"LifeExtension",FUND:"FUNDChains",FUNK:"FUNKCoin",FX:"FCoin",GCC:"GlobalCryptocurrency",GEN:"Genstake",GENE:"Genesiscoin",GMR:"Gimmer",GOLD:"GoldMint",GOT:"Giotto Coin",GSX:"GlowShares",GT:"GTcoin",HTML5:"HTML",HYPERX:"HYPER",ICN:"iCoin",INSANE:"INSN",JNT:"JointCoin",JPC:"JupiterCoin",JWL:"Jewels",KNC:"KingN Coin",LBTCX:"LiteBitcoin",LIZI:"LiZi",LOC:"LocoCoin",LOCX:"LOC",LUNYR:"LUN",LUN:"LunarCoin",LUNA:"Luna Coin",MASK:"Yobit MASK",MDT:"Midnight",MEME:"Memez Token",MIS:"MIScoin",MM:"MasterMint",NAV:"NavajoCoin",NBT:"NiceBytes",OMG:"OMGame",ONX:"Onix",PAC:"$PAC",PLAY:"PlayCoin",PIVX:"Darknet",PURE:"PurePOS",PUTIN:"PutinCoin",SPACE:"Spacecoin",STK:"StakeCoin",SUB:"Subscriptio",PAY:"EPAY",PLC:"Platin Coin",RAI:"RaiderCoin",RCN:"RCoin",REP:"Republicoin",RUR:"RUB",SBTC:"Super Bitcoin",SMC:"SmartCoin",SOLO:"SoloCoin",SOUL:"SoulCoin",STAR:"StarCoin",SUPER:"SuperCoin",TNS:"Transcodium",TTC:"TittieCoin",UNI:"Universe",UST:"Uservice",VOL:"VolumeCoin",XIN:"XINCoin",XMT:"SummitCoin",XRA:"Ratecoin",BCHN:"BSV"},options:{maxUrlLength:2048,fetchOrdersRequiresSymbol:!0,networks:{ETH:"ERC20",TRX:"TRC20",BSC:"BEP20"}},precisionMode:o.kb,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"The given order has already been cancelled":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"Total transaction amount":r.InvalidOrder,"The given order has already been closed and cannot be cancelled":r.InvalidOrder,"Insufficient funds":r.InsufficientFunds,"invalid key":r.AuthenticationError,"invalid nonce":r.InvalidNonce,"Total order amount is less than minimal amount":r.InvalidOrder,"Rate Limited":r.RateLimitExceeded}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},orders:{}})}parseBalance(e){const t=this.safeDict(e,"return",{}),i=this.safeInteger(t,"server_time"),s={info:e,timestamp:i,datetime:this.iso8601(i)},r=this.safeDict(t,"funds",{}),a=this.safeDict(t,"funds_incl_orders",{}),o=Object.keys(this.extend(r,a));for(let e=0;e<o.length;e++){const t=o[e],i=this.safeCurrencyCode(t),n=this.account();n.free=this.safeString(r,t),n.total=this.safeString(a,t),s[i]=n}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchMarkets(e={}){const t=await this.publicGetInfo(e),i=this.safeDict(t,"pairs",{}),s=Object.keys(i),r=[];for(let e=0;e<s.length;e++){const t=s[e],o=i[t],[n,d]=t.split("_");let h=n.toUpperCase(),c=d.toUpperCase();h=this.safeCurrencyCode(h),c=this.safeCurrencyCode(c);const l=this.safeInteger(o,"hidden");let u=this.safeString(o,"fee");u=a.Y.stringDiv(u,"100"),r.push({id:t,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:n,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),maker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(o,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(o,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(o,"min_amount"),max:this.safeNumber(o,"max_amount")},price:{min:this.safeNumber(o,"min_price"),max:this.safeNumber(o,"max_price")},cost:{min:this.safeNumber(o,"min_total"),max:void 0}},created:void 0,info:o})}return r}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),a={pair:s.id};void 0!==t&&(a.limit=t);const o=await this.publicGetDepthPair(this.extend(a,i));if(!(s.id in o))throw new r.ExchangeError(this.id+" "+s.symbol+" order book is empty or not available");const n=o[s.id];return this.parseOrderBook(n,e)}async fetchOrderBooks(e=void 0,t=void 0,i={}){let s;if(await this.loadMarkets(),void 0===e){if(s=this.ids.join("-"),s.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else s=this.marketIds(e),s=s.join("-");const a={pair:s};void 0!==t&&(a.limit=t);const o=await this.publicGetDepthPair(this.extend(a,i)),n={};s=Object.keys(o);for(let e=0;e<s.length;e++){const t=s[e],i=this.safeSymbol(t);n[i]=this.parseOrderBook(o[t],i)}return n}parseTicker(e,t=void 0){const i=this.safeTimestamp(e,"updated"),s=this.safeString(e,"last");return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:s,last:s,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickersHelper(e,t={}){const i={pair:e},s=await this.publicGetTickerPair(this.extend(i,t)),r={},a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e],i=s[t],o=this.safeMarket(t);r[o.symbol]=this.parseTicker(i,o)}return r}async fetchTickers(e=void 0,t={}){let i;if([i,t]=this.handleParamBool(t,"all",!1),void 0===e&&!i)throw new r.ArgumentsRequired(this.id+' fetchTickers() requires "symbols" argument or use `params["all"] = true` to send multiple requests for all markets');await this.loadMarkets();const s=[],a=this.safeInteger(this.options,"maxUrlLength",2048);if(i){e=this.symbols;let i="";for(let e=0;e<this.ids.length;e++){i+=(""===i?"":"-")+this.ids[e],i.length>a&&(s.push(this.fetchTickersHelper(i,t)),i="")}""!==i&&s.push(this.fetchTickersHelper(i,t))}else{e=this.marketSymbols(e);const i=this.marketIds(e),o=i.length,n=i.join("-"),d=n.length+40;if(d>a)throw new r.ArgumentsRequired(this.id+" fetchTickers() is being requested for "+o.toString()+" markets (which has an URL length of "+d.toString()+" characters), but it exceedes max URL length ("+a.toString()+"), please pass limisted symbols array to fetchTickers to fit in one request");s.push(this.fetchTickersHelper(n,t))}const o=await Promise.all(s);let n={};for(let t=0;t<o.length;t++){const i=this.filterByArrayTickers(o[t],"symbol",e);n=this.extend(n,i)}return n}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=void 0){const i=this.safeTimestamp(e,"timestamp");let s=this.safeString(e,"type");"ask"===s?s="sell":"bid"===s&&(s="buy");const r=this.safeString2(e,"rate","price"),a=this.safeString2(e,"trade_id","tid"),o=this.safeString(e,"order_id"),n=this.safeString(e,"pair"),d=this.safeSymbol(n,t),h=this.safeString(e,"amount"),c=this.parseNumber(r),l=this.parseNumber(h),u="limit";let f;const p=this.safeNumber(e,"commission");if(void 0!==p){const t=this.safeString(e,"commissionCurrency");f={cost:p,currency:this.safeCurrencyCode(t)}}if(void 0!==this.safeString(e,"is_your_order")&&void 0===f){const e=this.calculateFee(d,u,s,l,c,"taker");f={currency:this.safeString(e,"currency"),cost:this.safeString(e,"cost"),rate:this.safeString(e,"rate")}}return this.safeTrade({id:a,order:o,timestamp:i,datetime:this.iso8601(i),symbol:d,type:u,side:s,takerOrMaker:void 0,price:r,amount:h,cost:void 0,fee:f,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==i&&(a.limit=i);const o=await this.publicGetTradesPair(this.extend(a,s));if(Array.isArray(o)){if(0===o.length)return[]}const n=this.safeList(o,r.id,[]);return this.parseTrades(n,r,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.publicGetInfo(e),i=this.safeDict(t,"pairs",{}),s=Object.keys(i),r={};for(let e=0;e<s.length;e++){const t=s[e],o=this.safeDict(i,t,{}),n=this.safeSymbol(t,void 0,"_"),d=this.safeString(o,"fee_buyer"),h=this.safeString(o,"fee_seller"),c=this.parseNumber(a.Y.stringDiv(d,"100")),l=this.parseNumber(a.Y.stringDiv(h,"100"));r[n]={info:o,symbol:n,taker:c,maker:l,percentage:!0,tierBased:!1}}return r}async createOrder(e,t,i,s,a=void 0,o={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");await this.loadMarkets();const n=this.market(e),d={pair:n.id,type:i,amount:this.amountToPrecision(e,s),rate:this.priceToPrecision(e,a)},h=await this.privatePostTrade(this.extend(d,o)),c=this.safeDict(h,"return");return this.parseOrder(c,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={order_id:parseInt(e)},r=await this.privatePostCancelOrder(this.extend(s,i)),a=this.safeDict(r,"return",{});return this.parseOrder(a)}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"open"},e,e)}parseOrder(e,t=void 0){let i=this.safeString2(e,"id","order_id"),s=this.parseOrderStatus(this.safeString(e,"status","open"));"0"===i&&(i=this.safeString(e,"init_order_id"),s="closed");const r=this.safeTimestamp2(e,"timestamp_created","server_time"),a=this.safeString(e,"pair"),o=this.safeSymbol(a,t),n=this.safeString(e,"start_amount"),d=this.safeString2(e,"amount","remains"),h=this.safeString(e,"received","0.0"),c=this.safeString(e,"rate"),l=this.safeString(e,"type");return this.safeOrder({info:e,id:i,clientOrderId:void 0,symbol:o,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:l,price:c,triggerPrice:void 0,cost:void 0,amount:n,remaining:d,filled:h,status:s,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(s,i));e=e.toString();const a=this.safeDict(r,"return",{});return this.parseOrder(this.extend({id:e},a[e]))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a={};if(void 0!==e){const t=this.market(e);a.pair=t.id}const o=await this.privatePostActiveOrders(this.extend(a,s)),n=this.safeDict(o,"return",{});return this.parseOrders(n,undefined,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={pair:a.id};void 0!==i&&(o.count=i),void 0!==t&&(o.since=this.parseToInt(t/1e3));const n=await this.privatePostTradeHistory(this.extend(o,s)),d=this.safeDict(n,"return",{}),h=Object.keys(d),c=[];for(let e=0;e<h.length;e++){const t=this.safeString(h,e),i=this.parseTrade(this.extend(d[t],{trade_id:t}),a);c.push(i)}return this.filterBySymbolSinceLimit(c,a.symbol,t,i)}async createDepositAddress(e,t={}){const i=await this.fetchDepositAddress(e,this.extend({need_new:1},t)),s=this.safeString(i,"address");return this.checkAddress(s),{currency:e,address:s,tag:void 0,network:void 0,info:i.info}}async fetchDepositAddress(e,t={}){await this.loadMarkets();let i=this.currency(e).id;const s=this.safeDict(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(s,r,r),void 0!==r&&("ERC20"!==r&&(i+=r.toLowerCase()),t=this.omit(t,"network"));const a={coinName:i,need_new:0},o=await this.privatePostGetDepositAddress(this.extend(a,t)),n=this.safeString(o.return,"address");return this.checkAddress(n),{info:o,currency:e,network:void 0,address:n,tag:void 0}}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),this.checkAddress(i),await this.loadMarkets();const o={coinName:this.currency(e).id,amount:t,address:i};if(void 0!==s)throw new r.ExchangeError(this.id+" withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.");return{info:await this.privatePostWithdrawCoinsToAddress(this.extend(o,a)),id:void 0,txid:void 0,type:void 0,currency:void 0,network:void 0,amount:void 0,status:void 0,timestamp:void 0,datetime:void 0,address:void 0,addressFrom:void 0,addressTo:void 0,tag:void 0,tagFrom:void 0,tagTo:void 0,updated:void 0,comment:void 0,fee:{currency:void 0,cost:void 0,rate:void 0}}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t];const d=this.omit(s,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const i=this.hmac(this.encode(a),this.encode(this.secret),n.Zf);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:i}}else"public"===t?(o+="/"+this.version+"/"+this.implodeParams(e,s),Object.keys(d).length&&(o+="?"+this.urlencode(d))):(o+="/"+this.implodeParams(e,s),"GET"===i?Object.keys(d).length&&(o+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n&&"success"in n){let e=this.safeValue(n,"success");if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(n,"code"),t=this.safeString(n,"error"),i=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,i),this.throwExactlyMatchedException(this.exceptions.exact,t,i),this.throwBroadlyMatchedException(this.exceptions.broad,t,i),new r.ExchangeError(i)}}}}},1530:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(58291),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zaif",name:"Zaif",countries:["JP"],rateLimit:100,version:"1",has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766927-39ca2ada-5eeb-11e7-972f-1b4199518ca6.jpg",api:{rest:"https://api.zaif.jp"},www:"https://zaif.jp",doc:["https://techbureau-api-document.readthedocs.io/ja/latest/index.html","https://corp.zaif.jp/api-docs","https://corp.zaif.jp/api-docs/api_links","https://www.npmjs.com/package/zaif.jp","https://github.com/you21979/node-zaif"],fees:"https://zaif.jp/fee?lang=en"},fees:{trading:{percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0")}},api:{public:{get:{"depth/{pair}":1,"currencies/{pair}":1,"currencies/all":1,"currency_pairs/{pair}":1,"currency_pairs/all":1,"last_price/{pair}":1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{active_orders:5,cancel_order:5,deposit_history:5,get_id_info:5,get_info:10,get_info2:5,get_personal_info:5,trade:5,trade_history:50,withdraw:5,withdraw_history:5}},ecapi:{post:{createInvoice:1,getInvoice:1,getInvoiceIdsByOrderNumber:1,cancelInvoice:1}},tlapi:{post:{get_positions:66,position_history:66,active_positions:5,create_position:33,change_position:33,cancel_position:33}},fapi:{get:{"groups/{group_id}":1,"last_price/{group_id}/{pair}":1,"ticker/{group_id}/{pair}":1,"trades/{group_id}/{pair}":1,"depth/{group_id}/{pair}":1}}},options:{},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!0,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:void 0,fetchOpenOrders:{marginMode:!0,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"unsupported currency_pair":r.BadRequest},broad:{}}})}async fetchMarkets(e={}){const t=await this.publicGetCurrencyPairsAll(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"currency_pair"),i=this.safeString(e,"name"),[s,r]=i.split("/"),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r);return{id:t,symbol:a+"/"+o,base:a,quote:o,settle:void 0,baseId:s,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"item_unit_step"),price:this.parseNumber(this.parsePrecision(this.safeString(e,"aux_unit_point")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"item_unit_min"),max:void 0},price:{min:this.safeNumber(e,"aux_unit_min"),max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}parseBalance(e){const t=this.safeValue(e,"return",{}),i=this.safeValue(t,"deposit"),s={info:e,timestamp:void 0,datetime:void 0},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],o=this.safeCurrencyCode(t),n=this.safeString(r,t),d=this.account();d.free=n,d.total=n,void 0!==i&&t in i&&(d.total=this.safeString(i,t)),s[o]=d}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={pair:s.id},a=await this.publicGetDepthPair(this.extend(r,i));return this.parseOrderBook(a,s.symbol)}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeString(e,"vwap"),r=this.safeString(e,"volume"),o=a.Y.stringMul(r,s),n=this.safeString(e,"last");return this.safeTicker({symbol:i,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:s,open:void 0,close:n,last:n,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:r,quoteVolume:o,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pair:i.id},r=await this.publicGetTickerPair(this.extend(s,t));return this.parseTicker(r,i)}parseTrade(e,t=void 0){let i=this.safeString(e,"trade_type");i="bid"===i?"buy":"sell";const s=this.safeTimestamp(e,"date"),r=this.safeString2(e,"id","tid"),a=this.safeString(e,"price"),o=this.safeString(e,"amount"),n=this.safeString(e,"currency_pair"),d=this.safeSymbol(n,t,"_");return this.safeTrade({id:r,info:e,timestamp:s,datetime:this.iso8601(s),symbol:d,type:void 0,side:i,order:void 0,takerOrMaker:void 0,price:a,amount:o,cost:void 0,fee:void 0},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};let o=await this.publicGetTradesPair(this.extend(a,s));if(1===o.length){const e=o[0];Object.keys(e).length||(o=[])}return this.parseTrades(o,r,t,i)}async createOrder(e,t,i,s,a=void 0,o={}){if(await this.loadMarkets(),"limit"!==t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const n=this.market(e),d={currency_pair:n.id,action:"buy"===i?"bid":"ask",amount:s,price:a},h=await this.privatePostTrade(this.extend(d,o));return this.safeOrder({info:h,id:h.return.order_id.toString()},n)}async cancelOrder(e,t=void 0,i={}){const s={order_id:e},r=await this.privatePostCancelOrder(this.extend(s,i)),a=this.safeDict(r,"return");return this.parseOrder(a)}parseOrder(e,t=void 0){let i=this.safeString(e,"action");i="bid"===i?"buy":"sell";const s=this.safeTimestamp(e,"timestamp"),r=this.safeString(e,"currency_pair"),a=this.safeSymbol(r,t,"_"),o=this.safeString(e,"price"),n=this.safeString(e,"amount"),d=this.safeString2(e,"id","order_id");return this.safeOrder({id:d,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,status:"open",symbol:a,type:"limit",timeInForce:void 0,postOnly:void 0,side:i,price:o,triggerPrice:void 0,cost:void 0,amount:n,filled:void 0,remaining:void 0,trades:void 0,fee:void 0,info:e,average:void 0},t)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const o=await this.privatePostActiveOrders(this.extend(a,s));return this.parseOrders(o.return,r,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const o=await this.privatePostTradeHistory(this.extend(a,s));return this.parseOrders(o.return,r,t,i)}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),this.checkAddress(i),await this.loadMarkets();const o=this.currency(e);if("JPY"===e)throw new r.ExchangeError(this.id+" withdraw() does not allow "+e+" withdrawals");const n={currency:o.id,amount:t,address:i};void 0!==s&&(n.message=s);const d=await this.privatePostWithdraw(this.extend(n,a)),h=this.safeDict(d,"return");return this.parseTransaction(h,o)}parseTransaction(e,t=void 0){let i;t=this.safeCurrency(void 0,t);const s=this.safeValue(e,"fee");return void 0!==s&&(i={cost:s,currency:t.code}),{id:this.safeString(e,"id"),txid:this.safeString(e,"txid"),timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:i,info:e}}customNonce(){const e=this.numberToString(this.milliseconds()/1e3);return parseFloat(e).toFixed(8)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api.rest+"/";if("public"===t)o+="api/"+this.version+"/"+this.implodeParams(e,s);else if("fapi"===t)o+="fapi/"+this.version+"/"+this.implodeParams(e,s);else{this.checkRequiredCredentials(),o+="ecapi"===t?"ecapi":"tlapi"===t?"tlapi":"tapi";const i=this.customNonce();a=this.urlencode(this.extend({method:e,nonce:i},s)),r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:this.hmac(this.encode(a),this.encode(this.secret),n.Zf)}}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.id+" "+o,l=this.safeString(n,"error");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c);if(!this.safeBool(n,"success",!0))throw new r.ExchangeError(c)}}},20285:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarafza",name:"Zarafza",countries:["IR"],rateLimit:1e3,version:"v2",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.zarafza.com"},www:"https://zarafza.com",doc:"https://api.zarafza.com/v2/prices"},api:{public:{get:{"v2/prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV2Prices(e);return[this.parseMarket(t)]}parseMarket(e){const t=this.safeDict(e,"data",{}),i=this.safeDict(t,"G18",{}),s=this.safeDict(i,"sell",{});return{id:"G18",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"G18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(s,"price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV2Prices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV2Prices(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"data",{}),s=this.safeDict(i,"G18",{}),r=this.safeDict(s,"buy",{}),a=this.safeDict(s,"sell",{}),o=this.safeNumber(a,"price"),n=this.safeNumber(r,"price");let d=o;return void 0!==n&&(void 0===d||n>d)&&(d=n),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:o,bidVolume:void 0,ask:n,askVolume:void 0,vwap:void 0,open:void 0,close:d,last:d,previousClose:void 0,change:void 0,percentage:this.safeNumber(a,"change"),average:void 0,baseVolume:this.safeNumber(s,"volume"),quoteVolume:void 0,info:s},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},57562:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarminex",name:"Zarminex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.zarminex.ir"},www:"https://zarminex.ir",doc:"https://api.zarminex.ir/function_url/"},api:{public:{get:{function_url:1}}}})}async fetchMarkets(e={}){const t=await this.publicGetFunctionUrl(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"cached_price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetFunctionUrl(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetFunctionUrl(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){let i=this.safeNumber(e,"buy"),s=this.safeNumber(e,"sell");void 0!==i&&(i/=10),void 0!==s&&(s/=10);let r=i;return void 0!==s&&(void 0===r||s>r)&&(r=s),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:i,bidVolume:void 0,ask:s,askVolume:void 0,vwap:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},93290:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarniv",name:"Zarniv",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://zarniv.ir"},www:"https://zarniv.ir",doc:"https://zarniv.ir/user/get_gold_price/"},api:{public:{get:{"user/get_gold_price":1,"user/get_silver_price":1}}}})}fetchPrice(e,t={}){return"gold"===e?this.publicGetUserGetGoldPrice(t):this.publicGetUserGetSilverPrice(t)}async fetchMarkets(e={}){const t=await this.fetchPrice("gold",e),i=await this.fetchPrice("silver",e);return[this.parseMarketEntry(t,"gold"),this.parseMarketEntry(i,"silver")]}parseMarketEntry(e,t){let i="XAG-1G";"gold"===t&&(i="XAU18");const s="IRT";return{id:i+s,symbol:i+"/"+s,base:i,quote:s,settle:void 0,baseId:t,quoteId:s,settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"base_price_per_gram"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.fetchPrice(i.baseId,t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.fetchPrice("gold",t),s=await this.fetchPrice("silver",t),r=this.market("XAU18/IRT"),a=this.market("XAG-1G/IRT"),o=this.parseTicker(i,r),n=this.parseTicker(s,a),d={};return d[o.symbol]=o,d[n.symbol]=n,this.filterByArrayTickers(d,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeString(e,"server_time");let s;void 0!==i&&(s=this.parse8601(i+"+03:30"));const r=this.safeNumber(e,"buy_price_per_gram"),a=this.safeNumber(e,"sell_price_per_gram");let o=r;return void 0!==a&&(void 0===o||a>o)&&(o=a),this.safeTicker({symbol:t.symbol,timestamp:s,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:a,askVolume:void 0,vwap:void 0,open:void 0,close:o,last:o,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},30528:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarpin",name:"Zarpin",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api-khazaneh.zarpin.com"},www:"https://zarpin.com",doc:"https://api-khazaneh.zarpin.com/v1/prc/prices"},api:{public:{get:{"v1/prc/prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV1PrcPrices(e);return this.parseMarkets(t)}parseMarkets(e){let t=[];Array.isArray(e)&&(t=e);const i=[];for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"code");"GOLD_IRT"!==r&&"SILVER_IRT"!==r||i.push(this.parseMarket(s))}return i}parseMarket(e){const t=this.safeString(e,"code");let i="XAG-1G";"GOLD_IRT"===t&&(i="XAU18");const s="IRT";return{id:t,symbol:i+"/"+s,base:i,quote:s,settle:void 0,baseId:t,quoteId:s,settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1PrcPrices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1PrcPrices(t),s=this.parseMarkets(i),r={};for(let e=0;e<s.length;e++){const t=this.parseTicker(i,s[e]);r[t.symbol]=t}return this.filterByArrayTickers(r,"symbol",e)}parseTicker(e,t=void 0){let i=[];Array.isArray(e)&&(i=e);let s={};for(let e=0;e<i.length;e++){const r=i[e];if(this.safeString(r,"code")===t.baseId){s=r;break}}return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeNumber(s,"max_24h_price"),low:this.safeNumber(s,"min_24h_price"),bid:this.safeNumber(s,"price"),bidVolume:void 0,ask:this.safeNumber(s,"price"),askVolume:void 0,vwap:void 0,open:this.safeNumber(s,"price_at_in_last_24h"),close:this.safeNumber(s,"price"),last:this.safeNumber(s,"price"),previousClose:this.safeNumber(s,"price_at_in_last_24h"),change:void 0,percentage:this.safeNumber(s,"price_change_24h"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:s},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},46022:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(65517),r=i(62079),a=i(51579),o=i(85147),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zonda",name:"Zonda",countries:["EE"],rateLimit:1e3,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:void 0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchOrderBooks:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:void 0,fetchTransfer:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:void 0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"60","3m":"180","5m":"300","15m":"900","30m":"1800","1h":"3600","2h":"7200","4h":"14400","6h":"21600","12h":"43200","1d":"86400","3d":"259200","1w":"604800"},hostname:"zondacrypto.exchange",urls:{referral:"https://auth.zondaglobal.com/ref/jHlbB4mIkdS1",logo:"https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg",www:"https://zondaglobal.com",api:{public:"https://{hostname}/API/Public",private:"https://{hostname}/API/Trading/tradingApi.php",v1_01Public:"https://api.{hostname}/rest",v1_01Private:"https://api.{hostname}/rest"},doc:["https://docs.zondacrypto.exchange/","https://github.com/BitBayNet/API"],support:"https://zondaglobal.com/en/helpdesk/zonda-exchange",fees:"https://zondaglobal.com/legal/zonda-exchange/fees"},api:{public:{get:["{id}/all","{id}/market","{id}/orderbook","{id}/ticker","{id}/trades"]},private:{post:["info","trade","cancel","orderbook","orders","transfer","withdraw","history","transactions"]},v1_01Public:{get:["trading/ticker","trading/ticker/{symbol}","trading/stats","trading/stats/{symbol}","trading/orderbook/{symbol}","trading/transactions/{symbol}","trading/candle/history/{symbol}/{resolution}"]},v1_01Private:{get:["api_payments/deposits/crypto/addresses","payments/withdrawal/{detailId}","payments/deposit/{detailId}","trading/offer","trading/stop/offer","trading/config/{symbol}","trading/history/transactions","balances/BITBAY/history","balances/BITBAY/balance","fiat_cantor/rate/{baseId}/{quoteId}","fiat_cantor/history","client_payments/v2/customer/crypto/{currency}/channels/deposit","client_payments/v2/customer/crypto/{currency}/channels/withdrawal","client_payments/v2/customer/crypto/deposit/fee","client_payments/v2/customer/crypto/withdrawal/fee"],post:["trading/offer/{symbol}","trading/stop/offer/{symbol}","trading/config/{symbol}","balances/BITBAY/balance","balances/BITBAY/balance/transfer/{source}/{destination}","fiat_cantor/exchange","api_payments/withdrawals/crypto","api_payments/withdrawals/fiat","client_payments/v2/customer/crypto/deposit","client_payments/v2/customer/crypto/withdrawal"],delete:["trading/offer/{symbol}/{id}/{side}/{price}","trading/stop/offer/{symbol}/{id}/{side}/{price}"],put:["balances/BITBAY/balance/{id}"]}},fees:{trading:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.001"),percentage:!0,tierBased:!1},fiat:{maker:this.parseNumber("0.0030"),taker:this.parseNumber("0.0043"),percentage:!0,tierBased:!0,tiers:{taker:[[this.parseNumber("0.0043"),this.parseNumber("0")],[this.parseNumber("0.0042"),this.parseNumber("1250")],[this.parseNumber("0.0041"),this.parseNumber("3750")],[this.parseNumber("0.0040"),this.parseNumber("7500")],[this.parseNumber("0.0039"),this.parseNumber("10000")],[this.parseNumber("0.0038"),this.parseNumber("15000")],[this.parseNumber("0.0037"),this.parseNumber("20000")],[this.parseNumber("0.0036"),this.parseNumber("25000")],[this.parseNumber("0.0035"),this.parseNumber("37500")],[this.parseNumber("0.0034"),this.parseNumber("50000")],[this.parseNumber("0.0033"),this.parseNumber("75000")],[this.parseNumber("0.0032"),this.parseNumber("100000")],[this.parseNumber("0.0031"),this.parseNumber("150000")],[this.parseNumber("0.0030"),this.parseNumber("200000")],[this.parseNumber("0.0029"),this.parseNumber("250000")],[this.parseNumber("0.0028"),this.parseNumber("375000")],[this.parseNumber("0.0027"),this.parseNumber("500000")],[this.parseNumber("0.0026"),this.parseNumber("625000")],[this.parseNumber("0.0025"),this.parseNumber("875000")]],maker:[[this.parseNumber("0.0030"),this.parseNumber("0")],[this.parseNumber("0.0029"),this.parseNumber("1250")],[this.parseNumber("0.0028"),this.parseNumber("3750")],[this.parseNumber("0.0028"),this.parseNumber("7500")],[this.parseNumber("0.0027"),this.parseNumber("10000")],[this.parseNumber("0.0026"),this.parseNumber("15000")],[this.parseNumber("0.0025"),this.parseNumber("20000")],[this.parseNumber("0.0025"),this.parseNumber("25000")],[this.parseNumber("0.0024"),this.parseNumber("37500")],[this.parseNumber("0.0023"),this.parseNumber("50000")],[this.parseNumber("0.0023"),this.parseNumber("75000")],[this.parseNumber("0.0022"),this.parseNumber("100000")],[this.parseNumber("0.0021"),this.parseNumber("150000")],[this.parseNumber("0.0021"),this.parseNumber("200000")],[this.parseNumber("0.0020"),this.parseNumber("250000")],[this.parseNumber("0.0019"),this.parseNumber("375000")],[this.parseNumber("0.0018"),this.parseNumber("500000")],[this.parseNumber("0.0018"),this.parseNumber("625000")],[this.parseNumber("0.0017"),this.parseNumber("875000")]]}},funding:{withdraw:{}}},options:{fetchTickerMethod:"v1_01PublicGetTradingTickerSymbol",fetchTickersMethod:"v1_01PublicGetTradingTicker",fiatCurrencies:["EUR","USD","GBP","PLN"],transfer:{fillResponseFromRequest:!0}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb,exceptions:{400:r.ExchangeError,401:r.InvalidOrder,402:r.InvalidOrder,403:r.InvalidOrder,404:r.InvalidOrder,405:r.InvalidOrder,406:r.InsufficientFunds,408:r.InvalidOrder,501:r.AuthenticationError,502:r.AuthenticationError,503:r.InvalidNonce,504:r.ExchangeError,505:r.AuthenticationError,506:r.AccountSuspended,509:r.ExchangeError,510:r.BadSymbol,FUNDS_NOT_SUFFICIENT:r.InsufficientFunds,OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS:r.InvalidOrder,OFFER_NOT_FOUND:r.OrderNotFound,OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED:r.OrderImmediatelyFillable,ACTION_LIMIT_EXCEEDED:r.RateLimitExceeded,UNDER_MAINTENANCE:r.OnMaintenance,REQUEST_TIMESTAMP_TOO_OLD:r.InvalidNonce,PERMISSIONS_NOT_SUFFICIENT:r.PermissionDenied,INVALID_STOP_RATE:r.InvalidOrder,TIMEOUT:r.ExchangeError,RESPONSE_TIMEOUT:r.ExchangeError,ACTION_BLOCKED:r.PermissionDenied,INVALID_HASH_SIGNATURE:r.AuthenticationError},commonCurrencies:{GGC:"Global Game Coin"}})}async fetchMarkets(e={}){const t=await this.v1_01PublicGetTradingTicker(e),i=this.safeValue(t,"items",{}),s=Object.values(i);return this.parseMarkets(s)}parseMarket(e){const t=this.safeValue(e,"market",{}),i=this.safeString(t,"code"),s=this.safeValue(t,"first",{}),r=this.safeValue(t,"second",{}),a=this.safeString(s,"currency"),o=this.safeString(r,"currency"),n=this.safeCurrencyCode(a),d=this.safeCurrencyCode(o);let h=this.safeValue(this.fees,"trading",{});const c=this.safeValue(this.options,"fiatCurrencies",[]);return(this.inArray(n,c)||this.inArray(d,c))&&(h=this.safeValue(this.fees,"fiat",{})),{id:i,symbol:n+"/"+d,base:n,quote:d,settle:void 0,baseId:a,quoteId:o,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(h,"taker"),maker:this.safeNumber(h,"maker"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,optionType:void 0,strike:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(s,"scale"))),price:this.parseNumber(this.parsePrecision(this.safeString(r,"scale")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(s,"minOffer"),max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=await this.v1_01PrivateGetTradingOffer(this.extend({},s)),a=this.safeList(r,"items",[]);return this.parseOrders(a,void 0,t,i,{status:"open"})}parseOrder(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"-"),r=this.safeInteger(e,"time"),a=this.safeString(e,"startAmount"),o=this.safeString(e,"currentAmount"),n=this.safeValue(e,"postOnly");return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:void 0,info:e,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,status:void 0,symbol:s,type:this.safeString(e,"mode"),timeInForce:void 0,postOnly:n,side:this.safeStringLower(e,"offerType"),price:this.safeString(e,"rate"),triggerPrice:void 0,amount:a,cost:void 0,filled:void 0,remaining:o,average:void 0,fee:void 0,trades:void 0},t)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};if(e){const t=[this.marketId(e)];e=this.symbol(e),r.markets=t}const a={query:this.json(this.extend(r,s))},o=await this.v1_01PrivateGetTradingHistoryTransactions(a),n=this.safeValue(o,"items"),d=this.parseTrades(n,void 0,t,i);return void 0===e?d:this.filterBySymbol(d,e)}parseBalance(e){const t=this.safeValue(e,"balances");if(void 0===t)throw new r.ExchangeError(this.id+" empty balance response "+this.json(e));const i={info:e};for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.used=this.safeString(s,"lockedFunds"),o.free=this.safeString(s,"availableFunds"),i[a]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1_01PrivateGetBalancesBITBAYBalance(e);return this.parseBalance(t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={symbol:s.id},a=await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(r,i)),o=this.safeValue(a,"buy",[]),n=this.safeValue(a,"sell",[]),d=this.safeInteger(a,"timestamp");return{symbol:s.symbol,bids:this.parseBidsAsks(o,"ra","ca"),asks:this.parseBidsAsks(n,"ra","ca"),timestamp:d,datetime:this.iso8601(d),nonce:this.safeInteger(a,"seqNo")}}parseTicker(e,t=void 0){const i=this.safeValue(e,"market"),s=this.safeString2(i,"code","m");t=this.safeMarket(s,t);const r=this.safeInteger(e,"time"),a=this.safeValue(e,"rate");return this.safeTicker({symbol:this.safeSymbol(s,t),timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"h"),low:this.safeString(e,"l"),bid:this.safeNumber(e,"highestBid"),bidVolume:void 0,ask:this.safeNumber(e,"lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"r24h"),close:a,last:a,previousClose:this.safeValue(e,"previousRate"),change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"v"),quoteVolume:void 0,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},a="v1_01PublicGetTradingTickerSymbol",o=this.safeString(this.options,"fetchTickerMethod",a),n=this.safeString2(t,"method","fetchTickerMethod",o);let d;if(n===a)d=await this.v1_01PublicGetTradingTickerSymbol(this.extend(s,t));else{if("v1_01PublicGetTradingStatsSymbol"!==n)throw new r.BadRequest(this.id+' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');d=await this.v1_01PublicGetTradingStatsSymbol(this.extend(s,t))}const h=this.safeValue2(d,"ticker","stats");return this.parseTicker(h,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i="v1_01PublicGetTradingTicker",s=this.safeString(this.options,"fetchTickersMethod",i),a=this.safeString2(t,"method","fetchTickersMethod",s);let o;if(a===i)o=await this.v1_01PublicGetTradingTicker(t);else{if("v1_01PublicGetTradingStats"!==a)throw new r.BadRequest(this.id+' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');o=await this.v1_01PublicGetTradingStats(t)}const n=this.safeDict(o,"items");return this.parseTickers(n,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=[];if(void 0!==e){const t=this.currency(e);r.push(t.id)}let a={balanceCurrencies:r};void 0!==t&&(a.fromTime=t),void 0!==i&&(a.limit=i),a=this.extend(a,s);const o=(await this.v1_01PrivateGetBalancesBITBAYHistory({query:this.json(a)})).items;return this.parseLedger(o,void 0,t,i)}parseLedgerEntry(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeValue(e,"balance",{}),r=this.safeString(s,"currency");t=this.safeCurrency(r,t);const a=this.safeValue(e,"change",{});let n=this.safeString(a,"total"),d="in";o.Y.stringLt(n,"0")&&(d="out",n=o.Y.stringNeg(n));const h=this.safeValue(e,"fundsBefore",{}),c=this.safeValue(e,"fundsAfter",{});return this.safeLedgerEntry({info:e,id:this.safeString(e,"historyId"),direction:d,account:void 0,referenceId:this.safeString(e,"detailId"),referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(r),amount:this.parseNumber(n),before:this.safeNumber(h,"total"),after:this.safeNumber(c,"total"),status:"ok",timestamp:i,datetime:this.iso8601(i),fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({ADD_FUNDS:"transaction",BITCOIN_GOLD_FORK:"transaction",CREATE_BALANCE:"transaction",FUNDS_MIGRATION:"transaction",WITHDRAWAL_LOCK_FUNDS:"transaction",WITHDRAWAL_SUBTRACT_FUNDS:"transaction",WITHDRAWAL_UNLOCK_FUNDS:"transaction",TRANSACTION_COMMISSION_OUTCOME:"fee",TRANSACTION_COMMISSION_RETURN:"fee",TRANSACTION_OFFER_ABORTED_RETURN:"trade",TRANSACTION_OFFER_COMPLETED_RETURN:"trade",TRANSACTION_POST_INCOME:"trade",TRANSACTION_POST_OUTCOME:"trade",TRANSACTION_PRE_LOCKING:"trade"},e,e)}parseOHLCV(e,t=void 0){const i=this.safeValue(e,1,{});return[this.safeInteger(e,0),this.safeNumber(i,"o"),this.safeNumber(i,"h"),this.safeNumber(i,"l"),this.safeNumber(i,"c"),this.safeNumber(i,"v")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.baseId+"-"+a.quoteId,resolution:this.safeString(this.timeframes,t,t)},n=(s=void 0===s?100:Math.min(s,11e3))*this.parseTimeframe(t)*1e3;void 0===i?(o.to=this.milliseconds(),o.from=o.to-n):(o.from=i,o.to=this.sum(o.from,n));const d=await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(o,r)),h=this.safeList(d,"items",[]);return this.parseOHLCVs(h,a,t,i,s)}parseTrade(e,t=void 0){const i=this.safeInteger2(e,"time","t"),s=this.safeStringLower2(e,"userAction","ty"),r=this.safeValue(e,"wasTaker");let a;void 0!==r&&(a=r?"taker":"maker");const o=this.safeString2(e,"rate","r"),n=this.safeString2(e,"amount","a"),d=this.safeString(e,"commissionValue"),h=this.safeString(e,"market"),c=(t=this.safeMarket(h,t,"-")).symbol;let l;if(void 0!==d){l={currency:"buy"===s?t.base:t.quote,cost:d}}const u=this.safeString(e,"offerId");let f;return void 0!==u&&(f=u?"limit":"market"),this.safeTrade({id:this.safeString(e,"id"),order:u,timestamp:i,datetime:this.iso8601(i),symbol:c,type:f,side:s,price:o,amount:n,cost:void 0,takerOrMaker:a,fee:l,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.baseId+"-"+r.quoteId};void 0!==t&&(a.fromTime=t-1),void 0!==i&&(a.limit=i);const o=await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(a,s)),n=this.safeList(o,"items");return this.parseTrades(n,r,t,i)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d=n.baseId+"-"+n.quoteId;s=parseFloat(this.amountToPrecision(e,s));const h={symbol:d,offerType:i.toUpperCase(),amount:s},c=this.safeValue2(o,"stopPrice","stopLossPrice"),l=void 0!==c,u="limit"===t,f="market"===t,p="stop-limit"===t||u&&l,m="stop-market"===t||f&&l,g=p||m;if(u||p)h.rate=this.priceToPrecision(e,a),h.mode=p?"stop-limit":"limit";else{if(!f&&!m)throw new r.ExchangeError(this.id+" createOrder() invalid type");h.mode=m?"stop-market":"market"}let v;if(o=this.omit(o,["stopPrice","stopLossPrice"]),g){if(!l)throw new r.ExchangeError(this.id+" createOrder() zonda requires `triggerPrice` parameter for stop-limit or stop-market orders");h.stopRate=this.priceToPrecision(e,c),v=await this.v1_01PrivatePostTradingStopOfferSymbol(this.extend(h,o))}else v=await this.v1_01PrivatePostTradingOfferSymbol(this.extend(h,o));const y=this.safeString2(v,"offerId","stopOfferId"),b=this.safeBool(v,"completed",!1)?"closed":"open",w=this.safeValue(v,"transactions");return this.safeOrder({id:y,info:v,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,status:b,symbol:e,type:t,side:i,price:a,amount:s,cost:void 0,filled:void 0,remaining:void 0,average:void 0,fee:void 0,trades:w,clientOrderId:void 0})}async cancelOrder(e,t=void 0,i={}){const s=this.safeString(i,"side");if(void 0===s)throw new r.ExchangeError(this.id+' cancelOrder() requires a `side` parameter ("buy" or "sell")');const a=this.safeValue(i,"price");if(void 0===a)throw new r.ExchangeError(this.id+" cancelOrder() requires a `price` parameter (float or string)");await this.loadMarkets();const o=this.market(t),n={symbol:o.baseId+"-"+o.quoteId,id:e,side:s,price:a},d=await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(n,i));return this.parseOrder(d)}isFiat(e){return this.safeBool({USD:!0,EUR:!0,PLN:!0},e,!1)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"currency"),s=this.safeString(e,"address");return this.checkAddress(s),{info:e,currency:this.safeCurrencyCode(i,t),network:void 0,address:s,tag:this.safeString(e,"tag")}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={currency:i.id},r=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(s,t)),a=this.safeValue(r,"data"),o=this.safeDict(a,0);return this.parseDepositAddress(o,i)}async fetchDepositAddresses(e=void 0,t={}){await this.loadMarkets();const i=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(t),s=this.safeList(i,"data");return this.parseDepositAddresses(s,e)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o={source:i,destination:s,currency:e,funds:this.currencyToPrecision(e,t)},n=await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(o,r)),d=this.parseTransfer(n,a),h=this.safeValue(this.options,"transfer",{});return this.safeBool(h,"fillResponseFromRequest",!0)&&(d.amount=t),d}parseTransfer(e,t=void 0){const i=this.safeString(e,"status"),s=this.safeValue(e,"from",{}),r=this.safeString(s,"id"),a=this.safeValue(e,"to",{}),o=this.safeString(a,"id"),n=this.safeString(s,"currency");return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(n,t),amount:void 0,fromAccount:r,toAccount:o,status:this.parseTransferStatus(i)}}parseTransferStatus(e){return this.safeString({Ok:"ok",Fail:"failed"},e,e)}async withdraw(e,t,i,s=void 0,r={}){let a;[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const o=this.currency(e),n={currency:o.id,amount:t,address:i};this.isFiat(e)?a=await this.v1_01PrivatePostApiPaymentsWithdrawalsFiat(this.extend(n,r)):(void 0!==s&&(n.tag=s),a=await this.v1_01PrivatePostApiPaymentsWithdrawalsCrypto(this.extend(n,r)));const d=this.safeDict(a,"data");return this.parseTransaction(d,o)}parseTransaction(e,t=void 0){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:void 0,info:e}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.implodeHostname(this.urls.api[t]);if("public"===t){const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s)+".json",Object.keys(t).length&&(o+="?"+this.urlencode(t))}else if("v1_01Public"===t){const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s),Object.keys(t).length&&(o+="?"+this.urlencode(t))}else if("v1_01Private"===t){this.checkRequiredCredentials();const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s);const d=this.milliseconds().toString();let h;"POST"!==i?(Object.keys(t).length&&(o+="?"+this.urlencode(t)),h=this.apiKey+d):void 0===a&&(a=this.json(t),h=this.apiKey+d+a),r={"Request-Timestamp":d,"Operation-Id":this.uuid(),"API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(h),this.encode(this.secret),n.Zf),"Content-Type":"application/json"}}else this.checkRequiredCredentials(),a=this.urlencode(this.extend({method:e,moment:this.nonce()},s)),r={"Content-Type":"application/x-www-form-urlencoded","API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(a),this.encode(this.secret),n.Zf)};return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n){if("code"in n){const e=this.safeString(n,"code"),t=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions,e,t),new r.ExchangeError(t)}if("status"in n){if("Fail"===this.safeString(n,"status")){const e=this.safeValue(n,"errors"),t=this.id+" "+o;for(let i=0;i<e.length;i++){const s=e[i];this.throwExactlyMatchedException(this.exceptions,s,t)}throw new r.ExchangeError(t)}}}}}},51591:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},43544:e=>{var t=String.prototype.replace,i=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return t.call(e,i,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},64580:(e,t,i)=>{var s=i(71603),r=i(43437),a=i(43544);e.exports={formats:a,parse:r,stringify:s}},43437:(e,t,i)=>{var s=i(83247),r=Object.prototype.hasOwnProperty,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:s.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},o=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},n=function(e,t,i){if(e){var s=i.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,o=/(\[[^[\]]*])/.exec(s),n=o?s.slice(0,o.index):s,d=[];if(n){if(!i.plainObjects&&r.call(Object.prototype,n)&&!i.allowPrototypes)return;d.push(n)}for(var h=0;null!==(o=a.exec(s))&&h<i.depth;){if(h+=1,!i.plainObjects&&r.call(Object.prototype,o[1].slice(1,-1))&&!i.allowPrototypes)return;d.push(o[1])}return o&&d.push("["+s.slice(o.index)+"]"),function(e,t,i){for(var s=t,r=e.length-1;r>=0;--r){var a,o=e[r];if("[]"===o&&i.parseArrays)a=[].concat(s);else{a=i.plainObjects?Object.create(null):{};var n="["===o.charAt(0)&&"]"===o.charAt(o.length-1)?o.slice(1,-1):o,d=parseInt(n,10);i.parseArrays||""!==n?!isNaN(d)&&o!==n&&String(d)===n&&d>=0&&i.parseArrays&&d<=i.arrayLimit?(a=[])[d]=s:a[n]=s:a={0:s}}s=a}return s}(d,t,i)}};e.exports=function(e,t){var i=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||s.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth?e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return i.plainObjects?Object.create(null):{};for(var d="string"==typeof e?function(e,t){var i,n={},d=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,h=t.parameterLimit===1/0?void 0:t.parameterLimit,c=d.split(t.delimiter,h),l=-1,u=t.charset;if(t.charsetSentinel)for(i=0;i<c.length;++i)0===c[i].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[i]?u="utf-8":"utf8=%26%2310003%3B"===c[i]&&(u="iso-8859-1"),l=i,i=c.length);for(i=0;i<c.length;++i)if(i!==l){var f,p,m=c[i],g=m.indexOf("]="),v=-1===g?m.indexOf("="):g+1;-1===v?(f=t.decoder(m,a.decoder,u),p=t.strictNullHandling?null:""):(f=t.decoder(m.slice(0,v),a.decoder,u),p=t.decoder(m.slice(v+1),a.decoder,u)),p&&t.interpretNumericEntities&&"iso-8859-1"===u&&(p=o(p)),p&&t.comma&&p.indexOf(",")>-1&&(p=p.split(",")),r.call(n,f)?n[f]=s.combine(n[f],p):n[f]=p}return n}(e,i):e,h=i.plainObjects?Object.create(null):{},c=Object.keys(d),l=0;l<c.length;++l){var u=c[l],f=n(u,d[u],i);h=s.merge(h,f,i)}return s.compact(h)}},71603:(e,t,i)=>{var s=i(83247),r=i(43544),a=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},n=Array.isArray,d=Array.prototype.push,h=function(e,t){d.apply(e,n(t)?t:[t])},c=Date.prototype.toISOString,l={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:s.encode,encodeValuesOnly:!1,formatter:r.formatters[r.default],indices:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},u=function e(t,i,r,a,o,d,c,u,f,p,m,g,v){var y=t;if("function"==typeof c?y=c(i,y):y instanceof Date?y=p(y):"comma"===r&&n(y)&&(y=y.join(",")),null===y){if(a)return d&&!g?d(i,l.encoder,v):i;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||s.isBuffer(y))return d?[m(g?i:d(i,l.encoder,v))+"="+m(d(y,l.encoder,v))]:[m(i)+"="+m(String(y))];var b,w=[];if(void 0===y)return w;if(n(c))b=c;else{var k=Object.keys(y);b=u?k.sort(u):k}for(var S=0;S<b.length;++S){var O=b[S];o&&null===y[O]||(n(y)?h(w,e(y[O],"function"==typeof r?r(i,O):i,r,a,o,d,c,u,f,p,m,g,v)):h(w,e(y[O],i+(f?"."+O:"["+O+"]"),r,a,o,d,c,u,f,p,m,g,v)))}return w};e.exports=function(e,t){var i,s=e,d=function(e){if(!e)return l;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||l.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=r.default;if(void 0!==e.format){if(!a.call(r.formatters,e.format))throw new TypeError("Unknown format option provided.");i=e.format}var s=r.formatters[i],o=l.filter;return("function"==typeof e.filter||n(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:l.addQueryPrefix,allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,delimiter:void 0===e.delimiter?l.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:l.encode,encoder:"function"==typeof e.encoder?e.encoder:l.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:l.encodeValuesOnly,filter:o,formatter:s,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:l.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:l.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling}}(t);"function"==typeof d.filter?s=(0,d.filter)("",s):n(d.filter)&&(i=d.filter);var c,f=[];if("object"!=typeof s||null===s)return"";c=t&&t.arrayFormat in o?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=o[c];i||(i=Object.keys(s)),d.sort&&i.sort(d.sort);for(var m=0;m<i.length;++m){var g=i[m];d.skipNulls&&null===s[g]||h(f,u(s[g],g,p,d.strictNullHandling,d.skipNulls,d.encode?d.encoder:null,d.filter,d.sort,d.allowDots,d.serializeDate,d.formatter,d.encodeValuesOnly,d.charset))}var v=f.join(d.delimiter),y=!0===d.addQueryPrefix?"?":"";return d.charsetSentinel&&("iso-8859-1"===d.charset?y+="utf8=%26%2310003%3B&":y+="utf8=%E2%9C%93&"),v.length>0?y+v:""}},83247:e=>{var t=Object.prototype.hasOwnProperty,i=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),r=function(e,t){for(var i=t&&t.plainObjects?Object.create(null):{},s=0;s<e.length;++s)void 0!==e[s]&&(i[s]=e[s]);return i};e.exports={arrayToObject:r,assign:function(e,t){return Object.keys(t).reduce((function(e,i){return e[i]=t[i],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],s=[],r=0;r<t.length;++r)for(var a=t[r],o=a.obj[a.prop],n=Object.keys(o),d=0;d<n.length;++d){var h=n[d],c=o[h];"object"==typeof c&&null!==c&&-1===s.indexOf(c)&&(t.push({obj:o,prop:h}),s.push(c))}return function(e){for(;e.length>1;){var t=e.pop(),s=t.obj[t.prop];if(i(s)){for(var r=[],a=0;a<s.length;++a)void 0!==s[a]&&r.push(s[a]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,i){var s=e.replace(/\+/g," ");if("iso-8859-1"===i)return s.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(s)}catch(e){return s}},encode:function(e,t,i){if(0===e.length)return e;var r="string"==typeof e?e:String(e);if("iso-8859-1"===i)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var a="",o=0;o<r.length;++o){var n=r.charCodeAt(o);45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?a+=r.charAt(o):n<128?a+=s[n]:n<2048?a+=s[192|n>>6]+s[128|63&n]:n<55296||n>=57344?a+=s[224|n>>12]+s[128|n>>6&63]+s[128|63&n]:(o+=1,n=65536+((1023&n)<<10|1023&r.charCodeAt(o)),a+=s[240|n>>18]+s[128|n>>12&63]+s[128|n>>6&63]+s[128|63&n])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(s,a,o){if(!a)return s;if("object"!=typeof a){if(i(s))s.push(a);else{if(!s||"object"!=typeof s)return[s,a];(o&&(o.plainObjects||o.allowPrototypes)||!t.call(Object.prototype,a))&&(s[a]=!0)}return s}if(!s||"object"!=typeof s)return[s].concat(a);var n=s;return i(s)&&!i(a)&&(n=r(s,o)),i(s)&&i(a)?(a.forEach((function(i,r){if(t.call(s,r)){var a=s[r];a&&"object"==typeof a&&i&&"object"==typeof i?s[r]=e(a,i,o):s.push(i)}else s[r]=i})),s):Object.keys(a).reduce((function(i,s){var r=a[s];return t.call(i,s)?i[s]=e(i[s],r,o):i[s]=r,i}),n)}}},64350:(e,t,i)=>{i.d(t,{HM:()=>L,Wt:()=>R});var s=Uint8Array,r=Uint16Array,a=Uint32Array,o=new s([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),n=new s([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),d=new s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var i=new r(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var o=new a(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)o[n]=n-i[s]<<5|s;return[i,o]},c=h(o,2),l=c[0],u=c[1];l[28]=258,u[258]=28;for(var f=h(n,0),p=f[0],m=(f[1],new r(32768)),g=0;g<32768;++g){var v=(43690&g)>>>1|(21845&g)<<1;v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4,m[g]=((65280&v)>>>8|(255&v)<<8)>>>1}var y=function(e,t,i){for(var s=e.length,a=0,o=new r(t);a<s;++a)e[a]&&++o[e[a]-1];var n,d=new r(t);for(a=0;a<t;++a)d[a]=d[a-1]+o[a-1]<<1;if(i){n=new r(1<<t);var h=15-t;for(a=0;a<s;++a)if(e[a])for(var c=a<<4|e[a],l=t-e[a],u=d[e[a]-1]++<<l,f=u|(1<<l)-1;u<=f;++u)n[m[u]>>>h]=c}else for(n=new r(s),a=0;a<s;++a)e[a]&&(n[a]=m[d[e[a]-1]++]>>>15-e[a]);return n},b=new s(288);for(g=0;g<144;++g)b[g]=8;for(g=144;g<256;++g)b[g]=9;for(g=256;g<280;++g)b[g]=7;for(g=280;g<288;++g)b[g]=8;var w=new s(32);for(g=0;g<32;++g)w[g]=5;var k=y(b,9,1),S=y(w,5,1),O=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},T=function(e,t,i){var s=t/8|0;return(e[s]|e[s+1]<<8)>>(7&t)&i},P=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},M=function(e){return(e+7)/8|0},I=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var o=new(2==e.BYTES_PER_ELEMENT?r:4==e.BYTES_PER_ELEMENT?a:s)(i-t);return o.set(e.subarray(t,i)),o},x=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(e,t,i){var s=new Error(t||x[e]);if(s.code=e,Error.captureStackTrace&&Error.captureStackTrace(s,A),!i)throw s;return s},C=function(e,t,i){var r=e.length;if(!r||i&&i.f&&!i.l)return t||new s(0);var a=!t||i,h=!i||i.i;i||(i={}),t||(t=new s(3*r));var c=function(e){var i=t.length;if(e>i){var r=new s(Math.max(2*i,e));r.set(t),t=r}},u=i.f||0,f=i.p||0,m=i.b||0,g=i.l,v=i.d,b=i.m,w=i.n,x=8*r;do{if(!g){u=T(e,f,1);var C=T(e,f+1,3);if(f+=3,!C){var _=e[(G=M(f)+4)-4]|e[G-3]<<8,B=G+_;if(B>r){h&&A(0);break}a&&c(m+_),t.set(e.subarray(G,B),m),i.b=m+=_,i.p=f=8*B,i.f=u;continue}if(1==C)g=k,v=S,b=9,w=5;else if(2==C){var E=T(e,f,31)+257,L=T(e,f+10,15)+4,R=E+T(e,f+5,31)+1;f+=14;for(var N=new s(R),D=new s(19),q=0;q<L;++q)D[d[q]]=T(e,f+3*q,7);f+=3*L;var V=O(D),F=(1<<V)-1,H=y(D,V,1);for(q=0;q<R;){var G,U=H[T(e,f,F)];if(f+=15&U,(G=U>>>4)<16)N[q++]=G;else{var W=0,j=0;for(16==G?(j=3+T(e,f,3),f+=2,W=N[q-1]):17==G?(j=3+T(e,f,7),f+=3):18==G&&(j=11+T(e,f,127),f+=7);j--;)N[q++]=W}}var z=N.subarray(0,E),K=N.subarray(E);b=O(z),w=O(K),g=y(z,b,1),v=y(K,w,1)}else A(1);if(f>x){h&&A(0);break}}a&&c(m+131072);for(var Y=(1<<b)-1,X=(1<<w)-1,Q=f;;Q=f){var Z=(W=g[P(e,f)&Y])>>>4;if((f+=15&W)>x){h&&A(0);break}if(W||A(2),Z<256)t[m++]=Z;else{if(256==Z){Q=f,g=null;break}var $=Z-254;if(Z>264){var J=o[q=Z-257];$=T(e,f,(1<<J)-1)+l[q],f+=J}var ee=v[P(e,f)&X],te=ee>>>4;ee||A(3),f+=15ⅇK=p[te];if(te>3){J=n[te];K+=P(e,f)&(1<<J)-1,f+=J}if(f>x){h&&A(0);break}a&&c(m+131072);for(var ie=m+$;m<ie;m+=4)t[m]=t[m-K],t[m+1]=t[m+1-K],t[m+2]=t[m+2-K],t[m+3]=t[m+3-K];m=ie}}i.l=g,i.p=Q,i.b=m,i.f=u,g&&(u=1,i.m=b,i.d=v,i.n=w)}while(!u);return m==t.length?t:I(t,0,m)},_=new s(0),B=function(e){31==e[0]&&139==e[1]&&8==e[2]||A(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=e[10]|2+(e[11]<<8));for(var s=(t>>3&1)+(t>>4&1);s>0;s-=!e[i++]);return i+(2&t)},E=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0};function L(e,t=void 0){return C(e,t)}function R(e,t=void 0){return C(e.subarray(B(e),-8),t||new s(E(e)))}var N="undefined"!=typeof TextDecoder&&new TextDecoder;try{N.decode(_,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},56378:(e,t,i)=>{i.d(t,{b:()=>s});
|
|
26
|
+
const l=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),u=BigInt("0x800000000000000000000000000000000000000000000000000000000000000");function f(e){for(;0===e[0];)e=e.subarray(1);const t=8*e.length-252,i=h.Ph(e);return t>0?i>>BigInt(t):i}function p(e){return"string"==typeof e&&1&(e=M(e)).length&&(e="0"+e),h.aT(e)}const m=(0,d.x3)({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:(0,o.Fp)(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:l,nBitLength:252,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...(0,c.Z)(r.s),bits2int:f,bits2int_modN:e=>{const t=h.Ph(e).toString(16);return 63===t.length&&(e=p(t+"0")),(0,o.zi)(f(e),l)}});function g(e){return h.qj("","string"==typeof e?p(e):e)}function v(e){return h.My(g(e)).padStart(64,"0")}function y(e){const{r:t,s:i}=e;if(t<0n||t>=u)throw new Error(`Signature.r should be [1, ${u})`);const s=(0,o.B8)(i,l);if(s<0n||s>=u)throw new Error(`inv(Signature.s) should be [1, ${u})`)}function b(e){const t=g(e);if(h.Ph(t)>=u)throw new Error(`msgHash should be [0, ${u})`);return t}function w(e,t,i){const s=m.sign(b(e),v(t),i);return y(s),s}const{CURVE:k,ProjectivePoint:S,Signature:O,utils:T}=m;function P(e){return`0x${h.My(e.subarray(1)).replace(/^0+/gm,"")}`}function M(e){return e.replace(/^0x/i,"")}function I(e){return P(function(e,t=!1){return m.getPublicKey(v(e),t)}(e,!0))}function x(e){if(130!==(e=M(e)).length)throw new Error("Wrong ethereum signature");return function(e){const t=g(e),i=2n**256n,s=i-(0,o.zi)(i,l);for(let e=0;;e++){const i=D(h.Id(t,h.IV(BigInt(e))));if(i<s)return(0,o.zi)(i,l).toString(16);if(1e5===e)throw new Error("grindKey is broken: tried 100k vals")}}(e.substring(0,64))}const A=[new S(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new S(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new S(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new S(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new S(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function C(e,t){const i=[];let s=e;for(let e=0;e<248;e++)i.push(s),s=s.double();s=t;for(let e=0;e<4;e++)i.push(s),s=s.double();return i}const _=C(A[1],A[2]),B=C(A[3],A[4]);function E(e,t,i){let s=function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e){if(!Number.isSafeInteger(e))throw new Error(`Invalid pedersenArg: ${e}`);t=BigInt(e)}else t=h.Ph(g(e));if(!(0n<=t&&t<m.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}(t);for(let t=0;t<252;t++){const r=i[t];if(!r)throw new Error("invalid constant index");if(r.equals(e))throw new Error("Same point");0n!==(1n&s)&&(e=e.add(r)),s>>=1n}return e}function L(e,t){let i=A[0];return i=E(i,e,_),i=E(i,t,B),P(i.toRawBytes(!0))}const R=h.OG(250),N=e=>h.Ph((0,s.lY)(e))&R,D=e=>h.Ph((0,r.s)(e));function q(e,t,i){const s=e.fromBytes((0,r.s)((0,a.AI)(`${t}${i}`)));return e.create(s)}function V(e,t){if((0,o.jr)(e.Fp),!Number.isSafeInteger(e.rate)||!Number.isSafeInteger(e.capacity))throw new Error(`Wrong poseidon opts: ${e}`);const i=e.rate+e.capacity,s=e.roundsFull+e.roundsPartial,r=[];for(let t=0;t<s;t++){const s=[];for(let r=0;r<i;r++)s.push(q(e.Fp,"Hades",i*t+r));r.push(s)}const a=(0,n.sN)({...e,t:i,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:r});return a.m=i,a.rate=e.rate,a.capacity=e.capacity,a}const F=V({Fp:(0,o.Fp)(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481")),rate:2,capacity:1,roundsFull:8,roundsPartial:83},[[3,1,1],[1,-1,1],[1,1,-2]].map((e=>e.map(BigInt))));function H(e,t,i=F){return i([e,t,2n])[0]}function G(e,t=F){const{m:i,rate:s}=t;if(!Array.isArray(e))throw new Error("bigint array expected in values");const r=Array.from(e);for(r.push(1n);r.length%s!=0;)r.push(0n);let a=new Array(i).fill(0n);for(let e=0;e<r.length;e+=s){for(let t=0;t<s;t++){const i=r[e+t];if(void 0===i)throw new Error("invalid index");a[t]+=i}a=t(a)}return a[0]}},58325:(e,t,i)=>{i.d(t,{He:()=>h,Kp:()=>d,Vi:()=>o,bE:()=>c,n$:()=>r,p7:()=>s,s9:()=>a});const s=31,r=2n**250n-1n,a=2n**251n+17n*2n**192n+1n,o=2n**251n-256n,n=(e,t)=>({min:e,max:t}),d=n(0n,a-1n),h=n(-(2n**127n),2n**127n-1n),c=n(0n,2n**128n-1n);var l,u,f,p;!function(e){e.SN_MAIN="https://alpha-mainnet.starknet.io",e.SN_SEPOLIA="https://alpha-sepolia.starknet.io"}(l||(l={})),function(e){e.SN_MAIN="SN_MAIN",e.SN_SEPOLIA="SN_SEPOLIA"}(u||(u={})),function(e){e.SN_MAIN="0x534e5f4d41494e",e.SN_SEPOLIA="0x534e5f5345504f4c4941"}(f||(f={})),function(e){e.DECLARE="0x6465636c617265",e.DEPLOY="0x6465706c6f79",e.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",e.INVOKE="0x696e766f6b65",e.L1_HANDLER="0x6c315f68616e646c6572"}(p||(p={}))},20040:(e,t,i)=>{var s,r,a;i.d(t,{Fg:()=>r,fE:()=>s,uS:()=>a}),function(e){e.DEPLOY="DEPLOY",e.CALL="CALL",e.INVOKE="INVOKE"}(s||(s={})),function(e){e.u8="core::integer::u8",e.u16="core::integer::u16",e.u32="core::integer::u32",e.u64="core::integer::u64",e.u128="core::integer::u128",e.u256="core::integer::u256",e.u512="core::integer::u512"}(r||(r={})),function(e){e.ClassHash="core::starknet::class_hash::ClassHash",e.ContractAddress="core::starknet::contract_address::ContractAddress",e.Secp256k1Point="core::starknet::secp256k1::Secp256k1Point"}(a||(a={}))},30162:(e,t,i)=>{i.d(t,{K:()=>s});const s={Active:"1",Legacy:"0"}},79550:(e,t,i)=>{function s(e,t){if(!e)throw new Error(t||"Assertion failure")}i.d(t,{A:()=>s})},54921:(e,t,i)=>{i.d(t,{e:()=>a});var s=i(11686),r=i(67925);function a(e){if((0,s.sI)(e)||Number.isInteger(e))return e.toString();if((0,r.Kg)(e)){if((0,s.qv)(e))return BigInt(e).toString();if((0,r.KH)(e)){if(!(0,r.O4)(e))throw new Error(`${e} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt((0,r.Mu)(e)).toString()}if((0,s.A6)(e))return e}if((0,s.Lm)(e))return""+ +e;throw new Error(`${e} can't be computed by felt()`)}},13283:(e,t,i)=>{i.d(t,{is:()=>n,wO:()=>a});var s=i(90178),r=i(54921);const a=(1n<<128n)-1n,o=(1n<<256n)-1n;class n{constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const t=n.validateProps(e[0].low,e[0].high);this.low=t.low,this.high=t.high}else if(1===e.length){const t=n.validate(e[0]);this.low=t&a,this.high=t>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const t=n.validateProps(e[0],e[1]);this.low=t.low,this.high=t.high}}}static validate(e){const t=BigInt(e);if(t<0n)throw Error("bigNumberish is smaller than UINT_256_MIN");if(t>o)throw new Error("bigNumberish is bigger than UINT_256_MAX");return t}static validateProps(e,t){const i=BigInt(e),s=BigInt(t);if(i<0n||i>340282366920938463463374607431768211455n)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(s<0n||s>340282366920938463463374607431768211455n)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:i,high:s}}static is(e){try{n.validate(e)}catch(e){return!1}return!0}static isAbiType(e){return e===n.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:(0,s.VO)(this.low.toString(16)),high:(0,s.VO)(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[(0,r.e)(this.low),(0,r.e)(this.high)]}}n.abiSelector="core::integer::u256"},40274:(e,t,i)=>{i.d(t,{Ns:()=>n});var s=i(90178),r=i(54921),a=i(13283);const o=(1n<<512n)-1n;class n{constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const t=n.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}else if(1===e.length){const t=n.validate(e[0]);this.limb0=t&a.wO,this.limb1=(t&a.wO<<128n)>>128n,this.limb2=(t&a.wO<<256n)>>256n,this.limb3=t>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const t=n.validateProps(e[0],e[1],e[2],e[3]);this.limb0=t.limb0,this.limb1=t.limb1,this.limb2=t.limb2,this.limb3=t.limb3}}}static validate(e){const t=BigInt(e);if(t<0n)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(t>o)throw Error("bigNumberish is bigger than UINT_512_MAX.");return t}static validateProps(e,t,i,s){const r=BigInt(e),o=BigInt(t),n=BigInt(i),d=BigInt(s);return[r,o,n,d].forEach(((e,t)=>{if(e<0n||e>a.wO)throw Error(`limb${t} is not in the range of a u128 number`)})),{limb0:r,limb1:o,limb2:n,limb3:d}}static is(e){try{n.validate(e)}catch(e){return!1}return!0}static isAbiType(e){return e===n.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:(0,s.VO)(this.limb0.toString(16)),limb1:(0,s.VO)(this.limb1.toString(16)),limb2:(0,s.VO)(this.limb2.toString(16)),limb3:(0,s.VO)(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[(0,r.e)(this.limb0),(0,r.e)(this.limb1),(0,r.e)(this.limb2),(0,r.e)(this.limb3)]}}n.abiSelector="core::integer::u512"},62256:(e,t,i)=>{i.d(t,{f:()=>a,p:()=>o});var s=i(11686),r=i(67925);function a(e){const t=0n===BigInt(e.pending_word)?"":(0,r.Wb)((0,s.nj)(e.pending_word));return e.data.reduce(((e,t)=>e+(0n===BigInt(t)?"":(0,r.Wb)((0,s.nj)(t)))),"")+t}function o(e){const t=(0,r.mE)(e),i=t[t.length-1],s=t.map(r.Mu),[a,o]=void 0===i||31===i.length?["0x00",0]:[s.pop(),i.length];return{data:0===s.length?[]:s,pending_word:a,pending_word_len:o}}},15307:(e,t,i)=>{i.d(t,{$H:()=>m,AB:()=>M,CS:()=>O,Fi:()=>v,G$:()=>d,GY:()=>y,Gw:()=>g,Z$:()=>k,Zm:()=>h,ak:()=>w,cl:()=>T,ct:()=>o,e4:()=>f,gr:()=>b,iN:()=>P,iO:()=>u,mQ:()=>c,s8:()=>S,sB:()=>n,u:()=>p,wJ:()=>l});var s=i(20040),r=i(54921),a=i(13283);const o=e=>/_len$/.test(e),n=e=>"felt"===e||"core::felt252"===e,d=e=>/\*/.test(e)||e.startsWith("core::array::Array::")||e.startsWith("core::array::Span::"),h=e=>/^\(.*\)$/i.test(e),c=e=>/\(.*\)/i.test(e)&&e.includes(":"),l=(e,t)=>e in t,u=(e,t)=>e in t,f=e=>e.startsWith("core::option::Option::"),p=e=>e.startsWith("core::result::Result::"),m=e=>Object.values(s.Fg).includes(e),g=e=>Object.values(s.uS).includes(e),v=e=>"core::bool"===e,y=e=>"core::starknet::eth_address::EthAddress"===e,b=e=>"core::bytes_31::bytes31"===e,w=e=>"core::byte_array::byteArray.js"===e,k=e=>"core::starknet::secp256k1::Secp256k1Point"===e,S=e=>e.includes("::"),O=e=>S(e)?e.substring(e.indexOf("<")+1,e.lastIndexOf(">")):e.replace("*","");function T(e){const{cairo:t}=function(e){if(e.find((e=>"interface"===e.type)))return{cairo:"1",compiler:"2"};const t=e.find((e=>"function"===e.type&&(e.inputs.length||e.outputs.length)));if(!t)return{cairo:void 0,compiler:void 0};const i=t.inputs.length?t.inputs:t.outputs;if(S(i[0].type))return{cairo:"1",compiler:"1"};return{cairo:"0",compiler:"0"}}(e);if(void 0===t)throw Error("Unable to determine Cairo version");return"1"===t}const P=e=>new a.is(e).toUint256DecimalString();function M(e){return(0,r.e)(e)}},36863:(e,t,i)=>{i.d(t,{b:()=>s});class s{constructor(e){const t=Object.values(e);if(0===t.length)throw new Error("This Enum must have at least 1 variant");if(1!==t.filter((e=>void 0!==e)).length)throw new Error("This Enum must have exactly one active variant");this.variant=e}unwrap(){const e=Object.entries(this.variant).find((e=>void 0!==e[1]));if(void 0!==e)return e[1]}activeVariant(){const e=Object.entries(this.variant).find((e=>void 0!==e[1]));return void 0===e?"":e[0]}}},49620:(e,t,i)=>{var s;i.d(t,{R:()=>s,c:()=>r}),function(e){e[e.Some=0]="Some",e[e.None=1]="None"}(s||(s={}));class r{constructor(e,t){if(!(e in s))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(e===s.Some){if(void 0===t)throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=t,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(void 0===this.Some)}isNone(){return!0===this.None}}},41668:(e,t,i)=>{var s;i.d(t,{B:()=>s,G:()=>r}),function(e){e[e.Ok=0]="Ok",e[e.Err=1]="Err"}(s||(s={}));class r{constructor(e,t){if(!(e in s))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");e===s.Ok?(this.Ok=t,this.Err=void 0):(this.Ok=void 0,this.Err=t)}unwrap(){if(void 0!==this.Ok)return this.Ok;if(void 0!==this.Err)return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(void 0===this.Ok)}isErr(){return!(void 0===this.Err)}}},79161:(e,t,i)=>{i.d(t,{A:()=>o});var s=i(11686),r=i(67925);const a={isBN:(e,t,i)=>{if(!(0,s.sI)(e[i]))throw new Error(`Data and formatter mismatch on ${i}:${t[i]}, expected response data ${i}:${e[i]} to be BN instead it is ${typeof e[i]}`)},unknown:(e,t,i)=>{throw new Error(`Unhandled formatter type on ${i}:${t[i]} for data ${i}:${e[i]}`)}};function o(e,t,i){return Object.entries(e).reduce(((s,[n,d])=>{const h=i??t[n];if(!(n in t)&&!i)return s[n]=d,s;if("string"===h){if(Array.isArray(e[n])){const t=o(e[n],e[n].map((e=>h)));return s[n]=Object.values(t).join(""),s}return a.isBN(e,t,n),s[n]=(0,r.Wb)(d),s}if("number"===h)return a.isBN(e,t,n),s[n]=Number(d),s;if("function"==typeof h)return s[n]=h(d),s;if(Array.isArray(h)){const t=o(e[n],h,h[0]);return s[n]=Object.values(t),s}return"object"==typeof h?(s[n]=o(e[n],h),s):(a.unknown(e,t,n),s)}),{})}},46907:(e,t,i)=>{i.d(t,{fP:()=>y});var s=i(20040),r=i(79550),a=i(11686),o=i(69793),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(79161),f=i(591),p=i(90916),m=i(14365),g=i(43463),v=i(39873);class y{constructor(e){this.structs=y.getAbiStruct(e),this.enums=y.getAbiEnum(e),this.parser=(0,f.k)(e),this.abi=this.parser.getLegacyFormat()}validate(e,t,i=[]){if(e!==s.fE.DEPLOY){const i=this.abi.filter((t=>{if("function"!==t.type)return!1;const i="view"===t.stateMutability||"view"===t.state_mutability;return e===s.fE.INVOKE?!i:i})).map((e=>e.name));(0,r.A)(i.includes(t),(e===s.fE.INVOKE?"invocable":"viewable")+" method not found in abi")}const a=this.abi.find((i=>e===s.fE.DEPLOY?i.name===t&&"constructor"===i.type:i.name===t&&"function"===i.type));if((0,f.CO)(t,i,a))return;const o=this.parser.methodInputsLength(a);if(i.length!==o)throw Error(`Invalid number of arguments, expected ${o} arguments, but got ${i.length}`);(0,v.A)(a,i,this.structs,this.enums)}compile(e,t){const i=this.abi.find((t=>t.name===e));if((0,f.CO)(e,t,i))return[];let s;if(Array.isArray(t))s=t;else{const e=(0,p.A)(t,i.inputs,this.structs,this.enums);s=Object.values(e),(0,v.A)(i,s,this.structs,this.enums)}const r=s[Symbol.iterator](),a=i.inputs.reduce(((e,t)=>(0,h.ct)(t.name)&&!(0,h.s8)(t.type)?e:e.concat((0,m.A)(r,t,this.structs,this.enums))),[]);return Object.defineProperty(a,"__compiled__",{enumerable:!1,writable:!1,value:!0}),a}static compile(e){const t=e=>{const t=(e,i=".")=>{const s=Array.isArray(e)?[e.length.toString(),...e]:e;return Object.entries(s).flatMap((([e,r])=>{let u=r;"entrypoint"===e?u=(0,o.BK)(u):(0,n.IN)(u)&&(u=(0,d.p)(u));const f=Array.isArray(s)&&"0"===e?"$$len":e;if((0,a.sI)(u))return[[`${i}${f}`,(0,h.AB)(u)]];if(Object(u)===u){const e=Object.getOwnPropertyNames(Object.getPrototypeOf(u)),s=[...Object.getOwnPropertyNames(u),...e];if(s.includes("isSome")&&s.includes("isNone")){const e=u,s=e.isSome()?c.R.Some:c.R.None;return e.isSome()?t({0:s,1:e.unwrap()},`${i}${f}.`):[[`${i}${f}`,(0,h.AB)(s)]]}if(s.includes("isOk")&&s.includes("isErr")){const e=u,s=e.isOk()?l.B.Ok:l.B.Err;return t({0:s,1:e.unwrap()},`${i}${f}.`)}if(s.includes("variant")&&s.includes("activeVariant")){const e=u,s=e.activeVariant(),r=Object.keys(e.variant).findIndex((e=>e===s));return"object"==typeof e.unwrap()&&0===Object.keys(e.unwrap()).length?[[`${i}${f}`,(0,h.AB)(r)]]:t({0:r,1:e.unwrap()},`${i}${f}.`)}return t(u,`${i}${f}.`)}return[[`${i}${f}`,(0,h.AB)(u)]]}))};return Object.fromEntries(t(e))};let i;if(Array.isArray(e)){const s=t({...e});i=Object.values(s)}else{const s=t(e);i=Object.values(s)}return Object.defineProperty(i,"__compiled__",{enumerable:!1,writable:!1,value:!0}),i}parse(e,t){const{outputs:i}=this.abi.find((t=>t.name===e)),s=t.flat()[Symbol.iterator](),r=i.flat().reduce(((e,t,i)=>{const r=t.name??i;return e[r]=(0,g.A)(s,t,this.structs,this.enums,e),e[r]&&e[`${r}_len`]&&delete e[`${r}_len`],e}),{});return 1===Object.keys(r).length&&0 in r?r[0]:r}format(e,t,i){const s=this.parse(e,t);return(0,u.A)(s,i)}static getAbiStruct(e){return e.filter((e=>"struct"===e.type)).reduce(((e,t)=>({...e,[t.name]:t})),{})}static getAbiEnum(e){const t=e.filter((e=>"enum"===e.type)).reduce(((e,t)=>({...e,[t.name]:t})),{});return delete t["core::bool"],t}static toCalldata(e=[]){return y.compile(e)}static toHex(e=[]){return y.compile(e).map((e=>(0,a.nj)(e)))}decodeParameters(e,t){const i=Array.isArray(e)?e:[e],s=t.flat()[Symbol.iterator](),r=i.map((e=>(0,g.A)(s,{name:"",type:e},this.structs,this.enums)));return 1===r.length?r[0]:r}}},591:(e,t,i)=>{i.d(t,{CO:()=>n,k:()=>o});var s=i(15307),r=i(30568),a=i(17799);function o(e){const t=function(e){return e.find((e=>"interface"===e.type))?2:(0,s.cl)(e)?1:0}(e);if(0===t||1===t)return new r.V(e);if(2===t)return new a.O(e);throw Error(`Unsupported ABI version ${t}`)}function n(e,t,i){return"constructor"===e&&!i&&!t.length}},30568:(e,t,i)=>{i.d(t,{V:()=>r});var s=i(15307);class r{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.reduce(((e,t)=>(0,s.ct)(t.name)?e:e+1),0)}getMethod(e){return this.abi.find((t=>t.name===e))}getLegacyFormat(){return this.abi}}},17799:(e,t,i)=>{i.d(t,{O:()=>s});class s{constructor(e){this.abi=e}methodInputsLength(e){return e.inputs.length}getMethod(e){return this.abi.find((e=>"interface"===e.type)).items.find((t=>t.name===e))}getLegacyFormat(){return this.abi.flatMap((e=>"interface"===e.type?e.items:e))}}},90916:(e,t,i)=>{i.d(t,{A:()=>l});var s=i(13283),r=i(40274),a=i(15307),o=i(41668),n=i(49620),d=i(36863),h=i(37593),c=i(67925);function l(e,t,i,l){const u=(e,t)=>{if((0,a.G$)(t))return function(e,t){const i=(0,a.CS)(t);if((0,c.Kg)(e))return e;return e.map((e=>u(e,i)))}(e,t);if((0,a.iO)(t,l)){const i=l[t];return p(e,i)}if((0,a.Zm)(t))return function(e,t){const i=(0,h.A)(t).reduce(((t,i,s)=>{const r=Object.keys(e),a=i=>Object.defineProperty(t,s.toString(),{enumerable:!0,value:i??e[r[s]]}),o=i?.type?i.type:i;return a(u(e[r[s]],o)),t}),{});return i}(e,t);if((0,a.GY)(t))return e;if((0,a.ak)(t))return e;if((0,a.Z$)(t))return e;if(s.is.isAbiType(t)){const i=e;if("object"!=typeof i)return i;if(!("low"in i)||!("high"in i))throw Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`);return{low:i.low,high:i.high}}if(r.Ns.isAbiType(t)){const i=e;if("object"!=typeof i)return i;if(!["limb0","limb1","limb2","limb3"].every((e=>e in i)))throw function(e){return Error(`Your object includes the property : ${e}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(t);return{limb0:i.limb0,limb1:i.limb1,limb2:i.limb2,limb3:i.limb3}}if((0,a.wJ)(t,i)){const s=i[t].members;return f(e,s)}return e},f=(e,t)=>t.reduce(((t,i)=>{if("undefined"===e[i.name]&&((0,a.s8)(i.type)||!(0,a.ct)(i.name)))throw Error(`Your object needs a property with key : ${i.name} .`);var s;return s=u(e[i.name],i.type),Object.defineProperty(t,i.name,{enumerable:!0,value:s??e[i.name]}),t}),{});const p=(e,t)=>{if((0,a.u)(t.name)){const i=e,s=t.name.substring(t.name.indexOf("<")+1,t.name.lastIndexOf(",")),r=t.name.substring(t.name.indexOf(",")+1,t.name.lastIndexOf(">"));return i.isOk()?new o.G(o.B.Ok,u(e.unwrap(),s)):new o.G(o.B.Err,u(e.unwrap(),r))}if((0,a.e4)(t.name)){const i=e,s=t.name.substring(t.name.indexOf("<")+1,t.name.lastIndexOf(">"));return i.isSome()?new n.c(n.R.Some,u(i.unwrap(),s)):new n.c(n.R.None,{})}const i=e,s=Object.entries(i.variant).map((e=>{if(void 0===e[1])return e;const s=t.type.substring(t.type.lastIndexOf("<")+1,t.type.lastIndexOf(">"));return"()"===s?e:[e[0],u(i.unwrap(),s)]}));return new d.b(Object.fromEntries(s))};return t.reduce(((t,i)=>{return(0,a.ct)(i.name)&&!(0,a.s8)(i.type)||(s=u(e[i.name],i.type),Object.defineProperty(t,i.name,{enumerable:!0,value:s})),t;var s}),{})}},14365:(e,t,i)=>{i.d(t,{A:()=>m});var s=i(13283),r=i(40274),a=i(90178),o=i(11686),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(37593);function f(e,t){switch(!0){case s.is.isAbiType(e):return new s.is(t).toApiRequest();case r.Ns.isAbiType(e):return new r.Ns(t).toApiRequest();case(0,h.gr)(e):return(0,n.Mu)(t.toString());case(0,h.Z$)(e):{const e=(0,a.ow)((0,o.nj)(t)).padStart(128,"0"),i=(0,h.iN)((0,a.VO)(e.slice(-64))),s=(0,h.iN)((0,a.VO)(e.slice(0,-64)));return[(0,h.AB)(s.low),(0,h.AB)(s.high),(0,h.AB)(i.low),(0,h.AB)(i.high)]}default:return(0,h.AB)(t)}}function p(e,t,i,a){if(void 0===e)throw Error(`Missing parameter for type ${t}`);if(Array.isArray(e)){const s=[];s.push((0,h.AB)(e.length));const r=(0,h.CS)(t);return e.reduce(((e,t)=>e.concat(p(t,r,i,a))),s)}if(i[t]&&i[t].members.length){if(s.is.isAbiType(t))return new s.is(e).toApiRequest();if(r.Ns.isAbiType(t))return new r.Ns(e).toApiRequest();if("core::starknet::eth_address::EthAddress"===t)return f(t,e);if("core::byte_array::ByteArray"===t)return function(e){const t=(0,d.p)(e);return[t.data.length.toString(),...t.data.map((e=>e.toString())),t.pending_word.toString(),t.pending_word_len.toString()]}(e);const{members:o}=i[t],n=e;return o.reduce(((e,t)=>e.concat(p(n[t.name],t.type,i,a))),[])}if((0,h.Zm)(t)){const s=function(e,t){const i=(0,u.A)(t),s=Object.values(e);if(s.length!==i.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${s} \n expected: ${i}`);return i.map(((e,t)=>({element:s[t],type:e.type??e})))}(e,t);return s.reduce(((e,t)=>{const s=p(t.element,t.type,i,a);return e.concat(s)}),[])}if(s.is.isAbiType(t))return new s.is(e).toApiRequest();if(r.Ns.isAbiType(t))return new r.Ns(e).toApiRequest();if((0,h.iO)(t,a)){const{variants:s}=a[t];if((0,h.e4)(t)){const t=e;if(t.isSome()){const e=s.find((e=>"Some"===e.name));if(void 0===e)throw Error("Error in abi : Option has no 'Some' variant.");const r=e.type;if("()"===r)return c.R.Some.toString();const o=p(t.unwrap(),r,i,a);return Array.isArray(o)?[c.R.Some.toString(),...o]:[c.R.Some.toString(),o]}return c.R.None.toString()}if((0,h.u)(t)){const t=e;if(t.isOk()){const e=s.find((e=>"Ok"===e.name));if(void 0===e)throw Error("Error in abi : Result has no 'Ok' variant.");const r=e.type;if("()"===r)return l.B.Ok.toString();const o=p(t.unwrap(),r,i,a);return Array.isArray(o)?[l.B.Ok.toString(),...o]:[l.B.Ok.toString(),o]}const r=s.find((e=>"Err"===e.name));if(void 0===r)throw Error("Error in abi : Result has no 'Err' variant.");const o=r.type;if("()"===o)return l.B.Err.toString();const n=p(t.unwrap(),o,i,a);return Array.isArray(n)?[l.B.Err.toString(),...n]:[l.B.Err.toString(),n]}const r=e,o=r.activeVariant(),n=s.find((e=>e.name===o));if(void 0===n)throw Error(`Not find in abi : Enum has no '${o}' variant.`);const d=n.type,u=s.findIndex((e=>e.name===o));if("()"===d)return u.toString();const f=p(r.unwrap(),d,i,a);return Array.isArray(f)?[u.toString(),...f]:[u.toString(),f]}if("object"==typeof e)throw Error(`Parameter ${e} do not align with abi parameter ${t}`);return f(t,e)}function m(e,t,i,r){const{name:a,type:o}=t;let{value:d}=e.next();switch(!0){case(0,h.G$)(o):if(!Array.isArray(d)&&!(0,n.KH)(d))throw Error(`ABI expected parameter ${a} to be array or long string, got ${d}`);return(0,n.Kg)(d)&&(d=(0,n.mE)(d)),p(d,t.type,i,r);case"core::starknet::eth_address::EthAddress"===o:return f(o,d);case(0,h.wJ)(o,i)||(0,h.Zm)(o)||s.is.isAbiType(o)||s.is.isAbiType(o):case(0,h.iO)(o,r):return p(d,o,i,r);default:return f(o,d)}}},43463:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(13283),r=i(40274),a=i(90178),o=i(11686),n=i(67925),d=i(62256),h=i(15307),c=i(49620),l=i(41668),u=i(36863),f=i(37593);function p(e,t){let i;switch(!0){case(0,h.Fi)(e):return i=t.next().value,Boolean(BigInt(i));case s.is.isAbiType(e):const o=t.next().value,d=t.next().value;return new s.is(o,d).toBigInt();case r.Ns.isAbiType(e):const c=t.next().value,l=t.next().value,u=t.next().value,f=t.next().value;return new r.Ns(c,l,u,f).toBigInt();case"core::starknet::eth_address::EthAddress"===e:return i=t.next().value,BigInt(i);case"core::bytes_31::bytes31"===e:return i=t.next().value,(0,n.Wb)(i);case(0,h.Z$)(e):const p=(0,a.ow)(t.next().value).padStart(32,"0"),m=(0,a.ow)(t.next().value).padStart(32,"0"),g=(0,a.ow)(t.next().value).padStart(32,"0"),v=(0,a.ow)(t.next().value).padStart(32,"0");return BigInt((0,a.VO)(m+p+v+g));default:return i=t.next().value,BigInt(i)}}function m(e,t,i,a){if("()"===t.type)return{};if(s.is.isAbiType(t.type)){const t=e.next().value,i=e.next().value;return new s.is(t,i).toBigInt()}if(r.Ns.isAbiType(t.type)){const t=e.next().value,i=e.next().value,s=e.next().value,a=e.next().value;return new r.Ns(t,i,s,a).toBigInt()}if((0,h.ak)(t.type)){const t=[],i=BigInt(e.next().value);for(;t.length<i;)t.push((0,o.nj)(e.next().value));const s={data:t,pending_word:(0,o.nj)(e.next().value),pending_word_len:BigInt(e.next().value)};return(0,d.f)(s)}if((0,h.G$)(t.type)){const s=[],r={name:"",type:(0,h.CS)(t.type)},o=BigInt(e.next().value);for(;s.length<o;)s.push(m(e,r,i,a));return s}if(i&&t.type in i&&i[t.type])return"core::starknet::eth_address::EthAddress"===t.type?p(t.type,e):i[t.type].members.reduce(((t,s)=>(t[s.name]=m(e,s,i,a),t)),{});if(a&&t.type in a&&a[t.type]){const s=Number(e.next().value),r=a[t.type].variants.reduce(((t,r,o)=>o===s?(t[r.name]=m(e,{name:"",type:r.type},i,a),t):(t[r.name]=void 0,t)),{});if(t.type.startsWith("core::option::Option")){const e=s===c.R.Some?r.Some:void 0;return new c.c(s,e)}if(t.type.startsWith("core::result::Result")){let e;return e=s===l.B.Ok?r.Ok:r.Err,new l.G(s,e)}return new u.b(r)}if((0,h.Zm)(t.type)){return(0,f.A)(t.type).reduce(((t,s,r)=>{const o=s?.name?s.name:r,n={name:o,type:s?.type?s.type:s};return t[o]=m(e,n,i,a),t}),{})}if((0,h.G$)(t.type)){const s=[],r={name:"",type:(0,h.CS)(t.type)},o=BigInt(e.next().value);for(;s.length<o;)s.push(m(e,r,i,a));return s}return p(t.type,e)}function g(e,t,i,s,r){const{name:a,type:o}=t;let n;switch(!0){case(0,h.ct)(a):return n=e.next().value,BigInt(n);case i&&o in i||(0,h.Zm)(o):case s&&(0,h.iO)(o,s):return m(e,t,i,s);case(0,h.G$)(o):if((0,h.s8)(o))return m(e,t,i,s);const d=[];if(r&&r[`${a}_len`]){const o=r[`${a}_len`];for(;d.length<o;)d.push(m(e,{name:a,type:t.type.replace("*","")},i,s))}return d;default:return p(o,e)}}},37593:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(15307);function r(e,t,i){for(let s=0,r=0;s<e.length;s++)if(e[s]===t)r++;else if(e[s]===i&&0==--r)return s;return Number.POSITIVE_INFINITY}function a(e){return(0,s.s8)(e)?function(e){const t=e.slice(1,-1),i=[];let s,a=0;for(;a<t.length;){switch(!0){case"("===t[a]:s=a+r(t.slice(a),"(",")")+1;break;case t.startsWith("core::result::Result::<",a)||t.startsWith("core::array::Array::<",a)||t.startsWith("core::option::Option::<",a):s=a+r(t.slice(a),"<",">")+1;break;default:{const e=t.indexOf(",",a);s=-1!==e?e:Number.POSITIVE_INFINITY}}i.push(t.slice(a,s)),a=s+2}return i}(e):function(e){const t=e.replace(/\s/g,"").slice(1,-1),{subTuple:i,result:r}=function(e){if(!e.includes("("))return{subTuple:[],result:e};const t=[];let i="",s=0;for(;s<e.length;){if("("===e[s]){let r=1;const a=s;for(s++;r;)")"===e[s]&&r--,"("===e[s]&&r++,s++;t.push(e.substring(a,s)),i+=" ",s--}else i+=e[s];s++}return{subTuple:t,result:i}}(t);let a=r.split(",").map((e=>i.length?e.replace(" ",i.shift()):e));return(0,s.mQ)(e)&&(a=a.reduce(((e,t)=>e.concat(function(e){const t=e.substring(0,e.indexOf(":"));return{name:t,type:e.substring(t.length+1)}}(t))),[])),a}(e)}},39873:(e,t,i)=>{i.d(t,{A:()=>b});var s=i(20040),r=i(79550),a=i(13283),o=i(40274),n=i(11686),d=i(67925),h=i(15307);const c=(e,t)=>{if((0,r.A)((0,d.Kg)(e)||(0,n.Et)(e)||(0,n.sI)(e),`Validate: arg ${t.name} should be a felt typed as (String, Number or BigInt)`),(0,d.Kg)(e)&&!(0,n.qv)(e))return;const i=BigInt(e.toString(10));(0,r.A)(i>=0n&&i<=2n**252n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^252-1]`)},l=(e,t)=>{(0,r.A)((0,d.Kg)(e),`Validate: arg ${t.name} should be a string.`),(0,r.A)(e.length<32,`Validate: arg ${t.name} cairo typed ${t.type} should be a string of less than 32 characters.`)},u=(e,t)=>{(0,r.A)((0,d.Kg)(e),`Validate: arg ${t.name} should be a string.`)},f=(e,t)=>{let i;switch((0,n.Et)(e)&&(0,r.A)(e<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),(0,r.A)((0,d.Kg)(e)||(0,n.Et)(e)||(0,n.sI)(e)||"object"==typeof e&&"low"in e&&"high"in e||"object"==typeof e&&["limb0","limb1","limb2","limb3"].every((t=>t in e)),`Validate: arg ${t.name} of cairo type ${t.type} should be type (String, Number or BigInt), but is ${typeof e} ${e}.`),t.type){case s.Fg.u256:i=new a.is(e).toBigInt();break;case s.Fg.u512:i=new o.Ns(e).toBigInt();break;default:i=(0,n.Dg)(e)}switch(t.type){case s.Fg.u8:(0,r.A)(i>=0n&&i<=255n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0 - 255]`);break;case s.Fg.u16:(0,r.A)(i>=0n&&i<=65535n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 65535]`);break;case s.Fg.u32:(0,r.A)(i>=0n&&i<=4294967295n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 4294967295]`);break;case s.Fg.u64:(0,r.A)(i>=0n&&i<=2n**64n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^64-1]`);break;case s.Fg.u128:(0,r.A)(i>=0n&&i<=2n**128n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^128-1]`);break;case s.Fg.u256:(0,r.A)(i>=0n&&i<=2n**256n-1n,`Validate: arg ${t.name} is ${t.type} 0 - 2^256-1`);break;case s.Fg.u512:(0,r.A)(o.Ns.is(i),`Validate: arg ${t.name} is ${t.type} 0 - 2^512-1`);break;case s.uS.ClassHash:case s.uS.ContractAddress:(0,r.A)(i>=0n&&i<=2n**252n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^252-1]`);break;case s.uS.Secp256k1Point:(0,r.A)(i>=0n&&i<=2n**512n-1n,`Validate: arg ${t.name} must be ${t.type} : a 512 bits number.`)}},p=(e,t)=>{(0,r.A)((0,n.Lm)(e),`Validate: arg ${t.name} of cairo type ${t.type} should be type (Boolean)`)},m=(e,t,i)=>{if(t.type!==s.Fg.u256&&t.type!==s.Fg.u512)if("core::starknet::eth_address::EthAddress"!==t.type)(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} is cairo type struct (${t.type}), and should be defined as js object (not array)`),i[t.type].members.forEach((({name:i})=>{(0,r.A)(Object.keys(e).includes(i),`Validate: arg ${t.name} should have a property ${i}`)}));else{(0,r.A)("object"!=typeof e,`EthAddress type is waiting a BigNumberish. Got ${e}`);const i=BigInt(e.toString(10));(0,r.A)(i>=0n&&i<=2n**160n-1n,`Validate: arg ${t.name} cairo typed ${t.type} should be in range [0, 2^160-1]`)}else f(e,t)},g=(e,t)=>{(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} is cairo type Enum (${t.type}), and should be defined as js object (not array)`);const i=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),s=[...Object.getOwnPropertyNames(e),...i];if(!((0,h.e4)(t.type)&&s.includes("isSome")&&s.includes("isNone")||(0,h.u)(t.type)&&s.includes("isOk")&&s.includes("isErr")||s.includes("variant")&&s.includes("activeVariant")))throw new Error(`Validate Enum: argument ${t.name}, type ${t.type}, value received ${e}, is not an Enum.`)},v=(e,t)=>{(0,r.A)("object"==typeof e&&!Array.isArray(e),`Validate: arg ${t.name} should be a tuple (defined as object)`)},y=(e,t,i,s)=>{const a=(0,h.CS)(t.type);if(!(0,h.sB)(a)||!(0,d.IN)(e))switch((0,r.A)(Array.isArray(e),`Validate: arg ${t.name} should be an Array`),!0){case(0,h.sB)(a):e.forEach((e=>c(e,t)));break;case(0,h.Zm)(a):e.forEach((e=>v(e,{name:t.name,type:a})));break;case(0,h.G$)(a):e.forEach((e=>y(e,{name:"",type:a},i,s)));break;case(0,h.wJ)(a,i):e.forEach((e=>m(e,{name:t.name,type:a},i)));break;case(0,h.iO)(a,s):e.forEach((e=>g(e,{name:t.name,type:a})));break;case(0,h.$H)(a)||(0,h.Gw)(a):e.forEach((e=>f(e,{name:"",type:a})));break;case(0,h.Fi)(a):e.forEach((e=>p(e,t)));break;default:throw new Error(`Validate Unhandled: argument ${t.name}, type ${t.type}, value ${e}`)}};function b(e,t,i,s){e.inputs.reduce(((e,r)=>{const a=t[e];switch(!0){case(0,h.ct)(r.name):return e;case(0,h.sB)(r.type):c(a,r);break;case(0,h.gr)(r.type):l(a,r);break;case(0,h.$H)(r.type)||(0,h.Gw)(r.type):f(a,r);break;case(0,h.Fi)(r.type):p(a,r);break;case(0,h.ak)(r.type):u(a,r);break;case(0,h.G$)(r.type):y(a,r,i,s);break;case(0,h.wJ)(r.type,i):m(a,r,i);break;case(0,h.iO)(r.type,s):g(a,r);break;case(0,h.Zm)(r.type):v(a,r);break;default:throw new Error(`Validate Unhandled: argument ${r.name}, type ${r.type}, value ${a}`)}return e+1}),0)}},90178:(e,t,i)=>{i.d(t,{VO:()=>a,ow:()=>r,yw:()=>s});function s(e){return(new TextEncoder).encode(e)}function r(e){return e.replace(/^0x/i,"")}function a(e){return`0x${r(e)}`}},69491:(e,t,i)=>{i.d(t,{CL:()=>d,dl:()=>u,ez:()=>l,h$:()=>h,r4:()=>f});var s=i(33187),r=i(58325),a=i(46907),o=i(15307),n=i(11686);function d(e,t){return(0,s.NO)(BigInt(e),BigInt(t))}function h(e,t){return(0,n.nj)((0,s.Ef)(BigInt(e),BigInt(t)))}function c(e){return[...e,e.length].reduce(((e,t)=>(0,s.NO)(BigInt(e),BigInt(t))),0).toString()}const l=c;function u(e){return(0,n.nj)((0,s.pd)(e.map((e=>BigInt(e)))))}function f(e,t,i,s){const d=c(a.fP.compile(i)),h=c([(0,o.AB)("0x535441524b4e45545f434f4e54524143545f41444452455353"),s,e,t,d]);return(0,n.nj)(BigInt(h)%r.Vi)}},38354:(e,t,i)=>{i.d(t,{v:()=>r});var s=i(69491);class r{constructor(e,t=s.CL){this.branches=[],this.hashMethod=t,this.leaves=e,this.root=this.build(e)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const t=[];for(let i=0;i<e.length;i+=2)i+1===e.length?t.push(r.hash(e[i],"0x0",this.hashMethod)):t.push(r.hash(e[i],e[i+1],this.hashMethod));return this.build(t)}static hash(e,t,i=s.CL){const[r,a]=[BigInt(e),BigInt(t)].sort(((e,t)=>e>=t?1:-1));return i(r,a)}getProof(e,t=this.leaves,i=[]){const s=t.indexOf(e);if(-1===s)throw new Error("leaf not found");if(1===t.length)return i;const a=s%2==0,o=(a?t[s+1]:t[s-1])??"0x0",n=[...i,o],d=this.leaves.length===t.length?-1:this.branches.findIndex((e=>e.length===t.length)),h=this.branches[d+1]??[this.root];return this.getProof(r.hash(a?e:o,a?o:e,this.hashMethod),h,n)}}},11686:(e,t,i)=>{i.d(t,{A6:()=>d,Dg:()=>a,Et:()=>h,Lm:()=>c,nj:()=>n,qv:()=>r,sI:()=>o});var s=i(90178);function r(e){return/^0x[0-9a-f]*$/i.test(e)}function a(e){return BigInt(e)}function o(e){return"bigint"==typeof e}function n(e){return(0,s.VO)(a(e).toString(16))}const d=e=>/^\d+$/.test(e);function h(e){return"number"==typeof e}function c(e){return"boolean"==typeof e}},69793:(e,t,i)=>{i.d(t,{BK:()=>d});var s=i(33187),r=i(58325),a=i(90178),o=i(11686);function n(e){const t=BigInt(function(e){return(0,a.VO)((0,s.Dq)((0,a.yw)(e)).toString(16))}(e));return t&r.n$}function d(e){return(0,o.nj)(n(e))}},67925:(e,t,i)=>{i.d(t,{IN:()=>c,KH:()=>h,Kg:()=>d,Mu:()=>u,O4:()=>n,Wb:()=>f,mE:()=>l});var s=i(58325),r=i(90178),a=i(11686);function o(e){return/^[\x00-\x7F]*$/.test(e)}function n(e){return e.length<=s.p7}function d(e){return"string"==typeof e}function h(e){return d(e)&&!(0,a.qv)(e)&&!(0,a.A6)(e)}const c=e=>h(e)&&!n(e);function l(e){const t=RegExp(`[^]{1,${s.p7}}`,"g");return e.match(t)||[]}function u(e){if(!o(e))throw new Error(`${e} is not an ASCII string`);if(!n(e))throw new Error(`${e} is too long`);return(0,r.VO)(e.replace(/./g,(e=>e.charCodeAt(0).toString(16))))}function f(e){if(!o(e))throw new Error(`${e} is not an ASCII string`);if((0,a.qv)(e))return(0,r.ow)(e).replace(/.{2}/g,(e=>String.fromCharCode(parseInt(e,16))));if(function(e){return/^[0-9]*$/i.test(e)}(e))return f("0X".concat(BigInt(e).toString(16)));throw new Error(`${e} is not Hex or decimal`)}},21878:(e,t,i)=>{i.d(t,{E:()=>S});var s=i(58325),r=i(30162),a=i(79550),o=i(62256),n=i(69491),d=i(69793),h=i(38354),c=i(11686),l=i(67925);const u={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},f={[r.K.Active]:{domain:"StarknetDomain",hashMethod:n.dl,hashMerkleMethod:n.h$,escapeTypeString:e=>`"${e}"`,presetTypes:u},[r.K.Legacy]:{domain:"StarkNetDomain",hashMethod:n.ez,hashMerkleMethod:n.CL,escapeTypeString:e=>e,presetTypes:{}}};function p(e,t,{min:i,max:s}){const r=BigInt(e);(0,a.A)(r>=i&&r<=s,`${r} (${t}) is out of bounds [${i}, ${s}]`)}function m({types:e,domain:t}){return f[r.K.Active].domain in e&&t.revision===r.K.Active?r.K.Active:f[r.K.Legacy].domain in e&&(t.revision??r.K.Legacy)===r.K.Legacy?r.K.Legacy:void 0}function g(e){try{return(0,c.nj)(e)}catch(t){if((0,l.Kg)(e))return(0,c.nj)((0,l.Mu)(e));throw new Error(`Invalid BigNumberish: ${e}`)}}function v(e,t,i=[],s="",a=r.K.Legacy){return"*"===t[t.length-1]?t=t.slice(0,-1):a===r.K.Active&&("enum"===t?t=s:t.match(/^\(.*\)$/)&&(t=t.slice(1,-1))),i.includes(t)||!e[t]?i:[t,...e[t].reduce(((t,i)=>[...t,...v(e,i.type,t,i.contains,a).filter((e=>!t.includes(e)))]),[])]}function y(e,t,i=r.K.Legacy){const s=i===r.K.Active?{...e,...f[i].presetTypes}:e,[a,...o]=v(s,t,void 0,void 0,i),n=a?[a,...o.sort()]:[],d=f[i].escapeTypeString;return n.map((e=>{const t=s[e].map((e=>{const t="enum"===e.type&&i===r.K.Active?e.contains:e.type,s=t.match(/^\(.*\)$/)?`(${t.slice(1,-1).split(",").map((e=>e?d(e):e)).join(",")})`:d(t);return`${d(e.name)}:${s}`}));return`${d(e)}(${t})`})).join("")}function b(e,t,i=r.K.Legacy){return(0,d.BK)(y(e,t,i))}function w(e,t,i,n={},l=r.K.Legacy){if(e[t])return[t,k(e,t,i,l)];if(f[l].presetTypes[t])return[t,k(f[l].presetTypes,t,i,l)];if(t.endsWith("*")){const s=i.map((i=>w(e,t.slice(0,-1),i,void 0,l)[1]));return[t,f[l].hashMethod(s)]}switch(t){case"enum":if(l===r.K.Active){const[s,r]=Object.entries(i)[0],a=e[n.parent][0],o=e[a.contains],d=o.find((e=>e.name===s)),h=o.indexOf(d),c=d.type.slice(1,-1).split(",").map(((t,i)=>{if(!t)return t;const s=r[i];return w(e,t,s,void 0,l)[1]}));return[t,f[l].hashMethod([h,...c])]}return[t,g(i)];case"merkletree":{const t=function(e,t){if(t.parent&&t.key){const i=e[t.parent].find((e=>e.name===t.key));if("merkletree"!==i.type)throw new Error(`${t.key} is not a merkle tree`);if(i.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${t.key}`);return i.contains}return"raw"}(e,n),s=i.map((i=>w(e,t,i,void 0,l)[1])),{root:r}=new h.v(s,f[l].hashMerkleMethod);return["felt",r]}case"selector":return["felt",(u=i,(0,c.qv)(u)?u:(0,d.BK)(u))];case"string":if(l===r.K.Active){const e=(0,o.p)(i),s=[e.data.length,...e.data,e.pending_word,e.pending_word_len];return[t,f[l].hashMethod(s)]}return[t,g(i)];case"i128":if(l===r.K.Active){const e=BigInt(i);return p(e,t,s.He),[t,g(e<0n?s.s9+e:e)]}return[t,g(i)];case"timestamp":case"u128":return l===r.K.Active&&p(i,t,s.bE),[t,g(i)];case"felt":case"shortstring":return l===r.K.Active&&p(g(i),t,s.Kp),[t,g(i)];case"ClassHash":case"ContractAddress":return l===r.K.Active&&p(i,t,s.Kp),[t,g(i)];case"bool":return l===r.K.Active&&(0,a.A)("boolean"==typeof i,`Type mismatch for ${t} ${i}`),[t,g(i)];default:if(l===r.K.Active)throw new Error(`Unsupported type: ${t}`);return[t,g(i)]}var u}function k(e,t,i,s=r.K.Legacy){return f[s].hashMethod(function(e,t,i,s=r.K.Legacy){const a=e[t]??f[s].presetTypes[t],[o,n]=a.reduce((([r,a],o)=>{if(void 0===i[o.name]||null===i[o.name]&&"enum"!==o.type)throw new Error(`Cannot encode data: missing data for '${o.name}'`);const n=i[o.name],d={parent:t,key:o.name},[h,c]=w(e,o.type,n,d,s);return[[...r,h],[...a,c]]}),[["felt"],[b(e,t,s)]]);return[o,n]}(e,t,i,s)[1])}function S(e,t){if(!function(e){const t=e;return Boolean(t.message&&t.primaryType&&t.types&&m(t))}(e))throw new Error("Typed data does not match JSON schema");const i=m(e),{domain:s,hashMethod:r}=f[i];return r([(0,l.Mu)("StarkNet Message"),k(e.types,s,e.domain,i),t,k(e.types,e.primaryType,e.message,i)])}},22634:(e,t,i)=>{var s;i.d(t,{V:()=>o});const r=new WeakMap,a=()=>{};class o{constructor(e){this.subscribers=[],this.settlement=null,this[s]="Unpromise",this.promise="function"==typeof e?new Promise(e):e;const t=this.promise.then((e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:e},t?.forEach((({resolve:t})=>{t(e)}))}));"catch"in t&&t.catch((e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"rejected",reason:e},t?.forEach((({reject:t})=>{t(e)}))}))}subscribe(){let e,t;const{settlement:i}=this;if(null===i){if(null===this.subscribers)throw new Error("Unpromise settled but still has subscribers");const i=function(){let e,t;const i=new Promise(((i,s)=>{e=i,t=s}));return{promise:i,resolve:e,reject:t}}();this.subscribers=(s=this.subscribers,r=i,[...s,r]),e=i.promise,t=()=>{null!==this.subscribers&&(this.subscribers=function(e,t){const i=e.indexOf(t);if(-1!==i)return function(e,t){return[...e.slice(0,t),...e.slice(t+1)]}(e,i);return e}(this.subscribers,i))}}else{const{status:s}=i;e="fulfilled"===s?Promise.resolve(i.value):Promise.reject(i.reason),t=a}var s,r;return Object.assign(e,{unsubscribe:t})}then(e,t){const i=this.subscribe(),{unsubscribe:s}=i;return Object.assign(i.then(e,t),{unsubscribe:s})}catch(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.catch(e),{unsubscribe:i})}finally(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.finally(e),{unsubscribe:i})}static proxy(e){const t=o.getSubscribablePromise(e);return void 0!==t?t:o.createSubscribablePromise(e)}static createSubscribablePromise(e){const t=new o(e);return r.set(e,t),r.set(t,t),t}static getSubscribablePromise(e){return r.get(e)}static resolve(e){const t="object"==typeof e&&null!==e&&"then"in e&&"function"==typeof e.then?e:Promise.resolve(e);return o.proxy(t).subscribe()}static async any(e){const t=(Array.isArray(e)?e:[...e]).map(o.resolve);try{return await Promise.any(t)}finally{t.forEach((({unsubscribe:e})=>{e()}))}}static async race(e){const t=(Array.isArray(e)?e:[...e]).map(o.resolve);try{return await Promise.race(t)}finally{t.forEach((({unsubscribe:e})=>{e()}))}}static async raceReferences(e){const t=e.map(n);try{return await Promise.race(t)}finally{for(const e of t)e.unsubscribe()}}}function n(e){return o.proxy(e).then((()=>[e]))}s=Symbol.toStringTag},7814:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"swapwallet",name:"Swapwallet",countries:["IR"],rateLimit:1e3,version:"v2",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://swapwallet.app/api/v2"},www:"https://swapwallet.app",doc:"https://swapwallet.app/api/v2/market/crypto/stats"},api:{public:{get:{"market/crypto/stats":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetMarketCryptoStats(e),i=this.safeDict(t,"result",{}),s=Object.keys(i),r=[];for(let e=0;e<s.length;e++){const t=s[e];r.push(this.parseMarket(this.extend(i[t],{id:t})))}return r}parseMarket(e){const t=this.safeString(e,"source"),i=this.safeString(e,"destination"),s=this.safeCurrencyCode(t),r=this.safeCurrencyCode(i);return{id:this.safeString(e,"id",t+"-"+i),symbol:s+"/"+r,base:s,quote:r,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.publicGetMarketCryptoStats(t),s=this.safeDict(i,"result",{}),r=Object.keys(s),a={};for(let e=0;e<r.length;e++){const t=r[e],i=this.parseTicker(s[t]);a[i.symbol]=i}return this.filterByArrayTickers(a,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e);return(await this.fetchTickers([i.symbol],t))[i.symbol]}parseTicker(e,t=void 0){const i=this.safeString(e,"source")+"-"+this.safeString(e,"destination"),s=this.safeSymbol(i,t,"-","otc"),r=this.safeDict(e,"marketData",{}),a=this.safeString(r,"latestPrice");return this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:this.safeString(r,"bestBuy"),bidVolume:void 0,ask:this.safeString(r,"bestSell"),askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:void 0,percentage:this.safeString(r,"dayChange"),average:void 0,baseVolume:this.safeString(r,"volume24h"),quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api[t]+"/"+this.implodeParams(e,s);return Object.keys(o).length&&(n+="?"+this.urlencode(o)),{url:n,method:i,body:a,headers:r=this.extend({"Content-Type":"application/json"},r)}}}},35619:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(5156);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tabdeal",name:"Tabdeal",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tabdeal/64x64.png",api:{public:"https://api.tabdeal.org"},www:"https://tabdeal.org",doc:["https://docs.tabdeal.org"]},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"1D","1w":"1W"},api:{public:{get:{"plots/market_information":1,"r/api/v1/depth":1,"r/plots/history/":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetPlotsMarketInformation(e),i=[];for(let e=0;e<t.length;e++){const s=this.parseMarket(t[e]);i.push(s)}return i}parseMarket(e){const t=this.safeString(e,"symbol");let[i,s]=t.split("_");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetPlotsMarketInformation(t),s={};for(let e=0;e<i.length;e++){const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"high",0),a=this.safeFloat(e,"low",0),o=this.safeFloat(e,"open",0),n=this.safeFloat(e,"price",0),d=this.safeFloat(e,"price",0),h=this.safeFloat(e,"price",0),c=this.safeFloat(e,"volume",0),l=c*h,u=this.safeString(e,"created");return this.safeTicker({symbol:s,timestamp:this.safeTimestamp(e,"created"),datetime:u,high:r,low:a,bid:n,bidVolume:void 0,ask:d,askVolume:void 0,vwap:void 0,open:o,close:h,last:h,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:c,quoteVolume:l,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.id,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetRPlotsHistory(n),h=this.safeList(d,"data"),c=[];for(let e=0;e<h.length;e++){const t=h[e],i=this.safeValue(t,"time"),s=this.safeFloat(t,"open"),r=this.safeFloat(t,"high"),a=this.safeFloat(t,"low"),o=this.safeFloat(t,"close"),n=this.safeFloat(t,"volume");c.push([i,s,r,a,o,n])}return this.parseOHLCVs(c,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={tabdealSymbol:this.market(e).id},r=await this.publicGetRApiV1Depth(s),a=this.milliseconds();return this.parseOrderBook(r,e,a)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"r/plots/history/"===e&&(n=n+"?"+this.urlencode(o)),"r/api/v1/depth"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},90200:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talaavan",name:"Talaavan",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://goldcore.talaavan.com"},www:"https://goldcore.talaavan.com",doc:"https://goldcore.talaavan.com/v1/price"},api:{public:{get:{"v1/price":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV1Price(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"status",!1),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1Price(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1Price(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"data",{});let s=this.safeNumber(i,"rate");return void 0!==s&&(s/=10),this.safeTicker({symbol:t.symbol,timestamp:this.parse8601(this.safeString(i,"date")),datetime:void 0,high:void 0,low:void 0,bid:s,bidVolume:void 0,ask:s,askVolume:void 0,vwap:void 0,open:void 0,close:s,last:s,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:i},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},30236:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talapp",name:"Talapp",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://talapp.ir"},www:"https://talapp.ir",doc:"https://talapp.ir/wp-json/talapp/v1/gold-prices"},api:{public:{get:{"wp-json/talapp/v1/gold-prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetWpJsonTalappV1GoldPrices(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:!this.safeBool(e,"stale",!1),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetWpJsonTalappV1GoldPrices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetWpJsonTalappV1GoldPrices(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeString(e,"fetched_at");let s;void 0!==i&&(s=this.parse8601(i.replace(" ","T")+"+03:30"));const r=this.safeNumber(e,"buy_gold"),a=this.safeNumber(e,"sell_gold");let o=r;return void 0!==a&&(void 0===o||a>o)&&(o=a),this.safeTicker({symbol:t.symbol,timestamp:s,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:a,askVolume:void 0,vwap:void 0,open:void 0,close:o,last:o,previousClose:void 0,change:void 0,percentage:this.safeNumber(e,"sell_diff"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},43829:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"talasea",name:"Talasea",countries:["IR"],rateLimit:1e3,version:"api",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,otc:!0,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},options:{defaultType:"otc"},urls:{api:{public:"https://api.talasea.ir/api"},www:"https://talasea.ir",doc:"https://talasea.ir"},api:{public:{get:{"market/getGoldPrice":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.01"),taker:this.parseNumber("0.01")}}})}async fetchMarkets(e={}){const t=await this.publicGetMarketGetGoldPrice(e);return[this.parseMarket(t)]}parseMarket(e){const t=this.safeBool(e,"disableBuy",!1),i=this.safeBool(e,"disableSell",!1);let s=!0;(t||i)&&(s=!1);return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:s,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"minOrderValue"),max:this.safeNumber(e,"maxOrderValue")}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetMarketGetGoldPrice(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetMarketGetGoldPrice(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:1e3*this.safeNumber(e,"price"),last:1e3*this.safeNumber(e,"price"),previousClose:void 0,change:void 0,percentage:this.safeNumber(e,"change24h"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api[t]+"/"+this.implodeParams(e,s);return Object.keys(o).length&&(n+="?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},80501:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"technogold",name:"Techno Gold",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api2.technogold.gold"},www:"https://technogold.gold",doc:"https://technogold.gold"},api:{public:{get:{"customer/tradeables/only-price/1":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetCustomerTradeablesOnlyPrice1(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"succeed",!0),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetCustomerTradeablesOnlyPrice1(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=this.market("XAU18/IRT"),s=await this.publicGetCustomerTradeablesOnlyPrice1(t),r=this.parseTicker(s,i),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"results",{}),s=this.safeNumber(i,"buy_price"),r=this.safeNumber(i,"sell_price");let a=s;return void 0!==r&&(void 0===a||r>a)&&(a=r),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:s,bidVolume:void 0,ask:r,askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},67496:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(73835);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tehran_exchange",name:"Tehran Exchange",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tehran_exchange/64x64.png",api:{public:"https://otc-api.tehran.exchange"},www:"https://tehran.exchange",doc:["https://tehran.exchange"]},api:{public:{get:{"otc/v1/market/pair":1,"otc/v1/market/order/pair/price":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")}}})}async fetchMarkets(e={}){const t=await this.publicGetOtcV1MarketPair(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"pairs",[]),r=[];for(let e=0;e<s.length;e++){const t=this.parseMarket(s[e]);r.push(t)}return r}parseMarket(e){const t=this.safeString(e,"pair"),i=this.safeString(e,"baseSymbol"),s=this.safeString(e,"quoteSymbol"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s),o=this.safeString(e,"status"),n=this.safeBool(e,"tradable",!1),d="TRADABLE"===o&&n,h=this.safeInteger(e,"amountPrecision"),c=this.safeInteger(e,"pricePrecision"),l=this.safeString(e,"minBaseAmount"),u=this.safeString(e,"minQuoteAmount"),f=this.safeString(e,"maxQuoteAmount");return{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:d,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:h,price:c},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(l),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.parseNumber(u),max:this.parseNumber(f)}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetOtcV1MarketPair(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"pairs",[]),a=[];for(let t=0;t<r.length;t++){const i=r[t],s=this.safeString(i,"pair"),o=this.safeSymbol(s);e.includes(o)&&a.push(i)}const o={};for(let e=0;e<a.length;e++){const t=a[e],i={pair:this.safeString(t,"pair"),side:"BUY",basedOn:"BASE",amount:1},s=await this.publicGetOtcV1MarketOrderPairPrice(i),r=this.safeDict(s,"data",{}),n=this.safeFloat(r,"price",0);t.price=n;const d=this.parseTicker(t);o[d.symbol]=d}return this.filterByArrayTickers(o,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[this.safeSymbol(e)]}parseTicker(e,t=void 0){const i=this.safeString(e,"baseSymbol")+"/"+this.safeString(e,"quoteSymbol"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"price");return this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:r,askVolume:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return Object.keys(o).length&&(n+="?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},77497:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(29012);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tetherland",name:"TetherLand",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/tetherland/64x64.png",api:{public:"https://service.tetherland.com"},www:"https://tetherland.org",doc:["https://docs.tetherland.com/docs/tetherland/71ca11f41704f-user-api"]},api:{public:{get:{"api/v5/currencies":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiV5Currencies(e),i=this.safeList(t,"data"),s=[],r=["USDT","IRT"];for(let e=0;e<i.length;e++)for(let t=0;t<r.length;t++){if("USDT"===i[e].symbol&&"USDT"===r[t])continue;i[e].quote=r[t];const a=this.parseMarket(i[e]);s.push(a)}return s}parseMarket(e){let[t,i]=[this.safeString(e,"symbol"),this.safeString(e,"quote")];const s=this.safeCurrencyCode(t),r=this.safeCurrencyCode(i),a=s+"/"+r;return t=t.toLowerCase(),i=i.toLowerCase(),{id:a,symbol:s+"/"+r,base:s,quote:r,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiV5Currencies(t),s=this.safeList(i,"data"),r={},a=["USDT","IRT"];for(let e=0;e<s.length;e++)for(let t=0;t<a.length;t++){if("USDT"===s[e].symbol&&"USDT"===a[t])continue;s[e].quote=a[t],s[e].id=s[e].symbol+"/"+s[e].quote;const i=this.parseTicker(s[e]);r[i.symbol]=i}return this.filterByArrayTickers(r,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeString(e,"quote"),r=this.safeSymbol(i,t,void 0,"spot");let a=parseFloat(this.safeString(e,"price","").replace(",",""));"IRT"===s&&(a=this.safeFloat(e,"toman_amount",0));const o=this.safeFloat(e,"changes_24h",0);return this.safeTicker({symbol:r,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:a,last:a,previousClose:void 0,change:o,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){return{url:this.urls.api.public+"/"+e,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},66213:(e,t,i)=>{i.d(t,{A:()=>n});var s=i(90334),r=i(62079),a=i(85147),o=i(51579);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"timex",name:"TimeX",countries:["AU"],version:"v1",rateLimit:1500,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1},timeframes:{"1m":"I1","5m":"I5","15m":"I15","30m":"I30","1h":"H1","2h":"H2","4h":"H4","6h":"H6","12h":"H12","1d":"D1","1w":"W1"},urls:{logo:"https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg",api:{rest:"https://plasma-relay-backend.timex.io"},www:"https://timex.io",doc:"https://plasma-relay-backend.timex.io/swagger-ui/index.html",referral:"https://timex.io/?refcode=1x27vNkTbP1uwkCck"},api:{addressbook:{get:["me"],post:["","id/{id}","id/{id}/remove"]},custody:{get:["credentials","credentials/h/{hash}","credentials/k/{key}","credentials/me","credentials/me/address","deposit-addresses","deposit-addresses/h/{hash}"]},history:{get:["orders","orders/details","orders/export/csv","trades","trades/export/csv"]},currencies:{get:["a/{address}","i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},manager:{get:["deposits","transfers","withdrawals"]},markets:{get:["i/{id}","s/{symbol}"],post:["perform","prepare","remove/perform","s/{symbol}/remove/prepare","s/{symbol}/update/perform","s/{symbol}/update/prepare"]},public:{get:["candles","currencies","markets","orderbook","orderbook/raw","orderbook/v2","tickers","trades"]},statistics:{get:["address"]},trading:{get:["balances","fees","orders"],post:["orders","orders/json"],put:["orders","orders/json"],delete:["orders","orders/json"]},tradingview:{get:["config","history","symbol_info","time"]}},precisionMode:o.kb,exceptions:{exact:{0:r.ExchangeError,1:r.NotSupported,4e3:r.BadRequest,4001:r.BadRequest,4002:r.InsufficientFunds,4003:r.AuthenticationError,4004:r.AuthenticationError,4005:r.BadRequest,4006:r.BadRequest,4007:r.BadRequest,4300:r.PermissionDenied,4100:r.AuthenticationError,4400:r.OrderNotFound,5001:r.InvalidOrder,5002:r.ExchangeError,400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.OrderNotFound,429:r.RateLimitExceeded,500:r.ExchangeError,503:r.ExchangeNotAvailable},broad:{Insufficient:r.InsufficientFunds}},options:{expireIn:31536e3,fetchTickers:{period:"1d"},fetchTrades:{sort:"timestamp,asc"},fetchMyTrades:{sort:"timestamp,asc"},fetchOpenOrders:{sort:"createdAt,asc"},fetchClosedOrders:{sort:"createdAt,asc"},defaultSort:"timestamp,asc",defaultSortOrders:"createdAt,asc"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchTime(e={}){const t=await this.tradingviewGetTime(e);return 1e3*this.parseToInt(t)}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e);return this.parseMarkets(t)}async fetchCurrencies(e={}){const t=await this.publicGetCurrencies(e);return this.parseCurrencies(t)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){const a=this.safeString(s,"address");if(s=this.omit(s,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const o={address:a},n=await this.managerGetDeposits(this.extend(o,s)),d=this.safeCurrency(e);return this.parseTransactions(n,d,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const a=this.safeString(s,"address");if(s=this.omit(s,"address"),void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires an address parameter");const o={address:a},n=await this.managerGetWithdrawals(this.extend(o,s)),d=this.safeCurrency(e);return this.parseTransactions(n,d,t,i)}getCurrencyByAddress(e){const t=this.currencies;for(let i=0;i<t.length;i++){const s=t[i],r=this.safeValue(s,"info",{});if(this.safeString(r,"address")===e)return s}}parseTransaction(e,t=void 0){const i=this.safeString(e,"timestamp"),s=this.safeString(e,"token","");return t=this.getCurrencyByAddress(s),{info:e,id:this.safeString(e,"transferHash"),txid:this.safeString(e,"txid"),timestamp:this.parse8601(i),datetime:i,network:void 0,address:void 0,addressTo:this.safeString(e,"to"),addressFrom:this.safeString(e,"from"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:this.safeNumber(e,"value"),currency:this.safeCurrencyCode(void 0,t),status:"ok",updated:void 0,internal:void 0,comment:void 0,fee:void 0}}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=this.safeString(this.options.fetchTickers,"period","1d"),s={period:this.timeframes[i]},r=await this.publicGetTickers(this.extend(s,t));return this.parseTickers(r,e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=this.safeString(this.options.fetchTickers,"period","1d"),r={market:i.id,period:this.timeframes[s]},a=await this.publicGetTickers(this.extend(r,t)),o=this.safeDict(a,0);return this.parseTicker(o,i)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id};void 0!==t&&(s.limit=t);const r=await this.publicGetOrderbookV2(this.extend(s,i)),a=this.parse8601(this.safeString(r,"timestamp"));return this.parseOrderBook(r,e,a,"bid","ask","price","baseTokenAmount")}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a=this.safeValue(this.options,"fetchTrades",{}),o=this.safeValue(a,"sort","timestamp,asc"),n=this.safeString(s,"sort",o),d=this.omit(s,"sort"),h={market:r.id,sort:n};void 0!==t&&(h.from=this.iso8601(t)),void 0!==i&&(h.size=i);const c=await this.publicGetTrades(this.extend(h,d));return this.parseTrades(c,r,t,i)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,period:this.safeString(this.timeframes,t,t)},n=this.parseTimeframe(t),d=this.safeInteger(r,"until");if(void 0===s&&(s=1e3),void 0!==i)o.from=this.iso8601(i),o.till=void 0===d?this.iso8601(this.sum(i,this.sum(s,1)*n*1e3)):this.iso8601(d);else if(void 0!==d){o.till=this.iso8601(d);const e=d-this.sum(s,1)*n*1e3;o.from=this.iso8601(e)}else{const e=this.milliseconds();o.till=this.iso8601(e),o.from=this.iso8601(e-this.sum(s,1)*n*1e3-1)}r=this.omit(r,"until");const h=await this.publicGetCandles(this.extend(o,r));return this.parseOHLCVs(h,a,t,i,s)}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let i=0;i<e.length;i++){const s=e[i],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.total=this.safeString(s,"totalBalance"),o.used=this.safeString(s,"lockedBalance"),t[a]=o}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.tradingGetBalances(e);return this.parseBalance(t)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d=i.toUpperCase();let h=t.toUpperCase();this.safeBool(o,"postOnly",!1)&&(h="POST_ONLY",o=this.omit(o,["postOnly"]));const c={symbol:n.id,quantity:this.amountToPrecision(e,s),side:d,orderTypes:h};let l=o;if("LIMIT"===h||"POST_ONLY"===h){c.price=this.priceToPrecision(e,a);const i=this.safeInteger(this.options,"expireIn"),s=this.safeValue(o,"expireTime"),n=this.safeValue(o,"expireIn",i);if(void 0!==s)c.expireTime=s;else{if(void 0===n)throw new r.InvalidOrder(this.id+" createOrder() method requires a expireTime or expireIn param for a "+t+" order, you can also set the expireIn exchange-wide option");c.expireIn=n}l=this.omit(o,["expireTime","expireIn"])}else c.price=0;const u=await this.tradingPostOrders(this.extend(c,l)),f=this.safeValue(u,"orders",[]),p=this.safeDict(f,0,{});return this.parseOrder(p,n)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n=this.market(t),d={id:e};void 0!==r&&(d.quantity=this.amountToPrecision(t,r)),void 0!==a&&(d.price=this.priceToPrecision(t,a));const h=await this.tradingPutOrders(this.extend(d,o));if("unchangedOrders"in h){const e=this.safeValue(h,"unchangedOrders",[]),t=this.safeString(e,0);return this.safeOrder({id:t,info:h})}const c=this.safeValue(h,"changedOrders",[]),l=this.safeValue(c,0,{}),u=this.safeDict(l,"newOrder",{});return this.parseOrder(u,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s=await this.cancelOrders([e],t,i);return this.safeDict(s,0)}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s={id:e},r=await this.tradingDeleteOrders(this.extend(s,i)),a=this.safeList(r,"changedOrders",[]),o=this.safeList(r,"unchangedOrders",[]),n=[];for(let e=0;e<a.length;e++){const t=this.safeDict(a[e],"newOrder");n.push(this.parseOrder(t))}for(let e=0;e<o.length;e++)n.push(this.safeOrder({info:o[e],id:o[e],status:"unchanged"}));return n}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderHash:e},r=await this.historyGetOrdersDetails(s),a=this.safeValue(r,"order",{}),o=this.safeList(r,"trades",[]);return this.parseOrder(this.extend(a,{trades:o}))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchOpenOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==i&&(d.size=i);const c=await this.tradingGetOrders(this.extend(d,n)),l=this.safeList(c,"orders",[]);return this.parseOrders(l,h,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchClosedOrders",{}),a=this.safeValue(r,"sort","createdAt,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o,side:"BUY"};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==i&&(d.size=i);const c=await this.historyGetOrders(this.extend(d,n)),l=this.safeList(c,"orders",[]);return this.parseOrders(l,h,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.safeValue(this.options,"fetchMyTrades",{}),a=this.safeValue(r,"sort","timestamp,asc"),o=this.safeString(s,"sort",a),n=this.omit(s,"sort"),d={sort:o};let h;void 0!==e&&(h=this.market(e),d.symbol=h.id),void 0!==t&&(d.from=this.iso8601(t)),void 0!==i&&(d.size=i);const c=await this.historyGetTrades(this.extend(d,n)),l=this.safeList(c,"trades",[]);return this.parseTrades(l,h,t,i)}parseTradingFee(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeNumber(e,"fee");return{info:e,symbol:this.safeSymbol(i,t),maker:s,taker:s,percentage:void 0,tierBased:void 0}}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={markets:i.id},r=await this.tradingGetFees(this.extend(s,t)),a=this.safeValue(r,0,{});return this.parseTradingFee(a,i)}parseMarket(e){const t=this.safeValue(e,"locked"),i=this.safeString(e,"symbol"),s=this.safeString(e,"baseCurrency"),r=this.safeString(e,"quoteCurrency"),o=this.safeCurrencyCode(s),n=this.safeCurrencyCode(r),d=this.safeString(e,"quantityIncrement"),h=this.safeString(e,"baseMinSize"),c=a.Y.stringMax(d,h),l=this.safeString(e,"tickSize"),u=this.safeNumber(e,"quoteMinSize");return{id:i,symbol:o+"/"+n,base:o,quote:n,settle:void 0,baseId:s,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!t,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"quantityIncrement"),price:this.safeNumber(e,"tickSize")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(c),max:void 0},price:{min:this.parseNumber(l),max:void 0},cost:{min:u,max:void 0}},created:void 0,info:e}}parseCurrency(e){const t=this.safeString(e,"symbol"),i=this.safeCurrencyCode(t),s=this.safeString(e,"withdrawalFee"),r=this.safeInteger(e,"tradeDecimals");let a;if(void 0!==s&&void 0!==r){const e=s.length-r;if(e>0){const t=s.slice(0,e),i=s.slice(-e);a=this.parseNumber(t+"."+i)}else{let t=".";for(let i=0;i<-e;i++)t+="0";a=this.parseNumber(t+s)}}return this.safeCurrencyStructure({id:i,code:i,info:e,type:void 0,name:this.safeString(e,"name"),active:this.safeBool(e,"active"),deposit:this.safeBool(e,"depositEnabled"),withdraw:this.safeBool(e,"withdrawalEnabled"),fee:a,precision:this.parseNumber(this.parsePrecision(this.safeString(e,"decimals"))),limits:{withdraw:{min:void 0,max:void 0},amount:{min:void 0,max:void 0}},networks:{}})}parseTicker(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"/"),r=this.parse8601(this.safeString(e,"timestamp")),a=this.safeString(e,"last"),o=this.safeString(e,"open");return this.safeTicker({symbol:s,info:e,timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:o,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:this.safeString(e,"volumeQuote")},t)}parseTrade(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t),r=this.parse8601(this.safeString(e,"timestamp")),o=this.safeString(e,"price"),n=this.safeString(e,"quantity"),d=this.parseNumber(o),h=this.parseNumber(n),c=this.parseNumber(a.Y.stringMul(o,n)),l=this.safeString(e,"id"),u=this.safeStringLower2(e,"direction","side"),f=this.safeStringLower(e,"makerOrTaker");let p,m;void 0!==f&&(p=this.safeString(e,f+"OrderId"));const g=this.safeNumber(e,"fee"),v=this.safeCurrencyCode(this.safeString(e,"feeToken"));return void 0!==g&&(m={cost:g,currency:v}),this.safeTrade({info:e,id:l,timestamp:r,datetime:this.iso8601(r),symbol:s,order:p,type:void 0,side:u,price:d,amount:h,cost:c,takerOrMaker:f,fee:m})}parseOHLCV(e,t=void 0){return[this.parse8601(this.safeString(e,"timestamp")),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}parseOrder(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeStringLower(e,"type"),r=this.safeStringLower(e,"side"),o=this.safeString(e,"symbol"),n=this.safeSymbol(o,t),d=this.parse8601(this.safeString(e,"createdAt")),h=this.safeString(e,"price"),c=this.safeString(e,"quantity"),l=this.safeString(e,"filledQuantity"),u=this.omitZero(this.safeString(e,"cancelledQuantity"));let f;f=a.Y.stringEquals(l,c)?"closed":void 0!==u?"canceled":"open";const p=this.safeValue(e,"trades",[]),m=this.safeString(e,"clientOrderId");return this.safeOrder({info:e,id:i,clientOrderId:m,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:n,type:s,timeInForce:void 0,postOnly:void 0,side:r,price:h,triggerPrice:void 0,amount:c,cost:void 0,average:void 0,filled:l,remaining:void 0,status:f,fee:void 0,trades:p},t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={symbol:i.code},r=await this.currenciesGetSSymbol(this.extend(s,t)),a=this.safeDict(r,"currency",{});return this.parseDepositAddress(a,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,currency:this.safeCurrencyCode(i,t),network:void 0,address:this.safeString(e,"address"),tag:void 0}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.extractParams(e);e=this.implodeParams(e,s),s=this.omit(s,o);let n=this.urls.api.rest+"/"+t+"/"+e;if(Object.keys(s).length&&(n+="?"+this.urlencodeWithArrayRepeat(s)),"public"!==t&&"tradingview"!==t){this.checkRequiredCredentials();r={authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)}}return{url:n,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n&&e>=400){const e=this.id+" "+o;let t=this.safeValue(n,"error");void 0===t&&(t=n);const i=this.safeString2(t,"code","status"),s=this.safeString2(t,"message","debugMessage");throw this.throwBroadlyMatchedException(this.exceptions.broad,s,e),this.throwExactlyMatchedException(this.exceptions.exact,i,e),this.throwExactlyMatchedException(this.exceptions.exact,s,e),new r.ExchangeError(e)}}}},42490:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(47999),r=i(51579),a=i(62079),o=i(85147),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tokocrypto",name:"Tokocrypto",countries:["ID"],certified:!1,pro:!1,version:"v1",has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:void 0,borrowMargin:void 0,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:void 0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createReduceOnlyOrder:void 0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:void 0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLedger:void 0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpg",api:{rest:{public:"https://www.tokocrypto.com",binance:"https://api.binance.com/api/v3",private:"https://www.tokocrypto.com"}},www:"https://tokocrypto.com",doc:"https://www.tokocrypto.com/apidocs/",fees:"https://www.tokocrypto.com/fees/newschedule"},api:{binance:{get:{ping:1,time:1,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},trades:1,aggTrades:1,historicalTrades:5,klines:1,"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:1,noSymbol:2},exchangeInfo:10},put:{userDataStream:1},post:{userDataStream:1},delete:{userDataStream:1}},public:{get:{"open/v1/common/time":1,"open/v1/common/symbols":1,"open/v1/market/depth":1,"open/v1/market/trades":1,"open/v1/market/agg-trades":1,"open/v1/market/klines":1}},private:{get:{"open/v1/orders/detail":1,"open/v1/orders":1,"open/v1/account/spot":1,"open/v1/account/spot/asset":1,"open/v1/orders/trades":1,"open/v1/withdraws":1,"open/v1/deposits":1,"open/v1/deposits/address":1},post:{"open/v1/orders":1,"open/v1/orders/cancel":1,"open/v1/orders/oco":1,"open/v1/withdraws":1,"open/v1/user-data-stream":1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0075"),maker:this.parseNumber("0.0075")}},precisionMode:r.kb,options:{createMarketBuyOrderRequiresPrice:!0,defaultTimeInForce:"GTC",hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,newOrderRespType:{market:"FULL",limit:"FULL"},quoteOrderQty:!1,networks:{ERC20:"ETH",TRC20:"TRX",BEP2:"BNB",BEP20:"BSC",OMNI:"OMNI",EOS:"EOS",SPL:"SOL"},reverseNetworks:{"tronscan.org":"TRC20","etherscan.io":"ERC20","bscscan.com":"BSC","explorer.binance.org":"BEP2","bithomp.com":"XRP","bloks.io":"EOS","stellar.expert":"XLM","blockchair.com/bitcoin":"BTC","blockchair.com/bitcoin-cash":"BCH","blockchair.com/ecash":"XEC","explorer.litecoin.net":"LTC","explorer.avax.network":"AVAX","solscan.io":"SOL","polkadot.subscan.io":"DOT","dashboard.internetcomputer.org":"ICP","explorer.chiliz.com":"CHZ","cardanoscan.io":"ADA","mainnet.theoan.com":"AION","algoexplorer.io":"ALGO","explorer.ambrosus.com":"AMB","viewblock.io/zilliqa":"ZIL","viewblock.io/arweave":"AR","explorer.ark.io":"ARK","atomscan.com":"ATOM","www.mintscan.io":"CTK","explorer.bitcoindiamond.org":"BCD","btgexplorer.com":"BTG","bts.ai":"BTS","explorer.celo.org":"CELO","explorer.nervos.org":"CKB","cerebro.cortexlabs.ai":"CTXC","chainz.cryptoid.info":"VIA","explorer.dcrdata.org":"DCR","digiexplorer.info":"DGB","dock.subscan.io":"DOCK","dogechain.info":"DOGE","explorer.elrond.com":"EGLD","blockscout.com":"ETC","explore-fetchhub.fetch.ai":"FET","filfox.info":"FIL","fio.bloks.io":"FIO","explorer.firo.org":"FIRO","neoscan.io":"NEO","ftmscan.com":"FTM","explorer.gochain.io":"GO","block.gxb.io":"GXS","hash-hash.info":"HBAR","www.hiveblockexplorer.com":"HIVE","explorer.helium.com":"HNT","tracker.icon.foundation":"ICX","www.iostabc.com":"IOST","explorer.iota.org":"IOTA","iotexscan.io":"IOTX","irishub.iobscan.io":"IRIS","kava.mintscan.io":"KAVA","scope.klaytn.com":"KLAY","kmdexplorer.io":"KMD","kusama.subscan.io":"KSM","explorer.lto.network":"LTO","polygonscan.com":"POLYGON","explorer.ont.io":"ONT","minaexplorer.com":"MINA","nanolooker.com":"NANO","explorer.nebulas.io":"NAS","explorer.nbs.plus":"NBS","explorer.nebl.io":"NEBL","nulscan.io":"NULS","nxscan.com":"NXS","explorer.harmony.one":"ONE","explorer.poa.network":"POA","qtum.info":"QTUM","explorer.rsk.co":"RSK","www.oasisscan.com":"ROSE","ravencoin.network":"RVN","sc.tokenview.com":"SC","secretnodes.com":"SCRT","explorer.skycoin.com":"SKY","steemscan.com":"STEEM","explorer.stacks.co":"STX","www.thetascan.io":"THETA","scan.tomochain.com":"TOMO","explore.vechain.org":"VET","explorer.vite.net":"VITE","www.wanscan.org":"WAN","wavesexplorer.com":"WAVES","wax.eosx.io":"WAXP","waltonchain.pro":"WTC","chain.nem.ninja":"XEM","verge-blockchain.info":"XVG","explorer.yoyow.org":"YOYOW","explorer.zcha.in":"ZEC","explorer.zensystem.io":"ZEN"},impliedNetworks:{ETH:{ERC20:"ETH"},TRX:{TRC20:"TRX"}},legalMoney:{MXN:!0,UGX:!0,SEK:!0,CHF:!0,VND:!0,AED:!0,DKK:!0,KZT:!0,HUF:!0,PEN:!0,PHP:!0,USD:!0,TRY:!0,EUR:!0,NGN:!0,PLN:!0,BRL:!0,ZAR:!0,KES:!0,ARS:!0,RUB:!0,AUD:!0,NOK:!0,CZK:!0,GBP:!0,UAH:!0,GHS:!0,HKD:!0,CAD:!0,INR:!0,JPY:!0,NZD:!0}},exceptions:{exact:{"System is under maintenance.":a.OnMaintenance,"System abnormality":a.ExchangeError,"You are not authorized to execute this request.":a.PermissionDenied,"API key does not exist":a.AuthenticationError,"Order would trigger immediately.":a.OrderImmediatelyFillable,"Stop price would trigger immediately.":a.OrderImmediatelyFillable,"Order would immediately match and take.":a.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":a.InsufficientFunds,"Rest API trading is not enabled.":a.ExchangeNotAvailable,"You don't have permission.":a.PermissionDenied,"Market is closed.":a.ExchangeNotAvailable,"Too many requests. Please try again later.":a.DDoSProtection,"This action disabled is on this account.":a.AccountSuspended,"-1000":a.ExchangeNotAvailable,"-1001":a.ExchangeNotAvailable,"-1002":a.AuthenticationError,"-1003":a.RateLimitExceeded,"-1004":a.DDoSProtection,"-1005":a.PermissionDenied,"-1006":a.BadResponse,"-1007":a.RequestTimeout,"-1010":a.BadResponse,"-1011":a.PermissionDenied,"-1013":a.InvalidOrder,"-1014":a.InvalidOrder,"-1015":a.RateLimitExceeded,"-1016":a.ExchangeNotAvailable,"-1020":a.BadRequest,"-1021":a.InvalidNonce,"-1022":a.AuthenticationError,"-1023":a.BadRequest,"-1099":a.AuthenticationError,"-1100":a.BadRequest,"-1101":a.BadRequest,"-1102":a.BadRequest,"-1103":a.BadRequest,"-1104":a.BadRequest,"-1105":a.BadRequest,"-1106":a.BadRequest,"-1108":a.BadRequest,"-1109":a.AuthenticationError,"-1110":a.BadRequest,"-1111":a.BadRequest,"-1112":a.InvalidOrder,"-1113":a.BadRequest,"-1114":a.BadRequest,"-1115":a.BadRequest,"-1116":a.BadRequest,"-1117":a.BadRequest,"-1118":a.BadRequest,"-1119":a.BadRequest,"-1120":a.BadRequest,"-1121":a.BadSymbol,"-1125":a.AuthenticationError,"-1127":a.BadRequest,"-1128":a.BadRequest,"-1130":a.BadRequest,"-1131":a.BadRequest,"-1136":a.BadRequest,"-2008":a.AuthenticationError,"-2010":a.ExchangeError,"-2011":a.OrderNotFound,"-2013":a.OrderNotFound,"-2014":a.AuthenticationError,"-2015":a.AuthenticationError,"-2016":a.BadRequest,"-2018":a.InsufficientFunds,"-2019":a.InsufficientFunds,"-2020":a.OrderNotFillable,"-2021":a.OrderImmediatelyFillable,"-2022":a.InvalidOrder,"-2023":a.InsufficientFunds,"-2024":a.InsufficientFunds,"-2025":a.InvalidOrder,"-2026":a.InvalidOrder,"-2027":a.InvalidOrder,"-2028":a.InsufficientFunds,"-3000":a.ExchangeError,"-3001":a.AuthenticationError,"-3002":a.BadSymbol,"-3003":a.BadRequest,"-3004":a.ExchangeError,"-3005":a.InsufficientFunds,"-3006":a.InsufficientFunds,"-3007":a.ExchangeError,"-3008":a.InsufficientFunds,"-3009":a.BadRequest,"-3010":a.ExchangeError,"-3011":a.BadRequest,"-3012":a.ExchangeError,"-3013":a.BadRequest,"-3014":a.AccountSuspended,"-3015":a.ExchangeError,"-3016":a.BadRequest,"-3017":a.ExchangeError,"-3018":a.AccountSuspended,"-3019":a.AccountSuspended,"-3020":a.InsufficientFunds,"-3021":a.BadRequest,"-3022":a.AccountSuspended,"-3023":a.BadRequest,"-3024":a.ExchangeError,"-3025":a.BadRequest,"-3026":a.BadRequest,"-3027":a.BadSymbol,"-3028":a.BadSymbol,"-3029":a.ExchangeError,"-3036":a.AccountSuspended,"-3037":a.ExchangeError,"-3038":a.BadRequest,"-3041":a.InsufficientFunds,"-3042":a.BadRequest,"-3043":a.BadRequest,"-3044":a.DDoSProtection,"-3045":a.ExchangeError,"-3999":a.ExchangeError,"-4001":a.BadRequest,"-4002":a.BadRequest,"-4003":a.BadRequest,"-4004":a.AuthenticationError,"-4005":a.RateLimitExceeded,"-4006":a.BadRequest,"-4007":a.BadRequest,"-4008":a.BadRequest,"-4010":a.BadRequest,"-4011":a.BadRequest,"-4012":a.BadRequest,"-4013":a.AuthenticationError,"-4014":a.PermissionDenied,"-4015":a.ExchangeError,"-4016":a.PermissionDenied,"-4017":a.PermissionDenied,"-4018":a.BadSymbol,"-4019":a.BadSymbol,"-4021":a.BadRequest,"-4022":a.BadRequest,"-4023":a.ExchangeError,"-4024":a.InsufficientFunds,"-4025":a.InsufficientFunds,"-4026":a.InsufficientFunds,"-4027":a.ExchangeError,"-4028":a.BadRequest,"-4029":a.BadRequest,"-4030":a.ExchangeError,"-4031":a.ExchangeError,"-4032":a.ExchangeError,"-4033":a.BadRequest,"-4034":a.ExchangeError,"-4035":a.PermissionDenied,"-4036":a.BadRequest,"-4037":a.ExchangeError,"-4038":a.ExchangeError,"-4039":a.BadRequest,"-4040":a.BadRequest,"-4041":a.ExchangeError,"-4042":a.ExchangeError,"-4043":a.BadRequest,"-4044":a.BadRequest,"-4045":a.ExchangeError,"-4046":a.AuthenticationError,"-4047":a.BadRequest,"-5001":a.BadRequest,"-5002":a.InsufficientFunds,"-5003":a.InsufficientFunds,"-5004":a.BadRequest,"-5005":a.InsufficientFunds,"-5006":a.BadRequest,"-5007":a.BadRequest,"-5008":a.InsufficientFunds,"-5009":a.BadRequest,"-5010":a.ExchangeError,"-5011":a.BadRequest,"-5012":a.ExchangeError,"-5013":a.InsufficientFunds,"-5021":a.BadRequest,"-6001":a.BadRequest,"-6003":a.BadRequest,"-6004":a.ExchangeError,"-6005":a.InvalidOrder,"-6006":a.BadRequest,"-6007":a.BadRequest,"-6008":a.BadRequest,"-6009":a.RateLimitExceeded,"-6011":a.BadRequest,"-6012":a.InsufficientFunds,"-6013":a.ExchangeError,"-6014":a.BadRequest,"-6015":a.BadRequest,"-6016":a.BadRequest,"-6017":a.BadRequest,"-6018":a.BadRequest,"-6019":a.AuthenticationError,"-6020":a.BadRequest,"-7001":a.BadRequest,"-7002":a.BadRequest,"-9000":a.InsufficientFunds,"-10017":a.BadRequest,"-11008":a.InsufficientFunds,"-12014":a.RateLimitExceeded,"-13000":a.BadRequest,"-13001":a.BadRequest,"-13002":a.BadRequest,"-13003":a.BadRequest,"-13004":a.BadRequest,"-13005":a.BadRequest,"-13006":a.InvalidOrder,"-13007":a.AuthenticationError,"-21001":a.BadRequest,"-21002":a.BadRequest,"-21003":a.BadRequest,100001003:a.BadRequest,2202:a.InsufficientFunds,3210:a.InvalidOrder,3203:a.InvalidOrder,3211:a.InvalidOrder,3207:a.InvalidOrder,3218:a.OrderNotFound},broad:{"has no operation privilege":a.PermissionDenied,MAX_POSITION:a.InvalidOrder}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!0,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetOpenV1CommonTime(e);return this.safeInteger(t,"timestamp")}async fetchMarkets(e={}){const t=await this.publicGetOpenV1CommonSymbols(e);this.options.adjustForTimeDifference&&await this.loadTimeDifference();const i=this.safeValue(t,"data",{}),s=this.safeValue(i,"list",[]),r=[];for(let e=0;e<s.length;e++){const t=s[e],i=this.safeString(t,"baseAsset"),a=this.safeString(t,"quoteAsset"),o=this.safeString(t,"symbol"),n=this.safeStringLower(t,"symbol"),d=this.safeString(t,"marginAsset"),h=this.safeCurrencyCode(i),c=this.safeCurrencyCode(a),l=this.safeCurrencyCode(d),u=h+"/"+c,f=this.safeValue(t,"filters",[]),p=this.indexBy(f,"filterType");let m="1"===this.safeString(t,"spotTradingEnable");const g=this.safeValue(t,"permissions",[]);for(let e=0;e<g.length;e++)if("TRD_GRP_003"===g[e]){m=!1;break}const v={id:o,lowercaseId:n,symbol:u,base:h,quote:c,settle:l,baseId:i,quoteId:a,settleId:d,type:"spot",spot:!0,margin:this.safeBool(t,"isMarginTradingAllowed",!1),swap:!1,future:!1,delivery:!1,option:!1,active:m,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(t,"quantityPrecision"))),price:this.parseNumber(this.parsePrecision(this.safeString(t,"pricePrecision"))),base:this.parseNumber(this.parsePrecision(this.safeString(t,"baseAssetPrecision"))),quote:this.parseNumber(this.parsePrecision(this.safeString(t,"quotePrecision")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t};if("PRICE_FILTER"in p){const e=this.safeValue(p,"PRICE_FILTER",{});v.precision.price=this.safeNumber(e,"tickSize"),v.limits.price={min:this.safeNumber(e,"minPrice"),max:this.safeNumber(e,"maxPrice")},v.precision.price=e.tickSize}if("LOT_SIZE"in p){const e=this.safeValue(p,"LOT_SIZE",{});v.precision.amount=this.safeNumber(e,"stepSize"),v.limits.amount={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MARKET_LOT_SIZE"in p){const e=this.safeValue(p,"MARKET_LOT_SIZE",{});v.limits.market={min:this.safeNumber(e,"minQty"),max:this.safeNumber(e,"maxQty")}}if("MIN_NOTIONAL"in p){const e=this.safeValue(p,"MIN_NOTIONAL",{});v.limits.cost.min=this.safeNumber2(e,"minNotional","notional")}r.push(v)}return r}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={};let a;void 0!==t&&(r.limit=t),"USDT"===s.quote?(r.symbol=s.baseId+s.quoteId,a=await this.binanceGetDepth(this.extend(r,i))):(r.symbol=s.id,a=await this.publicGetOpenV1MarketDepth(this.extend(r,i)));const o=this.safeValue(a,"data",a),n=this.safeInteger2(a,"T","timestamp"),d=this.parseOrderBook(o,e,n);return d.nonce=this.safeInteger(o,"lastUpdateId"),d}parseTrade(e,t=void 0){const i=this.safeInteger2(e,"T","time"),s=this.safeString2(e,"p","price"),r=this.safeString2(e,"q","qty"),a=this.safeString2(e,"quoteQty","baseQty"),o=this.safeString(e,"symbol"),n=this.safeSymbol(o,t);let d,h=this.safeString2(e,"t","a");h=this.safeString2(e,"id","tradeId",h);const c=this.safeString(e,"orderId"),l=this.safeValue2(e,"m","isBuyerMaker");let u,f;return void 0!==l?(d=l?"sell":"buy",u="taker"):"side"in e?d=this.safeStringLower(e,"side"):"isBuyer"in e&&(d=e.isBuyer?"buy":"sell"),"commission"in e&&(f={cost:this.safeString(e,"commission"),currency:this.safeCurrencyCode(this.safeString(e,"commissionAsset"))}),"isMaker"in e&&(u=e.isMaker?"maker":"taker"),"maker"in e&&(u=e.maker?"maker":"taker"),this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:n,id:h,order:c,type:void 0,side:d,takerOrMaker:u,price:s,amount:r,cost:a,fee:f},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:this.getMarketIdByType(r)};if("USDT"!==r.quote){void 0!==i&&(a.limit=i);const e=this.publicGetOpenV1MarketTrades(this.extend(a,s)),o=this.safeDict(e,"data",{}),n=this.safeList(o,"list",[]);return this.parseTrades(n,r,t,i)}void 0!==i&&(a.limit=i);let o;return"binanceGetAggTrades"===this.safeString(this.options,"fetchTradesMethod","binanceGetTrades")&&void 0!==t?(a.startTime=t,a.endTime=this.sum(t,36e5),o=await this.binanceGetAggTrades(this.extend(a,s))):o=await this.binanceGetTrades(this.extend(a,s)),this.parseTrades(o,r,t,i)}parseTicker(e,t=void 0){const i=this.safeInteger(e,"closeTime"),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t),a=this.safeString(e,"lastPrice");let o,n;return"baseVolume"in e?(o=this.safeString(e,"baseVolume"),n=this.safeString(e,"volume")):(o=this.safeString(e,"volume"),n=this.safeString(e,"quoteVolume")),this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"highPrice"),low:this.safeString(e,"lowPrice"),bid:this.safeString(e,"bidPrice"),bidVolume:this.safeString(e,"bidQty"),ask:this.safeString(e,"askPrice"),askVolume:this.safeString(e,"askQty"),vwap:this.safeString(e,"weightedAvgPrice"),open:this.safeString(e,"openPrice"),close:a,last:a,previousClose:this.safeString(e,"prevClosePrice"),change:this.safeString(e,"priceChange"),percentage:this.safeString(e,"priceChangePercent"),average:void 0,baseVolume:o,quoteVolume:n,info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.binanceGetTicker24hr(t);return this.parseTickers(i,e)}getMarketIdByType(e){return"USDT"===e.quote?e.baseId+e.quoteId:e.id}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.baseId+i.quoteId},r=await this.binanceGetTicker24hr(this.extend(s,t));if(Array.isArray(r)){const e=this.safeDict(r,0,{});return this.parseTicker(e,i)}return this.parseTicker(r,i)}async fetchBidsAsks(e=void 0,t={}){await this.loadMarkets();const i=await this.binanceGetTickerBookTicker(t);return this.parseTickers(i,e)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.safeString(r,"price"),n=this.safeInteger(r,"until");r=this.omit(r,["price","until"]),s=void 0===s?500:Math.min(s,1500);const d={interval:this.safeString(this.timeframes,t,t),limit:s};let h;"index"===o?d.pair=a.id:d.symbol=this.getMarketIdByType(a),void 0!==i&&(d.startTime=i),void 0!==n&&(d.endTime=n),h="USDT"===a.quote?await this.binanceGetKlines(this.extend(d,r)):await this.publicGetOpenV1MarketKlines(this.extend(d,r));const c=this.safeList(h,"data",h);return this.parseOHLCVs(c,a,t,i,s)}async fetchBalance(e={}){await this.loadMarkets();const t=this.safeString2(this.options,"fetchBalance","defaultType","spot"),i=this.safeString(e,"type",t),s=this.safeString2(this.options,"marginMode","defaultMarginMode"),r=this.safeStringLower(e,"marginMode",s),a=await this.privateGetOpenV1AccountSpot(this.extend({},e));return this.parseBalanceCustom(a,i,r)}parseBalanceCustom(e,t=void 0,i=void 0){const s=this.safeInteger(e,"updateTime"),r={info:e,timestamp:s,datetime:this.iso8601(s)},a=this.safeValue(e,"data",{}),o=this.safeValue(a,"accountAssets",[]);for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"asset"),s=this.safeCurrencyCode(i),a=this.account();a.free=this.safeString(t,"free"),a.used=this.safeString(t,"locked"),r[s]=a}return this.safeBalance(r)}parseOrderStatus(e){return this.safeString({"-2":"open",0:"open",1:"open",2:"closed",3:"canceled",4:"canceling",5:"rejected",6:"expired",NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",PENDING_CANCEL:"canceling",REJECTED:"rejected",EXPIRED:"expired"},e,e)}parseOrder(e,t=void 0){const i=this.parseOrderStatus(this.safeString(e,"status")),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t),a=this.safeString(e,"executedQty","0"),o=this.safeInteger(e,"createTime"),n=this.safeString(e,"avgPrice"),d=this.safeString2(e,"price","executedPrice"),h=this.safeString(e,"origQty"),c=this.safeStringN(e,["cummulativeQuoteQty","cumQuote","executedQuoteQty","cumBase"]),l=this.safeString(e,"orderId"),u=this.parseOrderType(this.safeStringLower(e,"type"));let f=this.safeStringLower(e,"side");"0"===f?f="buy":"1"===f&&(f="sell");const p=this.safeValue(e,"fills",[]),m=this.safeString2(e,"clientOrderId","clientId");let g=this.safeString(e,"timeInForce");"GTX"===g&&(g="PO");const v="limit_maker"===u||"PO"===g;return this.safeOrder({info:e,id:l,clientOrderId:m,timestamp:o,datetime:this.iso8601(o),lastTradeTimestamp:void 0,symbol:r,type:u,timeInForce:g,postOnly:v,reduceOnly:this.safeValue(e,"reduceOnly"),side:f,price:d,triggerPrice:this.parseNumber(this.omitZero(this.safeString(e,"stopPrice"))),amount:h,cost:c,average:n,filled:a,remaining:void 0,status:i,fee:void 0,trades:p},t)}parseOrderType(e){return this.safeString({2:"market",1:"limit",4:"limit",7:"limit"},e,e)}async createOrder(e,t,i,s,n=void 0,d={}){await this.loadMarkets();const h=this.market(e),c=this.safeString2(d,"clientOrderId","clientId");this.safeBool(d,"postOnly",!1)&&(t="LIMIT_MAKER"),d=this.omit(d,["clientId","clientOrderId"]);const l=t.toUpperCase();let u=l;const f=this.safeValue2(d,"triggerPrice","stopPrice");void 0!==f&&(d=this.omit(d,["triggerPrice","stopPrice"]),"MARKET"===u?u="STOP_LOSS":"LIMIT"===u&&(u="STOP_LOSS_LIMIT"));const p=this.safeValue(h.info,"orderTypes");if(!this.inArray(u,p))throw l!==u?new a.InvalidOrder(this.id+" triggerPrice parameter is not allowed for "+e+" "+t+" orders"):new a.InvalidOrder(this.id+" "+t+" is not a valid order type for the "+e+" market");const m={symbol:h.baseId+"_"+h.quoteId,type:this.safeString({LIMIT:1,MARKET:2,STOP_LOSS:3,STOP_LOSS_LIMIT:4,TAKE_PROFIT:5,TAKE_PROFIT_LIMIT:6,LIMIT_MAKER:7},u)};if("buy"===i?m.side=0:"sell"===i&&(m.side=1),void 0===c){const e=this.safeValue(this.options,"broker");if(void 0!==e){const t=this.safeString(e,"marketType");void 0!==t&&(m.clientId=t+this.uuid22())}}else m.clientId=c;let g=!1,v=!1,y=!1;if("MARKET"===u)if("buy"===i){const e=h.precision.price;let t,i=!0;[i,d]=this.handleOptionAndParams(d,"createOrder","createMarketBuyOrderRequiresPrice",!0);const c=this.safeNumber2(d,"cost","quoteOrderQty");if(d=this.omit(d,["cost","quoteOrderQty"]),void 0!==c)t=c;else if(i){if(void 0===n)throw new a.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument");{const e=this.numberToString(s),i=this.numberToString(n);t=o.Y.stringMul(e,i)}}else t=s;m.quoteOrderQty=this.decimalToPrecision(t,r.R3,e,this.precisionMode)}else y=!0;else"LIMIT"===u?(g=!0,y=!0):"STOP_LOSS"===u||"TAKE_PROFIT"===u?(v=!0,y=!0,(h.linear||h.inverse)&&(g=!0)):"STOP_LOSS_LIMIT"===u||"TAKE_PROFIT_LIMIT"===u?(y=!0,v=!0,g=!0):"LIMIT_MAKER"===u&&(g=!0,y=!0);if(y&&(m.quantity=this.amountToPrecision(e,s)),g){if(void 0===n)throw new a.InvalidOrder(this.id+" createOrder() requires a price argument for a "+t+" order");m.price=this.priceToPrecision(e,n)}if(v){if(void 0===f)throw new a.InvalidOrder(this.id+" createOrder() requires a triggerPrice extra param for a "+t+" order");m.stopPrice=this.priceToPrecision(e,f)}const b=await this.privatePostOpenV1Orders(this.extend(m,d)),w=this.safeDict(b,"data",{});return this.parseOrder(w,h)}async fetchOrder(e,t=void 0,i={}){const s={orderId:e},r=await this.privateGetOpenV1Orders(this.extend(s,i)),a=this.safeValue(r,"data",{}),o=this.safeValue(a,"list",[]),n=this.safeDict(o,0,{});return this.parseOrder(n)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const r=this.market(e),o={symbol:r.id};void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i);const n=await this.privateGetOpenV1Orders(this.extend(o,s)),d=this.safeValue(n,"data",{}),h=this.safeList(d,"list",[]);return this.parseOrders(h,r,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({type:1},s))}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({type:2},s))}async cancelOrder(e,t=void 0,i={}){const s={orderId:e},r=await this.privatePostOpenV1OrdersCancel(this.extend(s,i)),a=this.safeDict(r,"data",{});return this.parseOrder(a)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const r=this.market(e),o={symbol:r.id},n=this.safeInteger2(s,"until","endTime");void 0!==t&&(o.startTime=t),void 0!==n&&(o.endTime=n,s=this.omit(s,["endTime","until"])),void 0!==i&&(o.limit=i);const d=await this.privateGetOpenV1OrdersTrades(this.extend(o,s)),h=this.safeValue(d,"data",{}),c=this.safeList(h,"list",[]);return this.parseTrades(c,r,t,i)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i={asset:this.currency(e).id},s=this.safeValue(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(s,r,r),void 0!==r&&(i.network=r,t=this.omit(t,"network"));const a=await this.privateGetOpenV1DepositsAddress(this.extend(i,t)),o=this.safeValue(a,"data",{}),n=this.safeString(o,"address");let d=this.safeString(o,"addressTag","");return 0===d.length&&(d=void 0),this.checkAddress(n),{info:a,currency:e,network:this.safeString(o,"network"),address:n,tag:d}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={},o=this.safeInteger(s,"until");if(void 0!==e&&(r=this.currency(e),a.coin=r.id),void 0!==t){a.startTime=t;let e=this.sum(t,7776e6);void 0!==o&&(e=Math.min(e,o)),a.endTime=e}void 0!==i&&(a.limit=i);const n=await this.privateGetOpenV1Deposits(this.extend(a,s)),d=this.safeValue(n,"data",{}),h=this.safeList(d,"list",[]);return this.parseTransactions(h,r,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t,r.endTime=this.sum(t,7776e6)),void 0!==i&&(r.limit=i);const o=await this.privateGetOpenV1Withdraws(this.extend(r,s)),n=this.safeValue(o,"data",{}),d=this.safeList(n,"list",[]);return this.parseTransactions(d,a,t,i)}parseTransactionStatusByType(e,t=void 0){const i=this.safeValue({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",1:"canceled",2:"pending",3:"failed",4:"pending",5:"failed",10:"ok"}},t,{});return this.safeString(i,e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"address");let s=this.safeString(e,"addressTag");void 0!==s&&s.length<1&&(s=void 0);let r=this.safeString(e,"txId");void 0!==r&&r.indexOf("Internal transfer ")>=0&&(r=r.slice(18));const a=this.safeString2(e,"coin","fiatCurrency"),o=this.safeCurrencyCode(a,t);let n;const d=this.safeInteger(e,"insertTime"),h=this.safeInteger2(e,"createTime","timestamp");let c=this.safeString(e,"type");void 0===c&&(void 0!==d&&void 0===h?(c="deposit",n=d):void 0===d&&void 0!==h&&(c="withdrawal",n=h));const l=this.safeNumber2(e,"transactionFee","totalFee"),u={currency:void 0,cost:void 0,rate:void 0};void 0!==l&&(u.currency=o,u.cost=l);let f=!1;void 0!==this.safeInteger(e,"transferType")&&(f=!0);let p=this.safeString(e,"id");if(void 0===p){const t=this.safeValue(e,"data",{});p=this.safeString(t,"withdrawId"),c="withdrawal"}return{info:e,id:p,txid:r,type:c,currency:o,network:this.safeString(e,"network"),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatusByType(this.safeString(e,"status"),c),timestamp:n,datetime:this.iso8601(n),address:i,addressFrom:void 0,addressTo:i,tag:s,tagFrom:void 0,tagTo:s,updated:this.safeInteger2(e,"successTime","updateTime"),comment:void 0,internal:f,fee:u}}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a=this.currency(e),o={asset:a.id,address:i,amount:this.numberToString(t)};void 0!==s&&(o.addressTag=s);const[n,d]=this.handleNetworkCodeAndParams(r),h=this.networkCodeToId(n);void 0!==h&&(o.network=h.toUpperCase());const c=await this.privatePostOpenV1Withdraws(this.extend(o,d));return this.parseTransaction(c,a)}sign(e,t="public",i="GET",s={},r=void 0,o=void 0){if(!(t in this.urls.api.rest))throw new a.NotSupported(this.id+" does not have a testnet/sandbox URL for "+t+" endpoints");let d=this.urls.api.rest[t];d+="/"+e,"wapi"===t&&(d+=".html");if("userDataStream"===e||"listenKey"===e){if(!this.apiKey)throw new a.AuthenticationError(this.id+" userDataStream endpoint requires `apiKey` credential");r={"X-MBX-APIKEY":this.apiKey,"Content-Type":"application/x-www-form-urlencoded"},"GET"!==i&&(o=this.urlencode(s))}else if("private"===t||"sapi"===t&&"system/status"!==e||"sapiV3"===t||"wapi"===t&&"systemStatus"!==e||"dapiPrivate"===t||"dapiPrivateV2"===t||"fapiPrivate"===t||"fapiPrivateV2"===t){let a;this.checkRequiredCredentials();const h=this.safeInteger(this.options,"recvWindow"),c=this.extend({timestamp:this.nonce()},s);void 0!==h&&(c.recvWindow=h);const l=this.safeInteger(s,"recvWindow");void 0!==l&&(c.recvWindow=l),a="sapi"===t&&"asset/dust"===e?this.urlencodeWithArrayRepeat(c):"batchOrders"===e||e.indexOf("sub-account")>=0||"capital/withdraw/apply"===e||e.indexOf("staking")>=0?this.rawencode(c):this.urlencode(c);a+="&signature="+this.hmac(this.encode(a),this.encode(this.secret),n.s),r={"X-MBX-APIKEY":this.apiKey},"GET"===i||"DELETE"===i||"wapi"===t?d+="?"+a:(o=a,r["Content-Type"]="application/x-www-form-urlencoded")}else Object.keys(s).length&&(d+="?"+this.urlencode(s));return{url:d,method:i,body:o,headers:r}}handleErrors(e,t,i,s,r,n,d,h,c){if(418===e||429===e)throw new a.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(e>=400){if(n.indexOf("Price * QTY is zero or less")>=0)throw new a.InvalidOrder(this.id+" order cost = amount * price is zero or less "+n);if(n.indexOf("LOT_SIZE")>=0)throw new a.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+n);if(n.indexOf("PRICE_FILTER")>=0)throw new a.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) "+n)}if(void 0===d)return;const l=this.safeBool(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const f=this.safeString(d,"code");if(void 0!==f){if("200"===f||o.Y.stringEquals(f,"0"))return;if("-2015"===f&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new a.DDoSProtection(this.id+" "+n);const e=this.id+" "+n;if("No need to change margin type."===u)throw new a.MarginModeAlreadySet(e);throw this.throwExactlyMatchedException(this.exceptions.exact,f,e),new a.ExchangeError(e)}if(!l)throw new a.ExchangeError(this.id+" "+n)}calculateRateLimiterCost(e,t,i,s,r={}){if("noCoin"in r&&!("coin"in s))return r.noCoin;if("noSymbol"in r&&!("symbol"in s))return r.noSymbol;if("noPoolId"in r&&!("poolId"in s))return r.noPoolId;if("byLimit"in r&&"limit"in s){const e=s.limit,t=r.byLimit;for(let i=0;i<t.length;i++){const s=t[i];if(e<=s[0])return s[1]}}return this.safeInteger(r,"cost",1)}}},90237:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(53016);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"toobit",name:"Toobit",countries:["KY"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://toobit-docs.github.io/apidocs/spot/v1/en/images/logo.svg",api:{public:"https://api.toobit.com"},www:"https://www.toobit.com/",doc:["https://toobit-docs.github.io/apidocs/spot/v1/en/#change-log"]},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},api:{public:{get:{"quote/v1/ticker/24hr":1,"quote/v1/klines":1,"/api/v1/exchangeInfo":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiV1ExchangeInfo(),i=this.safeValue(t,"symbols",[]),s=[];for(let e=0;e<i.length;e++){const t=i[e],r=this.safeValue(t,"status"),a=this.safeValue(t,"symbol");if("TRADING"!==r||"TESTA1S3TESTX8Z9"===a)continue;const o=this.parseMarket(t);s.push(o)}return s}parseMarket(e){const t=this.safeValue(e,"symbol"),i=this.safeValue(e,"baseAsset"),s=this.safeValue(e,"quoteAsset"),r=this.safeValue(e,"baseAssetPrecision"),a=this.safeValue(e,"quotePrecision"),o=this.safeValue(e,"allowMargin",!1),n=this.safeValue(e,"filters",[]);let d,h,c,l,u,f,p,m,g;for(let e=0;e<n.length;e++){const t=n[e],i=this.safeValue(t,"filterType");"PRICE_FILTER"===i?(d=this.safeNumber(t,"minPrice"),h=this.safeNumber(t,"maxPrice"),c=this.safeString(t,"tickSize")):"LOT_SIZE"===i?(l=this.safeNumber(t,"minQty"),u=this.safeNumber(t,"maxQty"),f=this.safeString(t,"stepSize")):"MIN_NOTIONAL"===i?p=this.safeNumber(t,"minNotional"):"TRADE_AMOUNT"===i&&(m=this.safeNumber(t,"minAmount"),g=this.safeNumber(t,"maxAmount"))}const v=t,y=this.safeCurrencyCode(i),b=this.safeCurrencyCode(s);return{id:v,symbol:y+"/"+b,base:y,quote:b,settle:void 0,baseId:i.toLowerCase(),quoteId:s.toLowerCase(),settleId:void 0,type:"spot",spot:!0,margin:o,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:f?this.precisionFromString(f.toString()):this.precisionFromString(r),price:c?this.precisionFromString(c.toString()):this.precisionFromString(a)},limits:{leverage:{min:void 0,max:void 0},amount:{min:l,max:u},price:{min:d,max:h},cost:{min:p||m,max:g}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetQuoteV1Ticker24hr(),s={};for(let e=0;e<i.length;e++){if(0===this.safeFloat(i[e],"v"))continue;const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i={symbol:this.market(e).id},s=await this.publicGetQuoteV1Ticker24hr(i);return this.parseTicker(s[0])}parseTicker(e,t=void 0){let i=this.safeValue(e,"s");const s=i;i=this.safeSymbol(s,t,void 0,"spot");const r=this.safeFloat(e,"h"),a=this.safeFloat(e,"l"),o=this.safeFloat(e,"o"),n=this.safeFloat(e,"c"),d=this.safeFloat(e,"c"),h=this.safeFloat(e,"pcp"),c=this.safeFloat(e,"pc"),l=this.safeFloat(e,"v"),u=this.safeFloat(e,"qv"),f=this.safeString(e,"t"),p=this.safeFloat(e,"b",0),m=this.safeFloat(e,"a",0);return this.safeTicker({symbol:i,timestamp:f,datetime:this.parse8601(f),high:r,low:a,bid:p,bidVolume:void 0,ask:m,askVolume:void 0,vwap:void 0,open:o,close:n,last:d,previousClose:void 0,change:c,percentage:h,average:void 0,baseVolume:l,quoteVolume:u,info:e},t)}async fetchOHLCV(e,t="1h",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=Date.now(),n={symbol:a.id,from:o-864e5,to:o,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i),void 0!==t&&(n.interval=this.safeString(this.timeframes,t,t));const d=await this.publicGetQuoteV1Klines(n),h=[];for(let e=0;e<d.length;e++){const t=d[e],i=this.safeTimestamp(t,0),s=this.safeFloat(t,1),r=this.safeFloat(t,2),a=this.safeFloat(t,3),o=this.safeFloat(t,4),n=this.safeFloat(t,5);h.push([i,s,r,a,o,n])}return this.parseOHLCVs(h,a,t,i,s)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"quote/v1/ticker/24hr"===e&&(n=n+"?"+this.urlencode(o)),"quote/v1/klines"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},45887:(e,t,i)=>{i.d(t,{A:()=>o});var s=i(94352),r=i(62079),a=i(51579);class o extends s.A{describe(){return this.deepExtend(super.describe(),{id:"tradeogre",name:"tradeogre",countries:[],rateLimit:100,version:"v2",pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createMarketOrder:!1,createOrder:!0,createOrders:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAccounts:!1,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!1},urls:{referral:"",logo:"https://github.com/ccxt/ccxt/assets/43336371/3aa748b7-ea44-45e9-a9e7-b1d207a2578a",api:{rest:"https://tradeogre.com/api/v1"},www:"https://tradeogre.com",doc:"https://tradeogre.com/help/api",fees:"https://tradeogre.com/help/fees"},fees:{trading:{maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},api:{public:{get:{markets:1,"orders/{market}":1,"ticker/{market}":1,"history/{market}":1,"chart/{interval}/{market}/{timestamp}":1,"chart/{interval}/{market}":1}},private:{get:{"account/balances":1,"account/order/{uuid}":1},post:{"order/buy":1,"order/sell":1,"order/cancel":1,orders:1,"account/orders":1,"account/balance":1}}},commonCurrencies:{},precisionMode:a.kb,exceptions:{exact:{"Must be authorized":r.AuthenticationError,"Market not found":r.BadRequest,"Insufficient funds":r.InsufficientFunds,"Order not found":r.BadRequest}},timeframes:{"1m":"1m","15m":"15m","1h":"1h","4h":"4h","1d":"1d","1w":"1w"},options:{},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e),i=[];for(let e=0;e<t.length;e++){const s=t[e],r=Object.keys(s),a=this.safeString(r,0),o=a.split("-"),n=this.safeString(o,0),d=this.safeString(o,1),h=this.safeCurrencyCode(n),c=this.safeCurrencyCode(d),l=this.safeMarketStructure({id:a,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:n,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,taker:this.fees.trading.taker,maker:this.fees.trading.maker,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision("8")),price:this.parseNumber(this.parsePrecision("8"))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:s});i.push(l)}return i}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={market:i.id},r=await this.publicGetTickerMarket(this.extend(s,t));return this.parseTicker(r,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.publicGetMarkets(this.extend({},t)),s={};for(let e=0;e<i.length;e++){const t=i[e],r=Object.keys(t),a=this.safeString(r,0),o=this.safeMarket(a),n=t[a],d=this.parseTicker(n,o);s[d.symbol]=d}return this.filterByArrayTickers(s,"symbol",e)}parseTicker(e,t=void 0){return this.safeTicker({symbol:this.safeString(t,"symbol"),timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"initialprice"),close:this.safeString(e,"price"),last:this.safeString(e,"price"),previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"volume"),quoteVolume:void 0,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,interval:this.safeString(this.timeframes,t,t)};let n;const d=this.safeInteger(r,"until");return void 0!==d?(r=this.omit(r,"until"),o.timestamp=this.parseToInt(d/1e3),n=await this.publicGetChartIntervalMarketTimestamp(this.extend(o,r))):n=await this.publicGetChartIntervalMarket(this.extend(o,r)),this.parseOHLCVs(n,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,5)]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id},r=await this.publicGetOrdersMarket(this.extend(s,i)),a={bids:this.safeDict(r,"buy",{}),asks:this.safeDict(r,"sell",{})},o=this.parseOrderBook(a,e);return o.nonce=this.safeInteger(r,"s"),o}parseBidsAsks(e,t=0,i=1,s=2){const r=Object.keys(e),a=[];for(let t=0;t<r.length;t++){const i=this.safeString(r,t),s=this.safeNumber(r,t),o=this.safeNumber(e,i);a.push([s,o])}return a}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},o=await this.publicGetHistoryMarket(this.extend(a,s));return this.parseTrades(o,r,t,i)}parseTrade(e,t=void 0){const i=this.safeIntegerProduct(e,"date",1e3);return this.safeTrade({info:e,id:void 0,timestamp:i,datetime:this.iso8601(i),symbol:this.safeString(t,"symbol"),order:void 0,type:void 0,side:this.safeString(e,"type"),takerOrMaker:void 0,price:this.safeString(e,"price"),amount:this.safeString(e,"quantity"),cost:void 0,fee:{currency:void 0,cost:void 0}},t)}async fetchBalance(e={}){let t;await this.loadMarkets();const i=this.safeString(e,"currency");if(void 0!==i){t=await this.privatePostAccountBalance(e);const s={info:t},r=this.safeCurrencyCode(i),a={total:this.safeNumber(t,"balance"),free:this.safeNumber(t,"available")};return s[r]=a,this.safeBalance(s)}t=await this.privateGetAccountBalances(e);const s=this.safeDict(t,"balances",{});return this.parseBalance(s)}parseBalance(e){const t={info:e},i=Object.keys(e);for(let s=0;s<i.length;s++){const r=i[s],a={total:e[r]};t[this.safeCurrencyCode(r)]=a}return this.safeBalance(t)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e);if("market"===t)throw new r.BadRequest(this.id+" createOrder does not support market orders");if(void 0===a)throw new r.ArgumentsRequired(this.id+" createOrder requires a price parameter");const d={market:n.id,quantity:this.amountToPrecision(e,s),price:this.priceToPrecision(e,a)};let h;return h="buy"===i?await this.privatePostOrderBuy(this.extend(d,o)):await this.privatePostOrderSell(this.extend(d,o)),this.parseOrder(h,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privatePostOrderCancel(this.extend(s,i));return this.parseOrder(r)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();return[await this.cancelOrder("all",e,t)]}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a={};void 0!==e&&(a.market=r.id);const o=await this.privatePostAccountOrders(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateGetAccountOrderUuid(this.extend(s,i));return this.parseOrder(r,void 0)}parseOrder(e,t=void 0){const i=this.safeIntegerProduct(e,"date",1e3),s=this.safeString(e,"market");return t=this.safeMarket(s,t),this.safeOrder({info:e,id:this.safeString(e,"uuid"),clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,symbol:t.symbol,type:void 0,timeInForce:void 0,postOnly:void 0,side:this.safeString(e,"type"),price:this.safeString(e,"price"),triggerPrice:void 0,amount:void 0,cost:void 0,average:void 0,filled:this.safeString(e,"fulfilled"),remaining:this.safeString(e,"quantity"),status:void 0,fee:{currency:void 0,cost:void 0},trades:void 0},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api.rest+"/"+this.implodeParams(e,s);return s=this.omit(s,this.extractParams(e)),"GET"===i&&Object.keys(s).length&&(o+="?"+this.urlencode(s)),"private"===t&&(r={"Content-Type":"application/x-www-form-urlencoded",Referer:"CCXT",authorization:"Basic "+this.stringToBase64(this.apiKey+":"+this.secret)},"GET"!==i&&(a=this.urlencode(s))),{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;if(!("success"in n))return;if(this.safeBool(n,"success"))return;if("true"===this.safeString(n,"success"))return;const c=this.safeValue(n,"error"),l=this.safeString(c,"code"),u=this.id+" "+this.json(n);throw this.throwExactlyMatchedException(this.exceptions.exact,l,u),new r.ExchangeError(u)}}},58586:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(51419);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"twox",name:"Twox",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,otc:!0,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/twox/64x64.png",api:{public:"https://api.twox.ir"},www:"https://twox.ir",doc:["https://twox.ir"]},api:{public:{get:{"api/currencies":1}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiCurrencies(e),i=[],s=["IRT","USDT"];for(let e=0;e<t.length;e++){const r=this.extend({},t[e]),a=this.safeString(r,"symbol");for(let e=0;e<s.length;e++){const t=s[e];if(a===t||0===r.sellPrice||"IRT"===a)break;r.base=a,r.quote=t;const o=this.parseMarket(r);i.push(o)}}return i}parseMarket(e){let t=this.safeString(e,"base"),i=this.safeString(e,"quote");const s=this.safeCurrencyCode(t),r=this.safeCurrencyCode(i),a=s+r;return t=t.toLowerCase(),i=i.toLowerCase(),{id:a,symbol:s+"/"+r,base:s,quote:r,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiCurrencies(t),s={},r=["IRT","USDT"];for(let e=0;e<i.length;e++){const t=this.safeString(i[e],"symbol");for(let a=0;a<r.length;a++){const o=r[a];if(t===o||0===i[e].sellPrice||"IRT"===t)continue;i[e].base=t,i[e].quote=o,i[e].symbol=t+o;const n=this.parseTicker(i[e]);s[n.symbol]=n}}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){return(await this.fetchTickers([e]))[e]}parseTicker(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,void 0,"otc"),r=this.safeFloat(e,"sellPrice"),a=this.safeFloat(e,"buyPrice"),o=this.safeFloat(e,"latestPrice");let n,d,h;"IRT"===e.quote?(n=r,d=a,h=r):(n=o,d=a,h=r);const c=this.safeFloat(e,"priceChangePercent"),l=this.safeFloat(e,"sellPriceChange"),u=this.safeFloat(e,"buyPriceChange");let f;return f="IRT"===e.quote?l:u,this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:d,bidVolume:void 0,ask:h,askVolume:void 0,vwap:void 0,open:void 0,close:n,last:n,previousClose:void 0,change:f,percentage:c,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){return{url:this.urls.api.public+"/"+e,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},73551:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(70786);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"ubitex",name:"Ubitex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://ubitex.io/_next/image?url=https%3A%2F%2Fipfs.ubitex.io%2Fipfs%2FQmNqYsDFS1GoEeVYsPHkp8lFkodFeKo5cXLQlt1suO3T&w=256&q=75",api:{public:"https://appapi.ubitex.io"},www:"https://ubitex.io/",doc:["https://ubitex.io/"]},timeframes:{"1m":"1","1h":"60","1d":"1D"},api:{public:{get:{"api/dashboard/PairList":1,"api/chart/history":1,"api/dashboard":1}}},commonCurrencies:{TMN:"IRT"},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetApiDashboardPairList(e),i=[];for(let e=0;e<t.length;e++){const s=this.parseMarket(t[e]);i.push(s)}return i}parseMarket(e){const t=this.safeString(e,"id");let i=this.safeString(e,"destinationCoinSymbol"),s=this.safeString(e,"sourceCoinSymbol");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetApiDashboardPairList(t),s={};for(let e=0;e<i.length;e++){const t=this.parseTicker(i[e]);s[t.symbol]=t}return this.filterByArrayTickers(s,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={src:this.safeStringUpper(i,"quoteId"),dest:this.safeStringUpper(i,"baseId")},r=await this.publicGetApiDashboardPairList(s),a=this.safeDict(r,0);return this.parseTicker(a)}parseTicker(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeSymbol(i,t,void 0,"spot"),r=this.safeFloat(e,"highestRecentOrder",0),a=this.safeFloat(e,"lowestRecentOrder",0),o=this.safeFloat(e,"bestBuy",0),n=this.safeFloat(e,"bestSell",0),d=this.safeFloat(e,"lastOrderPrice",0),h=this.safeFloat(e,"change",0),c=this.safeFloat(e,"todayTradeAmount",0);return this.safeTicker({symbol:s,timestamp:void 0,datetime:void 0,high:r,low:a,bid:o,bidVolume:void 0,ask:n,askVolume:void 0,vwap:void 0,open:d,close:d,last:d,previousClose:void 0,change:h,percentage:void 0,average:void 0,baseVolume:c,quoteVolume:void 0,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=100,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.base+a.quote,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t),countback:s};"IRT"===a.quote&&(n.symbol=a.base+"TMN"),void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetApiChartHistory(n),h=this.safeValue(d,"o",[]),c=this.safeList(d,"h",[]),l=this.safeList(d,"l",[]),u=this.safeList(d,"c",[]),f=this.safeList(d,"v",[]),p=this.safeList(d,"t",[]),m=[];for(let e=0;e<h.length;e++)m.push([p[e],h[e],c[e],l[e],u[e],f[e]]);return this.parseOHLCVs(m,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={id:this.market(e).id},r=await this.publicGetApiDashboard(s),a=this.milliseconds();return this.parseOrderBook(r,e,a,"buyers","sellers","price","totalAmount")}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return void 0!==this.safeString(s,"src")&&void 0!==this.safeString(s,"dest")&&(n=n+"?"+this.urlencode(o)),"api/dashboard"===e&&(n=n+"/"+s.id+"/market"),"api/chart/history"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},90930:(e,t,i)=>{i.d(t,{A:()=>c});var s=i(76405),r=i(62079),a=i(85147),o=i(51579),n=i(37481),d=i(54852),h=i(75354);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"upbit",name:"Upbit",countries:["KR"],version:"v1",rateLimit:50,pro:!0,has:{CORS:!0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,editOrder:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!1,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,transfer:!1,withdraw:!0},timeframes:{"1s":"seconds","1m":"minutes","3m":"minutes","5m":"minutes","10m":"minutes","15m":"minutes","30m":"minutes","1h":"minutes","4h":"minutes","1d":"days","1w":"weeks","1M":"months","1y":"years"},hostname:"api.upbit.com",urls:{logo:"https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg",api:{public:"https://{hostname}",private:"https://{hostname}"},www:"https://upbit.com",doc:"https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C",fees:"https://upbit.com/service_center/guide"},api:{public:{get:{"market/all":2,"candles/{timeframe}":2,"candles/{timeframe}/{unit}":2,"candles/seconds":2,"candles/minutes/{unit}":2,"candles/minutes/1":2,"candles/minutes/3":2,"candles/minutes/5":2,"candles/minutes/10":2,"candles/minutes/15":2,"candles/minutes/30":2,"candles/minutes/60":2,"candles/minutes/240":2,"candles/days":2,"candles/weeks":2,"candles/months":2,"candles/years":2,"trades/ticks":2,ticker:2,"ticker/all":2,orderbook:2,"orderbook/supported_levels":2}},private:{get:{accounts:.67,"orders/chance":.67,order:.67,"orders/closed":.67,"orders/open":.67,"orders/uuids":.67,withdraws:.67,withdraw:.67,"withdraws/chance":.67,"withdraws/coin_addresses":.67,deposits:.67,"deposits/chance/coin":.67,deposit:.67,"deposits/coin_addresses":.67,"deposits/coin_address":.67,"travel_rule/vasps":.67,"status/wallet":.67,api_keys:.67},post:{orders:2.5,"orders/cancel_and_new":2.5,"withdraws/coin":.67,"withdraws/krw":.67,"deposits/krw":.67,"deposits/generate_coin_address":.67,"travel_rule/deposit/uuid":.67,"travel_rule/deposit/txid":.67},delete:{order:.67,"orders/open":40,"orders/uuids":.67}}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!1},hedged:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:200}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"This key has expired.":r.AuthenticationError,"Missing request parameter error. Check the required parameters!":r.BadRequest,"side is missing, side does not have a valid value":r.InvalidOrder},broad:{thirdparty_agreement_required:r.PermissionDenied,out_of_scope:r.PermissionDenied,order_not_found:r.OrderNotFound,insufficient_funds:r.InsufficientFunds,invalid_access_key:r.AuthenticationError,jwt_verification:r.AuthenticationError,create_ask_error:r.ExchangeError,create_bid_error:r.ExchangeError,volume_too_large:r.InvalidOrder,invalid_funds:r.InvalidOrder}},options:{createMarketBuyOrderRequiresPrice:!0,tradingFeesByQuoteCurrency:{KRW:5e-4}},commonCurrencies:{TON:"Tokamak Network"}})}async fetchCurrency(e,t={}){await this.loadMarkets();const i=this.currency(e);return await this.fetchCurrencyById(i.id,t)}async fetchCurrencyById(e,t={}){const i={currency:e},s=await this.privateGetWithdrawsChance(this.extend(i,t)),r=this.safeValue(s,"member_level",{}),o=this.safeValue(s,"currency",{}),n=this.safeValue(s,"withdraw_limit",{}),d=this.safeValue(n,"can_withdraw"),h=this.safeString(o,"wallet_state"),c=this.safeValue(r,"wallet_locked"),l=this.safeValue(r,"locked");let u=!0;void 0===d||d?("working"!==h||void 0!==c&&c||void 0!==l&&l)&&(u=!1):u=!1;const f=this.safeString(n,"onetime"),p=this.safeString(n,"daily",f),m=this.safeString(n,"remaining_daily",p);let g;g=a.Y.stringGt(m,"0")?m:p;const v=this.safeString(o,"code"),y=this.safeCurrencyCode(v);return{info:s,id:v,code:y,name:y,active:u,fee:this.safeNumber(o,"withdraw_fee"),precision:void 0,limits:{withdraw:{min:this.safeNumber(n,"minimum"),max:this.parseNumber(g)}}}}async fetchMarket(e,t={}){await this.loadMarkets();const i=this.market(e);return await this.fetchMarketById(i.id,t)}async fetchMarketById(e,t={}){const i={market:e},s=await this.privateGetOrdersChance(this.extend(i,t)),r=this.safeValue(s,"market"),o=this.safeValue(r,"bid"),n=this.safeValue(r,"ask"),d=this.safeString(r,"id"),h=this.safeString(n,"currency"),c=this.safeString(o,"currency"),l=this.safeCurrencyCode(h),u=this.safeCurrencyCode(c),f=this.safeString(r,"state"),p=this.safeString(s,"bid_fee"),m=this.safeString(s,"ask_fee"),g=this.parseNumber(a.Y.stringMax(p,m));return this.safeMarketStructure({id:d,symbol:l+"/"+u,base:l,quote:u,settle:void 0,baseId:h,quoteId:c,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:"active"===f,contract:!1,linear:void 0,inverse:void 0,taker:g,maker:g,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber("1e-8"),price:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(n,"min_total"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(o,"min_total"),max:this.safeNumber(r,"max_total")},info:s}})}async fetchMarkets(e={}){const t=await this.publicGetMarketAll(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"market"),[i,s]=t.split("-"),r=this.safeCurrencyCode(s),a=this.safeCurrencyCode(i);return this.safeMarketStructure({id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:s,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,a,this.fees.trading.taker),maker:this.safeNumber(this.options.tradingFeesByQuoteCurrency,a,this.fees.trading.maker),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{price:this.parseNumber("1e-8"),amount:this.parseNumber("1e-8")},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e})}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};for(let i=0;i<e.length;i++){const s=e[i],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.free=this.safeString(s,"balance"),o.used=this.safeString(s,"locked"),t[a]=o}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetAccounts(e);return this.parseBalance(t)}async fetchOrderBooks(e=void 0,t=void 0,i={}){let s;await this.loadMarkets(),void 0===e?s=this.ids.join(","):(s=this.marketIds(e),s=s.join(","));const r={markets:s},a=await this.publicGetOrderbook(this.extend(r,i)),o={};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"market"),s=this.safeSymbol(i,void 0,"-"),r=this.safeInteger(t,"timestamp");o[s]={symbol:s,bids:this.sortBy(this.parseBidsAsks(t.orderbook_units,"bid_price","bid_size"),0,!0),asks:this.sortBy(this.parseBidsAsks(t.orderbook_units,"ask_price","ask_size"),0),timestamp:r,datetime:this.iso8601(r),nonce:void 0}}return o}async fetchOrderBook(e,t=void 0,i={}){const s=await this.fetchOrderBooks([e],t,i);return this.safeValue(s,e)}parseTicker(e,t=void 0){const i=this.safeInteger(e,"trade_timestamp"),s=this.safeString2(e,"market","code");t=this.safeMarket(s,t,"-");const r=this.safeString(e,"trade_price");return this.safeTicker({symbol:t.symbol,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high_price"),low:this.safeString(e,"low_price"),bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:this.safeString(e,"opening_price"),close:r,last:r,previousClose:this.safeString(e,"prev_closing_price"),change:this.safeString(e,"signed_change_price"),percentage:this.safeString(e,"signed_change_rate"),average:void 0,baseVolume:this.safeString(e,"acc_trade_volume_24h"),quoteVolume:this.safeString(e,"acc_trade_price_24h"),info:e},t)}async fetchTickers(e=void 0,t={}){let i;await this.loadMarkets(),void 0===(e=this.marketSymbols(e))?i=this.ids.join(","):(i=this.marketIds(e),i=i.join(","));const s={markets:i},r=await this.publicGetTicker(this.extend(s,t)),a={};for(let e=0;e<r.length;e++){const t=this.parseTicker(r[e]);a[t.symbol]=t}return this.filterByArrayTickers(a,"symbol",e)}async fetchTicker(e,t={}){const i=await this.fetchTickers([e],t);return this.safeValue(i,e)}parseTrade(e,t=void 0){const i=this.safeString2(e,"sequential_id","uuid");let s,r=this.safeInteger(e,"timestamp");void 0===r&&(r=this.parse8601(this.safeString(e,"created_at")));const a=this.safeStringLower2(e,"ask_bid","side");"ask"===a?s="sell":"bid"===a&&(s="buy");const o=this.safeString(e,"funds"),n=this.safeString2(e,"trade_price","price"),d=this.safeString2(e,"trade_volume","volume"),h=this.safeString2(e,"market","code");let c;t=this.safeMarket(h,t,"-");const l=this.safeString(e,a+"_fee");return void 0!==l&&(c={currency:t.quote,cost:l}),this.safeTrade({id:i,info:e,order:undefined,timestamp:r,datetime:this.iso8601(r),symbol:t.symbol,type:void 0,side:s,takerOrMaker:void 0,price:n,amount:d,cost:o,fee:c},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e);void 0===i&&(i=200);const a={market:r.id,count:i},o=await this.publicGetTradesTicks(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchTradingFee(e,t={}){await this.loadMarkets();const i={market:this.market(e).id},s=await this.privateGetOrdersChance(this.extend(i,t)),r=this.safeString(s,"ask_fee"),o=this.safeString(s,"bid_fee"),n=a.Y.stringMax(r,o),d=this.safeString(s,"maker_ask_fee"),h=this.safeString(s,"maker_bid_fee"),c=a.Y.stringMax(d,h);return{info:s,symbol:e,maker:this.parseNumber(c),taker:this.parseNumber(n),percentage:!0,tierBased:!1}}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.fetchMarkets(e),i={};for(let e=0;e<t.length;e++){const s={};s.maker=this.safeNumber(t[e],"maker"),s.taker=this.safeNumber(t[e],"taker"),s.symbol=this.safeString(t[e],"symbol"),s.percentage=!0,s.tierBased=!1,s.info=t[e],i[this.safeString(t[e],"symbol")]=s}return i}parseOHLCV(e,t=void 0){return[this.parse8601(this.safeString(e,"candle_date_time_utc")),this.safeNumber(e,"opening_price"),this.safeNumber(e,"high_price"),this.safeNumber(e,"low_price"),this.safeNumber(e,"trade_price"),this.safeNumber(e,"candle_acc_trade_volume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.parseTimeframe(t),n=this.safeString(this.timeframes,t,t);void 0===s&&(s=200);const d={market:a.id,timeframe:n,count:s};let h;if(void 0!==i&&(d.to=this.iso8601(this.sum(i,o*s*1e3))),"minutes"===n){const e=Math.round(o/60);d.unit=e,h=await this.publicGetCandlesTimeframeUnit(this.extend(d,r))}else h=await this.publicGetCandlesTimeframe(this.extend(d,r));return this.parseOHLCVs(h,a,t,i,s)}calcOrderPrice(e,t,i=void 0,s={}){let o;const n=this.safeValue(this.options,"createMarketBuyOrderRequiresPrice"),d=this.safeString(s,"cost");if(void 0!==d)o=this.costToPrecision(e,d);else if(n){if(void 0===i||void 0===t)throw new r.InvalidOrder(this.id+" createOrder() requires the price and amount argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument");const s=this.numberToString(t),n=this.numberToString(i),d=a.Y.stringMul(s,n);o=this.costToPrecision(e,d)}else{if(void 0===t)throw new r.ArgumentsRequired(this.id+' When createMarketBuyOrderRequiresPrice is false, "amount" is required and should be the total quote amount to spend.');o=this.costToPrecision(e,t)}return o}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e);let d;if("buy"===i)d="bid";else{if("sell"!==i)throw new r.InvalidOrder(this.id+" createOrder() supports only buy or sell in the side argument.");d="ask"}const h={market:n.id,side:d};if("limit"===t){if(void 0===a||void 0===s)throw new r.ArgumentsRequired(this.id+" the limit type order in createOrder() is required price and amount.");h.ord_type="limit",h.price=this.priceToPrecision(e,a),h.volume=this.amountToPrecision(e,s)}else{if("market"!==t)throw new r.InvalidOrder(this.id+" createOrder() supports only limit or market types in the type argument.");if("buy"===i){h.ord_type="price";const t=this.calcOrderPrice(e,s,a,o);h.price=t}else{if(void 0===s)throw new r.ArgumentsRequired(this.id+" the market sell type order in createOrder() is required amount.");h.ord_type="market",h.volume=this.amountToPrecision(e,s)}}if("best"===this.safeString2(o,"ordType","ord_type"))if(o=this.omit(o,["ordType","ord_type"]),h.ord_type="best","buy"===i){const t=this.calcOrderPrice(e,s,a,o);h.price=t}else{if(void 0===s)throw new r.ArgumentsRequired(this.id+" the best sell type order in createOrder() is required amount.");h.volume=this.amountToPrecision(e,s)}const c=this.safeString(o,"clientOrderId");if(void 0!==c&&(h.identifier=c),"market"!==h.ord_type&&"price"!==h.ord_type){const e=this.safeStringLower2(o,"timeInForce","time_in_force");if(o=this.omit(o,["timeInForce"]),void 0!==e)h.time_in_force=e;else if("best"===h.ord_type)throw new r.ArgumentsRequired(this.id+" the best type order in createOrder() is required timeInForce.")}o=this.omit(o,["clientOrderId","cost"]);const l=await this.privatePostOrders(this.extend(h,o));return this.parseOrder(l)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateDeleteOrder(this.extend(s,i));return this.parseOrder(r)}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){await this.loadMarkets();const d={},h=this.safeString(n,"clientOrderId");if(n=this.omit(n,"clientOrderId"),void 0!==e)d.prev_order_uuid=e;else{if(void 0===h)throw new r.ArgumentsRequired(this.id+" editOrder() is required id or clientOrderId.");d.prev_order_identifier=h}if("limit"===i){if(void 0===o||void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required price and amount to create limit type order.");d.new_ord_type="limit",d.new_price=this.priceToPrecision(t,o),d.new_volume=this.amountToPrecision(t,a)}else{if("market"!==i)throw new r.InvalidOrder(this.id+" editOrder() supports only limit or market types in the type argument.");if("buy"===s){d.new_ord_type="price";const e=this.calcOrderPrice(t,a,o,n);d.new_price=e}else{if(void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required amount to create market sell type order.");d.new_ord_type="market",d.new_volume=this.amountToPrecision(t,a)}}if("best"===this.safeString2(n,"newOrdType","new_ord_type"))if(n=this.omit(n,["newOrdType","new_ord_type"]),d.new_ord_type="best","buy"===s){const e=this.calcOrderPrice(t,a,o,n);d.new_price=e}else{if(void 0===a)throw new r.ArgumentsRequired(this.id+" editOrder() is required amount to create best sell order.");d.new_volume=this.amountToPrecision(t,a)}const c=this.safeString(n,"newClientOrderId");if(void 0!==c&&(d.new_identifier=c),"market"!==d.new_ord_type&&"price"!==d.new_ord_type){const e=this.safeStringLower2(n,"newTimeInForce","new_time_in_force");if(n=this.omit(n,["newTimeInForce","new_time_in_force"]),void 0!==e)d.new_time_in_force=e;else if("best"===d.new_ord_type)throw new r.ArgumentsRequired(this.id+" the best type order is required timeInForce.")}n=this.omit(n,["newClientOrderId","cost"]);const l=await this.privatePostOrdersCancelAndNew(this.extend(d,n)),u={};return u.uuid=this.safeString(l,"new_order_uuid"),u.identifier=this.safeString(l,"new_order_identifier"),u.side=this.safeString(l,"side"),u.market=this.safeString(l,"market"),this.parseOrder(u)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetDeposits(this.extend(r,s));return this.parseTransactions(o,a,t,i)}async fetchDeposit(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e};let r;void 0!==t&&(r=this.currency(t),s.currency=r.id);const a=await this.privateGetDeposit(this.extend(s,i));return this.parseTransaction(a,r)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetWithdraws(this.extend(r,s));return this.parseTransactions(o,a,t,i)}async fetchWithdrawal(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e};let r;void 0!==t&&(r=this.currency(t),s.currency=r.id);const a=await this.privateGetWithdraw(this.extend(s,i));return this.parseTransaction(a,r)}parseTransactionStatus(e){return this.safeString({submitting:"pending",submitted:"pending",almost_accepted:"pending",rejected:"failed",accepted:"ok",processing:"pending",done:"ok",canceled:"canceled"},e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"done_at"),s=this.parse8601(this.safeString(e,"created_at",i));let r=this.safeString(e,"type");"withdraw"===r&&(r="withdrawal");const a=this.safeString(e,"currency"),o=this.safeCurrencyCode(a,t);return{info:e,id:this.safeString(e,"uuid"),currency:o,amount:this.safeNumber(e,"amount"),network:void 0,address:undefined,addressTo:void 0,addressFrom:void 0,tag:undefined,tagTo:void 0,tagFrom:void 0,status:this.parseTransactionStatus(this.safeStringLower(e,"state")),type:r,updated:this.parse8601(i),txid:this.safeString(e,"txid"),timestamp:s,datetime:this.iso8601(s),internal:void 0,comment:void 0,fee:{currency:o,cost:this.safeNumber(e,"fee")}}}parseOrderStatus(e){return this.safeString({wait:"open",done:"closed",cancel:"canceled"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"uuid");let s=this.safeString(e,"side");s="bid"===s?"buy":"sell";const r=this.safeString(e,"identifier");let o=this.safeString(e,"ord_type");const n=this.parse8601(this.safeString(e,"created_at")),d=this.parseOrderStatus(this.safeString(e,"state"));let h,c=this.safeString(e,"price");const l=this.safeString(e,"volume"),u=this.safeString(e,"remaining_volume"),f=this.safeString(e,"executed_volume");let p,m,g;"price"===o&&(o="market",p=c,c=void 0);let v=this.safeString(e,"paid_fee");const y=this.safeString(e,"market");t=this.safeMarket(y,t);let b=this.safeValue(e,"trades",[]);b=this.parseTrades(b,t,void 0,void 0,{order:i,type:o});const w=b.length;if(w>0){h=b[w-1].timestamp;let e=!1;void 0===v&&(e=!0,v="0"),p="0";for(let t=0;t<w;t++){const i=b[t];if(p=a.Y.stringAdd(p,this.safeString(i,"cost")),e){const e=this.safeValue(b[t],"fee",{}),i=this.safeString(e,"cost");void 0!==i&&(v=a.Y.stringAdd(v,i))}}m=a.Y.stringDiv(p,f)}return void 0!==v&&(g={currency:t.quote,cost:v}),this.safeOrder({info:e,id:i,clientOrderId:r,timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:h,symbol:t.symbol,type:o,timeInForce:this.safeStringUpper(e,"time_in_force"),postOnly:void 0,side:s,price:c,triggerPrice:void 0,cost:this.parseNumber(p),average:this.parseNumber(m),amount:l,filled:f,remaining:u,status:d,fee:g,trades:b})}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.market=a.id),void 0!==i&&(r.limit=i);const o=await this.privateGetOrdersOpen(this.extend(r,s));return this.parseOrders(o,a,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a={state:"done"};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==t&&(a.start_time=t),void 0!==i&&(a.limit=i),[a,s]=this.handleUntilOption("end_time",a,s);const o=await this.privateGetOrdersClosed(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a={state:"cancel"};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==t&&(a.start_time=t),void 0!==i&&(a.limit=i),[a,s]=this.handleUntilOption("end_time",a,s);const o=await this.privateGetOrdersClosed(this.extend(a,s));return this.parseOrders(o,r,t,i)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={uuid:e},r=await this.privateGetOrder(this.extend(s,i));return this.parseOrder(r)}async fetchDepositAddresses(e=void 0,t={}){await this.loadMarkets();const i=await this.privateGetDepositsCoinAddresses(t);return this.parseDepositAddresses(i,e)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"deposit_address"),s=this.safeString(e,"secondary_address"),r=this.safeString(e,"currency"),a=this.safeCurrencyCode(r),o=this.safeString(e,"net_type");return this.checkAddress(i),{info:e,currency:a,network:this.networkIdToCode(o),address:i,tag:s}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e);let s;if([s,t]=this.handleNetworkCodeAndParams(t),void 0===s)throw new r.ArgumentsRequired(this.id+' fetchDepositAddress requires params["network"]');const a=await this.privateGetDepositsCoinAddress(this.extend({currency:i.id,net_type:this.networkCodeToId(s,i.code)},t));return this.parseDepositAddress(a)}async createDepositAddress(e,t={}){await this.loadMarkets();const i={currency:this.currency(e).id},s=await this.privatePostDepositsGenerateCoinAddress(this.extend(i,t));if(void 0!==this.safeString(s,"message"))throw new r.AddressPending(this.id+" is generating "+e+" deposit address, call fetchDepositAddress or createDepositAddress one more time later to retrieve the generated address");return this.parseDepositAddress(s)}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),await this.loadMarkets();const o=this.currency(e),n={amount:t};let d;if("KRW"!==e){this.checkAddress(i);const e=this.safeStringUpper2(a,"network","net_type");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a network argument");a=this.omit(a,["network"]),n.net_type=e,n.currency=o.id,n.address=i,void 0!==s&&(n.secondary_address=s),a=this.omit(a,"network"),d=await this.privatePostWithdrawsCoin(this.extend(n,a))}else d=await this.privatePostWithdrawsKrw(this.extend(n,a));return this.parseTransaction(d)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.implodeParams(this.urls.api[t],{hostname:this.hostname});o+="/"+this.version+"/"+this.implodeParams(e,s);const c=this.omit(s,this.extractParams(e));if("POST"!==i&&Object.keys(c).length&&(o+="?"+this.urlencode(c)),"private"===t){this.checkRequiredCredentials(),r={};const e=this.uuid(),t={access_key:this.apiKey,nonce:e},o=Object.keys(c).length;let l;if("GET"!==i&&"DELETE"!==i&&(a=this.json(s),r["Content-Type"]="application/json"),o&&(l=this.rawencode(c)),void 0!==l){const e=this.hash(this.encode(l),n.Zf);t.query_hash=e,t.query_hash_alg="SHA512"}const u=(0,h.a)(t,this.encode(this.secret),d.s);r.Authorization="Bearer "+u}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.safeValue(n,"error");if(void 0!==c){const e=this.safeString(c,"message"),t=this.safeString(c,"name"),i=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,i),this.throwExactlyMatchedException(this.exceptions.exact,t,i),this.throwBroadlyMatchedException(this.exceptions.broad,e,i),this.throwBroadlyMatchedException(this.exceptions.broad,t,i),new r.ExchangeError(i)}}}},84910:(e,t,i)=>{i.d(t,{A:()=>c});var s=i(38139),r=i(62079),a=i(85147),o=i(51579),n=i(38432),d=i(40987),h=i(88283);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"vertex",name:"Vertex",countries:[],version:"v1",rateLimit:50,certified:!1,pro:!0,dex:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!0,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!1,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:void 0,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":60,"5m":300,"15m":900,"1h":3600,"2h":7200,"4h":14400,"1d":86400,"1w":604800,"1M":604800},hostname:"vertexprotocol.com",urls:{logo:"https://github.com/ccxt/ccxt/assets/43336371/bd04a0fa-3b48-47b6-9d8b-124954d520a8",api:{v1:{archive:"https://archive.prod.{hostname}/v1",gateway:"https://gateway.prod.{hostname}/v1",trigger:"https://trigger.prod.{hostname}/v1"},v2:{archive:"https://archive.prod.{hostname}/v2",gateway:"https://gateway.prod.{hostname}/v2"}},test:{v1:{archive:"https://archive.sepolia-test.{hostname}/v1",gateway:"https://gateway.sepolia-test.{hostname}/v1",trigger:"https://trigger.sepolia-test.{hostname}/v1"},v2:{archive:"https://archive.sepolia-test.{hostname}/v2",gateway:"https://gateway.sepolia-test.{hostname}/v2"}},www:"https://vertexprotocol.com/",doc:"https://docs.vertexprotocol.com/",fees:"https://docs.vertexprotocol.com/basics/fees",referral:"https://app.vertexprotocol.com?referrer=0xCfC9BaB96a2eA3d3c3F031c005e82E1D9F295aC1"},api:{v1:{archive:{post:{"":1}},gateway:{get:{query:1,symbols:1,time:1},post:{query:1,execute:1}},trigger:{post:{execute:1,query:1}}},v2:{archive:{get:{tickers:1,contracts:1,trades:1,vrtx:1}},gateway:{get:{assets:.6667,pairs:1,orderbook:1}}}},fees:{swap:{taker:this.parseNumber("0.0002"),maker:this.parseNumber("0.0002")},spot:{taker:this.parseNumber("0.0002"),maker:this.parseNumber("0.0002")}},requiredCredentials:{apiKey:!1,secret:!1,walletAddress:!0,privateKey:!0},exceptions:{exact:{1e3:r.RateLimitExceeded,1015:r.RateLimitExceeded,1001:r.PermissionDenied,1002:r.PermissionDenied,1003:r.PermissionDenied,2e3:r.InvalidOrder,2001:r.InvalidOrder,2002:r.InvalidOrder,2003:r.InvalidOrder,2004:r.InvalidOrder,2005:r.InvalidOrder,2006:r.InvalidOrder,2007:r.InvalidOrder,2008:r.InvalidOrder,2009:r.InvalidOrder,2010:r.InvalidOrder,2011:r.BadRequest,2012:r.BadRequest,2013:r.InvalidOrder,2014:r.PermissionDenied,2015:r.InvalidOrder,2016:r.InvalidOrder,2017:r.InvalidOrder,2019:r.InvalidOrder,2020:r.InvalidOrder,2021:r.InvalidOrder,2022:r.InvalidOrder,2023:r.InvalidOrder,2024:r.InsufficientFunds,2025:r.InsufficientFunds,2026:r.BadRequest,2027:r.AuthenticationError,2028:r.AuthenticationError,2029:r.AuthenticationError,2030:r.BadRequest,2031:r.InvalidOrder,2033:r.InvalidOrder,2034:r.InvalidOrder,2035:r.InvalidOrder,2036:r.InvalidOrder,2037:r.InvalidOrder,2038:r.InvalidOrder,2039:r.InvalidOrder,2040:r.InvalidOrder,2041:r.InvalidOrder,2042:r.InvalidOrder,2043:r.InvalidOrder,2044:r.InvalidOrder,2045:r.InvalidOrder,2046:r.InvalidOrder,2047:r.InvalidOrder,2048:r.InvalidOrder,2049:r.ExchangeError,2050:r.PermissionDenied,2051:r.InvalidOrder,2052:r.InvalidOrder,2053:r.InvalidOrder,2054:r.InvalidOrder,2055:r.InvalidOrder,2056:r.InvalidOrder,2057:r.InvalidOrder,2058:r.InvalidOrder,2059:r.InvalidOrder,2060:r.InvalidOrder,2061:r.InvalidOrder,2062:r.InvalidOrder,2063:r.InvalidOrder,2064:r.InvalidOrder,2065:r.InvalidOrder,2066:r.InvalidOrder,2067:r.InvalidOrder,2068:r.InvalidOrder,2069:r.InvalidOrder,2070:r.InvalidOrder,2071:r.InvalidOrder,2072:r.InvalidOrder,2073:r.InvalidOrder,2074:r.InvalidOrder,2075:r.InvalidOrder,2076:r.InvalidOrder,3e3:r.BadRequest,3001:r.BadRequest,3002:r.BadRequest,3003:r.BadRequest,4e3:r.BadRequest,4001:r.ExchangeError,4002:r.ExchangeError,4003:r.ExchangeError,4004:r.InvalidOrder,5e3:r.ExchangeError},broad:{}},precisionMode:o.kb,commonCurrencies:{},options:{defaultType:"swap",sandboxMode:!1,timeDifference:0,brokerId:5930043274845996},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:1e5,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:void 0,inverse:void 0}}})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}convertToX18(e){if("string"==typeof e)return a.Y.stringMul(e,"1000000000000000000");const t=this.numberToString(e);return a.Y.stringMul(t,"1000000000000000000")}convertFromX18(e){if("string"==typeof e)return a.Y.stringDiv(e,"1000000000000000000");const t=this.numberToString(e);return a.Y.stringDiv(t,"1000000000000000000")}async fetchCurrencies(e={}){const t=await this.v2GatewayGetAssets(this.extend({},e)),i={};for(let e=0;e<t.length;e++){const s=this.safeDict(t,e,{}),r=this.safeString(s,"ticker_id");if(void 0!==r&&r.indexOf("PERP")>0)continue;const a=this.safeString(s,"symbol"),o=this.safeCurrencyCode(a);i[o]=this.safeCurrencyStructure({id:this.safeString(s,"product_id"),name:a,code:o,precision:void 0,info:s,active:void 0,deposit:this.safeBool(s,"can_deposit"),withdraw:this.safeBool(s,"can_withdraw"),networks:void 0,fee:void 0,limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}}})}return i}parseMarket(e){const t=this.safeString(e,"type"),i="USDC",s=this.safeCurrencyCode(i),r=this.safeString(e,"symbol"),a=this.safeCurrencyCode(r),o=i,n=this.safeCurrencyCode(o);let d=a+"/"+s;const h="spot"===t,c=!h,l=!h;if(l){d=a.split("-")[0]+"/"+s+":"+n}const u=this.safeString(e,"price_increment_x18"),f=this.safeString(e,"size_increment"),p=this.safeString(e,"min_size"),m=this.safeNumber(e,"taker_fee_rate_x18"),g=this.safeNumber(e,"maker_fee_rate_x18"),v=!!h&&void 0,y=!h||void 0,b=h?void 0:this.parseNumber("1");return{id:this.safeString(e,"product_id"),symbol:d,base:a,quote:s,settle:h?void 0:n,baseId:r,quoteId:i,settleId:h?void 0:o,type:h?"spot":"swap",spot:h,margin:void 0,swap:l,future:!1,option:!1,active:!0,contract:c,linear:y,inverse:v,taker:this.parseNumber(this.convertFromX18(m)),maker:this.parseNumber(this.convertFromX18(g)),contractSize:b,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.convertFromX18(f)),price:this.parseNumber(this.convertFromX18(u))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(this.convertFromX18(p)),max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchMarkets(e={}){const t=await this.v1GatewayGetQuery(this.extend({type:"symbols"},e)),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"symbols",{}),r=Object.keys(s),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeDict(s,t,{});a.push(this.parseMarket(i))}return a}async fetchTime(e={}){const t=await this.v1GatewayGetTime(e);return this.parseToInt(t)}async fetchStatus(e={}){const t=await this.v1GatewayGetQuery(this.extend({type:"status"},e));let i=this.safeString(t,"data");return i="active"===i?"ok":"error",{status:i,updated:void 0,eta:void 0,url:void 0,info:t}}parseTrade(e,t=void 0){let i,s,r,o;const n=this.convertFromX18(this.safeString(e,"fee"));void 0!==n&&(o={cost:n,currency:void 0});const d=this.safeString2(e,"trade_id","submission_idx"),h=this.safeString(e,"digest"),c=this.safeTimestamp(e,"timestamp");if(void 0===c){const o=this.safeDict(this.safeDict(e,"pre_balance",{}),"base",{});let n;n="perp"in o?this.safeString(this.safeDict(o,"perp",{}),"product_id"):this.safeString(this.safeDict(o,"spot",{}),"product_id"),t=this.safeMarket(n);const d=this.safeDict(e,"order",{});i=this.convertFromX18(this.safeString(d,"priceX18")),s=this.convertFromX18(this.safeString(e,"base_filled")),r=a.Y.stringLt(s,"0")?"sell":"buy"}else{const a=this.safeString(e,"ticker_id").split("_"),o=a[0].split("-")[0]+a[1];t=this.safeMarket(o,t),i=this.safeString(e,"price"),s=this.safeString(e,"base_filled"),r=this.safeStringLower(e,"trade_type")}s=a.Y.stringAbs(s);const l=t.symbol;return this.safeTrade({id:d,timestamp:c,datetime:this.iso8601(c),symbol:l,side:r,price:i,amount:s,cost:void 0,order:h,takerOrMaker:void 0,type:void 0,fee:o,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={ticker_id:r.baseId+"_USDC"};void 0!==i&&(a.limit=i);const o=await this.v2ArchiveGetTrades(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r,a;await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchMyTrades",s);const o={subaccount:this.convertAddressToSender(r)};void 0!==e&&(a=this.market(e),o.product_ids=[this.parseToNumeric(a.id)]);const n=this.safeInteger(s,"until");void 0!==n&&(s=this.omit(s,"until"),o.max_time=n),void 0!==i&&(o.limit=i);const d={matches:o},h=await this.v1ArchivePost(this.extend(d,s)),c=this.safeList(h,"matches",[]);return this.parseTrades(c,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();void 0===t&&(t=100);const s={ticker_id:this.market(e).baseId+"_USDC",depth:t},r=await this.v2GatewayGetOrderbook(this.extend(s,i)),a=this.safeInteger(r,"timestamp");return this.parseOrderBook(r,e,a,"bids","asks")}async fetchTradingFees(e={}){let t;await this.loadMarkets(),[t,e]=this.handlePublicAddress("fetchTradingFees",e);const i={type:"fee_rates",sender:this.convertAddressToSender(t)},s=await this.v1GatewayGetQuery(this.extend(i,e)),r=this.safeDict(s,"data",{}),a=this.safeList(r,"maker_fee_rates_x18",[]),o=this.safeList(r,"taker_fee_rates_x18",[]),n={};for(let e=0;e<o.length;e++){const t=this.safeMarket(this.numberToString(e));if(void 0===t.id)continue;const i=t.symbol;n[i]={info:s,symbol:i,maker:this.parseNumber(this.convertFromX18(a[e])),taker:this.parseNumber(this.convertFromX18(o[e])),percentage:!0,tierBased:!1}}return n}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,"timestamp"),this.parseNumber(this.convertFromX18(this.safeString(e,"open_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"high_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"low_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"close_x18"))),this.parseNumber(this.convertFromX18(this.safeString(e,"volume")))]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={product_id:this.parseToInt(a.id),granularity:this.safeInteger(this.timeframes,t)},n=this.safeInteger(r,"until");void 0!==n&&(r=this.omit(r,"until"),o.max_time=n),void 0!==s&&(o.limit=Math.min(s,1e3));const d={candlesticks:o},h=await this.v1ArchivePost(this.extend(d,r)),c=this.safeList(h,"candlesticks",[]);return this.parseOHLCVs(c,a,t,i,s)}parseFundingRate(e,t=void 0){let i=this.safeNumber(e,"funding_rate");if(void 0===i){const t=this.safeString(e,"funding_rate_x18");i=this.parseNumber(this.convertFromX18(t))}const s=this.safeTimestamp2(e,"update_time","next_funding_rate_timestamp"),r=this.safeNumber(e,"mark_price"),a=this.safeNumber(e,"index_price");return{info:e,symbol:t.symbol,markPrice:r,indexPrice:a,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:void 0,datetime:void 0,fundingRate:i,fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={funding_rate:{product_id:this.parseToInt(i.id)}},r=await this.v1ArchivePost(this.extend(s,t));return this.parseFundingRate(r,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets();void 0!==e&&(e=this.marketSymbols(e));const i=await this.v2ArchiveGetContracts(this.extend({},t)),s=Object.keys(i),r={};for(let e=0;e<s.length;e++){const t=s[e],a=t.split("-"),o=i[t],n=a[0]+"/USDC:USDC",d=this.market(n),h=this.parseFundingRate(o,d);r[h.symbol]=h}return this.filterByArray(r,"symbol",e)}parseOpenInterest(e,t=void 0){const i=this.safeString(e,"ticker_id");return this.safeOpenInterest({symbol:this.safeSymbol(i,t),openInterestAmount:this.safeNumber(e,"open_interest"),openInterestValue:this.safeNumber(e,"open_interest_usd"),timestamp:void 0,datetime:void 0,info:e},t)}async fetchOpenInterests(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v2ArchiveGetContracts(t),s=[],r=[],a=Object.keys(i);if(void 0===e){e=[];for(let t=0;t<a.length;t++){const i=a[t].split("-")[0]+"/USDC:USDC";this.inArray(i,e)||e.push(i)}}for(let t=0;t<a.length;t++){const o=a[t],n=this.safeMarket(o),d=this.safeDict(i,o,{});for(let t=0;t<e.length;t++){const i=this.market(e[t]),a=i.base+"_USDC";n.marketId===a&&(s.push(i.symbol),r.push(this.parseOpenInterest(d,i)))}}return this.filterByArray(r,"symbol",s)}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new r.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");const s=await this.v2ArchiveGetContracts(this.extend({},t)),a=i.base+"_USDC",o=this.safeDict(s,a,{});return this.parseOpenInterest(o,i)}parseTicker(e,t=void 0){const i=this.safeString(e,"base_currency");let s=i+"/"+this.safeString(e,"quote_currency");i.indexOf("PERP")>0&&(s=s.replace("-PERP","")+":USDC"),t=this.safeMarket(s,t);const r=this.safeString(e,"last_price");return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:this.safeString(e,"price_change_percent_24h"),average:void 0,baseVolume:this.safeString(e,"base_volume"),quoteVolume:this.safeString(e,"quote_volume"),info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!0,!0,!0);const i=await this.v2ArchiveGetTickers(this.extend({},t)),s=Object.values(i);return this.parseTickers(s,e)}async queryContracts(e={}){const t=this.safeDict(this.options,"v1contracts");if(void 0!==t)return t;const i=await this.v1GatewayGetQuery(this.extend({type:"contracts"},e)),s=this.safeDict(i,"data",{});return this.options.v1contracts=s,s}nonce(){return this.milliseconds()-this.options.timeDifference}hashMessage(e){return"0x"+this.hash(e,n.lY,"hex")}signHash(e,t){const i=(0,h.h1)(e.slice(-64),t.slice(-64),d.bI,void 0),s=i.r,r=i.s,a=this.intToBase16(this.sum(27,i.v));return"0x"+s.padStart(64,"0")+r.padStart(64,"0")+a}signMessage(e,t){return this.signHash(this.hashMessage(e),t.slice(-64))}buildSig(e,t,i,s=""){const r={chainId:e,name:"Vertex",verifyingContract:s,version:"0.0.1"},a=this.ethEncodeStructuredData(r,t,i);return this.signMessage(a,this.privateKey)}buildCreateOrderSig(e,t,i){return this.buildSig(t,{Order:[{name:"sender",type:"bytes32"},{name:"priceX18",type:"int128"},{name:"amount",type:"int128"},{name:"expiration",type:"uint64"},{name:"nonce",type:"uint64"}]},e,i)}buildListTriggerTxSig(e,t,i){return this.buildSig(t,{ListTriggerOrders:[{name:"sender",type:"bytes32"},{name:"recvTime",type:"uint64"}]},e,i)}buildCancelAllOrdersSig(e,t,i){return this.buildSig(t,{CancellationProducts:[{name:"sender",type:"bytes32"},{name:"productIds",type:"uint32[]"},{name:"nonce",type:"uint64"}]},e,i)}buildCancelOrdersSig(e,t,i){return this.buildSig(t,{Cancellation:[{name:"sender",type:"bytes32"},{name:"productIds",type:"uint32[]"},{name:"digests",type:"bytes32[]"},{name:"nonce",type:"uint64"}]},e,i)}buildWithdrawSig(e,t,i){return this.buildSig(t,{WithdrawCollateral:[{name:"sender",type:"bytes32"},{name:"productId",type:"uint32"},{name:"amount",type:"uint128"},{name:"nonce",type:"uint64"}]},e,i)}convertAddressToSender(e){return(e+"64656661756c74").padEnd(66,"0")}getNonce(e,t){return void 0===e&&(e=this.nonce()),a.Y.stringAdd(a.Y.stringMul(a.Y.stringAdd(this.numberToString(e),this.numberToString(t)),"1048576"),"1000")}getExpiration(e,t,i,s){let r=a.Y.stringAdd(this.numberToString(e),"86400");return"ioc"===t?r=a.Y.stringOr(r,"4611686018427387904"):"fok"===t?r=a.Y.stringOr(r,"9223372036854775808"):i&&(r=a.Y.stringOr(r,"13835058055282163712")),s&&(r=a.Y.stringOr(r,"2305843009213693952")),r}getAmount(e,t){let i=this.numberToString(e);return"sell"===t?e>0&&(i=a.Y.stringMul(i,"-1")):e<0&&(i=a.Y.stringMul(i,"-1")),i}async createOrder(e,t,i,s,o=void 0,n={}){this.checkRequiredCredentials();const d="market"===t.toLowerCase();if(d&&void 0===o)throw new r.ArgumentsRequired(this.id+" createOrder() requires a price argument for market order");await this.loadMarkets();const h=this.market(e),c=this.parseToInt(h.id),l=await this.queryContracts(),u=this.safeString(l,"chain_id"),f=this.safeList(l,"book_addrs",[]),p=this.safeString(f,c),m=d?"fok":void 0,g=this.safeStringLower(n,"timeInForce",m),v=this.safeBool(n,"postOnly",!1),y=this.safeBool(n,"reduceOnly",!1),b=this.safeString2(n,"triggerPrice","stopPrice"),w=this.safeString(n,"stopLossPrice",b),k=this.safeString(n,"takeProfitPrice"),S=w||k,O=this.nonce();let T=this.getNonce(O,9e4);if(v&&y)throw new r.NotSupported(this.id+" reduceOnly not supported when postOnly is enabled");const P=this.getExpiration(O,g,v,y);S&&(T=a.Y.stringOr(T,"9223372036854775808"));const M=this.getAmount(s,i),I={sender:this.convertAddressToSender(this.walletAddress),priceX18:this.convertToX18(this.priceToPrecision(e,o)),amount:this.convertToX18(this.amountToPrecision(e,M)),expiration:P,nonce:T},x={place_order:{product_id:c,order:{sender:I.sender,priceX18:I.priceX18,amount:I.amount,expiration:this.numberToString(I.expiration),nonce:I.nonce},signature:this.buildCreateOrderSig(I,u,p),id:this.safeInteger(this.options,"brokerId",5930043274845996)}};let A;if(n=this.omit(n,["timeInForce","reduceOnly","postOnly","triggerPrice","stopPrice","stopLossPrice","takeProfitPrice"]),S){const e={};void 0!==w?e.last_price_below=this.convertToX18(w):void 0!==k&&(e.last_price_above=this.convertToX18(k)),x.place_order.trigger=e,A=await this.v1TriggerPostExecute(this.extend(x,n))}else A=await this.v1GatewayPostExecute(this.extend(x,n));const C=this.safeDict(A,"data",{});return this.safeOrder({id:this.safeString(C,"digest")})}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){this.checkRequiredCredentials();const d="market"===i.toLowerCase();if(d&&void 0===o)throw new r.ArgumentsRequired(this.id+" editOrder() requires a price argument for market order");await this.loadMarkets();const h=this.market(t),c=this.parseToInt(h.id),l=d?"fok":void 0,u=this.safeStringLower(n,"timeInForce",l),f=this.safeBool(n,"postOnly",!1),p=this.safeBool(n,"reduceOnly",!1),m=this.safeString2(n,"triggerPrice","stopPrice"),g=this.safeString(n,"stopLossPrice",m),v=this.safeString(n,"takeProfitPrice"),y=g||v,b=await this.queryContracts(),w=this.safeString(b,"chain_id"),k=this.safeList(b,"book_addrs",[]),S=this.safeString(k,c),O=this.safeString(b,"endpoint_addr"),T=this.nonce(),P=this.getNonce(T,9e4),M=this.convertAddressToSender(this.walletAddress);if(f&&p)throw new r.NotSupported(this.id+" reduceOnly not supported when postOnly is enabled");if(y)throw new r.NotSupported(this.id+" editOrder() not supported for trigger order");const I=this.getExpiration(T,u,f,p),x=this.getAmount(a,s),A={sender:M,priceX18:this.convertToX18(this.priceToPrecision(t,o)),amount:this.convertToX18(this.amountToPrecision(t,x)),expiration:I,nonce:P},C={sender:M,productIds:[c],digests:[e],nonce:P},_={cancel_and_place:{cancel_tx:{sender:C.sender,productIds:C.productIds,digests:C.digests,nonce:this.numberToString(C.nonce)},cancel_signature:this.buildCancelOrdersSig(C,w,O),place_order:{product_id:c,order:{sender:A.sender,priceX18:A.priceX18,amount:A.amount,expiration:this.numberToString(A.expiration),nonce:A.nonce},signature:this.buildCreateOrderSig(A,w,S),id:this.safeInteger(this.options,"brokerId",5930043274845996)}}};n=this.omit(n,["timeInForce","reduceOnly","postOnly","triggerPrice","stopPrice","stopLossPrice","takeProfitPrice"]);const B=await this.v1GatewayPostExecute(this.extend(_,n)),E=this.safeDict(B,"data",{});return this.safeOrder({id:this.safeString(E,"digest")})}parseOrderStatus(e){if(void 0!==e){const t={pending:"open"};if("string"==typeof e)return this.safeString(t,e,e);if(void 0!==this.safeDict(e,"cancelled"))return"canceled";const i=this.safeDict(e,"triggered",{});return"success"===this.safeString(i,"status","failure")?"closed":"canceled"}return e}parseOrder(e,t=void 0){let i=this.safeString(e,"product_id"),s=this.safeTimestamp(e,"placed_at"),r=this.safeString(e,"amount"),a=this.safeString(e,"price_x18");const o=this.safeString(e,"unfilled_amount");let n;const d=this.safeValue(e,"status");if(void 0!==d){const t=this.safeDict(e,"order",{}),o=this.safeDict(t,"order",{});i=this.safeString(t,"product_id"),r=this.safeString(o,"amount"),a=this.safeString(o,"priceX18"),s=this.safeTimestamp(e,"updated_at");const d=this.safeDict(t,"trigger",{}),h=this.safeStringN(d,["price_above","price_below","last_price_above","last_price_below"]);void 0!==h&&(n=this.parseToNumeric(this.convertFromX18(h)))}const h=(t=this.safeMarket(i,t)).symbol;let c,l,u,f;void 0!==a&&(c=this.parseToNumeric(this.convertFromX18(a))),void 0!==r&&(l=this.parseToNumeric(this.convertFromX18(r))),void 0!==o&&(u=this.parseToNumeric(this.convertFromX18(o))),void 0!==l&&void 0!==u&&(f=l<0||u<0?"sell":"buy");const p=this.parseTimeInForce(this.safeString(e,"order_type")),m="PO"===p;return this.safeOrder({info:e,id:this.safeString(e,"digest"),clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:void 0,symbol:h,type:void 0,timeInForce:p,postOnly:m,reduceOnly:void 0,side:f,price:c,triggerPrice:n,amount:l,cost:void 0,average:void 0,filled:void 0,remaining:u,status:this.parseOrderStatus(d),fee:void 0,trades:void 0},t)}parseTimeInForce(e){return this.safeStringUpper({POST_ONLY:"PO"},e,e)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(t),r={type:"order",product_id:this.parseToInt(s.id),digest:e},a=await this.v1GatewayGetQuery(this.extend(r,i)),o=this.safeDict(a,"data");return this.parseOrder(o,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;this.checkRequiredCredentials(),await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchOpenOrders",s);const a={};let o;const n=this.safeBool2(s,"stop","trigger");let d;if(s=this.omit(s,["stop","trigger"]),void 0!==e&&(o=this.market(e),a.product_id=this.parseToNumeric(o.id)),n){const e=await this.queryContracts(),t=this.safeString(e,"chain_id"),o=this.safeString(e,"endpoint_addr"),n={sender:this.convertAddressToSender(r),recvTime:this.nonce()+9e4};a.signature=this.buildListTriggerTxSig(n,t,o),a.tx={sender:n.sender,recvTime:this.numberToString(n.recvTime)},a.type="list_trigger_orders",a.pending=!0;const h=this.safeInteger(s,"until");s=this.omit(s,"until"),void 0!==h&&(a.max_update_time=h),void 0!==i&&(a.limit=i),d=await this.v1TriggerPostQuery(this.extend(a,s))}else this.checkRequiredArgument("fetchOpenOrders",e,"symbol"),a.type="subaccount_orders",a.sender=this.convertAddressToSender(r),d=await this.v1GatewayPostQuery(this.extend(a,s));const h=this.safeDict(d,"data",{}),c=this.safeList(h,"orders");return this.parseOrders(c,o,t,i)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){this.checkRequiredCredentials();const a=this.safeBool2(s,"stop","trigger");if(s=this.omit(s,["stop","trigger"]),!a)throw new r.NotSupported(this.id+" fetchOrders only support trigger orders");let o,n;[o,s]=this.handlePublicAddress("fetchOrders",s),await this.loadMarkets();const d={type:"list_trigger_orders",pending:!1};void 0!==e&&(n=this.market(e),d.product_id=this.parseToNumeric(n.id));const h=await this.queryContracts(),c=this.safeString(h,"chain_id"),l=this.safeString(h,"endpoint_addr"),u={sender:this.convertAddressToSender(o),recvTime:this.nonce()+9e4};d.signature=this.buildListTriggerTxSig(u,c,l),d.tx={sender:u.sender,recvTime:this.numberToString(u.recvTime)};const f=this.safeInteger(s,"until");s=this.omit(s,"until"),void 0!==f&&(d.max_update_time=f),void 0!==i&&(d.limit=i);const p=await this.v1TriggerPostQuery(this.extend(d,s)),m=this.safeDict(p,"data",{}),g=this.safeList(m,"orders");return this.parseOrders(g,n,t,i)}async cancelAllOrders(e=void 0,t={}){if(this.checkRequiredCredentials(),await this.loadMarkets(),void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a symbol argument");const i=this.market(e).id,s=await this.queryContracts(),a=this.safeString(s,"chain_id"),o=this.safeString(s,"endpoint_addr"),n=this.nonce(),d=this.getNonce(n,9e4),h={sender:this.convertAddressToSender(this.walletAddress),productIds:[this.parseToNumeric(i)],nonce:d},c={cancel_product_orders:{tx:{sender:h.sender,productIds:h.productIds,nonce:this.numberToString(h.nonce)},signature:this.buildCancelAllOrdersSig(h,a,o)}},l=this.safeBool2(t,"stop","trigger");let u;return t=this.omit(t,["stop","trigger"]),u=l?await this.v1TriggerPostExecute(this.extend(c,t)):await this.v1GatewayPostExecute(this.extend(c,t)),[this.safeOrder({info:u})]}async cancelOrder(e,t=void 0,i={}){const s=await this.cancelOrders([e],t,i);return this.safeOrder({info:s})}async cancelOrders(e,t=void 0,i={}){if(this.checkRequiredCredentials(),void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrders() requires a symbol argument");await this.loadMarkets();const s=this.market(t).id,a=await this.queryContracts(),o=this.safeString(a,"chain_id"),n=this.safeString(a,"endpoint_addr"),d=this.nonce(),h=this.getNonce(d,9e4),c={sender:this.convertAddressToSender(this.walletAddress),productIds:[],digests:e,nonce:h},l=c.productIds,u=this.parseToNumeric(s);for(let t=0;t<e.length;t++)l.push(u);const f={cancel_orders:{tx:{sender:c.sender,productIds:l,digests:c.digests,nonce:this.numberToString(c.nonce)},signature:this.buildCancelOrdersSig(c,o,n)}},p=this.safeBool2(i,"stop","trigger");let m;return i=this.omit(i,["stop","trigger"]),m=p?await this.v1TriggerPostExecute(this.extend(f,i)):await this.v1GatewayPostExecute(this.extend(f,i)),m}async fetchBalance(e={}){let t;[t,e]=this.handlePublicAddress("fetchBalance",e);const i={type:"subaccount_info",subaccount:this.convertAddressToSender(t)},s=await this.v1GatewayGetQuery(this.extend(i,e)),r=this.safeDict(s,"data",{}),a=this.safeList(r,"spot_balances",[]),o={info:s};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"product_id"),s=this.safeMarket(i),r="0"===i;if(void 0===s.id&&!r)continue;const n=r?"USDC":this.safeString(s,"baseId"),d=this.safeCurrencyCode(n),h=this.account(),c=this.safeDict(t,"balance",{}),l=this.convertFromX18(this.safeString(c,"amount"));h.total=l,o[d]=h}return this.safeBalance(o)}parsePosition(e,t=void 0){const i=this.safeString(e,"product_id");t=this.safeMarket(i);const s=this.safeDict(e,"balance",{}),r=this.convertFromX18(this.safeString(s,"amount"));let o="buy";return a.Y.stringLt(r,"1")&&(o="sell"),this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:void 0,datetime:void 0,lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:void 0,notional:void 0,leverage:void 0,unrealizedPnl:void 0,contracts:void 0,contractSize:this.parseToNumeric(r),marginRatio:void 0,liquidationPrice:void 0,markPrice:void 0,lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:o,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchPositions(e=void 0,t={}){let i;[i,t]=this.handlePublicAddress("fetchPositions",t);const s={type:"subaccount_info",subaccount:this.convertAddressToSender(i)},r=await this.v1GatewayGetQuery(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"perp_balances",[]);e=this.marketSymbols(e);const n=[];for(let e=0;e<o.length;e++){const i=this.extend(this.parsePosition(o[e],void 0),t);0!==i.contractSize&&n.push(i)}return this.filterByArrayPositions(n,"symbol",e,!1)}async queryNonces(){const e={type:"nonces",address:this.walletAddress},t=await this.v1GatewayGetQuery(e);return this.safeDict(t,"data",{})}async withdraw(e,t,i,s=void 0,r={}){this.checkRequiredCredentials(),await this.loadMarkets();const a=this.currency(e),o=await this.queryContracts(),n=this.safeString(o,"chain_id"),d=this.safeString(o,"endpoint_addr"),h=await this.queryNonces(),c=this.safeNumber(h,"tx_nonce"),l={sender:this.convertAddressToSender(this.walletAddress),productId:this.parseToNumeric(a.id),amount:t.toString(),nonce:c},u={withdraw_collateral:{tx:{sender:l.sender,productId:l.productId,amount:l.amount,nonce:this.numberToString(l.nonce)},signature:this.buildWithdrawSig(l,n,d)}},f=await this.v1GatewayPostExecute(this.extend(u,r)),p=this.parseTransaction(f,a);return this.extend(p,{amount:t,address:i})}parseTransaction(e,t=void 0){let i;return void 0!==t&&(i=t.code),{info:e,id:void 0,txid:void 0,timestamp:void 0,datetime:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,type:"withdrawal",amount:void 0,currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:void 0,network:void 0,comment:void 0,internal:void 0,fee:void 0}}parseTransactionStatus(e){return this.safeString({success:"ok"},e,e)}handlePublicAddress(e,t){let i;[i,t]=this.handleOptionAndParams(t,e,"user");let s=i;if([s,t]=this.handleOptionAndParams(t,e,"address",i),void 0!==s&&""!==s)return[s,t];if(void 0!==this.walletAddress&&""!==this.walletAddress)return[this.walletAddress,t];throw new r.ArgumentsRequired(this.id+" "+e+"() requires a user parameter inside 'params' or the wallet address set")}handleErrors(e,t,i,s,a,o,n,d,h){if(!n)return;if("failure"===this.safeString(n,"status","")){const e=this.safeString(n,"error"),t=this.id+" "+o,i=this.safeString(n,"error_code");throw this.throwExactlyMatchedException(this.exceptions.exact,i,t),this.throwBroadlyMatchedException(this.exceptions.broad,e,t),new r.ExchangeError(t)}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.safeString(t,0),n=this.safeString(t,1);let d=this.implodeHostname(this.urls.api[o][n]);return"v1"===o&&"archive"===n||(d=d+"/"+e),"POST"===i?(r={"Content-Type":"application/json"},a=this.json(s)):Object.keys(s).length&&(d+="?"+this.urlencode(s)),"execute"!==e&&(void 0!==r?r["Accept-Encoding"]="gzip":r={"Accept-Encoding":"gzip"}),{url:d,method:i,body:a,headers:r}}}},88633:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(16140);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wallex",name:"Wallex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!1,cancelOrders:!1,createDepositAddress:!1,createOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,editOrder:!1,fetchBalance:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:"emulated",fetchPositions:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchWithdrawals:!1,setLeverage:!1,setMarginMode:!1,transfer:!1,withdraw:!1},comment:"This comment is optional",urls:{logo:"https://cdn.arz.digital/cr-odin/img/exchanges/wallex/64x64.png",api:{public:"https://api.wallex.ir"},www:"https://wallex.ir",doc:["https://api-docs.wallex.ir"]},timeframes:{"1m":"1","1h":"60","3h":"180","6h":"360","12h":"720","1d":"1D"},api:{public:{get:{"v1/markets":1,"v1/currencies/stats":1,"v1/depth":1,"v1/udf/history":1}}},commonCurrencies:{TMN:"IRT"},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}})}async fetchMarkets(e={}){const t=await this.publicGetV1Markets(e),i=this.safeDict(t,"result"),s=this.safeDict(i,"symbols"),r=Object.keys(s),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.parseMarket(s[t]);a.push(i)}return a}parseMarket(e){const t=this.safeString(e,"symbol");let i=this.safeString(e,"baseAsset"),s=this.safeString(e,"quoteAsset");const r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return i=i.toLowerCase(),s=s.toLowerCase(),{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1Markets(t),s=this.safeDict(i,"result"),r=this.safeDict(s,"symbols"),a=Object.keys(r),o={};for(let e=0;e<a.length;e++){const t=a[e],i=this.parseTicker(r[t]);o[i.symbol]=i}return this.filterByArrayTickers(o,"symbol",e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1Markets(t),r=this.safeDict(s,"result"),a=this.safeDict(r,"symbols");return this.parseTicker(a[i.id])}parseTicker(e,t=void 0){const i=this.safeValue(e,"stats"),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t,void 0,"spot"),a=this.safeFloat(i,"24h_highPrice",0),o=this.safeFloat(i,"24h_lowPrice",0),n=this.safeFloat(i,"bidPrice",0),d=this.safeFloat(i,"askPrice",0),h=this.safeFloat(i,"lastPrice",0),c=this.safeFloat(i,"24h_quoteVolume",0),l=this.safeFloat(i,"24h_volume",0);return this.safeTicker({symbol:r,timestamp:void 0,datetime:void 0,high:a,low:o,bid:n,bidVolume:void 0,ask:d,askVolume:void 0,vwap:void 0,open:void 0,close:h,last:h,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:l,quoteVolume:c,info:e},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.milliseconds(),n={symbol:a.id,from:o/1e3-86400,to:o/1e3,resolution:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.from=i/1e3),n.from=this.safeInteger(n,"from"),n.to=this.safeInteger(n,"to"),void 0!==t&&(n.resolution=this.safeString(this.timeframes,t,t));const d=await this.publicGetV1UdfHistory(n),h=this.safeValue(d,"o",[]),c=this.safeList(d,"h",[]),l=this.safeList(d,"l",[]),u=this.safeList(d,"c",[]),f=this.safeList(d,"v",[]),p=this.safeList(d,"t",[]),m=[];for(let e=0;e<h.length;e++)m.push([p[e],h[e],c[e],l[e],u[e],f[e]]);return this.parseOHLCVs(m,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id},r=await this.publicGetV1Depth(s),a=this.safeDict(r,"result",{}),o=this.milliseconds();return this.parseOrderBook(a,e,o,"bid","ask","price","quantity")}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e));let n=this.urls.api.public+"/"+e;return"v1/udf/history"===e&&(n=n+"?"+this.urlencode(o)),"v1/depth"===e&&(n=n+"?"+this.urlencode(o)),{url:n,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},56314:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wallgold",name:"WallGold",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.wallgold.ir"},www:"https://wallgold.ir",doc:"https://wallgold.ir"},api:{public:{get:{"api/v1/price":1}}}})}async fetchMarkets(e={}){const t=await this.fetchPrice("buy",e);return[this.parseMarket(t)]}fetchPrice(e,t={}){return this.publicGetApiV1Price(this.extend({side:e,symbol:"GLD_18C_750TMN"},t))}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:this.safeBool(e,"success",!0),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.fetchPrice("buy",t),r=await this.fetchPrice("sell",t);return this.parseTicker(s,i,r)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=this.market("XAU18/IRT"),s=await this.fetchPrice("buy",t),r=await this.fetchPrice("sell",t),a=this.parseTicker(s,i,r),o={};return o[a.symbol]=a,this.filterByArrayTickers(o,"symbol",e)}parseTicker(e,t=void 0,i=void 0){const s=this.safeDict(e,"result",{}),r=this.safeDict(i,"result",s),a=this.safeNumber(s,"price"),o=this.safeNumber(r,"price");let n=a;void 0!==o&&(void 0===n||o>n)&&(n=o);const d=this.safeString(s,"currentTime"),h=d?this.parse8601(d):void 0;return this.safeTicker({symbol:t.symbol,timestamp:h,datetime:void 0,high:void 0,low:void 0,bid:a,bidVolume:void 0,ask:o,askVolume:void 0,vwap:void 0,open:void 0,close:n,last:n,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:{buy:e,sell:i}},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{"Content-Type":"application/json"}}}}},57073:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(47698),r=i(62079),a=i(85147),o=i(6414),n=i(51579);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"wavesexchange",name:"Waves.Exchange",countries:["CH"],certified:!1,pro:!1,dex:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:void 0,fetchDepositAddressesByNetwork:void 0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,reduceMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,signIn:!0,transfer:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","3h":"3h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg",test:{matcher:"https://matcher-testnet.wx.network",node:"https://nodes-testnet.wavesnodes.com",public:"https://api-testnet.wavesplatform.com/v0",private:"https://api-testnet.wx.network/v1",forward:"https://testnet.wx.network/api/v1/forward/matcher",market:"https://testnet.wx.network/api/v1/forward/marketdata/api/v1"},api:{matcher:"https://matcher.wx.network",node:"https://nodes.wx.network",public:"https://api.wavesplatform.com/v0",private:"https://api.wx.network/v1",forward:"https://wx.network/api/v1/forward/matcher",market:"https://wx.network/api/v1/forward/marketdata/api/v1"},doc:["https://docs.wx.network","https://docs.waves.tech","https://api.wavesplatform.com/v0/docs/","https://nodes.wavesnodes.com/api-docs/index.html","https://matcher.waves.exchange/api-docs/index.html"],www:"https://wx.network"},api:{matcher:{get:["matcher","matcher/settings","matcher/settings/rates","matcher/balance/reserved/{publicKey}","matcher/debug/allSnashotOffsets","matcher/debug/currentOffset","matcher/debug/lastOffset","matcher/debug/oldestSnapshotOffset","matcher/debug/config","matcher/debug/address/{address}","matcher/debug/status","matcher/debug/address/{address}/check","matcher/orderbook","matcher/orderbook/{baseId}/{quoteId}","matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}","matcher/orderbook/{baseId}/{quoteId}/{orderId}","matcher/orderbook/{baseId}/{quoteId}/info","matcher/orderbook/{baseId}/{quoteId}/status","matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}","matcher/orderbook/{publicKey}","matcher/orderbook/{publicKey}/{orderId}","matcher/orders/{address}","matcher/orders/{address}/{orderId}","matcher/transactions/{orderId}","api/v1/orderbook/{baseId}/{quoteId}"],post:["matcher/orderbook","matcher/orderbook/market","matcher/orderbook/cancel","matcher/orderbook/{baseId}/{quoteId}/cancel","matcher/orderbook/{baseId}/{quoteId}/calculateFee","matcher/orderbook/{baseId}/{quoteId}/delete","matcher/orderbook/{baseId}/{quoteId}/cancelAll","matcher/debug/saveSnapshots","matcher/orders/{address}/cancel","matcher/orders/cancel/{orderId}","matcher/orders/serialize"],delete:["matcher/orderbook/{baseId}/{quoteId}","matcher/settings/rates/{assetId}"],put:["matcher/settings/rates/{assetId}"]},node:{get:["addresses","addresses/balance/{address}","addresses/balance/{address}/{confirmations}","addresses/balance/details/{address}","addresses/data/{address}","addresses/data/{address}/{key}","addresses/effectiveBalance/{address}","addresses/effectiveBalance/{address}/{confirmations}","addresses/publicKey/{publicKey}","addresses/scriptInfo/{address}","addresses/scriptInfo/{address}/meta","addresses/seed/{address}","addresses/seq/{from}/{to}","addresses/validate/{address}","alias/by-address/{address}","alias/by-alias/{alias}","assets/{assetId}/distribution/{height}/{limit}","assets/balance/{address}","assets/balance/{address}/{assetId}","assets/details/{assetId}","assets/nft/{address}/limit/{limit}","blockchain/rewards","blockchain/rewards/height","blocks/address/{address}/{from}/{to}/","blocks/at/{height}","blocks/delay/{signature}/{blockNum}","blocks/first","blocks/headers/last","blocks/headers/seq/{from}/{to}","blocks/height","blocks/height/{signature}","blocks/last","blocks/seq/{from}/{to}","blocks/signature/{signature}","consensus/algo","consensus/basetarget","consensus/basetarget/{blockId}","consensus/{generatingbalance}/address","consensus/generationsignature","consensus/generationsignature/{blockId}","debug/balances/history/{address}","debug/blocks/{howMany}","debug/configInfo","debug/historyInfo","debug/info","debug/minerInfo","debug/portfolios/{address}","debug/state","debug/stateChanges/address/{address}","debug/stateChanges/info/{id}","debug/stateWaves/{height}","leasing/active/{address}","node/state","node/version","peers/all","peers/blacklisted","peers/connected","peers/suspended","transactions/address/{address}/limit/{limit}","transactions/info/{id}","transactions/status","transactions/unconfirmed","transactions/unconfirmed/info/{id}","transactions/unconfirmed/size","utils/seed","utils/seed/{length}","utils/time","wallet/seed"],post:["addresses","addresses/data/{address}","addresses/sign/{address}","addresses/signText/{address}","addresses/verify/{address}","addresses/verifyText/{address}","debug/blacklist","debug/print","debug/rollback","debug/validate","node/stop","peers/clearblacklist","peers/connect","transactions/broadcast","transactions/calculateFee","tranasctions/sign","transactions/sign/{signerAddress}","tranasctions/status","utils/hash/fast","utils/hash/secure","utils/script/compileCode","utils/script/compileWithImports","utils/script/decompile","utils/script/estimate","utils/sign/{privateKey}","utils/transactionsSerialize"],delete:["addresses/{address}","debug/rollback-to/{signature}"]},public:{get:["assets","pairs","candles/{baseId}/{quoteId}","transactions/exchange"]},private:{get:["deposit/addresses/{currency}","deposit/addresses/{currency}/{platform}","platforms","deposit/currencies","withdraw/currencies","withdraw/addresses/{currency}/{address}"],post:["oauth2/token"]},forward:{get:["matcher/orders/{address}","matcher/orders/{address}/{orderId}"],post:["matcher/orders/{wavesAddress}/cancel"]},market:{get:["tickers"]}},currencies:{WX:this.safeCurrencyStructure({id:"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",numericId:void 0,code:"WX",precision:this.parseNumber("1e-8")})},precisionMode:n.kb,options:{allowedCandles:1440,accessToken:void 0,createMarketBuyOrderRequiresPrice:!0,matcherPublicKey:void 0,quotes:void 0,createOrderDefaultExpiry:24192e5,wavesAddress:void 0,withdrawFeeUSDN:7420,withdrawFeeWAVES:1e5,wavesPrecision:1e-8,messagePrefix:"W",networks:{ERC20:"ETH",BEP20:"BSC"}},features:{spot:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{EGG:"Waves Ducks"},requiresEddsa:!0,exceptions:{3147270:r.InsufficientFunds,112:r.InsufficientFunds,4:r.ExchangeError,13:r.ExchangeNotAvailable,14:r.ExchangeNotAvailable,3145733:r.AccountSuspended,3148040:r.DuplicateOrderId,3148801:r.AuthenticationError,9440512:r.AuthenticationError,9440771:r.BadSymbol,9441026:r.InvalidOrder,9441282:r.InvalidOrder,9441286:r.InvalidOrder,9441295:r.InvalidOrder,9441540:r.InvalidOrder,9441542:r.InvalidOrder,106954752:r.AuthenticationError,106954769:r.AuthenticationError,106957828:r.AuthenticationError,106960131:r.AuthenticationError,106981137:r.AuthenticationError,9437184:r.BadRequest,9437193:r.OrderNotFound,1048577:r.BadRequest,1051904:r.AuthenticationError}})}setSandboxMode(e){this.options.messagePrefix=e?"T":"W",this.options.sandboxMode=e,super.setSandboxMode(e)}async getFeesForAsset(e,t,i,s,r={}){await this.loadMarkets();const a=this.market(e);i=this.toRealSymbolAmount(e,i),s=this.toRealSymbolPrice(e,s);const o=this.extend({baseId:a.baseId,quoteId:a.quoteId,orderType:t,amount:i,price:s},r);return await this.matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee(o)}async customCalculateFee(e,t,i,s,r,o="taker",n={}){const d=await this.getFeesForAsset(e,i,s,r);let h;h=this.safeBool(n,"isDiscountFee",!1)?this.safeValue(d,"discount"):this.safeValue(d,"base");const c=this.safeString(h,"matcherFee"),l=this.safeString(h,"feeAssetId"),u=this.safeCurrencyCode(l),f=this.fromRealCurrencyAmount(u,c),p=this.numberToString(s),m=this.numberToString(r),g=this.feeToPrecision(e,this.parseNumber(f)),v=a.Y.stringDiv(f,a.Y.stringMul(p,m));return{type:o,currency:u,rate:this.parseNumber(v),cost:this.parseNumber(g)}}async getQuotes(){let e=this.safeValue(this.options,"quotes");if(e)return e;{const t=await this.matcherGetMatcherSettings();e={};const i=this.safeValue(t,"priceAssets");for(let t=0;t<i.length;t++)e[i[t]]=!0;return this.options.quotes=e,e}}async fetchMarkets(e={}){const t=await this.marketGetTickers(),i=[];for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"amountAssetID"),a=this.safeString(s,"priceAssetID"),o=r+"/"+a,n=this.safeString(s,"symbol");let[d,h]=n.split("/");d=this.safeCurrencyCode(d),h=this.safeCurrencyCode(h);const c=d+"/"+h;i.push({id:o,symbol:c,base:d,quote:h,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(s,"amountAssetDecimals"))),price:this.parseNumber(this.parsePrecision(this.safeString(s,"priceAssetDecimals")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:s})}return i}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r=this.extend({baseId:s.baseId,quoteId:s.quoteId},i),a=await this.matcherGetMatcherOrderbookBaseIdQuoteId(r),o=this.safeInteger(a,"timestamp");return{symbol:e,bids:this.parseOrderBookSide(this.safeValue(a,"bids"),s,t),asks:this.parseOrderBookSide(this.safeValue(a,"asks"),s,t),timestamp:o,datetime:this.iso8601(o),nonce:void 0}}parseOrderBookSide(e,t=void 0,i=void 0){const s=t.precision,r=this.safeString(this.options,"wavesPrecision","1e-8"),o=this.safeString(s,"amount"),n=this.safeString(s,"price"),d=a.Y.stringDiv(o,n),h=a.Y.stringDiv(r,d),c=[];for(let t=0;t<e.length;t++){const s=e[t],r=this.safeString(s,"price","0"),n=this.safeString(s,"amount","0");let d,l;if(void 0!==h&&void 0!==r&&(d=a.Y.stringMul(r,h)),void 0!==o&&void 0!==n&&(l=a.Y.stringMul(n,o)),void 0!==i&&t>i)break;c.push([this.parseNumber(d),this.parseNumber(l)])}return c}checkRequiredKeys(){if(void 0===this.apiKey)throw new r.AuthenticationError(this.id+" requires apiKey credential");if(void 0===this.secret)throw new r.AuthenticationError(this.id+" requires secret credential");let e,t;try{e=this.base58ToBinary(this.apiKey)}catch(e){throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key")}try{t=this.base58ToBinary(this.secret)}catch(e){throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key")}const i=this.binaryToBase16(e),s=this.binaryToBase16(t);if(64!==i.length)throw new r.AuthenticationError(this.id+" apiKey must be a base58 encoded public key");if(64!==s.length)throw new r.AuthenticationError(this.id+" secret must be a base58 encoded private key");return!0}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e)),n="matcher/orders/{wavesAddress}/cancel"===e;e=this.implodeParams(e,s);let d=this.urls.api[t]+"/"+e,h=this.urlencodeWithArrayRepeat(o);if("private"===t||"forward"===t){r={Accept:"application/json"};const e=this.safeString(this.options,"accessToken");e&&(r.Authorization="Bearer "+e),r["content-type"]="POST"===i?"application/json":"application/x-www-form-urlencoded",n&&(a=this.json([o.orderId]),h=""),h.length>0&&(d+="?"+h)}else"matcher"===t?"POST"===i?(r={Accept:"application/json","Content-Type":"application/json"},a=this.json(o)):r=o:"POST"===i?(r={"content-type":"application/json"},a=this.json(o)):(r={"content-type":"application/x-www-form-urlencoded"},h.length>0&&(d+="?"+h));return{url:d,method:i,body:a,headers:r}}async signIn(e={}){if(!this.safeString(this.options,"accessToken")){const e="ffffff01",t=604800;let i=this.sum(this.seconds(),t);i=i.toString();const s="wx.network",r=this.safeString(this.options,"messagePrefix","W")+":"+s+":"+i,a=e+this.binaryToBase16(this.encode(r)),n=this.binaryToBase16(this.base58ToBinary(this.secret)),d=this.axolotl(a,n,o.ev),h={grant_type:"password",scope:"general",username:this.apiKey,password:i+":"+d,client_id:s},c=await this.privatePostOauth2Token(h);return this.options.accessToken=this.safeString(c,"access_token"),this.options.accessToken}}parseTicker(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString(e,"symbol"),r=(t=this.safeMarket(s,t,"/")).symbol,a=this.safeString2(e,"24h_close","lastPrice"),o=this.safeString2(e,"24h_low","low"),n=this.safeString2(e,"24h_high","high"),d=this.safeString2(e,"24h_vwap","weightedAveragePrice"),h=this.safeString2(e,"24h_volume","volume"),c=this.safeString2(e,"24h_priceVolume","quoteVolume"),l=this.safeString2(e,"24h_open","firstPrice");return this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:n,low:o,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:d,open:l,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:h,quoteVolume:c,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pairs:i.id},r=await this.publicGetPairs(this.extend(s,t)),a=this.safeValue(r,"data",[]),o=this.safeValue(a,0,{}),n=this.safeDict(o,"data",{});return this.parseTicker(n,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.marketGetTickers(t);return this.parseTickers(i,e)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={baseId:a.baseId,quoteId:a.quoteId,interval:this.safeString(this.timeframes,t,t)},n=this.safeInteger(this.options,"allowedCandles",1440),d=this.safeInteger(r,"until"),h=void 0!==d;void 0===s&&(s=n),s=Math.min(n,s);const c=1e3*this.parseTimeframe(t);if(void 0===i){const e=this.milliseconds(),t=h?d:e,i=this.parseToInt(t/c)*c-(s-1)*c;o.timeStart=i.toString(),h&&(o.timeEnd=d.toString())}else if(o.timeStart=i.toString(),h)o.timeEnd=d.toString();else{const e=this.sum(i,c*s);o.timeEnd=e.toString()}r=this.omit(r,"until");const l=await this.publicGetCandlesBaseIdQuoteId(this.extend(o,r)),u=this.safeValue(l,"data",[]);let f,p=this.parseOHLCVs(u,a,t,i,s);p=this.filterFutureCandles(p);const m=p.length;for(let e=0;e<p.length;e++){const t=m-e-1,i=p[t];void 0===i[1]&&(i[1]=f,i[2]=f,i[3]=f,i[4]=f,p[t]=i),f=i[4]}return p}filterFutureCandles(e){const t=[],i=this.milliseconds();for(let s=0;s<e.length&&!(e[s][0]>i);s++)t.push(e[s]);return t}parseOHLCV(e,t=void 0){const i=this.safeValue(e,"data",{});return[this.parse8601(this.safeString(i,"time")),this.safeNumber(i,"open"),this.safeNumber(i,"high"),this.safeNumber(i,"low"),this.safeNumber(i,"close"),this.safeNumber(i,"volume",0)]}async fetchDepositAddress(e,t={}){await this.signIn();const i=this.safeValue(this.options,"networks",{}),s=this.safeStringUpper(t,"network"),a=this.safeString(i,s,s);t=this.omit(t,["network"]);const o=await this.privateGetPlatforms(),n={},d={},h=this.safeValue(o,"items",[]);for(let e=0;e<h.length;e++){const t=h[e],i=this.safeString(t,"id"),s=this.safeValue(t,"currencies",[]);for(let e=0;e<s.length;e++){const t=this.safeString(s,e);n[t]=!0,t in d||(d[t]={}),d[t][i]=!0}}if(!(e in n)){const t=Object.keys(n);throw new r.ExchangeError(this.id+" fetchDepositAddress() "+e+" not supported. Currency code must be one of "+t.join(", "))}let c;if(void 0===a){const i={currency:e};c=await this.privateGetDepositAddressesCurrency(this.extend(i,t))}else{const i=d[e];if(!(a in i)){const t=Object.keys(i);throw new r.ExchangeError(this.id+" "+a+" network "+e+" deposit address not supported. Network must be one of "+t.join(", "))}if("WAVES"===a){const t={publicKey:this.apiKey};return{info:await this.nodeGetAddressesPublicKeyPublicKey(this.extend(t,t)),currency:e,network:a,address:this.safeString(c,"address"),tag:void 0}}{const i={currency:e,platform:a};c=await this.privateGetDepositAddressesCurrencyPlatform(this.extend(i,t))}}const l=this.safeValue(c,"currency"),u=this.safeString(l,"platform_id"),f=this.safeValue(this.options,"networkByIds",{}),p=this.safeString(f,u,u),m=this.safeValue(c,"deposit_addresses");return{info:c,currency:e,network:p,address:this.safeString(m,0),tag:void 0}}async getMatcherPublicKey(){const e=this.safeString(this.options,"matcherPublicKey");if(e)return e;{const e=await this.matcherGetMatcher();return this.options.matcherPublicKey=e.slice(1,e.length-1),this.options.matcherPublicKey}}getAssetBytes(e){return"WAVES"===e?this.numberToBE(0,1):this.binaryConcat(this.numberToBE(1,1),this.base58ToBinary(e))}getAssetId(e){return"WAVES"===e?"":e}toRealCurrencyAmount(e,t,i=void 0){const s=this.currency(e),r=a.Y.stringDiv(this.numberToString(t),this.safeString(s,"precision"));return parseInt(r)}fromRealCurrencyAmount(e,t){if(!(e in this.currencies))return t;const i=this.currency(e),s=this.safeString(i,"precision");return a.Y.stringMul(t,s)}toRealSymbolPrice(e,t){const i=this.market(e),s=a.Y.stringDiv(this.numberToString(t),this.safeString(i.precision,"price"));return parseInt(s)}fromRealSymbolPrice(e,t){const i=this.markets[e];return a.Y.stringMul(t,this.safeString(i.precision,"price"))}toRealSymbolAmount(e,t){const i=this.market(e),s=a.Y.stringDiv(this.numberToString(t),this.safeString(i.precision,"amount"));return parseInt(s)}fromRealSymbolAmount(e,t){const i=this.markets[e];return a.Y.stringMul(t,i.precision.amount)}safeGetDynamic(e){const t=this.safeValue(e,"orderFee");return"dynamic"in t?this.safeValue(t,"dynamic"):this.safeValue(t.composite.default,"dynamic")}safeGetRates(e){const t=this.safeValue(e,"rates");return void 0===t?{WAVES:1}:t}async createOrder(e,t,i,s,a=void 0,n={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const d=this.market(e),h=await this.getMatcherPublicKey(),c=this.getAssetId(d.baseId),l=this.getAssetId(d.quoteId),u="market"===t,f=this.safeFloat2(n,"triggerPrice","stopPrice"),p=void 0!==f;if(u&&void 0===a)throw new r.InvalidOrder(this.id+" createOrder() requires a price argument for "+t+" orders to determine the max price for buy and the min price for sell");const m=this.milliseconds();let g;[g,n]=this.handleOptionAndParams(n,"createOrder","defaultExpiry",this.safeInteger(this.options,"createOrderDefaultExpiry",24192e5));const v=this.sum(m,g),y=await this.getFeesForAsset(e,i,s,a),b=this.safeValue2(y,"base","discount"),w=this.safeString(b,"feeAssetId"),k=this.safeCurrencyCode(w),S=this.safeString(b,"matcherFee"),O=this.safeValue(y,"discount"),T=this.safeString(O,"feeAssetId"),P=this.safeCurrencyCode(T),M=this.safeString(O,"matcherFee");let I,x;if("feeAsset"in n||"feeAsset"in this.options){const e=this.safeString(n,"feeAsset",this.safeString(this.options,"feeAsset")),t=this.currency(e);I=this.safeString(t,"id")}const A=await this.fetchBalance();if(void 0!==I){if(w!==I&&T!==I)throw new r.InvalidOrder(this.id+" asset fee must be "+k+" or "+P);const e=this.safeCurrencyCode(I),t=I===w?S:M,i=parseFloat(this.fromRealCurrencyAmount(e,t));if(!(e in A&&A[e].free>=i))throw new r.InsufficientFunds(this.id+" not enough funds of the selected asset fee");x=parseInt(t)}const C=this.fromRealCurrencyAmount(k,S),_=this.fromRealCurrencyAmount(P,M);if(void 0===I&&(k in A&&A[k].free>=parseFloat(C)?(I=w,x=parseInt(S)):P in A&&A[P].free>=parseFloat(_)&&(I=T,x=parseInt(M))),void 0===I)throw new r.InsufficientFunds(this.id+" not enough funds on none of the eligible asset fees: "+k+" "+C+" or "+P+" "+_);s=this.toRealSymbolAmount(e,s),a=this.toRealSymbolPrice(e,a);const B={amountAsset:c,priceAsset:l},E=this.safeBool(this.options,"sandboxMode",!1)?84:87,L={senderPublicKey:this.apiKey,matcherPublicKey:h,assetPair:B,orderType:i,price:a,amount:s,timestamp:m,expiration:v,matcherFee:parseInt(x),priceMode:"assetDecimals",version:4,chainId:E};if(p){const t={v:1,c:{t:"sp",v:{p:this.toRealSymbolPrice(e,f)}}};L.attachment=this.binaryToBase58(this.encode(JSON.stringify(t)))}"WAVES"!==I&&(L.matcherFeeAssetId=I);let R=await this.matcherPostMatcherOrdersSerialize(L);'"'===R[0]&&'"'===R[R.length-1]&&(R=R.slice(1,R.length-1));const N=this.axolotl(this.binaryToBase16(this.base58ToBinary(R)),this.binaryToBase16(this.base58ToBinary(this.secret)),o.ev);if(L.signature=N,u){const e=await this.matcherPostMatcherOrderbookMarket(this.extend(L,n)),t=this.safeDict(e,"message");return this.parseOrder(t,d)}{const e=await this.matcherPostMatcherOrderbook(this.extend(L,n)),t=this.safeDict(e,"message");return this.parseOrder(t,d)}}async cancelOrder(e,t=void 0,i={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.signIn();const s=await this.getWavesAddress(),r=await this.forwardPostMatcherOrdersWavesAddressCancel({wavesAddress:s,orderId:e}),a=this.safeValue(r,"message"),o=this.safeValue(a,0),n=this.safeValue(o,0),d=this.safeString(n,"orderId");return this.safeOrder({info:r,id:d,clientOrderId:void 0,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,symbol:t,type:void 0,side:void 0,price:void 0,amount:void 0,cost:void 0,average:void 0,filled:void 0,remaining:void 0,status:void 0,fee:void 0,trades:void 0})}async fetchOrder(e,t=void 0,i={}){let s;this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.milliseconds(),a=[this.base58ToBinary(this.apiKey),this.numberToBE(r,8)],n=this.binaryConcatArray(a),d=this.binaryToBase16(this.base58ToBinary(this.secret)),h=this.axolotl(this.binaryToBase16(n),d,o.ev),c={Timestamp:r.toString(),Signature:h,publicKey:this.apiKey,orderId:e},l=await this.matcherGetMatcherOrderbookPublicKeyOrderId(this.extend(c,i));return this.parseOrder(l,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){if(this.checkRequiredDependencies(),this.checkRequiredKeys(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e),n=this.milliseconds(),d=[this.base58ToBinary(this.apiKey),this.numberToBE(n,8)],h=this.binaryConcatArray(d),c=this.binaryToBase16(this.base58ToBinary(this.secret)),l=this.axolotl(this.binaryToBase16(h),c,o.ev),u={Accept:"application/json",Timestamp:n.toString(),Signature:l,publicKey:this.apiKey,baseId:a.baseId,quoteId:a.quoteId},f=await this.matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKey(this.extend(u,s));return this.parseOrders(f,a,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),activeOnly:!0},o=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(o,r,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),await this.signIn(),void 0!==e&&(r=this.market(e));const a={address:await this.getWavesAddress(),closedOnly:!0},o=await this.forwardGetMatcherOrdersAddress(a);return this.parseOrders(o,r,t,i)}parseOrderStatus(e){return this.safeString({Cancelled:"canceled",Accepted:"open",Filled:"closed",PartiallyFilled:"open"},e,e)}getSymbolFromAssetPair(e){const t=this.safeString(e,"amountAsset","WAVES"),i=this.safeString(e,"priceAsset","WAVES");return this.safeCurrencyCode(t)+"/"+this.safeCurrencyCode(i)}parseOrder(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString2(e,"type","orderType");let r="limit";"type"in e&&(r=this.safeString(e,"orderType",r));const a=this.safeString(e,"id"),o=this.safeString(e,"filled"),n=this.safeString(e,"price"),d=this.safeString(e,"amount"),h=this.safeValue(e,"assetPair");let c;void 0!==h?c=this.getSymbolFromAssetPair(h):void 0!==t&&(c=t.symbol);const l=this.safeCurrencyCode(this.safeString(h,"amountAsset","WAVES")),u=this.fromRealSymbolPrice(c,n),f=this.fromRealCurrencyAmount(l,d),p=this.fromRealCurrencyAmount(l,o),m=this.fromRealSymbolPrice(c,this.safeString(e,"avgWeighedPrice")),g=this.parseOrderStatus(this.safeString(e,"status"));let v,y;if("type"in e){const t=this.safeCurrencyCode(this.safeString(e,"feeAsset"));v={currency:t,fee:this.parseNumber(this.fromRealCurrencyAmount(t,this.safeString(e,"filledFee")))}}else{const t=this.safeCurrencyCode(this.safeString(e,"matcherFeeAssetId","WAVES"));v={currency:t,fee:this.parseNumber(this.fromRealCurrencyAmount(t,this.safeString(e,"matcherFee")))}}const b=this.safeString(e,"attachment");if(void 0!==b){const e=this.parseJson(this.decode(this.base58ToBinary(b)));if(void 0!==e){const t=this.safeValue(e,"c");if(void 0!==t){const e=this.safeValue(t,"v");void 0!==e&&(y=this.safeString(e,"p"))}}}return this.safeOrder({info:e,id:a,clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,symbol:c,type:r,timeInForce:void 0,postOnly:void 0,side:s,price:u,triggerPrice:y,amount:f,cost:void 0,average:m,filled:p,remaining:void 0,status:g,fee:v,trades:void 0},t)}async getWavesAddress(){const e=this.safeString(this.options,"wavesAddress");if(void 0===e){const e={publicKey:this.apiKey},t=await this.nodeGetAddressesPublicKeyPublicKey(e);return this.options.wavesAddress=this.safeString(t,"address"),this.options.wavesAddress}return e}async fetchBalance(e={}){this.checkRequiredDependencies(),this.checkRequiredKeys(),await this.loadMarkets();const t=await this.getWavesAddress(),i={address:t},s=await this.nodeGetAssetsBalanceAddress(i),r=this.safeValue(s,"balances",[]);let n,d={};const h=[],c=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeInteger(t,"timestamp");n=void 0===n?i:Math.max(n,i);const s=this.safeValue(t,"issueTransaction"),a=this.safeString(t,"assetId"),o=this.safeString(t,"balance");if(a in this.currencies_by_id){const e=this.safeCurrencyCode(a);d[e]=this.account(),d[e].total=this.fromRealCurrencyAmount(e,o)}else void 0===s&&(h.push(a),c.push(o))}if(h.length){const e={ids:h},t=await this.publicGetAssets(e),i=this.safeValue(t,"data",[]);for(let e=0;e<i.length;e++){const t=i[e],s=c[e],r=this.safeValue(t,"data"),o=this.parsePrecision(this.safeString(r,"precision")),n=this.safeString(r,"ticker"),h=this.safeCurrencyCode(n);d[h]=this.account(),d[h].total=a.Y.stringMul(s,o)}}const l=this.milliseconds(),u=[this.base58ToBinary(this.apiKey),this.numberToBE(l,8)],f=this.binaryConcatArray(u),p=this.binaryToBase16(this.base58ToBinary(this.secret)),m=this.axolotl(this.binaryToBase16(f),p,o.ev),g={publicKey:this.apiKey,signature:m,timestamp:l.toString()},v=await this.matcherGetMatcherBalanceReservedPublicKey(g),y=Object.keys(v);for(let e=0;e<y.length;e++){const t=y[e],i=this.safeCurrencyCode(t);i in d||(d[i]=this.account());const s=this.safeString(v,t);d[i].used=this.fromRealCurrencyAmount(i,s)}const b={address:t},w=await this.nodeGetAddressesBalanceAddress(b);return d.WAVES=this.safeValue(d,"WAVES",this.account()),d.WAVES.total=this.fromRealCurrencyAmount("WAVES",this.safeString(w,"balance")),d=this.setUndefinedBalancesToZero(d),d.timestamp=n,d.datetime=this.iso8601(n),this.safeBalance(d)}setUndefinedBalancesToZero(e,t="used"){const i=Object.keys(e);for(let s=0;s<i.length;s++){const r=i[s];void 0===this.safeValue(e[r],"used")&&(e[r][t]="0")}return e}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={sender:await this.getWavesAddress()};let a;void 0!==e&&(a=this.market(e),r.amountAsset=a.baseId,r.priceAsset=a.quoteId);const o=await this.publicGetTransactionsExchange(r),n=this.safeValue(o,"data");return this.parseTrades(n,a,t,i)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={amountAsset:r.baseId,priceAsset:r.quoteId};void 0!==i&&(a.limit=Math.min(i,100)),void 0!==t&&(a.timeStart=t);const o=await this.publicGetTransactionsExchange(a),n=this.safeValue(o,"data");return this.parseTrades(n,r,t,i)}parseTrade(e,t=void 0){const i=this.safeValue(e,"data"),s=this.safeString(i,"timestamp"),r=this.parse8601(s),a=this.safeString(i,"id"),o=this.safeString(i,"price"),n=this.safeString(i,"amount"),d=this.safeValue(i,"order1"),h=this.safeValue(i,"order2");let c,l;if(this.safeString(d,"senderPublicKey")===this.apiKey)c=d;else if(this.safeString(h,"senderPublicKey")===this.apiKey)c=h;else{const e=this.safeString(d,"timestamp"),t=this.safeString(h,"timestamp");c=this.parse8601(e)>this.parse8601(t)?d:h}const u=this.safeValue(c,"assetPair");void 0!==u?l=this.getSymbolFromAssetPair(u):void 0!==t&&(l=t.symbol);const f=this.safeString(c,"orderType"),p=this.safeString(c,"id"),m={cost:this.safeString(c,"matcherFee"),currency:this.safeCurrencyCode(this.safeString(c,"matcherFeeAssetId","WAVES"))};return this.safeTrade({info:e,timestamp:r,datetime:s,symbol:l,id:a,order:p,type:void 0,side:f,takerOrMaker:void 0,price:o,amount:n,cost:void 0,fee:m},t)}parseDepositWithdrawFees(e,t=void 0,i=void 0){const s={};t=this.marketCodes(t);for(let r=0;r<e.length;r++){const a=e[r],o=this.safeString(a,i),n=this.safeValue(this.currencies_by_id,o),d=this.safeString(n,"code",o);if(void 0===t||this.inArray(d,t)){let e=this.safeValue(s,d);void 0===e?e={info:[a],withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}}:(e=s[d],e.info=this.arrayConcat(e.info,[a]));const t=this.safeString(a,"platform_id"),i=this.safeString(n,"code"),r=this.networkIdToCode(t,i);let o=this.safeValue(e.networks,r);void 0===o&&(o={withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0}});const h=this.safeString(a,"type"),c=this.safeValue(a,"fees");let l="deposit";"withdrawal_currency"===h&&(l="withdraw"),o[l]={fee:this.safeNumber(c,"flat"),percentage:!1},e.networks[r]=o,s[d]=e}}const r=Object.keys(s);for(let e=0;e<r.length;e++){const t=r[e],i=s[t],a=this.safeValue(i,"networks"),o=Object.keys(a);if(1===o.length){const e=this.safeValue(a,o[0]);s[t].withdraw=this.safeValue(e,"withdraw"),s[t].deposit=this.safeValue(e,"deposit")}}return s}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();let i=[],s=[];s.push(this.privateGetDepositCurrencies(t)),s.push(this.privateGetWithdrawCurrencies(t)),s=await Promise.all(s);for(let e=0;e<s.length;e++){const t=this.safeValue(s[e],"items");i=this.arrayConcat(i,t)}return this.parseDepositWithdrawFees(i,e,"id")}handleErrors(e,t,i,s,a,o,n,d,h){const c=this.safeString(n,"error"),l=this.safeBool(n,"success",!0),u=this.safeValue(this.exceptions,c);if(void 0!==u){const e=this.safeString(n,"message");throw new u(this.id+" "+e)}if("Validation Error"===this.safeString(n,"message"))throw new r.BadRequest(this.id+" "+o);if(!l)throw new r.ExchangeError(this.id+" "+o)}async withdraw(e,t,i,s=void 0,a={}){if([s,a]=this.handleWithdrawTagAndParams(s,a),"WAVES"!==e){const t=await this.privateGetWithdrawCurrencies(),i={},s=this.safeValue(t,"items",[]);for(let e=0;e<s.length;e++){const t=s[e];i[this.safeString(t,"id")]=!0}if(!(e in i)){const t=Object.keys(i);throw new r.ExchangeError(this.id+" withdraw() "+e+" not supported. Currency code must be one of "+t.toString())}}await this.loadMarkets();const n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],d={};for(let e=0;e<n.length;e++){d[n[e]]=!0}let h=!0;const c=this.remove0xPrefix(i).toLowerCase(),l=1*c.length;for(let e=0;e<l;e++){if(!(c[e]in d)){h=!1;break}}let u;if(await this.signIn(),"WAVES"!==e||h){const s={address:i,currency:e},a=await this.privateGetWithdrawAddressesCurrencyAddress(s),o=this.safeValue(a,"currency"),n=this.safeValue(o,"allowed_amount"),d=this.safeNumber(n,"min");if(t<=d)throw new r.BadRequest(this.id+" "+e+" withdraw failed, amount "+t.toString()+" must be greater than the minimum allowed amount of "+d.toString());const h=this.safeValue(a,"proxy_addresses",[]);u=this.safeString(h,0)}else u=i;const f=this.safeInteger(this.options,"withdrawFeeWAVES",1e5),p="WAVES",m=this.toRealCurrencyAmount(e,t),g=this.currency(e),v=this.milliseconds(),y=[this.numberToBE(4,1),this.numberToBE(2,1),this.base58ToBinary(this.apiKey),this.getAssetBytes(g.id),this.getAssetBytes(p),this.numberToBE(v,8),this.numberToBE(m,8),this.numberToBE(f,8),this.base58ToBinary(u),this.numberToBE(0,2)],b=this.binaryConcatArray(y),w=this.binaryToBase16(this.base58ToBinary(this.secret)),k=this.axolotl(this.binaryToBase16(b),w,o.ev),S={senderPublicKey:this.apiKey,amount:m,fee:f,type:4,version:2,attachment:"",feeAssetId:this.getAssetId(p),proofs:[k],assetId:this.getAssetId(g.id),recipient:u,timestamp:v,signature:k},O=await this.nodePostTransactionsBroadcast(S);return this.parseTransaction(O,g)}parseTransaction(e,t=void 0){const i=(t=this.safeCurrency(void 0,t)).code,s="4"===this.safeString(e,"type")?"withdraw":"deposit",r=this.parseNumber(this.fromRealCurrencyAmount(i,this.safeString(e,"amount"))),a=this.safeString(e,"fee"),o=this.safeString(e,"feeAssetId","WAVES"),n=this.safeCurrencyCode(o),d=this.parseNumber(this.fromRealCurrencyAmount(n,a)),h=this.safeInteger(e,"timestamp");return{id:this.safeString(e,"id"),txid:void 0,timestamp:h,datetime:this.iso8601(h),network:void 0,addressFrom:this.safeString(e,"sender"),address:void 0,addressTo:this.safeString(e,"recipient"),amount:r,type:s,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:{currency:n,cost:d},info:e}}}},75336:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(33965),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"whitebit",name:"WhiteBit",version:"v4",countries:["EE"],rateLimit:50,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!1,createConvertTrade:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchConvertQuote:!0,fetchConvertTrade:!1,fetchConvertTradeHistory:!0,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg",api:{v1:{public:"https://whitebit.com/api/v1/public",private:"https://whitebit.com/api/v1"},v2:{public:"https://whitebit.com/api/v2/public"},v4:{public:"https://whitebit.com/api/v4/public",private:"https://whitebit.com/api/v4"}},www:"https://www.whitebit.com",doc:"https://github.com/whitebit-exchange/api-docs",fees:"https://whitebit.com/fee-schedule",referral:"https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963"},api:{web:{get:["v1/healthcheck"]},v1:{public:{get:["markets","tickers","ticker","symbols","depth/result","history","kline"]},private:{post:["account/balance","order/new","order/cancel","orders","account/order_history","account/executed_history","account/executed_history/all","account/order"]}},v2:{public:{get:["markets","ticker","assets","fee","depth/{market}","trades/{market}"]}},v4:{public:{get:["assets","collateral/markets","fee","orderbook/depth/{market}","orderbook/{market}","ticker","trades/{market}","time","ping","markets","futures","platform/status","mining-pool"]},private:{post:["collateral-account/balance","collateral-account/balance-summary","collateral-account/positions/history","collateral-account/leverage","collateral-account/positions/open","collateral-account/summary","collateral-account/funding-history","main-account/address","main-account/balance","main-account/create-new-address","main-account/codes","main-account/codes/apply","main-account/codes/my","main-account/codes/history","main-account/fiat-deposit-url","main-account/history","main-account/withdraw","main-account/withdraw-pay","main-account/transfer","main-account/smart/plans","main-account/smart/investment","main-account/smart/investment/close","main-account/smart/investments","main-account/fee","main-account/smart/interest-payment-history","trade-account/balance","trade-account/executed-history","trade-account/order","trade-account/order/history","order/collateral/limit","order/collateral/market","order/collateral/stop-limit","order/collateral/trigger-market","order/collateral/bulk","order/new","order/market","order/stock_market","order/stop_limit","order/stop_market","order/cancel","order/cancel/all","order/kill-switch","order/kill-switch/status","order/bulk","order/modify","order/conditional-cancel","orders","oco-orders","order/collateral/oco","order/oco-cancel","order/oto-cancel","profile/websocket_token","convert/estimate","convert/confirm","convert/history","sub-account/create","sub-account/delete","sub-account/edit","sub-account/list","sub-account/transfer","sub-account/block","sub-account/unblock","sub-account/balances","sub-account/transfer/history","sub-account/api-key/create","sub-account/api-key/edit","sub-account/api-key/delete","sub-account/api-key/list","sub-account/api-key/reset","sub-account/api-key/ip-address/list","sub-account/api-key/ip-address/create","sub-account/api-key/ip-address/delete","mining/rewards","market/fee","conditional-orders"]}}},fees:{trading:{tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},options:{timeDifference:0,adjustForTimeDifference:!1,fiatCurrencies:["EUR","USD","RUB","UAH"],fetchBalance:{account:"spot"},accountsByType:{funding:"main",main:"main",spot:"spot",margin:"collateral",trade:"spot"},networksById:{BEP20:"BSC"},defaultType:"spot",brokerId:"ccxt"},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1440}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"Unauthorized request.":r.AuthenticationError,"The market format is invalid.":r.BadSymbol,"Market is not available":r.BadSymbol,"Invalid payload.":r.BadRequest,"Amount must be greater than 0":r.InvalidOrder,"Not enough balance.":r.InsufficientFunds,"The order id field is required.":r.InvalidOrder,"Not enough balance":r.InsufficientFunds,"This action is unauthorized.":r.PermissionDenied,"This API Key is not authorized to perform this action.":r.PermissionDenied,"Unexecuted order was not found.":r.OrderNotFound,"The selected from is invalid.":r.BadRequest,503:r.ExchangeNotAvailable,422:r.OrderNotFound},broad:{"This action is unauthorized":r.PermissionDenied,"Given amount is less than min amount":r.InvalidOrder,"Min amount step":r.InvalidOrder,"Total is less than":r.InvalidOrder,"fee must be no less than":r.InvalidOrder,"Enable your key in API settings":r.PermissionDenied,"You don't have such amount for transfer":r.InsufficientFunds}}})}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=await this.v4PublicGetMarkets();return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeString(e,"stock");let s=this.safeString(e,"money");s="PERP"===s?"USDT":s;const r=this.safeCurrencyCode(i),o=this.safeCurrencyCode(s),n=this.safeValue(e,"tradesEnabled"),d=this.safeValue(e,"isCollateral");let h,c,l,u=r+"/"+o;const f="futures"===this.safeString(e,"type"),p=d&&!f;let m=!1;const g=this.parseNumber(this.parsePrecision(this.safeString(e,"stockPrec"))),v=g;let y,b;f?(l=s,c=this.safeCurrencyCode(l),u=u+":"+c,h="swap",m=!0,y=!0,b=!1):h="spot";const w=this.safeString(e,"takerFee"),k=a.Y.stringDiv(w,"100"),S=this.safeString(e,"makerFee"),O=a.Y.stringDiv(S,"100");return{id:t,symbol:u,base:r,quote:o,settle:c,baseId:i,quoteId:s,settleId:l,type:h,spot:!f,margin:p,swap:f,future:!1,option:!1,active:n,contract:m,linear:y,inverse:b,taker:this.parseNumber(k),maker:this.parseNumber(O),contractSize:v,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:g,price:this.parseNumber(this.parsePrecision(this.safeString(e,"moneyPrec")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"minAmount"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"minTotal"),max:this.safeNumber(e,"maxTotal")}},created:void 0,info:e}}async fetchCurrencies(e={}){const t=await this.v4PublicGetAssets(e),i=Object.keys(t),s={};for(let e=0;e<i.length;e++){const r=i[e],a=t[r],o=this.safeCurrencyCode(r),n="providers"in a,d={},h=this.safeDict(a,"networks",{}),c=this.safeList(h,"deposits",[]),l=this.safeList(h,"withdraws",[]),u=this.safeDict(a,"limits",{}),f=this.safeDict(u,"deposit",{}),p=this.safeDict(u,"withdraw",{}),m=this.arrayConcat(c,l);for(let e=0;e<m.length;e++){const t=m[e],i=this.networkIdToCode(t);d[i]={id:t,network:i,active:void 0,deposit:this.inArray(t,c),withdraw:this.inArray(t,l),fee:void 0,precision:void 0,limits:{deposit:{min:this.safeNumber(f,"min",void 0),max:this.safeNumber(f,"max",void 0)},withdraw:{min:this.safeNumber(p,"min",void 0),max:this.safeNumber(p,"max",void 0)}}}}s[o]=this.safeCurrencyStructure({id:r,code:o,info:a,name:void 0,active:void 0,deposit:this.safeBool(a,"can_deposit"),withdraw:this.safeBool(a,"can_withdraw"),fee:void 0,networks:void 0,type:n?"fiat":"crypto",precision:this.parseNumber(this.parsePrecision(this.safeString(a,"currency_precision"))),limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(a,"min_withdraw"),max:this.safeNumber(a,"max_withdraw")},deposit:{min:this.safeNumber(a,"min_deposit"),max:this.safeNumber(a,"max_deposit")}}})}return s}async fetchTransactionFees(e=void 0,t={}){await this.loadMarkets();const i=await this.v4PublicGetFee(t),s=Object.keys(i),r={},a={};for(let e=0;e<s.length;e++){const t=s[e],o=i[t],n=this.safeCurrencyCode(t),d=this.safeValue(o,"withdraw",{});r[n]=this.safeString(d,"fixed");const h=this.safeValue(o,"deposit",{});a[n]=this.safeString(h,"fixed")}return{withdraw:r,deposit:a,info:i}}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();const i=await this.v4PublicGetFee(t);return this.parseDepositWithdrawFees(i,e)}parseDepositWithdrawFees(e,t=void 0,i=void 0){const s={};t=this.marketCodes(t);const r=Object.keys(e);for(let i=0;i<r.length;i++){const a=r[i],o=a.split(" "),n=o[0],d=e[a],h=this.safeCurrencyCode(n);if(void 0===t||this.inArray(h,t)){void 0===this.safeValue(s,h)&&(s[h]=this.depositWithdrawFee({})),s[h].info[a]=d;let e=this.safeString(o,1);const t=this.safeValue(d,"withdraw"),i=this.safeValue(d,"deposit"),r=this.safeNumber(t,"fixed"),n=this.safeNumber(i,"fixed"),c={fee:r,percentage:void 0===r&&void 0},l={fee:n,percentage:void 0===n&&void 0};if(void 0!==e){const t=e.length;e=e.slice(1,t-1);const i=this.networkIdToCode(e);s[h].networks[i]={withdraw:c,deposit:l}}else s[h].withdraw=c,s[h].deposit=l}}const a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e],i=this.currency(t);s[t]=this.assignDefaultDepositWithdrawFees(s[t],i)}return s}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v4PublicGetAssets(e),i={};for(let e=0;e<this.symbols.length;e++){const s=this.symbols[e],r=this.market(s),o=this.safeValue(t,r.baseId,{});let n=this.safeString(o,"maker_fee"),d=this.safeString(o,"taker_fee");n=a.Y.stringDiv(n,"100"),d=a.Y.stringDiv(d,"100"),i[s]={info:o,symbol:r.symbol,percentage:!0,tierBased:!1,maker:this.parseNumber(n),taker:this.parseNumber(d)}}return i}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={market:i.id},r=await this.v1PublicGetTicker(this.extend(s,t)),a=this.safeDict(r,"result",{});return this.parseTicker(a,i)}parseTicker(e,t=void 0){const i=this.safeString(e,"tradingPairs");t=this.safeMarket(i,t);const s=this.safeStringN(e,["last","last_price","lastPrice"]),r=this.safeString(e,"close",s);return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString2(e,"bid","highestBid"),bidVolume:void 0,ask:this.safeString2(e,"ask","lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"open"),close:r,last:s,previousClose:void 0,change:void 0,percentage:this.safeString(e,"change"),average:void 0,baseVolume:this.safeStringN(e,["base_volume","volume","baseVolume24h"]),quoteVolume:this.safeStringN(e,["quote_volume","deal","quoteVolume24h"]),info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);let i,s="v4PublicGetTicker";[s,t]=this.handleOptionAndParams(t,"fetchTickers","method",s),i="v4PublicGetTicker"===s?await this.v4PublicGetTicker(t):await this.v2PublicGetTicker(t);const r=this.safeList(i,"result");if(void 0!==r)return this.parseTickers(r,e);const a=Object.keys(i),o={};for(let e=0;e<a.length;e++){const t=a[e],s=this.safeMarket(t),r=this.parseTicker(i[t],s);o[r.symbol]=r}return this.filterByArrayTickers(o,"symbol",e)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={market:this.market(e).id};void 0!==t&&(s.limit=t);const r=await this.v4PublicGetOrderbookMarket(this.extend(s,i)),a=this.safeTimestamp(r,"timestamp");return this.parseOrderBook(r,e,a)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={market:r.id},o=await this.v4PublicGetTradesMarket(this.extend(a,s));return this.parseTrades(o,r,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id);const o=await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(a,s));if(Array.isArray(o))return this.parseTrades(o,r,t,i);{let e=[];const s=Object.keys(o);for(let r=0;r<s.length;r++){const a=s[r],n=this.safeMarket(a,void 0,"_"),d=this.safeValue(o,a,[]),h=this.parseTrades(d,n,t,i);e=this.arrayConcat(e,h)}return e=this.sortBy2(e,"timestamp","id"),this.filterBySinceLimit(e,t,i,"timestamp")}}parseTrade(e,t=void 0){t=this.safeMarket(void 0,t);const i=this.safeTimestamp2(e,"time","trade_timestamp"),s=this.safeString2(e,"dealOrderId","orderId"),r=this.safeString(e,"deal"),a=this.safeString(e,"price"),o=this.safeString2(e,"amount","quote_volume"),n=this.safeString2(e,"id","tradeID"),d=this.safeString2(e,"type","side"),h=t.symbol,c=this.safeInteger(e,"role");let l,u;void 0!==c&&(l=1===c?"maker":"taker");const f=this.safeString(e,"fee");return void 0!==f&&(u={cost:f,currency:this.safeCurrencyCode(this.safeString(e,"feeAsset"))}),this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:h,id:n,order:s,type:void 0,takerOrMaker:l,side:d,price:a,amount:o,cost:r,fee:u},t)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,interval:this.safeString(this.timeframes,t,t)};if(void 0!==i){const e=1440;void 0===s&&(s=e),s=Math.min(s,e);const t=this.parseToInt(i/1e3);o.start=t}void 0!==s&&(o.limit=Math.min(s,1440));const n=await this.v1PublicGetKline(this.extend(o,r)),d=this.safeList(n,"result",[]);return this.parseOHLCVs(d,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,0),this.safeNumber(e,1),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,2),this.safeNumber(e,5)]}async fetchStatus(e={}){const t=await this.v4PublicGetPing(e),i=this.safeString(t,0);return{status:"pong"===i?"ok":i,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v4PublicGetTime(e);return this.safeInteger(t,"time")}async createMarketOrderWithCost(e,t,i,s={}){const r={cost:i};return await this.createOrder(e,"market",t,0,void 0,this.extend(r,s))}async createMarketBuyOrderWithCost(e,t,i={}){return await this.createMarketOrderWithCost(e,"buy",t,i)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d={market:n.id,side:i};let h;if([h,o]=this.handleParamString(o,"cost"),void 0!==h){if("buy"!==i||"market"!==t)throw new r.InvalidOrder(this.id+" createOrder() cost is only supported for market buy orders");d.amount=this.costToPrecision(e,h)}else d.amount=this.amountToPrecision(e,s);const c=this.safeString2(o,"clOrdId","clientOrderId");if(void 0===c){const e=this.safeString(this.options,"brokerId");void 0!==e&&(d.clientOrderId=e+this.uuid16())}else d.clientOrderId=c,o=this.omit(o,["clientOrderId"]);const l=this.safeString(n,"type"),u="limit"===t,f="market"===t,p=this.safeNumberN(o,["triggerPrice","stopPrice","activation_price"]),m=void 0!==p,g=this.isPostOnly(f,!1,o),[v,y]=this.handleMarginModeAndParams("createOrder",o);if(g&&(d.postOnly=!0),void 0!==v&&"cross"!==v)throw new r.NotSupported(this.id+" createOrder() is only available for cross margin");o=this.omit(y,["postOnly","triggerPrice","stopPrice"]);const b=void 0!==v||"swap"===l;let w;return m?(d.activation_price=this.priceToPrecision(e,p),u?(d.price=this.priceToPrecision(e,a),w=await this.v4PrivatePostOrderStopLimit(this.extend(d,o))):w=b?await this.v4PrivatePostOrderCollateralTriggerMarket(this.extend(d,o)):await this.v4PrivatePostOrderStopMarket(this.extend(d,o))):u?(d.price=this.priceToPrecision(e,a),w=b?await this.v4PrivatePostOrderCollateralLimit(this.extend(d,o)):await this.v4PrivatePostOrderNew(this.extend(d,o))):w=b?await this.v4PrivatePostOrderCollateralMarket(this.extend(d,o)):void 0!==h?await this.v4PrivatePostOrderMarket(this.extend(d,o)):await this.v4PrivatePostOrderStockMarket(this.extend(d,o)),this.parseOrder(w)}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" editOrder() requires a id argument");if(void 0===t)throw new r.ArgumentsRequired(this.id+" editOrder() requires a symbol argument");await this.loadMarkets();const d={orderId:e,market:this.market(t).id},h=this.safeString2(n,"clOrdId","clientOrderId");void 0!==h&&(d.clientOrderId=h);const c="limit"===i,l=this.safeNumberN(n,["triggerPrice","stopPrice","activation_price"]),u=void 0!==l;n=this.omit(n,["clOrdId","clientOrderId","triggerPrice","stopPrice"]),u?(d.activation_price=this.priceToPrecision(t,l),c?(d.amount=this.amountToPrecision(t,a),d.price=this.priceToPrecision(t,o)):"buy"===s?d.total=this.amountToPrecision(t,a):d.amount=this.amountToPrecision(t,a)):(d.amount=this.amountToPrecision(t,a),c&&(d.price=this.priceToPrecision(t,o)));const f=await this.v4PrivatePostOrderModify(this.extend(d,n));return this.parseOrder(f)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const s={market:this.market(t).id,orderId:parseInt(e)},a=await this.v4PrivatePostOrderCancel(this.extend(s,i));return this.parseOrder(a)}async cancelAllOrders(e=void 0,t={}){let i;await this.loadMarkets();const s={};let a;void 0!==e&&(i=this.market(e),s.market=i.id),[a,t]=this.handleMarketTypeAndParams("cancelAllOrders",i,t);const o=[];if("spot"===a){let e;[e,t]=this.handleOptionAndParams(t,"cancelAllOrders","isMargin",!1),e?o.push("margin"):o.push("spot")}else{if("swap"!==a)throw new r.NotSupported(this.id+" cancelAllOrders() does not support "+a+" type");o.push("futures")}s.type=o;const n=await this.v4PrivatePostOrderCancelAll(this.extend(s,t));return this.parseOrders(n,i)}async cancelAllOrdersAfter(e,t={}){await this.loadMarkets();const i=this.safeString(t,"symbol");if(void 0===i)throw new r.ArgumentsRequired(this.id+" cancelAllOrdersAfter() requires a symbol argument in params");const s=this.market(i);t=this.omit(t,"symbol");const a=e>0,o={market:s.id};o.timeout=a?this.numberToString(e/1e3):"null";return await this.v4PrivatePostOrderKillSwitch(this.extend(o,t))}parseBalance(e){const t=Object.keys(e),i={};for(let s=0;s<t.length;s++){const r=t[s],a=this.safeCurrencyCode(r),o=e[r];if("object"==typeof o&&void 0!==o){const e=this.account();e.free=this.safeString2(o,"available","main_balance"),e.used=this.safeString(o,"freeze"),e.total=this.safeString(o,"main_balance"),i[a]=e}else{const e=this.account();e.total=o,i[a]=e}}return this.safeBalance(i)}async fetchBalance(e={}){let t,i;if(await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),"swap"===t)i=await this.v4PrivatePostCollateralAccountBalance(e);else{const t=this.safeValue(this.options,"fetchBalance",{}),s=this.safeString(t,"account"),r=this.safeString2(e,"account","type",s);e=this.omit(e,["account","type"]),i="main"===r||"funding"===r?await this.v4PrivatePostMainAccountBalance(e):await this.v4PrivatePostTradeAccountBalance(e)}return this.parseBalance(i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.market=r.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostOrders(this.extend(a,s));return this.parseOrders(o,r,t,i,{status:"open"})}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),e=a.symbol,r.market=a.id),void 0!==i&&(r.limit=Math.min(i,100));const o=await this.v4PrivatePostTradeAccountOrderHistory(this.extend(r,s)),n=Object.keys(o);let d=[];for(let e=0;e<n.length;e++){const t=n[e],i=this.safeMarket(t,void 0,"_"),s=o[t];for(let e=0;e<s.length;e++){const t=this.parseOrder(s[e],i);d.push(this.extend(t,{status:"closed"}))}}return d=this.sortBy(d,"timestamp"),d=this.filterBySymbolSinceLimit(d,e,t,i),d}parseOrderType(e){return this.safeString({limit:"limit",market:"market","stop market":"market","stop limit":"limit","stock market":"market","margin limit":"limit","margin market":"market"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"market"),s=(t=this.safeMarket(i,t,"_")).symbol,r=this.safeString(e,"side"),a=this.safeString(e,"dealStock");let o=this.safeString(e,"left"),n=this.safeString(e,"clientOrderId");""===n&&(n=void 0);const d=this.safeString(e,"price"),h=this.safeNumber(e,"activation_price"),c=this.safeString2(e,"orderId","id"),l=this.safeString(e,"type"),u=this.parseOrderType(l);"market"===u&&(o=void 0);let f=this.safeString(e,"amount");const p=this.safeString(e,"dealMoney");"buy"!==r||"market"!==l&&"stop market"!==l||(f=a);const m=this.safeString(e,"dealFee");let g;void 0!==m&&(g={cost:this.parseNumber(m),currency:t.quote});const v=this.safeTimestamp2(e,"ctime","timestamp"),y=this.safeTimestamp(e,"ftime");return this.safeOrder({info:e,id:c,symbol:s,clientOrderId:n,timestamp:v,datetime:this.iso8601(v),lastTradeTimestamp:y,timeInForce:void 0,postOnly:void 0,status:void 0,side:r,price:d,type:u,triggerPrice:h,amount:f,filled:a,remaining:o,average:void 0,cost:p,fee:g,trades:void 0},t)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={orderId:parseInt(e)};let o;void 0!==t&&(o=this.market(t),a.market=o.id),void 0!==s&&(a.limit=Math.min(s,100));const n=await this.v4PrivatePostTradeAccountOrder(this.extend(a,r)),d=this.safeList(n,"records",[]);return this.parseTrades(d,o)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i={ticker:this.currency(e).id};let s;if(this.isFiat(e)){const e=this.safeString(t,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires a provider when the ticker is fiat");i.provider=e;const a=this.safeNumber(t,"amount");if(void 0===a)throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an amount when the ticker is fiat");i.amount=a;if(void 0===this.safeValue(t,"uniqueId"))throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() requires an uniqueId when the ticker is fiat");s=await this.v4PrivatePostMainAccountFiatDepositUrl(this.extend(i,t))}else s=await this.v4PrivatePostMainAccountAddress(this.extend(i,t));const a=this.safeString(s,"url"),o=this.safeValue(s,"account",{}),n=this.safeString(o,"address",a),d=this.safeString(o,"memo");return this.checkAddress(n),{info:s,currency:e,network:void 0,address:n,tag:d}}async createDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={ticker:i.id},r=await this.v4PrivatePostMainAccountCreateNewAddress(this.extend(s,t)),a=this.safeDict(r,"account",{});return this.parseDepositAddress(a,i)}parseDepositAddress(e,t=void 0){return{info:e,currency:this.safeCurrencyCode(void 0,t),network:void 0,address:this.safeString(e,"address"),tag:this.safeString(e,"memo")}}async setLeverage(e,t=void 0,i={}){if(await this.loadMarkets(),void 0!==t)throw new r.NotSupported(this.id+" setLeverage() does not allow to set per symbol");if(e<1||e>20)throw new r.BadRequest(this.id+" setLeverage() leverage should be between 1 and 20");const s={leverage:e};return await this.v4PrivatePostCollateralAccountLeverage(this.extend(s,i))}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeValue(this.options,"accountsByType"),n=this.safeString(o,i,i),d=this.safeString(o,s,s),h=this.currencyToPrecision(e,t),c={ticker:a.id,amount:h,from:n,to:d},l=await this.v4PrivatePostMainAccountTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=void 0){return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async withdraw(e,t,i,s=void 0,a={}){await this.loadMarkets();const o=this.currency(e),n={ticker:o.id,amount:this.currencyToPrecision(e,t),address:i};let d=this.safeValue(a,"uniqueId");if(void 0===d&&(d=this.uuid22()),n.uniqueId=d,void 0!==s&&(n.memo=s),this.isFiat(e)){const e=this.safeValue(a,"provider");if(void 0===e)throw new r.ArgumentsRequired(this.id+" withdraw() requires a provider when the ticker is fiat");n.provider=e}const h=await this.v4PrivatePostMainAccountWithdraw(this.extend(n,a));return this.extend({id:d},this.parseTransaction(h,o))}parseTransaction(e,t=void 0){t=this.safeCurrency(void 0,t);const i=this.safeString(e,"address"),s=this.safeTimestamp(e,"createdAt"),r=this.safeString(e,"ticker"),a=this.safeString(e,"status"),o=this.safeString(e,"method");return{id:this.safeString(e,"uniqueId"),txid:this.safeString(e,"transactionId"),timestamp:s,datetime:this.iso8601(s),network:this.safeString(e,"network"),addressFrom:"1"===o?i:void 0,address:i,addressTo:"2"===o?i:void 0,amount:this.safeNumber(e,"amount"),type:"1"===o?"deposit":"withdrawal",currency:this.safeCurrencyCode(r,t),status:this.parseTransactionStatus(a),updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:this.safeString(e,"description"),internal:void 0,fee:{cost:this.safeNumber(e,"fee"),currency:this.safeCurrencyCode(r,t)},info:e}}parseTransactionStatus(e){return this.safeString({1:"pending",2:"pending",3:"ok",4:"canceled",5:"pending",6:"pending",7:"ok",9:"canceled",10:"pending",11:"pending",12:"pending",13:"pending",14:"pending",15:"pending",16:"pending",17:"pending"},e,e)}async fetchDeposit(e,t=void 0,i={}){let s;await this.loadMarkets();const r={transactionMethod:1,uniqueId:e,limit:1,offset:0};void 0!==t&&(s=this.currency(t),r.ticker=s.id);const a=await this.v4PrivatePostMainAccountHistory(this.extend(r,i)),o=this.safeValue(a,"records",[]),n=this.safeDict(o,0,{});return this.parseTransaction(n,s)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={transactionMethod:1,limit:100,offset:0};void 0!==e&&(r=this.currency(e),a.ticker=r.id),void 0!==i&&(a.limit=Math.min(i,100));const o=await this.v4PrivatePostMainAccountHistory(this.extend(a,s)),n=this.safeList(o,"records",[]);return this.parseTransactions(n,r,t,i)}async fetchBorrowInterest(e=void 0,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={};let o;void 0!==t&&(o=this.market(t),a.market=o.id);const n=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(a,r)),d=this.parseBorrowInterests(n,o);return this.filterByCurrencySinceLimit(d,e,i,s)}parseBorrowInterest(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"_"),r=this.safeTimestamp(e,"modifyDate");return{info:e,symbol:s,currency:"USDT",interest:this.safeNumber(e,"unrealizedFunding"),interestRate:98e-5,amountBorrowed:this.safeNumber(e,"amount"),marginMode:"cross",timestamp:r,datetime:this.iso8601(r)}}async fetchFundingRate(e,t={}){await this.loadMarkets(),e=this.symbol(e);const i=await this.fetchFundingRates([e],t);return this.safeValue(i,e)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v4PublicGetFutures(t),s=this.safeList(i,"result",[]);return this.parseFundingRates(s,e)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"ticker_id"),s=this.safeSymbol(i,t),r=this.safeNumber(e,"markPrice"),a=this.safeNumber(e,"indexPrice"),o=this.safeNumber(e,"interestRate"),n=this.safeNumber(e,"funding_rate"),d=this.safeInteger(e,"next_funding_rate_timestamp");return{info:e,symbol:s,markPrice:r,indexPrice:a,interestRate:o,timestamp:void 0,datetime:void 0,fundingRate:n,fundingTimestamp:d,fundingDatetime:this.iso8601(d),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){if(await this.loadMarkets(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingHistory() requires a symbol argument");const a=this.market(e);let o={market:a.id};void 0!==t&&(o.startDate=t),void 0!==i&&(o.limit=t),[o,s]=this.handleUntilOption("endDate",o,s);const n=await this.v4PrivatePostCollateralAccountFundingHistory(o),d=this.safeList(n,"records",[]);return this.parseFundingHistories(d,a,t,i)}parseFundingHistory(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeInteger(e,"fundingTime");return{info:e,symbol:this.safeSymbol(i,t,void 0,"swap"),code:void 0,timestamp:s,datetime:this.iso8601(s),id:void 0,amount:this.safeNumber(e,"fundingAmount")}}parseFundingHistories(e,t=void 0,i=void 0,s=void 0){const r=[];for(let i=0;i<e.length;i++){const s=e[i];r.push(this.parseFundingHistory(s,t))}const a=this.sortBy(r,"timestamp");return this.filterBySinceLimit(a,i,s)}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.ticker=a.id),void 0!==i&&(r.limit=i);const o=await this.v4PrivatePostMainAccountHistory(this.extend(r,s)),n=this.safeList(o,"records");return this.parseTransactions(n,a,t,i)}async fetchConvertQuote(e,t,i=void 0,s={}){await this.loadMarkets();const r=this.currency(e),a=this.currency(t),o={from:e,to:t,amount:this.numberToString(i),direction:"from"},n=await this.v4PrivatePostConvertEstimate(this.extend(o,s));return this.parseConversion(n,r,a)}async createConvertTrade(e,t,i,s=void 0,r={}){await this.loadMarkets();const a=this.currency(t),o=this.currency(i),n={quoteId:e},d=await this.v4PrivatePostConvertConfirm(this.extend(n,r));return this.parseConversion(d,a,o)}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={};if(void 0!==e&&(r.fromTicker=e),void 0!==t){const e=this.parseToInt(t/1e3);r.from=this.numberToString(e)}void 0!==i&&(r.limit=i),[r,s]=this.handleUntilOption("to",r,s,.001);const a=await this.v4PrivatePostConvertHistory(this.extend(r,s)),o=this.safeList(a,"records",[]);return this.parseConversions(o,e,"fromCurrency","toCurrency",t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeList(e,"path",[]),r=this.safeDict(s,0,{}),a=this.safeString(r,"from"),o=this.safeString(r,"to"),n=this.safeTimestamp2(e,"date","expireAt"),d=this.safeString(e,"from",a),h=this.safeCurrencyCode(d,t),c=this.safeString(e,"to",o),l=this.safeCurrencyCode(c,i);return{info:e,timestamp:n,datetime:this.iso8601(n),id:this.safeString(e,"id"),fromCurrency:h,fromAmount:this.safeNumber2(e,"give","finalGive"),toCurrency:l,toAmount:this.safeNumber2(e,"receive","finalReceive"),price:this.safeNumber(e,"rate"),fee:void 0}}async fetchPositionHistory(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={market:this.market(e).id};void 0!==t&&(r.startDate=t),void 0!==i&&(r.limit=t),[r,s]=this.handleUntilOption("endDate",r,s);const a=await this.v4PrivatePostCollateralAccountPositionsHistory(this.extend(r,s)),o=this.parsePositions(a);return this.filterBySymbolSinceLimit(o,e,t,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v4PrivatePostCollateralAccountPositionsOpen(t);return this.parsePositions(i,e)}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(s,t)),a=this.safeDict(r,0,{});return this.parsePosition(a,i)}parsePosition(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeTimestamp(e,"openDate"),r=this.safeDict(e,"tpsl",{}),a=this.safeDict(e,"orderDetail",{});return this.safePosition({info:e,id:this.safeString(e,"positionId"),symbol:this.safeSymbol(i,t),notional:void 0,marginMode:void 0,liquidationPrice:this.safeNumber(e,"liquidationPrice"),entryPrice:this.safeNumber(e,"basePrice"),unrealizedPnl:this.safeNumber(e,"pnl"),realizedPnl:this.safeNumber(a,"realizedPnl"),percentage:this.safeNumber(e,"pnlPercent"),contracts:void 0,contractSize:void 0,markPrice:void 0,lastPrice:void 0,side:void 0,hedged:void 0,timestamp:s,datetime:this.iso8601(s),lastUpdateTimestamp:this.safeTimestamp(e,"modifyDate"),maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,collateral:this.safeNumber(e,"margin"),initialMargin:void 0,initialMarginPercentage:void 0,leverage:void 0,marginRatio:void 0,stopLossPrice:this.safeNumber(r,"stopLoss"),takeProfitPrice:this.safeNumber(r,"takeProfit")})}async fetchCrossBorrowRate(e,t={}){await this.loadMarkets();const i=this.currency(e),s={ticker:i.id},r=await this.v4PrivatePostMainAccountSmartPlans(this.extend(s,t)),a=this.safeList(r,0,[]);return this.parseBorrowRate(a,i)}parseBorrowRate(e,t=void 0){const i=this.safeString(e,"ticker"),s=this.safeString(e,"percent");return{currency:this.safeCurrencyCode(i,t),rate:this.parseNumber(a.Y.stringDiv(s,"100")),period:this.safeInteger(e,"duration"),timestamp:void 0,datetime:void 0,info:e}}isFiat(e){const t=this.safeValue(this.options,"fiatCurrencies",[]);return this.inArray(e,t)}nonce(){return this.milliseconds()-this.options.timeDifference}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.omit(s,this.extractParams(e)),d=this.safeValue(t,0),h=this.safeValue(t,1),c="/"+this.implodeParams(e,s);let l=this.urls.api[d][h]+c;if("public"===h&&Object.keys(o).length&&(l+="?"+this.urlencode(o)),"private"===h){this.checkRequiredCredentials();const e=this.nonce().toString(),t=this.encode(this.secret),i="/api/"+d+c;a=this.json(this.extend({request:i,nonce:e},s));const o=this.stringToBase64(a),h=this.hmac(this.encode(o),t,n.Zf);r={"Content-Type":"application/json","X-TXC-APIKEY":this.apiKey,"X-TXC-PAYLOAD":o,"X-TXC-SIGNATURE":h}}return{url:l,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+o);if(404===e)throw new r.ExchangeError(this.id+" "+e.toString()+" endpoint not found");if(void 0!==n){const e=this.safeString(n,"status"),t=this.safeValue(n,"errors"),i=this.safeString(n,"message"),s=this.safeInteger(n,"code"),a=void 0!==e&&"200"!==e&&void 0!==t;if(a||void 0!==s){const t=this.id+" "+o;let s=i;if(a)s=e;else{const e=this.safeDict(n,"errors",{}),t=Object.keys(e);if(t.length>0){const i=t[0],r=this.safeValue(e,i,[]);s=r.length>0?r[0]:o}}throw this.throwExactlyMatchedException(this.exceptions.exact,s,t),this.throwBroadlyMatchedException(this.exceptions.broad,o,t),new r.ExchangeError(t)}}}}},40669:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(17246),r=i(62079),a=i(85147),o=i(51579),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"woo",name:"WOO X",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,hostname:"woox.io",has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!0,createTrailingPercentOrder:!0,createTriggerOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!0,setLeverage:!0,setMargin:!1,setPositionMode:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg",api:{pub:"https://api-pub.woox.io",public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{pub:"https://api-pub.staging.woox.io",public:"https://api.staging.woox.io",private:"https://api.staging.woox.io"},www:"https://woox.io/",doc:["https://docs.woox.io/"],fees:["https://support.woox.io/hc/en-001/articles/4404611795353--Trading-Fees"],referral:{url:"https://woox.io/register?ref=DIJT0CNL",discount:.35}},api:{v1:{pub:{get:{"hist/kline":10,"hist/trades":10}},public:{get:{info:1,"info/{symbol}":1,system_info:1,market_trades:1,token:1,token_network:1,funding_rates:1,"funding_rate/{symbol}":1,funding_rate_history:1,futures:1,"futures/{symbol}":1,"orderbook/{symbol}":1,kline:1}},private:{get:{"client/token":1,"order/{oid}":1,"client/order/{client_order_id}":1,orders:1,"client/trade/{tid}":1,"order/{oid}/trades":1,"client/trades":1,"client/hist_trades":1,"staking/yield_history":1,"client/holding":1,"asset/deposit":10,"asset/history":60,"sub_account/all":60,"sub_account/assets":60,"sub_account/asset_detail":60,"sub_account/ip_restriction":10,"asset/main_sub_transfer_history":30,token_interest:60,"token_interest/{token}":60,"interest/history":60,"interest/repay":60,"funding_fee/history":30,positions:3.33,"position/{symbol}":3.33,"client/transaction_history":60,"client/futures_leverage":60},post:{order:1,"order/cancel_all_after":1,"asset/main_sub_transfer":30,"asset/ltv":30,"asset/withdraw":30,"asset/internal_withdraw":30,"interest/repay":60,"client/account_mode":120,"client/position_mode":5,"client/leverage":120,"client/futures_leverage":30,"client/isolated_margin":30},delete:{order:1,"client/order":1,orders:1,"asset/withdraw":120}}},v2:{private:{get:{"client/holding":1}}},v3:{public:{get:{systemInfo:1,instruments:1,token:1,tokenNetwork:1,tokenInfo:1,marketTrades:1,marketTradesHistory:1,orderbook:1,kline:1,klineHistory:1,futures:1,fundingRate:1,fundingRateHistory:1,insuranceFund:1}},private:{get:{"trade/order":2,"trade/orders":1,"trade/algoOrder":1,"trade/algoOrders":1,"trade/transaction":1,"trade/transactionHistory":5,"trade/tradingFee":5,"account/info":60,"account/tokenConfig":1,"account/symbolConfig":1,"account/subAccounts/all":60,"account/referral/summary":60,"account/referral/rewardHistory":60,"account/credentials":60,"asset/balances":1,"asset/token/history":60,"asset/transfer/history":30,"asset/wallet/history":60,"asset/wallet/deposit":60,"asset/staking/yieldHistory":60,"futures/positions":3.33,"futures/leverage":60,"futures/defaultMarginMode":60,"futures/fundingFee/history":30,"spotMargin/interestRate":60,"spotMargin/interestHistory":60,"spotMargin/maxMargin":60,"algo/order/{oid}":1,"algo/orders":1,balances:1,positions:3.33,buypower:1,"convert/exchangeInfo":1,"convert/assetInfo":1,"convert/rfq":60,"convert/trade":1,"convert/trades":1},post:{"trade/order":2,"trade/algoOrder":5,"trade/cancelAllAfter":1,"account/tradingMode":120,"account/listenKey":20,"asset/transfer":30,"asset/wallet/withdraw":60,"spotMargin/leverage":120,"spotMargin/interestRepay":60,"algo/order":5,"convert/rft":60},put:{"trade/order":2,"trade/algoOrder":2,"futures/leverage":60,"futures/positionMode":120,"order/{oid}":2,"order/client/{client_order_id}":2,"algo/order/{oid}":2,"algo/order/client/{client_order_id}":2},delete:{"trade/order":1,"trade/orders":1,"trade/algoOrder":1,"trade/algoOrders":1,"trade/allOrders":1,"algo/order/{order_id}":1,"algo/orders/pending":1,"algo/orders/pending/{symbol}":1,"orders/pending":1}}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{timeDifference:0,adjustForTimeDifference:!1,sandboxMode:!1,createMarketBuyOrderRequiresPrice:!0,"network-aliases-for-tokens":{HT:"ERC20",OMG:"ERC20",UATOM:"ATOM",ZRX:"ZRX"},networks:{TRX:"TRON",TRC20:"TRON",ERC20:"ETH",BEP20:"BSC",ARB:"Arbitrum"},networksById:{TRX:"TRC20",TRON:"TRC20"},defaultNetworkCodeForCurrencies:{},transfer:{fillResponseFromRequest:!0},brokerId:"bc830de7-50f3-460b-9ee0-f430f83f9dad"},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:90,untilDays:1e4,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!0,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forSwap:{extends:"default",createOrder:{hedged:!0}},swap:{linear:{extends:"forSwap"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{"-1000":r.OperationFailed,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.BadRequest,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.BadRequest,"-1012":r.BadRequest,"-1101":r.InvalidOrder,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder},broad:{"Can not place":r.ExchangeError,maintenance:r.OnMaintenance,"symbol must not be blank":r.BadRequest,"The token is not supported":r.BadRequest,"Your order and symbol are not valid or already canceled":r.BadRequest,"Insufficient WOO. Please enable margin trading for leverage trading":r.BadRequest}},precisionMode:o.kb})}async fetchStatus(e={}){const t=await this.v3PublicGetSystemInfo(e),i=this.safeDict(t,"data",{});let s=this.safeString(i,"status");return s=void 0===s?"error":"0"===s?"ok":"maintenance",{status:s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v3PublicGetSystemInfo(e);return this.safeInteger(t,"timestamp")}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=await this.v3PublicGetInstruments(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"rows",[]);return this.parseMarkets(s)}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("_"),s=this.safeString(i,0);let r,a=!1,o=!1;"SPOT"===s?(a=!0,r="spot"):"PERP"===s&&(o=!0,r="swap");const n=this.safeString(i,1),d=this.safeString(i,2),h=this.safeCurrencyCode(n),c=this.safeCurrencyCode(d);let l,u,f,p,m,g=h+"/"+c,v=!0;const y=o;y&&(v=!1,l=this.safeString(i,2),u=this.safeCurrencyCode(l),g=h+"/"+c+":"+u,f=this.parseNumber("1"),p=!0,m=!1);return{id:t,symbol:g,base:h,quote:c,settle:u,baseId:n,quoteId:d,settleId:l,type:r,spot:a,margin:v,swap:o,future:!1,option:!1,active:"TRADING"===this.safeString(e,"status"),contract:y,linear:p,inverse:m,contractSize:f,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"baseTick"),price:this.safeNumber(e,"quoteTick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"baseMin"),max:this.safeNumber(e,"baseMax")},price:{min:this.safeNumber(e,"quoteMin"),max:this.safeNumber(e,"quoteMax")},cost:{min:this.safeNumber(e,"minNotional"),max:void 0}},created:void 0,info:e}}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==i&&(a.limit=i);const o=await this.v3PublicGetMarketTrades(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]);return this.parseTrades(d,r,t,i)}parseTrade(e,t=void 0){const i="id"in e,s=this.safeString2(e,"executed_timestamp","executedTimestamp");let r;void 0!==s&&(r=s.indexOf(".")>-1?this.safeTimestamp2(e,"executed_timestamp","executedTimestamp"):this.safeInteger(e,"executedTimestamp"));const o=this.safeString(e,"symbol"),n=(t=this.safeMarket(o,t)).symbol,d=this.safeString2(e,"executed_price","executedPrice"),h=this.safeString2(e,"executed_quantity","executedQuantity"),c=this.safeString2(e,"order_id","orderId"),l=this.parseTokenAndFeeTemp(e,["fee_asset","feeAsset"],["fee"]),u=this.safeString(l,"cost");void 0!==u&&(l.cost=u);const f=a.Y.stringMul(d,h),p=this.safeStringLower(e,"side"),m=this.safeString(e,"id");let g;if(i){g="1"===this.safeString2(e,"is_maker","isMaker")?"maker":"taker"}return this.safeTrade({id:m,timestamp:r,datetime:this.iso8601(r),symbol:n,side:p,price:d,amount:h,cost:f,order:c,takerOrMaker:g,type:void 0,fee:l,info:e},t)}parseTokenAndFeeTemp(e,t,i){const s=this.safeStringN(e,i);let r;if(void 0!==s){const i=this.safeStringN(e,t);r={cost:s,currency:this.safeCurrencyCode(i)}}return r}parseTradingFee(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),maker:this.parseNumber(a.Y.stringDiv(this.safeString(e,"makerFee"),"100")),taker:this.parseNumber(a.Y.stringDiv(this.safeString(e,"takerFee"),"100")),percentage:void 0,tierBased:void 0}}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PrivateGetTradeTradingFee(this.extend(s,t)),a=this.safeDict(r,"data",{});return this.parseTradingFee(a,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v3PrivateGetAccountInfo(e),i=this.safeDict(t,"data",{}),s=this.safeString(i,"makerFeeRate"),r=this.safeString(i,"takerFeeRate"),o={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e];o[i]={info:t,symbol:i,maker:this.parseNumber(a.Y.stringDiv(s,"10000")),taker:this.parseNumber(a.Y.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return o}async fetchCurrencies(e={}){const t={},i=this.v1PublicGetToken(e),s=this.v1PublicGetTokenNetwork(e),[r,a]=await Promise.all([i,s]),o=this.safeList(r,"rows",[]),n=this.safeList(a,"rows",[]),d=this.groupBy(n,"token"),h=this.groupBy(o,"balance_token"),c=Object.keys(h);for(let e=0;e<c.length;e++){const i=c[e],s=this.safeCurrencyCode(i),r=this.indexBy(h[i],"network"),a=this.indexBy(d[i],"network"),o=Object.keys(a),n={};for(let e=0;e<o.length;e++){const t=o[e],i=this.safeDict(r,t,{}),d=this.safeDict(a,t,{}),h=this.networkIdToCode(t,s),c=this.safeString(i,"token");n[h]={id:t,currencyNetworkId:c,network:h,active:void 0,deposit:"1"===this.safeString(d,"allow_deposit"),withdraw:"1"===this.safeString(d,"allow_withdraw"),fee:this.safeNumber(d,"withdrawal_fee"),precision:this.parseNumber(this.parsePrecision(this.safeString(i,"decimals"))),limits:{withdraw:{min:this.safeNumber(d,"minimum_withdrawal"),max:void 0},deposit:{min:void 0,max:void 0}},info:[d,i]}}t[s]=this.safeCurrencyStructure({id:i,name:void 0,code:s,precision:void 0,active:void 0,fee:void 0,networks:n,deposit:void 0,withdraw:void 0,type:"crypto",limits:{deposit:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},info:[r,a]})}return t}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","buy",t,1,i)}async createMarketSellOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketSellOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","sell",t,1,i)}async createTrailingAmountOrder(e,t,i,s,a=void 0,o=void 0,n=void 0,d={}){if(void 0===o)throw new r.ArgumentsRequired(this.id+" createTrailingAmountOrder() requires a trailingAmount argument");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createTrailingAmountOrder() requires a trailingTriggerPrice argument");return d.trailingAmount=o,d.trailingTriggerPrice=n,await this.createOrder(e,t,i,s,a,d)}async createTrailingPercentOrder(e,t,i,s,a=void 0,o=void 0,n=void 0,d={}){if(void 0===o)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingPercent argument");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingTriggerPrice argument");return d.trailingPercent=o,d.trailingTriggerPrice=n,await this.createOrder(e,t,i,s,a,d)}async createOrder(e,t,i,s,o=void 0,n={}){const d=this.safeBool2(n,"reduceOnly","reduce_only");n=this.omit(n,["reduceOnly","reduce_only"]);const h=t.toUpperCase();await this.loadMarkets();const c=this.market(e),l=i.toUpperCase(),u={symbol:c.id,side:l};let f;[f,n]=this.handleMarginModeAndParams("createOrder",n),void 0!==f&&(u.marginMode=this.encodeMarginMode(f));const p=this.safeString2(n,"triggerPrice","stopPrice"),m=this.safeValue(n,"stopLoss"),g=this.safeValue(n,"takeProfit"),v=this.safeString(n,"algoType"),y=this.safeString2(n,"trailingTriggerPrice","activatedPrice",this.numberToString(o)),b=this.safeString2(n,"trailingAmount","callbackValue"),w=this.safeString2(n,"trailingPercent","callbackRate"),k=void 0!==b,S=void 0!==w,O=k||S,T=O||void 0!==p||void 0!==m||void 0!==g||void 0!==this.safeValue(n,"childOrders"),P="MARKET"===h,M=this.safeStringLower(n,"timeInForce"),I=this.isPostOnly(P,void 0,n),x=T?"clientAlgoOrderId":"clientOrderId";if(u.type=h,T||(I?u.type="POST_ONLY":"fok"===M?u.type="FOK":"ioc"===M&&(u.type="IOC")),d&&(u.reduceOnly=d),P||void 0===o||(u.price=this.priceToPrecision(e,o)),P&&!T){const t=this.safeStringN(n,["cost","order_amount","orderAmount"]);n=this.omit(n,["cost","order_amount","orderAmount"]);const i=void 0!==o;if(c.spot&&(i||void 0!==t)){let i;if(void 0!==t)i=this.costToPrecision(e,t);else{const t=this.numberToString(s),r=this.numberToString(o),n=a.Y.stringMul(t,r);i=this.costToPrecision(e,n)}u.amount=i}else u.quantity=this.amountToPrecision(e,s)}else"POSITIONAL_TP_SL"!==v&&(u.quantity=this.amountToPrecision(e,s));const A=this.safeStringN(n,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==A&&(u[x]=A),O){if(void 0===y)throw new r.ArgumentsRequired(this.id+" createOrder() requires a trailingTriggerPrice parameter for trailing orders");if(u.activatedPrice=this.priceToPrecision(e,y),u.algoType="TRAILING_STOP",k)u.callbackValue=b;else if(S){const e=a.Y.stringDiv(w,"100");u.callbackRate=e}}else if(void 0!==p)"TRAILING_STOP"!==v&&(u.triggerPrice=this.priceToPrecision(e,p),u.algoType="STOP");else if(void 0!==m||void 0!==g){u.algoType="BRACKET";const t={symbol:c.id,reduceOnly:!1,algoType:"POSITIONAL_TP_SL",childOrders:[]},i=t.childOrders,s="BUY"===l?"SELL":"BUY";if(void 0!==m){const t=this.safeString(m,"triggerPrice",m),r={side:s,algoType:"STOP_LOSS",triggerPrice:this.priceToPrecision(e,t),type:"CLOSE_POSITION",reduceOnly:!0};i.push(r)}if(void 0!==g){const t=this.safeString(g,"triggerPrice",g),r={side:s,algoType:"TAKE_PROFIT",triggerPrice:this.priceToPrecision(e,t),type:"CLOSE_POSITION",reduceOnly:!0};i.push(r)}u.childOrders=[t]}let C;n=this.omit(n,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit","trailingPercent","trailingAmount","trailingTriggerPrice"]),C=T?await this.v3PrivatePostTradeAlgoOrder(this.extend(u,n)):await this.v3PrivatePostTradeOrder(this.extend(u,n));let _=this.safeDict(C,"data",{});return _=this.safeDict(this.safeList(_,"rows"),0,_),_.timestamp=this.safeString(C,"timestamp"),this.parseOrder(_,c)}encodeMarginMode(e){return this.safeString({cross:"CROSS",isolated:"ISOLATED"},e,e)}async editOrder(e,t,i,s,r=void 0,o=void 0,n={}){await this.loadMarkets();const d=this.market(t),h={};void 0!==o&&(h.price=this.priceToPrecision(t,o)),void 0!==r&&(h.quantity=this.amountToPrecision(t,r));const c=this.safeString2(n,"clOrdID","clientOrderId"),l=this.safeString(n,"client_order_id",c),u=void 0!==l,f=this.safeNumberN(n,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==f&&(h.triggerPrice=this.priceToPrecision(t,f));const p=this.safeString2(n,"trailingTriggerPrice","activatedPrice",this.numberToString(o)),m=this.safeString2(n,"trailingAmount","callbackValue"),g=this.safeString2(n,"trailingPercent","callbackRate"),v=void 0!==m,y=void 0!==g,b=v||y;if(b)if(void 0!==p&&(h.activatedPrice=this.priceToPrecision(t,p)),v)h.callbackValue=m;else if(y){const e=a.Y.stringDiv(g,"100");h.callbackRate=e}n=this.omit(n,["clOrdID","clientOrderId","client_order_id","stopPrice","triggerPrice","takeProfitPrice","stopLossPrice","trailingTriggerPrice","trailingAmount","trailingPercent"]);const w=b||void 0!==f||void 0!==this.safeValue(n,"childOrders");let k;u?(h.client_order_id=l,k=w?await this.v3PrivatePutAlgoOrderClientClientOrderId(this.extend(h,n)):await this.v3PrivatePutOrderClientClientOrderId(this.extend(h,n))):(h.oid=e,k=w?await this.v3PrivatePutAlgoOrderOid(this.extend(h,n)):await this.v3PrivatePutOrderOid(this.extend(h,n)));const S=this.safeDict(k,"data",{});return this.parseOrder(S,d)}async cancelOrder(e,t=void 0,i={}){const s=this.safeBool2(i,"trigger","stop",!1);if(i=this.omit(i,["trigger","stop"]),!s&&void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={},n=this.safeString2(i,"clOrdID","clientOrderId"),d=this.safeString(i,"client_order_id",n);i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]);const h=void 0!==d;let c;s?(h?o.clientAlgoOrderId=d:o.algoOrderId=e,c=await this.v3PrivateDeleteTradeAlgoOrder(this.extend(o,i))):(o.symbol=a.id,h?o.clientOrderId=d:o.orderId=e,c=await this.v3PrivateDeleteTradeOrder(this.extend(o,i)));const l=this.safeDict(c,"data",{});return l.timestamp=this.safeString(c,"timestamp"),h?l.clientOrderId=d:l.orderId=e,this.parseOrder(l,a)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=this.safeBool2(t,"stop","trigger");t=this.omit(t,["stop","trigger"]);const s={};if(void 0!==e){const t=this.market(e);s.symbol=t.id}let r;r=i?await this.v3PrivateDeleteTradeAlgoOrders(t):await this.v3PrivateDeleteTradeOrders(this.extend(s,t));const a=this.safeDict(r,"data",{});return[this.safeOrder({info:a})]}async cancelAllOrdersAfter(e,t={}){await this.loadMarkets();const i={triggerAfter:e>0?Math.min(e,9e5):0};return await this.v3PrivatePostTradeCancelAllAfter(this.extend(i,t))}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.safeBool2(i,"stop","trigger");i=this.omit(i,["stop","trigger"]);const a={},o=this.safeString2(i,"clOrdID","clientOrderId");let n;r?(void 0!==o?a.clientAlgoOrderId=e:a.algoOrderId=e,n=await this.v3PrivateGetTradeAlgoOrder(this.extend(a,i))):(void 0!==o?a.clientOrderId=o:a.orderId=e,n=await this.v3PrivateGetTradeOrder(this.extend(a,i)));const d=this.safeDict(n,"data",{});return this.parseOrder(d,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchOrders",e,t,i,s,"page",500);const a={};let o;const n=this.safeBool2(s,"stop","trigger");s=this.omit(s,["stop","trigger"]),void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const d=this.safeInteger(s,"until");let h;s=this.omit(s,["until"]),void 0!==d&&(a.endTime=d),void 0!==i&&(a.size=Math.min(i,500)),h=n?await this.v3PrivateGetTradeAlgoOrders(this.extend(a,s)):await this.v3PrivateGetTradeOrders(this.extend(a,s));const c=this.safeValue(h,"data",{}),l=this.safeList(c,"rows",[]);return this.parseOrders(l,o,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"INCOMPLETE"});return await this.fetchOrders(e,t,i,r)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"COMPLETED"});return await this.fetchOrders(e,t,i,r)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrder(e,t=void 0){let i=this.safeTimestamp(e,"createdTime");void 0===i&&(i=this.safeInteger(e,"timestamp"));const s=this.safeString2(e,"orderId","algoOrderId"),r=this.omitZero(this.safeString2(e,"clientOrderId","clientAlgoOrderId")),a=this.safeString(e,"symbol"),o=(t=this.safeMarket(a,t)).symbol,n=this.safeString(e,"price"),d=this.safeString(e,"quantity"),h=this.safeString(e,"amount"),c=this.safeStringLower(e,"type"),l=this.safeValue2(e,"status","algoStatus"),u=this.safeStringLower(e,"side"),f=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),p=this.omitZero(this.safeString(e,"averageExecutedPrice")),m=this.safeNumber(e,"totalFee"),g=this.safeString(e,"feeAsset"),v=this.safeNumber(e,"triggerPrice"),y=this.safeTimestamp(e,"updatedTime");return this.safeOrder({id:s,clientOrderId:r,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,lastUpdateTimestamp:y,status:this.parseOrderStatus(l),symbol:o,type:c,timeInForce:this.parseTimeInForce(c),postOnly:void 0,reduceOnly:this.safeBool(e,"reduceOnly"),side:u,price:n,triggerPrice:v,takeProfitPrice:void 0,stopLossPrice:void 0,average:p,amount:d,filled:f,remaining:void 0,cost:h,trades:void 0,fee:{cost:m,currency:g},info:e},t)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id};void 0!==t&&(s.maxLevel=t);const r=await this.v3PublicGetOrderbook(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeInteger(r,"timestamp");return this.parseOrderBook(a,e,o,"bids","asks","price","quantity")}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==s&&(o.limit=Math.min(s,1e3)),void 0!==i&&(o.after=i);const n=this.safeInteger(r,"until");r=this.omit(r,"until"),void 0!==n&&(o.before=n);const d=await this.v3PublicGetKlineHistory(this.extend(o,r)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseOHLCVs(c,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"startTimestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={oid:e},n=await this.v1PrivateGetOrderOidTrades(this.extend(o,r)),d=this.safeList(n,"rows",[]);return this.parseTrades(d,a,i,s,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.endTime=n),void 0!==i&&(a.limit=i);const d=await this.v3PrivateGetTradeTransactionHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseTrades(c,o,t,i,s)}async fetchAccounts(e={}){const t=this.v3PrivateGetAccountInfo(e),i=this.v3PrivateGetAccountSubAccountsAll(e),[s,r]=await Promise.all([t,i]),a=[this.safeDict(s,"data",{})],o=this.safeDict(r,"data",{}),n=this.safeList(o,"rows",[]),d=this.arrayConcat(a,n);return this.parseAccounts(d,e)}parseAccount(e){return{info:e,id:this.safeString(e,"applicationId"),name:this.safeStringN(e,["name","account","alias"]),code:void 0,type:this.safeStringLower(e,"accountType","subaccount")}}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v3PrivateGetBalances(e),i=this.safeDict(t,"data");return this.parseBalance(i)}parseBalance(e){const t={info:e},i=this.safeList(e,"holding",[]);for(let e=0;e<i.length;e++){const s=i[e],r=this.safeCurrencyCode(this.safeString(s,"token")),a=this.account();a.total=this.safeString(s,"holding"),a.free=this.safeString(s,"availableBalance"),t[r]=a}return this.safeBalance(t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e);let s;[s,t]=this.handleNetworkCodeAndParams(t);const r={token:i.id,network:this.networkCodeToId(s)},a=await this.v3PrivateGetAssetWalletDeposit(this.extend(r,t)),o=this.safeDict(a,"data",{});return this.parseDepositAddress(o,i)}getDedicatedNetworkId(e,t){let i;[i,t]=this.handleNetworkCodeAndParams(t),i=this.networkIdToCode(i,e.code);const s=this.safeDict(e.networks,i);if(void 0===s){const t=Object.keys(e.networks);throw new r.BadRequest(this.id+' can not determine a network code, please provide unified "network" param, one from the following: '+this.json(t))}return[this.safeString(s,"currencyNetworkId"),t]}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address");return this.checkAddress(i),{info:e,currency:this.safeString(t,"code"),network:void 0,address:i,tag:this.safeString(e,"extra")}}async getAssetHistoryRows(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o;void 0!==e&&(a=this.currency(e),r.token=a.id),[o,s]=this.handleNetworkCodeAndParams(s),void 0!==o&&(r.network=this.networkCodeToId(o)),void 0!==t&&(r.startTime=t),void 0!==i&&(r.size=Math.min(i,1e3));const n=this.safeString(s,"type");s=this.omit(s,"type"),void 0!==n&&(r.type=n);const d=await this.v3PrivateGetAssetWalletHistory(this.extend(r,s)),h=this.safeDict(d,"data",{});return[a,this.safeList(h,"rows",[])]}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,s),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseLedger(o,a,t,i,s)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"token"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(s,t);const r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"tokenSide")?"in":"out",o=this.safeTimestamp(e,"createdTime"),n=this.parseTokenAndFeeTemp(e,["feeToken"],["feeAmount"]);return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),currency:s,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"txId"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,direction:a,timestamp:o,datetime:this.iso8601(o),type:this.parseLedgerEntryType(this.safeString(e,"type")),fee:n},t)}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}getCurrencyFromChaincode(e,t){if(void 0!==t)return t;{const i=e.split("_"),s=i.length,r=this.safeString(i,0);let a=this.safeString(i,1,r);s>2&&(a+="_"+this.safeString(i,2)),t=this.safeCurrency(a)}return t}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({tokenSide:"DEPOSIT"},s))}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({tokenSide:"WITHDRAW"},s))}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,this.extend({type:"BALANCE"},s)),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseTransactions(o,a,t,i,s)}parseTransaction(e,t=void 0){const i=this.safeString(e,"token"),s=this.getCurrencyFromChaincode(i,t).code;let r=this.safeStringLower2(e,"token_side","tokenSide");"withdraw"===r&&(r="withdrawal");const a=this.parseTokenAndFeeTemp(e,["fee_token","feeToken"],["fee_amount","feeAmount"]),o=this.safeString2(e,"target_address","targetAddress"),n=this.safeString2(e,"source_address","sourceAddress"),d=this.safeTimestamp2(e,"created_time","createdTime");return{info:e,id:this.safeStringN(e,["id","withdraw_id","withdrawId"]),txid:this.safeString2(e,"tx_id","txId"),timestamp:d,datetime:this.iso8601(d),address:void 0,addressFrom:n,addressTo:o,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:s,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeTimestamp2(e,"updated_time","updatedTime"),comment:void 0,internal:void 0,fee:a,network:void 0}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o={token:a.id,amount:this.parseToNumeric(t),from_application_id:i,to_application_id:s},n=await this.v1PrivatePostAssetMainSubTransfer(this.extend(o,r)),d=this.parseTransfer(n,a),h=this.safeDict(this.options,"transfer",{});return this.safeBool(h,"fillResponseFromRequest",!0)&&(d.amount=t,d.fromAccount=i,d.toAccount=s),d}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){const r={};let a;void 0!==e&&(a=this.currency(e)),void 0!==i&&(r.size=i),void 0!==t&&(r.startTime=t);const o=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==o&&(r.endTime=o);const n=await this.v3PrivateGetAssetTransferHistory(this.extend(r,s)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTransfers(h,a,t,i,s)}parseTransfer(e,t=void 0){const i=this.safeCurrencyCode(this.safeString(e,"token"),t),s=this.safeTimestamp(e,"createdTime"),r=this.safeBool(e,"success");let a;void 0!==r&&(a=r?"ok":"failed");const o=this.safeDict(e,"from",{}),n=this.safeDict(e,"to",{});return{id:this.safeString(e,"id"),timestamp:s,datetime:this.iso8601(s),currency:i,amount:this.safeNumber(e,"amount"),fromAccount:this.safeString(o,"applicationId"),toAccount:this.safeString(n,"applicationId"),status:this.parseTransferStatus(this.safeString(e,"status",a)),info:e}}parseTransferStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a=this.currency(e),o={amount:t,address:i};let n;void 0!==s&&(o.extra=s),[n,r]=this.getDedicatedNetworkId(a,r),o.token=n;const d=await this.v1PrivatePostAssetWithdraw(this.extend(o,r));return this.parseTransaction(d,a)}async repayMargin(e,t,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==i&&(r=this.market(i),i=r.symbol);const a=this.currency(e),o={token:a.id,amount:this.currencyToPrecision(e,t)},n=await this.v1PrivatePostInterestRepay(this.extend(o,s)),d=this.parseMarginLoan(n,a);return this.extend(d,{amount:t,symbol:i})}parseMarginLoan(e,t=void 0){return{id:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,symbol:void 0,timestamp:void 0,datetime:void 0,info:e}}nonce(){return this.milliseconds()-this.options.timeDifference}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=t[0],d=t[1],h=this.implodeParams(e,s);let c=this.implodeHostname(this.urls.api[d]);if(c+="/"+o+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===d)c+=d+"/"+h,Object.keys(s).length&&(c+="?"+this.urlencode(s));else if("pub"===d)c+=h,Object.keys(s).length&&(c+="?"+this.urlencode(s));else{if(this.checkRequiredCredentials(),"POST"===i&&("trade/algoOrder"===e||"trade/order"===e)){if(!this.safeBool(this.options,"sandboxMode",!1)){const t="bc830de7-50f3-460b-9ee0-f430f83f9dad",i=this.safeString(this.options,"brokerId",t);e.indexOf("algo")>-1?s.brokerId=i:s.broker_id=i}s=this.keysort(s)}let t="";const d=this.nonce().toString();if(c+=h,r={"x-api-key":this.apiKey,"x-api-timestamp":d},"v3"===o){if(t=d+i+"/"+o+"/"+h,"POST"===i||"PUT"===i)t+=a=this.json(s),r["content-type"]="application/json";else if(Object.keys(s).length){const e=this.urlencode(s);c+="?"+e,t+="?"+e}}else t=this.urlencode(s),"POST"===i||"PUT"===i||"DELETE"===i?a=t:Object.keys(s).length&&(c+="?"+t),t+="|"+d,r["content-type"]="application/x-www-form-urlencoded";r["x-api-signature"]=this.hmac(this.encode(t),this.encode(this.secret),n.s)}return{url:c,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,a,o,n,d){if(!o)return;const h=this.safeBool(o,"success"),c=this.safeString(o,"code");if(!h){const e=this.id+" "+this.json(o);this.throwBroadlyMatchedException(this.exceptions.broad,a,e),this.throwExactlyMatchedException(this.exceptions.exact,c,e)}}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t);let r=this.safeString(e,"fundingFee");const o=this.safeCurrencyCode("USD"),n=this.safeString(e,"id"),d=this.safeInteger(e,"updatedTime"),h=this.safeNumber(e,"fundingRate");return r="Pay"===this.safeString(e,"paymentType")?a.Y.stringNeg(r):r,{info:e,symbol:s,code:o,timestamp:d,datetime:this.iso8601(d),id:n,amount:this.parseNumber(r),rate:h}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingHistory",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.startTime=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.endTime=n),void 0!==i&&(a.size=Math.min(i,500));const d=await this.v3PrivateGetFuturesFundingFeeHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseIncomes(c,o,t,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.market(i);const s=this.safeInteger(e,"nextFundingTime"),r=this.safeInteger(e,"estFundingRateTimestamp"),a=this.safeInteger(e,"lastFundingRateTimestamp"),o=this.safeString(e,"estFundingIntervalHours");return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"estFundingRate"),fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"lastFundingRate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a),interval:o+"h"}}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PublicGetFundingRate(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"rows",[]),n=this.safeDict(o,0,{});return this.parseFundingRate(n,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v3PublicGetFundingRate(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parseFundingRates(r,e)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,i,s,"page",25);if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");const o=this.market(e);e=o.symbol;let n={symbol:o.id};void 0!==t&&(n.startTime=t),[n,s]=this.handleUntilOption("endTime",n,s);const d=await this.v3PublicGetFundingRateHistory(this.extend(n,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e],i=this.safeString(t,"symbol"),s=this.safeInteger(t,"fundingRateTimestamp");l.push({info:t,symbol:this.safeSymbol(i),fundingRate:this.safeNumber(t,"fundingRate"),timestamp:s,datetime:this.iso8601(s)})}const u=this.sortBy(l,"timestamp");return this.filterBySymbolSinceLimit(u,e,t,i)}async setPositionMode(e,t=void 0,i={}){let s;s=e?"HEDGE_MODE":"ONE_WAY";const r={positionMode:s};return await this.v3PrivatePutFuturesPositionMode(this.extend(r,i))}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e);let s;if(i.spot)s=await this.v3PrivateGetAccountInfo(t);else{if(!i.swap)throw new r.NotSupported(this.id+" fetchLeverage() is not supported for "+i.type+" markets");{const e={symbol:i.id};let r;[r,t]=this.handleMarginModeAndParams("fetchLeverage",t,"cross"),e.marginMode=this.encodeMarginMode(r),s=await this.v3PrivateGetFuturesLeverage(this.extend(e,t))}}const a=this.safeDict(s,"data",{});return this.parseLeverage(a,i)}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=this.safeStringLower(e,"marginMode");let r=this.safeInteger(e,"leverage");0===r&&(r=null);let a=r,o=r;const n=this.safeList(e,"details",[]);for(let e=0;e<n.length;e++){const t=this.safeDict(n,e,{}),i=this.safeInteger(t,"leverage"),s=this.safeString(t,"positionSide");"BOTH"===s?(a=i,o=i):"LONG"===s?a=i:"SHORT"===s&&(o=i)}return{info:e,symbol:t.symbol,marginMode:s,longLeverage:a,shortLeverage:o}}async setLeverage(e,t=void 0,i={}){await this.loadMarkets();const s={leverage:e};let a;if(void 0!==t&&(a=this.market(t)),void 0===t||a.spot)return await this.v3PrivatePostSpotMarginLeverage(this.extend(s,i));if(a.swap){let e;return s.symbol=a.id,[e,i]=this.handleMarginModeAndParams("fetchLeverage",i,"cross"),s.marginMode=this.encodeMarginMode(e),await this.v3PrivatePutFuturesLeverage(this.extend(s,i))}throw new r.NotSupported(this.id+" fetchLeverage() is not supported for "+a.type+" markets")}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"ADD",i)}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"REDUCE",i)}async modifyMarginHelper(e,t,i,s={}){await this.loadMarkets();const r={symbol:this.market(e).id,adjust_token:"USDT",adjust_amount:t,action:i};return await this.v1PrivatePostClientIsolatedMargin(this.extend(r,s))}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v3PrivateGetFuturesPositions(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"positions",[]),n=this.safeDict(o,0,{});return this.parsePosition(n,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.v3PrivateGetFuturesPositions(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"positions",[]);return this.parsePositions(r,e)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);let s,r=this.safeString(e,"holding");s=a.Y.stringGt(r,"0")?"long":"short";const o=this.safeString(t,"contractSize"),n=this.safeString2(e,"markPrice","mark_price"),d=this.safeString(e,"timestamp");let h;void 0!==d&&(h=d.indexOf(".")>-1?this.safeTimestamp(e,"timestamp"):this.safeInteger(e,"timestamp"));const c=this.safeString2(e,"averageOpenPrice","average_open_price"),l=a.Y.stringSub(n,c),u=a.Y.stringMul(l,r);r=a.Y.stringAbs(r);const f=a.Y.stringMul(r,n),p=this.safeString(e,"positionSide");return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:h,datetime:this.iso8601(h),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(c),notional:this.parseNumber(f),leverage:this.safeNumber(e,"leverage"),unrealizedPnl:this.parseNumber(u),contracts:this.parseNumber(r),contractSize:this.parseNumber(o),marginRatio:void 0,liquidationPrice:this.safeNumber2(e,"estLiqPrice","est_liq_price"),markPrice:this.parseNumber(n),lastPrice:void 0,collateral:void 0,marginMode:this.safeStringLower2(e,"marginMode","margin_mode"),side:s,percentage:void 0,hedged:"BOTH"!==p,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchConvertQuote(e,t,i=void 0,s={}){await this.loadMarkets();const r={sellToken:e.toUpperCase(),buyToken:t.toUpperCase(),sellQuantity:this.numberToString(i)},a=await this.v3PrivateGetConvertRfq(this.extend(r,s)),o=this.safeDict(a,"data",{}),n=this.safeString(o,"sellToken",e),d=this.currency(n),h=this.safeString(o,"buyToken",t),c=this.currency(h);return this.parseConversion(o,d,c)}async createConvertTrade(e,t,i,s=void 0,r={}){await this.loadMarkets();const a={quoteId:e},o=await this.v3PrivatePostConvertRft(this.extend(a,r)),n=this.safeDict(o,"data",{});return this.parseConversion(n)}async fetchConvertTrade(e,t=void 0,i={}){await this.loadMarkets();const s={quoteId:e},r=await this.v3PrivateGetConvertTrade(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeString(a,"sellAsset"),n=this.safeString(a,"buyAsset");let d,h;return void 0!==o&&(d=this.currency(o)),void 0!==n&&(h=this.currency(n)),this.parseConversion(a,d,h)}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={};[r,s]=this.handleUntilOption("endTime",r,s),void 0!==t&&(r.startTime=t),void 0!==i&&(r.size=i);const a=await this.v3PrivateGetConvertTrades(this.extend(r,s)),o=this.safeDict(a,"data",{}),n=this.safeList(o,"tradeVos",[]);return this.parseConversions(n,e,"sellAsset","buyAsset",t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeInteger2(e,"expireTimestamp","createdTime"),r=this.safeString2(e,"sellToken","buyAsset"),a=this.safeCurrencyCode(r,t),o=this.safeString2(e,"buyToken","sellAsset"),n=this.safeCurrencyCode(o,i);return{info:e,timestamp:s,datetime:this.iso8601(s),id:this.safeString(e,"quoteId"),fromCurrency:a,fromAmount:this.safeNumber2(e,"sellQuantity","sellAmount"),toCurrency:n,toAmount:this.safeNumber2(e,"buyQuantity","buyAmount"),price:this.safeNumber(e,"buyPrice"),fee:void 0}}async fetchConvertCurrencies(e={}){await this.loadMarkets();const t=await this.v3PrivateGetConvertAssetInfo(e),i={},s=this.safeList(t,"rows",[]);for(let e=0;e<s.length;e++){const t=s[e],r=this.safeString(t,"token"),a=this.safeCurrencyCode(r);i[a]={info:t,id:r,code:a,networks:void 0,type:void 0,name:void 0,active:void 0,deposit:void 0,withdraw:void 0,fee:void 0,precision:this.safeNumber(t,"tick"),limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},created:this.safeTimestamp(t,"createdTime")}}return i}defaultNetworkCodeForCurrency(e){const t=this.currency(e).networks,i=Object.keys(t);for(let e=0;e<i.length;e++){const t=i[e];if("ETH"===t)return t}return this.safeValue(i,0)}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}}},99641:(e,t,i)=>{i.d(t,{A:()=>l});var s=i(55308),r=i(62079),a=i(51579),o=i(85147),n=i(88283),d=i(6414),h=i(38432),c=i(40987);class l extends s.A{describe(){return this.deepExtend(super.describe(),{id:"woofipro",name:"WOOFI PRO",countries:["KY"],rateLimit:100,version:"v1",certified:!0,pro:!0,dex:!0,hostname:"dex.woo.org",has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!0,setMargin:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1mon","1y":"1y"},urls:{logo:"https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1",api:{public:"https://api-evm.orderly.org",private:"https://api-evm.orderly.org"},test:{public:"https://testnet-api-evm.orderly.org",private:"https://testnet-api-evm.orderly.org"},www:"https://dex.woo.org",doc:["https://orderly.network/docs/build-on-evm/building-on-evm"],fees:["https://dex.woo.org/en/orderly"],referral:{url:"https://dex.woo.org/en/trade?ref=CCXT",discount:.05}},api:{v1:{public:{get:{"public/volume/stats":1,"public/broker/name":1,"public/chain_info/{broker_id}":1,"public/system_info":1,"public/vault_balance":1,"public/insurancefund":1,"public/chain_info":1,"faucet/usdc":1,"public/account":1,get_account:1,registration_nonce:1,get_orderly_key:1,"public/liquidation":1,"public/liquidated_positions":1,"public/config":1,"public/campaign/ranking":10,"public/campaign/stats":10,"public/campaign/user":10,"public/campaign/stats/details":10,"public/campaigns":10,"public/points/leaderboard":1,"client/points":1,"public/points/epoch":1,"public/points/epoch_dates":1,"public/referral/check_ref_code":1,"public/referral/verify_ref_code":1,"referral/admin_info":1,"referral/info":1,"referral/referee_info":1,"referral/referee_rebate_summary":1,"referral/referee_history":1,"referral/referral_history":1,"referral/rebate_summary":1,"client/distribution_history":1,"tv/config":1,"tv/history":1,"tv/symbol_info":1,"public/funding_rate_history":1,"public/funding_rate/{symbol}":.33,"public/funding_rates":1,"public/info":1,"public/info/{symbol}":1,"public/market_trades":1,"public/token":1,"public/futures":1,"public/futures/{symbol}":1},post:{register_account:1}},private:{get:{"client/key_info":6,"client/orderly_key_ip_restriction":6,"order/{oid}":1,"client/order/{client_order_id}":1,"algo/order/{oid}":1,"algo/client/order/{client_order_id}":1,orders:1,"algo/orders":1,"trade/{tid}":1,trades:1,"order/{oid}/trades":1,"client/liquidator_liquidations":1,liquidations:1,"asset/history":60,"client/holding":1,withdraw_nonce:1,settle_nonce:1,"pnl_settlement/history":1,"volume/user/daily":60,"volume/user/stats":60,"client/statistics":60,"client/info":60,"client/statistics/daily":60,positions:3.33,"position/{symbol}":3.33,"funding_fee/history":30,"notification/inbox/notifications":60,"notification/inbox/unread":60,"volume/broker/daily":60,"broker/fee_rate/default":10,"broker/user_info":10,"orderbook/{symbol}":1,kline:1},post:{orderly_key:1,"client/set_orderly_key_ip_restriction":6,"client/reset_orderly_key_ip_restriction":6,order:1,"batch-order":10,"algo/order":1,liquidation:1,claim_insurance_fund:1,withdraw_request:1,settle_pnl:1,"notification/inbox/mark_read":60,"notification/inbox/mark_read_all":60,"client/leverage":120,"client/maintenance_config":60,delegate_signer:10,delegate_orderly_key:10,delegate_settle_pnl:10,delegate_withdraw_request:10,"broker/fee_rate/set":10,"broker/fee_rate/set_default":10,"broker/fee_rate/default":10,"referral/create":10,"referral/update":10,"referral/bind":10,"referral/edit_split":10},put:{order:1,"algo/order":1},delete:{order:1,"algo/order":1,"client/order":1,"algo/client/order":1,"algo/orders":1,orders:1,"batch-order":1,"client/batch-order":1}}}},requiredCredentials:{apiKey:!0,secret:!0,accountId:!0,privateKey:!1},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{sandboxMode:!1,brokerId:"CCXT",verifyingContractAddress:"0x6F7a338F2aA472838dEFD3283eB360d4Dff5D203"},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!0,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPriceType:void 0,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!1}}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{"-1000":r.ExchangeError,"-1001":r.AuthenticationError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.BadRequest,"-1006":r.InvalidOrder,"-1007":r.BadRequest,"-1008":r.InvalidOrder,"-1009":r.InsufficientFunds,"-1011":r.NetworkError,"-1012":r.BadRequest,"-1101":r.InsufficientFunds,"-1102":r.InvalidOrder,"-1103":r.InvalidOrder,"-1104":r.InvalidOrder,"-1105":r.InvalidOrder,"-1201":r.BadRequest,"-1202":r.BadRequest,29:r.BadRequest,9:r.AuthenticationError,3:r.AuthenticationError,2:r.BadRequest,15:r.BadRequest},broad:{}},precisionMode:a.kb})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}async fetchStatus(e={}){const t=await this.v1PublicGetPublicSystemInfo(e),i=this.safeDict(t,"data",{});let s=this.safeString(i,"status");return s=void 0===s?"error":"0"===s?"ok":"maintenance",{status:s,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v1PublicGetPublicSystemInfo(e);return this.safeInteger(t,"timestamp")}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("_"),s=this.safeString(i,1),r=this.safeString(i,2),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r),n=this.safeString(i,2),d=this.safeCurrencyCode(n);return{id:t,symbol:a+"/"+o+":"+d,base:a,quote:o,settle:d,baseId:s,quoteId:r,settleId:n,type:"swap",spot:!1,margin:!1,swap:!0,future:!1,option:!1,active:void 0,contract:!0,linear:!0,inverse:!1,contractSize:this.parseNumber("1"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"base_tick"),price:this.safeNumber(e,"quote_tick")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"base_min"),max:this.safeNumber(e,"base_max")},price:{min:this.safeNumber(e,"quote_min"),max:this.safeNumber(e,"quote_max")},cost:{min:this.safeNumber(e,"min_notional"),max:void 0}},created:this.safeInteger(e,"created_time"),info:e}}async fetchMarkets(e={}){const t=await this.v1PublicGetPublicInfo(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"rows",[]);return this.parseMarkets(s)}async fetchCurrencies(e={}){const t={},i=this.v1PublicGetPublicToken(e),s=this.v1PublicGetPublicChainInfo(e),[r,a]=await Promise.all([i,s]),o=this.safeDict(r,"data",{}),n=this.safeList(o,"rows",[]),d=this.safeDict(a,"data",{}),h=this.safeList(d,"rows",[]),c=this.indexBy(h,"chain_id");for(let e=0;e<n.length;e++){const i=n[e],s=this.safeString(i,"token"),r=this.safeList(i,"chain_details"),a=this.safeCurrencyCode(s),o={};for(let e=0;e<r.length;e++){const t=r[e],i=this.safeString(t,"chain_id"),s=this.safeDict(c,i),n=this.safeString(s,"name"),d=this.networkIdToCode(n,a);o[d]={id:i,network:d,limits:{withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},active:void 0,deposit:void 0,withdraw:void 0,fee:this.safeNumber(t,"withdrawal_fee"),precision:this.parseNumber(this.parsePrecision(this.safeString(t,"decimals"))),info:[t,s]}}t[a]=this.safeCurrencyStructure({id:s,name:void 0,code:a,precision:void 0,active:void 0,fee:void 0,networks:o,deposit:void 0,withdraw:void 0,limits:{deposit:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(i,"minimum_withdraw_amount"),max:void 0}},info:i})}return t}parseTokenAndFeeTemp(e,t,i){const s=this.safeString(e,i);let r;if(void 0!==s){const i=this.safeString(e,t);r={cost:s,currency:this.safeCurrencyCode(i)}}return r}parseTrade(e,t=void 0){const i="id"in e,s=this.safeInteger(e,"executed_timestamp"),r=this.safeString(e,"symbol"),a=(t=this.safeMarket(r,t)).symbol,n=this.safeString(e,"executed_price"),d=this.safeString(e,"executed_quantity"),h=this.safeString(e,"order_id"),c=this.parseTokenAndFeeTemp(e,"fee_asset","fee"),l=this.safeString(c,"cost");void 0!==l&&(c.cost=l);const u=o.Y.stringMul(n,d),f=this.safeStringLower(e,"side"),p=this.safeString(e,"id");let m;if(i){m="1"===this.safeString(e,"is_maker")?"maker":"taker"}return this.safeTrade({id:p,timestamp:s,datetime:this.iso8601(s),symbol:a,side:f,price:n,amount:d,cost:u,order:h,takerOrMaker:m,type:void 0,fee:c,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};void 0!==i&&(a.limit=i);const o=await this.v1PublicGetPublicMarketTrades(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]);return this.parseTrades(d,r,t,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.market(i);const s=this.safeInteger(e,"next_funding_time"),r=this.safeInteger(e,"est_funding_rate_timestamp"),a=this.safeInteger(e,"last_funding_rate_timestamp"),n=this.safeString(e,"last_funding_rate_timestamp"),d=this.safeString(e,"next_funding_time"),h=o.Y.stringSub(d,n);return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:this.parseNumber("0"),estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"est_funding_rate"),fundingTimestamp:s,fundingDatetime:this.iso8601(s),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:this.safeNumber(e,"last_funding_rate"),previousFundingTimestamp:a,previousFundingDatetime:this.iso8601(a),interval:this.parseFundingInterval(h)}}parseFundingInterval(e){return this.safeString({36e5:"1h",144e5:"4h",288e5:"8h",576e5:"16h",864e5:"24h"},e,e)}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v1PublicGetPublicFundingRateSymbol(this.extend(s,t)),a=this.safeDict(r,"data",{});return this.parseFundingRate(a,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.v1PublicGetPublicFundingRates(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parseFundingRates(r,e)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory",e,t,i,s,"page",25);let a={};if(void 0!==e){const t=this.market(e);e=t.symbol,a.symbol=t.id}void 0!==t&&(a.start_t=t),[a,s]=this.handleUntilOption("end_t",a,s,.001);const o=await this.v1PublicGetPublicFundingRateHistory(this.extend(a,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"rows",[]),h=[];for(let e=0;e<d.length;e++){const t=d[e],i=this.safeString(t,"symbol"),s=this.safeInteger(t,"funding_rate_timestamp");h.push({info:t,symbol:this.safeSymbol(i),fundingRate:this.safeNumber(t,"funding_rate"),timestamp:s,datetime:this.iso8601(s)})}const c=this.sortBy(h,"timestamp");return this.filterBySymbolSinceLimit(c,e,t,i)}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t);let r=this.safeString(e,"funding_fee");const a=this.safeCurrencyCode("USDC"),n=this.safeInteger(e,"updated_time"),d=this.safeNumber(e,"funding_rate");return r="Pay"===this.safeString(e,"payment_type")?o.Y.stringNeg(r):r,{info:e,symbol:s,code:a,timestamp:n,datetime:this.iso8601(n),id:void 0,amount:this.parseNumber(r),rate:d}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchFundingHistory","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchFundingHistory",e,t,i,s,"page",500);const a={};let o;void 0!==e&&(o=this.market(e),a.symbol=o.id),void 0!==t&&(a.start_t=t);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(a.end_t=n),void 0!==i&&(a.size=Math.min(i,500));const d=await this.v1PrivateGetFundingFeeHistory(this.extend(a,s)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"rows",[]);return this.parseIncomes(c,o,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.v1PrivateGetClientInfo(e),i=this.safeDict(t,"data",{}),s=this.safeString(i,"futures_maker_fee_rate"),r=this.safeString(i,"futures_taker_fee_rate"),a={};for(let e=0;e<this.symbols.length;e++){const i=this.symbols[e];a[i]={info:t,symbol:i,maker:this.parseNumber(o.Y.stringDiv(s,"10000")),taker:this.parseNumber(o.Y.stringDiv(r,"10000")),percentage:!0,tierBased:!0}}return a}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={symbol:this.market(e).id};void 0!==t&&(t=Math.min(t,1e3),s.max_level=t);const r=await this.v1PrivateGetOrderbookSymbol(this.extend(s,i)),a=this.safeDict(r,"data",{}),o=this.safeInteger(a,"timestamp");return this.parseOrderBook(a,e,o,"bids","asks","price","quantity")}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"start_timestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.id,type:this.safeString(this.timeframes,t,t)};void 0!==s&&(o.limit=Math.min(s,1e3));const n=await this.v1PrivateGetKline(this.extend(o,r)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseOHLCVs(h,a,t,i,s)}parseOrder(e,t=void 0){const i=this.safeIntegerN(e,["timestamp","created_time","createdTime"]),s=this.safeStringN(e,["order_id","orderId","algoOrderId"]),r=this.omitZero(this.safeString2(e,"client_order_id","clientOrderId")),a=this.safeString(e,"symbol"),n=(t=this.safeMarket(a,t)).symbol,d=this.safeString2(e,"order_price","price"),h=this.safeString2(e,"order_quantity","quantity"),c=this.safeString2(e,"order_amount","amount"),l=this.safeStringLower2(e,"order_type","type");let u=this.safeValue2(e,"status","algoStatus");const f=this.safeBool(e,"success");void 0!==f&&(u=f?"NEW":"REJECTED");const p=this.safeStringLower(e,"side"),m=this.omitZero(this.safeValue2(e,"executed","totalExecutedQuantity")),g=this.omitZero(this.safeString2(e,"average_executed_price","averageExecutedPrice")),v=o.Y.stringSub(c,m),y=this.safeValue2(e,"total_fee","totalFee"),b=this.safeString2(e,"fee_asset","feeAsset"),w=this.safeValue(e,"Transactions"),k=this.safeNumber(e,"triggerPrice");let S,O;const T=this.safeValue(e,"childOrders");if(void 0!==T){const e=this.safeValue(T,0),t=this.safeValue(e,"childOrders",[]);if(t.length>0){const e=this.safeValue(t,0),i=this.safeValue(t,1);S=this.safeNumber(e,"triggerPrice"),O=this.safeNumber(i,"triggerPrice")}}const P=this.safeInteger2(e,"updatedTime","updated_time");return this.safeOrder({id:s,clientOrderId:r,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,lastUpdateTimestamp:P,status:this.parseOrderStatus(u),symbol:n,type:this.parseOrderType(l),timeInForce:this.parseTimeInForce(l),postOnly:void 0,reduceOnly:this.safeBool(e,"reduce_only"),side:p,price:d,triggerPrice:k,takeProfitPrice:S,stopLossPrice:O,average:g,amount:h,filled:m,remaining:v,cost:c,trades:w,fee:{cost:y,currency:b},info:e},t)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",post_only:"PO"},e,void 0)}parseOrderStatus(e){if(void 0!==e){const t={NEW:"open",FILLED:"closed",CANCEL_SENT:"canceled",CANCEL_ALL_SENT:"canceled",CANCELLED:"canceled",PARTIAL_FILLED:"open",REJECTED:"rejected",INCOMPLETE:"open",COMPLETED:"closed"};return this.safeString(t,e,e)}return e}parseOrderType(e){return this.safeStringLower({LIMIT:"limit",MARKET:"market",POST_ONLY:"limit"},e,e)}createOrderRequest(e,t,i,s,r=void 0,a={}){const o=this.safeBool2(a,"reduceOnly","reduce_only"),n=t.toUpperCase(),d=this.market(e),h=i.toUpperCase(),c={symbol:d.id,side:h},l=this.safeString2(a,"triggerPrice","stopPrice"),u=this.safeValue(a,"stopLoss"),f=this.safeValue(a,"takeProfit"),p=this.safeString(a,"algoType"),m=void 0!==l||void 0!==u||void 0!==f||void 0!==this.safeValue(a,"childOrders"),g="MARKET"===n,v=this.safeStringLower(a,"timeInForce"),y=this.isPostOnly(g,void 0,a),b=m?"quantity":"order_quantity",w=m?"price":"order_price";c[m?"type":"order_type"]=n,m||(y?c.order_type="POST_ONLY":"fok"===v?c.order_type="FOK":"ioc"===v&&(c.order_type="IOC")),o&&(c.reduce_only=o),void 0!==r&&(c[w]=this.priceToPrecision(e,r)),(g&&!m||"POSITIONAL_TP_SL"!==p)&&(c[b]=this.amountToPrecision(e,s));const k=this.safeStringN(a,["clOrdID","clientOrderId","client_order_id"]);if(void 0!==k&&(c.client_order_id=k),void 0!==l)c.trigger_price=this.priceToPrecision(e,l),c.algo_type="STOP";else if(void 0!==u||void 0!==f){c.algo_type="TP_SL";const t={symbol:d.id,reduce_only:!1,algo_type:"POSITIONAL_TP_SL",child_orders:[]},i=t.child_orders,s="BUY"===h?"SELL":"BUY";if(void 0!==u){const t=this.safeNumber2(u,"triggerPrice","price",u),r={side:s,algo_type:"TP_SL",trigger_price:this.priceToPrecision(e,t),type:"LIMIT",reduce_only:!0};i.push(r)}if(void 0!==f){const i=this.safeNumber2(f,"triggerPrice","price",f),r={side:s,algo_type:"TP_SL",trigger_price:this.priceToPrecision(e,i),type:"LIMIT",reduce_only:!0};t.push(r)}c.child_orders=[t]}return a=this.omit(a,["reduceOnly","reduce_only","clOrdID","clientOrderId","client_order_id","postOnly","timeInForce","stopPrice","triggerPrice","stopLoss","takeProfit"]),this.extend(c,a)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.createOrderRequest(e,t,i,s,r,a),d=this.safeString2(a,"triggerPrice","stopPrice"),h=this.safeValue(a,"stopLoss"),c=this.safeValue(a,"takeProfit");let l;l=void 0!==d||void 0!==h||void 0!==c||void 0!==this.safeValue(a,"childOrders")?await this.v1PrivatePostAlgoOrder(n):await this.v1PrivatePostOrder(n);const u=this.safeDict(l,"data");u.timestamp=this.safeInteger(l,"timestamp");const f=this.parseOrder(u,o);return f.type=t,f}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t<e.length;t++){const s=e[t],a=this.safeString(s,"symbol"),o=this.safeString(s,"type"),n=this.safeString(s,"side"),d=this.safeValue(s,"amount"),h=this.safeValue(s,"price"),c=this.safeDict(s,"params",{}),l=this.safeString2(c,"triggerPrice","stopPrice"),u=this.safeValue(c,"stopLoss"),f=this.safeValue(c,"takeProfit");if(void 0!==l||void 0!==u||void 0!==f||void 0!==this.safeValue(c,"childOrders"))throw new r.NotSupported(this.id+" createOrders() only support non-stop order");const p=this.createOrderRequest(a,o,n,d,h,c);i.push(p)}const s={orders:i},a=await this.v1PrivatePostBatchOrder(this.extend(s,t)),o=this.safeDict(a,"data",{}),n=this.safeList(o,"rows",[]);return this.parseOrders(n)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n=this.market(t),d={order_id:e},h=this.safeStringN(o,["triggerPrice","stopPrice","takeProfitPrice","stopLossPrice"]);void 0!==h&&(d.triggerPrice=this.priceToPrecision(t,h));const c=void 0!==h||void 0!==this.safeValue(o,"childOrders"),l=c?"quantity":"order_quantity";let u;if(void 0!==a&&(d[c?"price":"order_price"]=this.priceToPrecision(t,a)),void 0!==r&&(d[l]=this.amountToPrecision(t,r)),o=this.omit(o,["stopPrice","triggerPrice","takeProfitPrice","stopLossPrice","trailingTriggerPrice","trailingAmount","trailingPercent"]),c)u=await this.v1PrivatePutAlgoOrder(this.extend(d,o));else{d.symbol=n.id,d.side=s.toUpperCase();const e=i.toUpperCase(),t=this.safeStringLower(o,"timeInForce"),r="MARKET"===e,a=this.isPostOnly(r,void 0,o);d.order_type=a?"POST_ONLY":"fok"===t?"FOK":"ioc"===t?"IOC":e;const h=this.safeStringN(o,["clOrdID","clientOrderId","client_order_id"]);o=this.omit(o,["clOrdID","clientOrderId","client_order_id","postOnly","timeInForce"]),void 0!==h&&(d.client_order_id=h),u=await this.v1PrivatePutOrder(this.extend(d,o))}const f=this.safeDict(u,"data",{});return f.timestamp=this.safeInteger(u,"timestamp"),this.parseOrder(f,n)}async cancelOrder(e,t=void 0,i={}){const s=this.safeBool2(i,"stop","trigger",!1);if(i=this.omit(i,["stop","trigger"]),!s&&void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={symbol:a.id},n=this.safeString2(i,"clOrdID","clientOrderId"),d=this.safeString(i,"client_order_id",n),h=void 0!==d;let c;s?h?(o.client_order_id=d,i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]),c=await this.v1PrivateDeleteAlgoClientOrder(this.extend(o,i))):(o.order_id=e,c=await this.v1PrivateDeleteAlgoOrder(this.extend(o,i))):h?(o.client_order_id=d,i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]),c=await this.v1PrivateDeleteClientOrder(this.extend(o,i))):(o.order_id=e,c=await this.v1PrivateDeleteOrder(this.extend(o,i)));const l={symbol:t};if(h?l.client_order_id=d:l.id=e,s)return this.extend(this.parseOrder(c),l);const u=this.safeDict(c,"data",{});return this.extend(this.parseOrder(u),l)}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeListN(i,["clOrdIDs","clientOrderIds","client_order_ids"]);i=this.omit(i,["clOrdIDs","clientOrderIds","client_order_ids"]);const r={};let a;return s?(r.client_order_ids=s.join(","),a=await this.v1PrivateDeleteClientBatchOrder(this.extend(r,i))):(r.order_ids=e.join(","),a=await this.v1PrivateDeleteBatchOrder(this.extend(r,i))),[this.safeOrder({info:a})]}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=this.safeBool2(t,"stop","trigger");t=this.omit(t,["stop","trigger"]);const s={};if(void 0!==e){const t=this.market(e);s.symbol=t.id}let r;return r=i?await this.v1PrivateDeleteAlgoOrders(this.extend(s,t)):await this.v1PrivateDeleteOrders(this.extend(s,t)),[this.safeOrder({info:r})]}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.safeBool2(i,"stop","trigger",!1),a={},o=this.safeStringN(i,["clOrdID","clientOrderId","client_order_id"]);let n;i=this.omit(i,["stop","trigger","clOrdID","clientOrderId","client_order_id"]),r?o?(a.client_order_id=o,n=await this.v1PrivateGetAlgoClientOrderClientOrderId(this.extend(a,i))):(a.oid=e,n=await this.v1PrivateGetAlgoOrderOid(this.extend(a,i))):o?(a.client_order_id=o,n=await this.v1PrivateGetClientOrderClientOrderId(this.extend(a,i))):(a.oid=e,n=await this.v1PrivateGetOrderOid(this.extend(a,i)));const d=this.safeDict(n,"data",n);return this.parseOrder(d,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;const a=this.safeBool2(s,"stop","trigger",!1),o=a?100:500;if([r,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchOrders",e,t,i,s,"page",o);let n,d,h={};s=this.omit(s,["stop","trigger"]),void 0!==e&&(n=this.market(e),h.symbol=n.id),void 0!==t&&(h.start_t=t),h.size=void 0!==i?i:o,a&&(h.algo_type="STOP"),[h,s]=this.handleUntilOption("end_t",h,s),d=a?await this.v1PrivateGetAlgoOrders(this.extend(h,s)):await this.v1PrivateGetOrders(this.extend(h,s));const c=this.safeValue(d,"data",d),l=this.safeList(c,"rows");return this.parseOrders(l,n,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"INCOMPLETE"});return await this.fetchOrders(e,t,i,r)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"COMPLETED"});return await this.fetchOrders(e,t,i,r)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),void 0!==t&&(a=this.market(t));const o={oid:e},n=await this.v1PrivateGetOrderOidTrades(this.extend(o,r)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTrades(h,a,i,s,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),r)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,"page",500);let a,o={};void 0!==e&&(a=this.market(e),o.symbol=a.id),void 0!==t&&(o.start_t=t),o.size=void 0!==i?i:500,[o,s]=this.handleUntilOption("end_t",o,s);const n=await this.v1PrivateGetTrades(this.extend(o,s)),d=this.safeDict(n,"data",{}),h=this.safeList(d,"rows",[]);return this.parseTrades(h,a,t,i,s)}parseBalance(e){const t={info:e},i=this.safeList(e,"holding",[]);for(let e=0;e<i.length;e++){const s=i[e],r=this.safeCurrencyCode(this.safeString(s,"token")),a=this.account();a.total=this.safeString(s,"holding"),a.frozen=this.safeString(s,"frozen"),t[r]=a}return this.safeBalance(t)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1PrivateGetClientHolding(e),i=this.safeDict(t,"data");return this.parseBalance(i)}async getAssetHistoryRows(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.balance_token=a.id),void 0!==t&&(r.start_t=t),void 0!==i&&(r.pageSize=i);const o=this.safeString(s,"type");s=this.omit(s,"type"),void 0!==o&&(r.type=o);const n=await this.v1PrivateGetAssetHistory(this.extend(r,s)),d=this.safeDict(n,"data",{});return[a,this.safeList(d,"rows",[])]}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"token"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(i,t);const r=this.safeNumber(e,"amount"),a="DEPOSIT"===this.safeString(e,"token_side")?"in":"out",o=this.safeInteger(e,"created_time"),n=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount");return this.safeLedgerEntry({id:this.safeString(e,"id"),currency:s,account:this.safeString(e,"account"),referenceAccount:void 0,referenceId:this.safeString(e,"tx_id"),status:this.parseTransactionStatus(this.safeString(e,"status")),amount:r,before:void 0,after:void 0,fee:n,direction:a,timestamp:o,datetime:this.iso8601(o),type:this.parseLedgerEntryType(this.safeString(e,"type")),info:e},t)}parseLedgerEntryType(e){return this.safeString({BALANCE:"transaction",COLLATERAL:"transfer"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,s),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseLedger(o,a,t,i,s)}parseTransaction(e,t=void 0){const i=this.safeString(e,"token");let s=this.safeStringLower(e,"token_side");"withdraw"===s&&(s="withdrawal");const r=this.parseTokenAndFeeTemp(e,"fee_token","fee_amount"),a=this.safeString(e,"target_address"),o=this.safeString(e,"source_address"),n=this.safeInteger(e,"created_time");return{info:e,id:this.safeString2(e,"id","withdraw_id"),txid:this.safeString(e,"tx_id"),timestamp:n,datetime:this.iso8601(n),address:void 0,addressFrom:o,addressTo:a,tag:this.safeString(e,"extra"),tagFrom:void 0,tagTo:void 0,type:s,amount:this.safeNumber(e,"amount"),currency:i,status:this.parseTransactionStatus(this.safeString(e,"status")),updated:this.safeInteger(e,"updated_time"),comment:void 0,internal:void 0,fee:r,network:void 0}}parseTransactionStatus(e){return this.safeString({NEW:"pending",CONFIRMING:"pending",PROCESSING:"pending",COMPLETED:"ok",CANCELED:"canceled"},e,e)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({side:"DEPOSIT"},s))}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchDepositsWithdrawals(e,t,i,this.extend({side:"WITHDRAW"},s))}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){const r=await this.getAssetHistoryRows(e,t,i,this.extend({},s)),a=this.safeValue(r,0),o=this.safeList(r,1);return this.parseTransactions(o,a,t,i,s)}async getWithdrawNonce(e={}){const t=await this.v1PrivateGetWithdrawNonce(e),i=this.safeDict(t,"data",{});return this.safeNumber(i,"withdraw_nonce")}hashMessage(e){return"0x"+this.hash(e,h.lY,"hex")}signHash(e,t){const i=(0,n.h1)(e.slice(-64),t.slice(-64),c.bI,void 0),s=i.r,r=i.s,a=this.intToBase16(this.sum(27,i.v));return"0x"+s.padStart(64,"0")+r.padStart(64,"0")+a}signMessage(e,t){return this.signHash(this.hashMessage(e),t.slice(-64))}async withdraw(e,t,i,s=void 0,a={}){if(await this.loadMarkets(),this.checkAddress(i),void 0!==e&&"USDC"!==(e=e.toUpperCase()))throw new r.NotSupported(this.id+" withdraw() only support USDC");const o=this.currency(e),n=this.safeString(this.options,"verifyingContractAddress"),d=this.safeString(a,"chainId"),h=this.safeDict(o,"networks",{}),c=this.safeDict(h,d,{});if(void 0===this.safeNumber(c,"id"))throw new r.BadRequest(this.id+" withdraw() require chainId parameter");const l=await this.getWithdrawNonce(a),u=this.nonce(),f={chainId:d,name:"Orderly",verifyingContract:n,version:"1"},p={brokerId:this.safeString(this.options,"keyBrokerId","woofi_pro"),chainId:this.parseToInt(d),receiver:i,token:e,amount:t.toString(),withdrawNonce:l,timestamp:u},m=this.ethEncodeStructuredData(f,{Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},p),g={signature:this.signMessage(m,this.privateKey),userAddress:i,verifyingContract:n,message:p};a=this.omit(a,"chainId");const v=await this.v1PrivatePostWithdrawRequest(this.extend(g,a)),y=this.safeDict(v,"data",{});return this.parseTransaction(y,o)}parseLeverage(e,t=void 0){const i=this.safeInteger(e,"max_leverage");return{info:e,symbol:t.symbol,marginMode:void 0,longLeverage:i,shortLeverage:i}}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.v1PrivateGetClientInfo(t),r=this.safeDict(s,"data",{});return this.parseLeverage(r,i)}async setLeverage(e,t=void 0,i={}){if(await this.loadMarkets(),e<1||e>50)throw new r.BadRequest(this.id+" leverage should be between 1 and 50");const s={leverage:e};return await this.v1PrivatePostClientLeverage(this.extend(s,i))}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);let s,r=this.safeString(e,"position_qty");s=o.Y.stringGt(r,"0")?"long":"short";const a=this.safeString(t,"contractSize"),n=this.safeString(e,"mark_price"),d=this.safeInteger(e,"timestamp"),h=this.safeString(e,"average_open_price"),c=this.safeString(e,"unsettled_pnl");r=o.Y.stringAbs(r);const l=o.Y.stringMul(r,n);return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:d,datetime:this.iso8601(d),lastUpdateTimestamp:void 0,initialMargin:void 0,initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(h),notional:this.parseNumber(l),leverage:void 0,unrealizedPnl:this.parseNumber(c),contracts:this.parseNumber(r),contractSize:this.parseNumber(a),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"est_liq_price"),markPrice:this.parseNumber(n),lastPrice:void 0,collateral:void 0,marginMode:"cross",marginType:void 0,side:s,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v1PrivateGetPositionSymbol(this.extend(s,t)),a=this.safeDict(r,"data");return this.parsePosition(a,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.v1PrivateGetPositions(t),s=this.safeDict(i,"data",{}),r=this.safeList(s,"rows",[]);return this.parsePositions(r,e)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=t[0],h=t[1],c=this.implodeParams(e,s);let l=this.implodeHostname(this.urls.api[h]);if(l+="/"+o+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===h)l+=c,Object.keys(s).length&&(l+="?"+this.urlencode(s));else{if(this.checkRequiredCredentials(),!("POST"!==i&&"PUT"!==i||"algo/order"!==e&&"order"!==e&&"batch-order"!==e)){if(!this.safeBool(this.options,"sandboxMode",!1)){const t=this.safeString(this.options,"brokerId","CCXT");if("batch-order"===e){const e=this.safeList(s,"orders",[]);for(let i=0;i<e.length;i++)s.orders[i].order_tag=t}else s.order_tag=t}s=this.keysort(s)}let t="";const h=this.nonce().toString();l+=c;let u=this.apiKey;u.indexOf("ed25519:")<0&&(u="ed25519:"+u),r={"orderly-account-id":this.accountId,"orderly-key":u,"orderly-timestamp":h},t=h+i+"/"+o+"/"+c,"POST"===i||"PUT"===i?(t+=a=this.json(s),r["content-type"]="application/json"):(Object.keys(s).length&&(l+="?"+this.urlencode(s),t+="?"+this.rawencode(s)),r["content-type"]="application/x-www-form-urlencoded","DELETE"===i&&(a=""));let f=this.secret;if(f.indexOf("ed25519:")>=0){const e=f.split("ed25519:");f=e[1]}const p=(0,n.q4)(this.encode(t),this.base58ToBinary(f),d.ev);r["orderly-signature"]=this.urlencodeBase64(this.base64ToBinary(p))}return{url:l,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(!n)return;const c=this.safeBool(n,"success"),l=this.safeString(n,"code");if(!c){const e=this.id+" "+this.json(n);throw this.throwBroadlyMatchedException(this.exceptions.broad,o,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),new r.ExchangeError(e)}}}},55344:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(43521),r=i(85147),a=i(51579),o=i(62079),n=i(54852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"xt",name:"XT",countries:["SC"],rateLimit:100,version:"v4",certified:!1,pro:!0,has:{CORS:!1,spot:!0,margin:!0,swap:!0,future:!0,option:!1,addMargin:!0,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!1,createReduceOnlyOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawals:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchL3OrderBook:!1,fetchLedger:!0,fetchLedgerEntry:!1,fetchLeverage:!1,fetchLeverageTiers:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrdersByStatus:!0,fetchOrderTrades:!1,fetchPosition:!0,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!0,repayMargin:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!1,signIn:!1,transfer:!0,withdraw:!0},precisionMode:a.kb,urls:{logo:"https://user-images.githubusercontent.com/14319357/232636712-466df2fc-560a-4ca4-aab2-b1d954a58e24.jpg",api:{spot:"https://sapi.xt.com",linear:"https://fapi.xt.com",inverse:"https://dapi.xt.com",user:"https://api.xt.com"},www:"https://xt.com",referral:"https://www.xt.com/en/accounts/register?ref=9PTM9VW",doc:["https://doc.xt.com/","https://github.com/xtpub/api-doc"],fees:"https://www.xt.com/en/rate"},api:{public:{spot:{get:{currencies:1,depth:10,kline:1,symbol:1,ticker:1,"ticker/book":1,"ticker/price":1,"ticker/24h":1,time:1,"trade/history":1,"trade/recent":1,"wallet/support/currency":1}},linear:{get:{"future/market/v1/public/contract/risk-balance":1,"future/market/v1/public/contract/open-interest":1,"future/market/v1/public/leverage/bracket/detail":1,"future/market/v1/public/leverage/bracket/list":1,"future/market/v1/public/q/agg-ticker":1,"future/market/v1/public/q/agg-tickers":1,"future/market/v1/public/q/deal":1,"future/market/v1/public/q/depth":1,"future/market/v1/public/q/funding-rate":1,"future/market/v1/public/q/funding-rate-record":1,"future/market/v1/public/q/index-price":1,"future/market/v1/public/q/kline":1,"future/market/v1/public/q/mark-price":1,"future/market/v1/public/q/symbol-index-price":1,"future/market/v1/public/q/symbol-mark-price":1,"future/market/v1/public/q/ticker":1,"future/market/v1/public/q/tickers":1,"future/market/v1/public/symbol/coins":3.33,"future/market/v1/public/symbol/detail":3.33,"future/market/v1/public/symbol/list":1}},inverse:{get:{"future/market/v1/public/contract/risk-balance":1,"future/market/v1/public/contract/open-interest":1,"future/market/v1/public/leverage/bracket/detail":1,"future/market/v1/public/leverage/bracket/list":1,"future/market/v1/public/q/agg-ticker":1,"future/market/v1/public/q/agg-tickers":1,"future/market/v1/public/q/deal":1,"future/market/v1/public/q/depth":1,"future/market/v1/public/q/funding-rate":1,"future/market/v1/public/q/funding-rate-record":1,"future/market/v1/public/q/index-price":1,"future/market/v1/public/q/kline":1,"future/market/v1/public/q/mark-price":1,"future/market/v1/public/q/symbol-index-price":1,"future/market/v1/public/q/symbol-mark-price":1,"future/market/v1/public/q/ticker":1,"future/market/v1/public/q/tickers":1,"future/market/v1/public/symbol/coins":3.33,"future/market/v1/public/symbol/detail":3.33,"future/market/v1/public/symbol/list":1}}},private:{spot:{get:{balance:1,balances:1,"batch-order":1,"deposit/address":1,"deposit/history":1,"history-order":1,"open-order":1,order:1,"order/{orderId}":1,trade:1,"withdraw/history":1},post:{order:.2,withdraw:10,"balance/transfer":1,"balance/account/transfer":1,"ws-token":1},delete:{"batch-order":1,"open-order":1,"order/{orderId}":1},put:{"order/{orderId}":1}},linear:{get:{"future/trade/v1/entrust/plan-detail":1,"future/trade/v1/entrust/plan-list":1,"future/trade/v1/entrust/plan-list-history":1,"future/trade/v1/entrust/profit-detail":1,"future/trade/v1/entrust/profit-list":1,"future/trade/v1/order/detail":1,"future/trade/v1/order/list":1,"future/trade/v1/order/list-history":1,"future/trade/v1/order/trade-list":1,"future/user/v1/account/info":1,"future/user/v1/balance/bills":1,"future/user/v1/balance/detail":1,"future/user/v1/balance/funding-rate-list":1,"future/user/v1/balance/list":1,"future/user/v1/position/adl":1,"future/user/v1/position/list":1,"future/user/v1/user/collection/list":1,"future/user/v1/user/listen-key":1},post:{"future/trade/v1/entrust/cancel-all-plan":1,"future/trade/v1/entrust/cancel-all-profit-stop":1,"future/trade/v1/entrust/cancel-plan":1,"future/trade/v1/entrust/cancel-profit-stop":1,"future/trade/v1/entrust/create-plan":1,"future/trade/v1/entrust/create-profit":1,"future/trade/v1/entrust/update-profit-stop":1,"future/trade/v1/order/cancel":1,"future/trade/v1/order/cancel-all":1,"future/trade/v1/order/create":1,"future/trade/v1/order/create-batch":1,"future/trade/v1/order/update":1,"future/user/v1/account/open":1,"future/user/v1/position/adjust-leverage":1,"future/user/v1/position/auto-margin":1,"future/user/v1/position/close-all":1,"future/user/v1/position/margin":1,"future/user/v1/user/collection/add":1,"future/user/v1/user/collection/cancel":1,"future/user/v1/position/change-type":1}},inverse:{get:{"future/trade/v1/entrust/plan-detail":1,"future/trade/v1/entrust/plan-list":1,"future/trade/v1/entrust/plan-list-history":1,"future/trade/v1/entrust/profit-detail":1,"future/trade/v1/entrust/profit-list":1,"future/trade/v1/order/detail":1,"future/trade/v1/order/list":1,"future/trade/v1/order/list-history":1,"future/trade/v1/order/trade-list":1,"future/user/v1/account/info":1,"future/user/v1/balance/bills":1,"future/user/v1/balance/detail":1,"future/user/v1/balance/funding-rate-list":1,"future/user/v1/balance/list":1,"future/user/v1/position/adl":1,"future/user/v1/position/list":1,"future/user/v1/user/collection/list":1,"future/user/v1/user/listen-key":1},post:{"future/trade/v1/entrust/cancel-all-plan":1,"future/trade/v1/entrust/cancel-all-profit-stop":1,"future/trade/v1/entrust/cancel-plan":1,"future/trade/v1/entrust/cancel-profit-stop":1,"future/trade/v1/entrust/create-plan":1,"future/trade/v1/entrust/create-profit":1,"future/trade/v1/entrust/update-profit-stop":1,"future/trade/v1/order/cancel":1,"future/trade/v1/order/cancel-all":1,"future/trade/v1/order/create":1,"future/trade/v1/order/create-batch":1,"future/trade/v1/order/update":1,"future/user/v1/account/open":1,"future/user/v1/position/adjust-leverage":1,"future/user/v1/position/auto-margin":1,"future/user/v1/position/close-all":1,"future/user/v1/position/margin":1,"future/user/v1/user/collection/add":1,"future/user/v1/user/collection/cancel":1}},user:{get:{"user/account":1,"user/account/api-key":1},post:{"user/account":1,"user/account/api-key":1},put:{"user/account/api-key":1},delete:{"user/account/{apikeyId}":1}}}},fees:{spot:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("5000"),this.parseNumber("0.0018")],[this.parseNumber("10000"),this.parseNumber("0.0016")],[this.parseNumber("20000"),this.parseNumber("0.0014")],[this.parseNumber("50000"),this.parseNumber("0.0012")],[this.parseNumber("150000"),this.parseNumber("0.0010")],[this.parseNumber("300000"),this.parseNumber("0.0008")],[this.parseNumber("600000"),this.parseNumber("0.0007")],[this.parseNumber("1200000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0005")],[this.parseNumber("6000000"),this.parseNumber("0.0004")],[this.parseNumber("15000000"),this.parseNumber("0.0003")],[this.parseNumber("30000000"),this.parseNumber("0.0002")]],taker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("5000"),this.parseNumber("0.0018")],[this.parseNumber("10000"),this.parseNumber("0.0016")],[this.parseNumber("20000"),this.parseNumber("0.0014")],[this.parseNumber("50000"),this.parseNumber("0.0012")],[this.parseNumber("150000"),this.parseNumber("0.0010")],[this.parseNumber("300000"),this.parseNumber("0.0008")],[this.parseNumber("600000"),this.parseNumber("0.0007")],[this.parseNumber("1200000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0005")],[this.parseNumber("6000000"),this.parseNumber("0.0004")],[this.parseNumber("15000000"),this.parseNumber("0.0003")],[this.parseNumber("30000000"),this.parseNumber("0.0002")]]}},contract:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0004"),taker:this.parseNumber("0.0006"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0004")],[this.parseNumber("200000"),this.parseNumber("0.00038")],[this.parseNumber("1000000"),this.parseNumber("0.00036")],[this.parseNumber("5000000"),this.parseNumber("0.00034")],[this.parseNumber("10000000"),this.parseNumber("0.00032")],[this.parseNumber("15000000"),this.parseNumber("0.00028")],[this.parseNumber("30000000"),this.parseNumber("0.00024")],[this.parseNumber("50000000"),this.parseNumber("0.0002")],[this.parseNumber("100000000"),this.parseNumber("0.00016")],[this.parseNumber("300000000"),this.parseNumber("0.00012")],[this.parseNumber("500000000"),this.parseNumber("0.00008")]],taker:[[this.parseNumber("0"),this.parseNumber("0.0006")],[this.parseNumber("200000"),this.parseNumber("0.000588")],[this.parseNumber("1000000"),this.parseNumber("0.00057")],[this.parseNumber("5000000"),this.parseNumber("0.00054")],[this.parseNumber("10000000"),this.parseNumber("0.00051")],[this.parseNumber("15000000"),this.parseNumber("0.00048")],[this.parseNumber("30000000"),this.parseNumber("0.00045")],[this.parseNumber("50000000"),this.parseNumber("0.00045")],[this.parseNumber("100000000"),this.parseNumber("0.00036")],[this.parseNumber("300000000"),this.parseNumber("0.00033")],[this.parseNumber("500000000"),this.parseNumber("0.0003")]]}}},exceptions:{exact:{400:o.NetworkError,404:o.ExchangeError,429:o.RateLimitExceeded,500:o.ExchangeError,502:o.ExchangeError,503:o.OnMaintenance,AUTH_001:o.AuthenticationError,AUTH_002:o.AuthenticationError,AUTH_003:o.AuthenticationError,AUTH_004:o.AuthenticationError,AUTH_005:o.AuthenticationError,AUTH_006:o.AuthenticationError,AUTH_007:o.AuthenticationError,AUTH_101:o.AuthenticationError,AUTH_102:o.AuthenticationError,AUTH_103:o.AuthenticationError,AUTH_104:o.AuthenticationError,AUTH_105:o.AuthenticationError,AUTH_106:o.PermissionDenied,SYMBOL_001:o.BadSymbol,SYMBOL_002:o.BadSymbol,SYMBOL_003:o.BadSymbol,SYMBOL_004:o.BadSymbol,SYMBOL_005:o.BadSymbol,ORDER_001:o.InvalidOrder,ORDER_002:o.InsufficientFunds,ORDER_003:o.InvalidOrder,ORDER_004:o.InvalidOrder,ORDER_005:o.InvalidOrder,ORDER_006:o.InvalidOrder,ORDER_007:o.PermissionDenied,ORDER_F0101:o.InvalidOrder,ORDER_F0102:o.InvalidOrder,ORDER_F0103:o.InvalidOrder,ORDER_F0201:o.InvalidOrder,ORDER_F0202:o.InvalidOrder,ORDER_F0203:o.InvalidOrder,ORDER_F0301:o.InvalidOrder,ORDER_F0401:o.InvalidOrder,ORDER_F0501:o.InvalidOrder,ORDER_F0502:o.InvalidOrder,ORDER_F0601:o.InvalidOrder,COMMON_001:o.ExchangeError,COMMON_002:o.ExchangeError,COMMON_003:o.BadRequest,CURRENCY_001:o.BadRequest,DEPOSIT_001:o.BadRequest,DEPOSIT_002:o.PermissionDenied,DEPOSIT_003:o.BadRequest,DEPOSIT_004:o.BadRequest,DEPOSIT_005:o.BadRequest,DEPOSIT_006:o.BadRequest,DEPOSIT_007:o.BadRequest,DEPOSIT_008:o.BadRequest,WITHDRAW_001:o.BadRequest,WITHDRAW_002:o.BadRequest,WITHDRAW_003:o.PermissionDenied,WITHDRAW_004:o.BadRequest,WITHDRAW_005:o.BadRequest,WITHDRAW_006:o.BadRequest,WITHDRAW_008:o.PermissionDenied,WITHDRAW_009:o.PermissionDenied,WITHDRAW_010:o.BadRequest,WITHDRAW_011:o.InsufficientFunds,WITHDRAW_012:o.PermissionDenied,WITHDRAW_013:o.PermissionDenied,WITHDRAW_014:o.BadRequest,WITHDRAW_015:o.BadRequest,WITHDRAW_016:o.BadRequest,WITHDRAW_017:o.BadRequest,WITHDRAW_018:o.BadRequest,WITHDRAW_019:o.BadRequest,WITHDRAW_020:o.PermissionDenied,WITHDRAW_021:o.PermissionDenied,WITHDRAW_022:o.BadRequest,WITHDRAW_023:o.BadRequest,WITHDRAW_024:o.BadRequest,WITHDRAW_025:o.BadRequest,FUND_001:o.BadRequest,FUND_002:o.InsufficientFunds,FUND_003:o.BadRequest,FUND_004:o.ExchangeError,FUND_005:o.PermissionDenied,FUND_014:o.BadRequest,FUND_015:o.BadRequest,FUND_016:o.BadRequest,FUND_017:o.BadRequest,FUND_018:o.BadRequest,FUND_019:o.BadRequest,FUND_020:o.BadRequest,FUND_021:o.BadRequest,FUND_022:o.BadRequest,FUND_044:o.BadRequest,TRANSFER_001:o.BadRequest,TRANSFER_002:o.InsufficientFunds,TRANSFER_003:o.BadRequest,TRANSFER_004:o.PermissionDenied,TRANSFER_005:o.PermissionDenied,TRANSFER_006:o.PermissionDenied,TRANSFER_007:o.RequestTimeout,TRANSFER_008:o.BadRequest,TRANSFER_009:o.BadRequest,TRANSFER_010:o.PermissionDenied,TRANSFER_011:o.PermissionDenied,TRANSFER_012:o.PermissionDenied,symbol_not_support_trading_via_api:o.BadSymbol,open_order_min_nominal_value_limit:o.InvalidOrder,insufficient_balance:o.InsufficientFunds},broad:{"The symbol does not support trading via API":o.BadSymbol,"Exceeds the minimum notional value of a single order":o.InvalidOrder,"insufficient balance":o.InsufficientFunds}},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},commonCurrencies:{},options:{adjustForTimeDifference:!1,timeDifference:0,accountsById:{spot:"SPOT",leverage:"LEVER",finance:"FINANCE",swap:"FUTURES_U",future:"FUTURES_U",linear:"FUTURES_U",inverse:"FUTURES_C"},networks:{ERC20:"Ethereum",TRC20:"Tron",BEP20:"BNB Smart Chain",BEP2:"BNB-BEP2",ETH:"Ethereum",TRON:"Tron",BNB:"BNB Smart Chain",AVAX:"AVAX C-Chain",GAL:"GAL(FT)",ALEO:"ALEO(IOU)",BTC:"Bitcoin",XT:"XT Smart Chain",ETC:"Ethereum Classic",MATIC:"Polygon",LTC:"Litecoin",BTS:"BitShares",XRP:"Ripple",XLM:"Stellar Network",ADA:"Cardano",XWC:"XWC-XWC",DOGE:"dogecoin",DCR:"Decred",SC:"Siacoin",XTZ:"Tezos",ZEC:"Zcash",XMR:"Monero",LSK:"Lisk",ATOM:"Cosmos",ONT:"Ontology",ALGO:"Algorand",SOL:"SOL-SOL",DOT:"Polkadot",ZEN:"Horizen",FIL:"Filecoin",CHZ:"chz",ICP:"Internet Computer",KSM:"Kusama",LUNA:"Terra",THETA:"Theta Token",FTM:"Fantom",VET:"VeChain",NEAR:"NEAR Protocol",ONE:"Harmony",KLAY:"Klaytn",AR:"Arweave",CELT:"OKT",EGLD:"Elrond eGold",CRO:"CRO-CRONOS",BCH:"Bitcoin Cash",GLMR:"Moonbeam",LOOP:"LOOP-LRC",REI:"REI Network",ASTR:"Astar Network",OP:"OPT",MMT:"MMT-MMT",TBC:"TBC-TBC",OMAX:"OMAX-OMAX CHAIN",GMMT:"GMMT chain",ZIL:"Zilliqa"},networksById:{Ethereum:"ERC20",Tron:"TRC20","BNB Smart Chain":"BEP20","BNB-BEP2":"BEP2",Bitcoin:"BTC","XT Smart Chain":"XT","Ethereum Classic":"ETC",Polygon:"MATIC",Litecoin:"LTC",BitShares:"BTS",Ripple:"XRP","Stellar Network":"XLM",Cardano:"ADA","XWC-XWC":"XWC",dogecoin:"DOGE",Decred:"DCR",Siacoin:"SC",Tezos:"XTZ",Zcash:"ZEC",Monero:"XMR",Lisk:"LSK",Cosmos:"ATOM",Ontology:"ONT",Algorand:"ALGO","SOL-SOL":"SOL",Polkadot:"DOT",Horizen:"ZEN",Filecoin:"FIL",chz:"CHZ","Internet Computer":"ICP",Kusama:"KSM",Terra:"LUNA","Theta Token":"THETA",Fantom:"FTM",VeChain:"VET","AVAX C-Chain":"AVAX","NEAR Protocol":"NEAR",Harmony:"ONE",Klaytn:"KLAY",Arweave:"AR",OKT:"CELT","Elrond eGold":"EGLD","CRO-CRONOS":"CRO","Bitcoin Cash":"BCH",Moonbeam:"GLMR","LOOP-LRC":"LOOP","REI Network":"REI","Astar Network":"ASTR","GAL(FT)":"GAL","ALEO(IOU)":"ALEO",OPT:"OP","MMT-MMT":"MMT","TBC-TBC":"TBC","OMAX-OMAX CHAIN":"OMAX","GMMT chain":"GMMT",Zilliqa:"ZIL"},createMarketBuyOrderRequiresPrice:!0,recvWindow:"5000"},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!0,limit:100,daysBack:1e5,untilDays:1e5,marketType:!0,subType:!0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:100,daysBack:1e5,untilDays:1e5,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchClosedOrders:{marginMode:!0,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!0,trailing:!1,marketType:!0,subType:!0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},stopLossPrice:!0,takeProfitPrice:!0},fetchMyTrades:{daysBack:void 0,untilDays:void 0}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicSpotGetTime(e),i=this.safeValue(t,"result");return this.safeInteger(i,"serverTime")}async fetchCurrencies(e={}){const t=[this.publicSpotGetWalletSupportCurrency(e),this.publicSpotGetCurrencies(e)],[i,s]=await Promise.all(t),r=this.safeValue(i,"result",[]),a=this.safeValue(s,"result",[]),o=this.safeValue(a,"currencies",[]),n=this.indexBy(r,"currency"),d={};for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"currency"),s=this.safeCurrencyCode(i),r=this.safeValue(n,i,{}),a=this.safeValue(r,"supportChains",[]),h={};for(let e=0;e<a.length;e++){const t=a[e],i=this.safeString(t,"chain"),r=this.networkIdToCode(i,s);h[r]={info:t,id:i,network:r,name:void 0,active:void 0,fee:this.safeNumber(t,"withdrawFeeAmount"),precision:void 0,deposit:this.safeBool(t,"depositEnabled"),withdraw:this.safeBool(t,"withdrawEnabled"),limits:{amount:{min:void 0,max:void 0},withdraw:{min:this.safeNumber(t,"withdrawMinAmount"),max:void 0},deposit:{min:void 0,max:void 0}}}}let c;c="FT"===this.safeString(t,"type")?"crypto":"other",d[s]=this.safeCurrencyStructure({info:t,id:i,code:s,name:this.safeString(t,"fullName"),active:void 0,fee:void 0,precision:this.parseNumber(this.parsePrecision(this.safeString(t,"maxPrecision"))),deposit:"1"===this.safeString(t,"depositStatus"),withdraw:"1"===this.safeString(t,"withdrawStatus"),networks:h,type:c,limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}}})}return d}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference();const t=[this.fetchSpotMarkets(e),this.fetchSwapAndFutureMarkets(e)],i=await Promise.all(t),s=i[0],r=i[1];return this.arrayConcat(s,r)}async fetchSpotMarkets(e={}){const t=await this.publicSpotGetSymbol(e),i=this.safeValue(t,"result",{}),s=this.safeValue(i,"symbols",[]);return this.parseMarkets(s)}async fetchSwapAndFutureMarkets(e={}){const t=await Promise.all([this.publicLinearGetFutureMarketV1PublicSymbolList(e),this.publicInverseGetFutureMarketV1PublicSymbolList(e)]),i=this.arrayConcat(this.safeValue(t[0],"result",[]),this.safeValue(t[1],"result",[]));return this.parseMarkets(i)}parseMarkets(e){const t=[];for(let i=0;i<e.length;i++)t.push(this.parseMarket(e[i]));return t}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeString2(e,"baseCurrency","baseCoin"),s=this.safeString2(e,"quoteCurrency","quoteCoin"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s),o=this.safeString(e,"state");let n=r+"/"+a;const d=this.safeValue(e,"filters",[]);let h,c,l,u,f,p,m;for(let e=0;e<d.length;e++){const t=d[e],i=this.safeString(t,"filter");"QUANTITY"===i&&(h=this.safeNumber(t,"min"),c=this.safeNumber(t,"max"),m=this.safeNumber(t,"tickSize")),"QUOTE_QTY"===i&&(l=this.safeNumber(t,"min")),"PRICE"===i&&(f=this.safeNumber(t,"min"),p=this.safeNumber(t,"max"))}void 0===m&&(m=this.parseNumber(this.parsePrecision(this.safeString(e,"quantityPrecision"))));const g=this.safeString(e,"underlyingType");let v,y,b,w,k,S=!1,O=!1,T=!1,P=!0,M="spot";if("U_BASED"===g?(n=n+":"+a,b=i,w=a,v=!0,y=!1):"COIN_BASED"===g&&(n=n+":"+r,b=i,w=r,v=!1,y=!0),void 0!==g){k=this.safeInteger(e,"deliveryDate");"perpetual"!==this.safeString(e,"productType")?(n=n+"-"+this.yymmdd(k),M="future",S=!0):(M="swap",O=!0),h=this.safeNumber(e,"minQty"),l=this.safeNumber(e,"minNotional"),u=this.safeNumber(e,"maxNotional"),f=this.safeNumber(e,"minPrice"),p=this.safeNumber(e,"maxPrice"),T=!0,P=!1}let I=!1;return T?I=this.safeValue(e,"isOpenApi",!1):"ONLINE"===o&&this.safeValue(e,"tradingEnabled")&&this.safeValue(e,"openapiEnabled")&&(I=!0),this.safeMarketStructure({id:t,symbol:n,base:r,quote:a,settle:w,baseId:i,quoteId:s,settleId:b,type:M,spot:P,margin:void 0,swap:O,future:S,option:!1,active:I,contract:T,linear:v,inverse:y,taker:this.safeNumber(e,"takerFee"),maker:this.safeNumber(e,"makerFee"),contractSize:this.safeNumber(e,"contractSize"),expiry:k,expiryDatetime:this.iso8601(k),strike:void 0,optionType:void 0,precision:{price:this.parseNumber(this.parsePrecision(this.safeString(e,"pricePrecision"))),amount:m,base:this.parseNumber(this.parsePrecision(this.safeString(e,"baseCoinPrecision"))),quote:this.parseNumber(this.parsePrecision(this.safeString(e,"quoteCoinPrecision")))},limits:{leverage:{min:this.parseNumber("1"),max:void 0},amount:{min:h,max:c},price:{min:f,max:p},cost:{min:l,max:u}},info:e})}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();let a=!1;if([a,r]=this.handleOptionAndParams(r,"fetchOHLCV","paginate",!1),a)return await this.fetchPaginatedCallDeterministic("fetchOHLCV",e,i,s,t,r,1e3);const o=this.market(e),n={symbol:o.id,interval:this.safeString(this.timeframes,t,t)};void 0!==i&&(n.startTime=i),n.limit=void 0!==s?s:1e3;const d=this.safeInteger(r,"until");let h;r=this.omit(r,["until"]),void 0!==d&&(n.endTime=d),h=o.linear?await this.publicLinearGetFutureMarketV1PublicQKline(this.extend(n,r)):o.inverse?await this.publicInverseGetFutureMarketV1PublicQKline(this.extend(n,r)):await this.publicSpotGetKline(this.extend(n,r));const c=this.safeValue(h,"result",[]);return this.parseOHLCVs(c,o,t,i,s)}parseOHLCV(e,t=void 0){const i=t.inverse?"v":"a";return[this.safeInteger(e,"t"),this.safeNumber(e,"o"),this.safeNumber(e,"h"),this.safeNumber(e,"l"),this.safeNumber(e,"c"),this.safeNumber2(e,"q",i)]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={symbol:s.id};let a;s.spot?(void 0!==t&&(r.limit=Math.min(t,500)),a=await this.publicSpotGetDepth(this.extend(r,i))):(r.level=void 0!==t?Math.min(t,50):50,s.linear?a=await this.publicLinearGetFutureMarketV1PublicQDepth(this.extend(r,i)):s.inverse&&(a=await this.publicInverseGetFutureMarketV1PublicQDepth(this.extend(r,i))));const o=this.safeValue(a,"result",{}),n=this.safeInteger2(o,"timestamp","t");if(s.spot){const t=this.parseOrderBook(o,e,n);return t.nonce=this.safeInteger(o,"lastUpdateId"),t}const d=this.parseOrderBook(o,e,n,"b","a");return d.nonce=this.safeInteger2(o,"u","lastUpdateId"),d}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r;r=i.linear?await this.publicLinearGetFutureMarketV1PublicQAggTicker(this.extend(s,t)):i.inverse?await this.publicInverseGetFutureMarketV1PublicQAggTicker(this.extend(s,t)):await this.publicSpotGetTicker(this.extend(s,t));const a=this.safeValue(r,"result");return i.spot?this.parseTicker(a[0],i):this.parseTicker(a,i)}async fetchTickers(e=void 0,t={}){let i;await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e),i=this.market(e[0]));const s={};let r,a,o;[r,t]=this.handleMarketTypeAndParams("fetchTickers",i,t),[a,t]=this.handleSubTypeAndParams("fetchTickers",i,t),o="inverse"===a?await this.publicInverseGetFutureMarketV1PublicQAggTickers(this.extend(s,t)):"linear"===a||"swap"===r||"future"===r?await this.publicLinearGetFutureMarketV1PublicQAggTickers(this.extend(s,t)):await this.publicSpotGetTicker24h(this.extend(s,t));const n=this.safeValue(o,"result",[]),d={};for(let e=0;e<n.length;e++){const t=this.parseTicker(n[e],i);d[t.symbol]=t}return this.filterByArray(d,"symbol",e)}async fetchBidsAsks(e=void 0,t={}){await this.loadMarkets();let i,s;if(void 0!==(e=this.marketSymbols(e))&&(i=this.market(e[0])),[s,t]=this.handleSubTypeAndParams("fetchBidsAsks",i,t),void 0!==s)throw new o.NotSupported(this.id+" fetchBidsAsks() is not available for swap and future markets, only spot markets are supported");const r=await this.publicSpotGetTickerBook(this.extend({},t)),a=this.safeValue(r,"result",[]);return this.parseTickers(a,e)}parseTicker(e,t=void 0){const i=this.safeString(e,"s");let s=void 0!==t?t.type:void 0;void 0===s&&(s="cv"in e||"aq"in e?"spot":"contract");const a=(t=this.safeMarket(i,t,"_",s)).symbol,o=this.safeInteger(e,"t");let n=this.safeString2(e,"cr","r");return void 0!==n&&(n=r.Y.stringMul(n,"100")),this.safeTicker({symbol:a,timestamp:o,datetime:this.iso8601(o),high:this.safeNumber(e,"h"),low:this.safeNumber(e,"l"),bid:this.safeNumber(e,"bp"),bidVolume:this.safeNumber(e,"bq"),ask:this.safeNumber(e,"ap"),askVolume:this.safeNumber(e,"aq"),vwap:void 0,open:this.safeString(e,"o"),close:this.safeString(e,"c"),last:this.safeString(e,"c"),previousClose:void 0,change:this.safeNumber(e,"cv"),percentage:this.parseNumber(n),average:void 0,baseVolume:this.safeNumber2(e,"a","q"),quoteVolume:this.safeNumber2(e,"a","v"),info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id};let o;r.spot?(void 0!==i&&(a.limit=i),o=await this.publicSpotGetTradeRecent(this.extend(a,s))):(void 0!==i&&(a.num=i),r.linear?o=await this.publicLinearGetFutureMarketV1PublicQDeal(this.extend(a,s)):r.inverse&&(o=await this.publicInverseGetFutureMarketV1PublicQDeal(this.extend(a,s))));const n=this.safeValue(o,"result",[]);return this.parseTrades(n,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o,n,d;if(void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.startTime=t),[o,s]=this.handleMarketTypeAndParams("fetchMyTrades",a,s),[n,s]=this.handleSubTypeAndParams("fetchMyTrades",a,s),void 0!==n||"swap"===o||"future"===o)void 0!==i&&(r.size=i),d="inverse"===n?await this.privateInverseGetFutureTradeV1OrderTradeList(this.extend(r,s)):await this.privateLinearGetFutureTradeV1OrderTradeList(this.extend(r,s));else{let e;[e,s]=this.handleMarginModeAndParams("fetchMyTrades",s);const t=void 0!==e?"LEVER":"SPOT";r.bizType=t,void 0!==i&&(r.limit=i),d=await this.privateSpotGetTrade(this.extend(r,s))}const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]);return this.parseTrades(c,a,t,i)}parseTrade(e,t=void 0){const i=this.safeString2(e,"s","symbol");let s=void 0!==t?t.type:void 0;let a,o;void 0===s&&(s="b"in e||"bizType"in e||"oi"in e?"spot":"contract"),t=this.safeMarket(i,t,"_",s);const n=this.safeBool(e,"b");if(void 0!==n)a=n?"sell":"buy",o="taker";else{const t=this.safeStringLower(e,"takerMaker");if(void 0!==t)o=t;else{const t=this.safeBool(e,"isMaker");void 0!==t&&(o=t?"maker":"taker")}const i=this.safeStringLower(e,"orderSide");if(void 0!==i)a=i;else{const t=this.safeString(e,"m");void 0!==t&&(a="BID"===t?"buy":"sell")}}const d=this.safeIntegerN(e,["t","time","timestamp"]),h=this.safeString2(e,"q","quantity");let c;return c="spot"===s?h:void 0===h?r.Y.stringMul(this.safeString(e,"a"),this.numberToString(t.contractSize)):r.Y.stringMul(h,this.numberToString(t.contractSize)),this.safeTrade({info:e,id:this.safeStringN(e,["i","tradeId","execId"]),timestamp:d,datetime:this.iso8601(d),symbol:t.symbol,order:this.safeString2(e,"orderId","oi"),type:this.safeStringLower(e,"orderType"),side:a,takerOrMaker:o,price:this.safeString2(e,"p","price"),amount:c,cost:void 0,fee:{currency:this.safeCurrencyCode(this.safeString2(e,"feeCurrency","feeCoin")),cost:this.safeString(e,"fee")}},t)}async fetchBalance(e={}){let t,i,s;await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),[i,e]=this.handleSubTypeAndParams("fetchBalance",void 0,e);const r="swap"===t||"future"===t;let a;if(s="inverse"===i?await this.privateInverseGetFutureUserV1BalanceList(e):"linear"===i||r?await this.privateLinearGetFutureUserV1BalanceList(e):await this.privateSpotGetBalances(e),void 0!==i||r)a=this.safeValue(s,"result",[]);else{const e=this.safeValue(s,"result",{});a=this.safeValue(e,"assets",[])}return this.parseBalance(a)}parseBalance(e){const t={info:e};for(let i=0;i<e.length;i++){const s=e[i],a=this.safeString2(s,"currency","coin"),o=this.safeCurrencyCode(a),n=this.account(),d=this.safeString2(s,"availableAmount","availableBalance");let h=this.safeString(s,"frozenAmount");const c=this.safeString2(s,"totalAmount","walletBalance");if(void 0===h){const e=r.Y.stringAdd(this.safeString(s,"crossedMargin"),this.safeString(s,"isolatedMargin"));h=r.Y.stringAdd(this.safeString(s,"openOrderMarginFrozen"),e)}n.free=d,n.used=h,n.total=c,t[o]=n}return this.safeBalance(t)}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new o.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return await this.createOrder(e,"market","buy",t,1,i)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e);return e=o.symbol,o.spot?await this.createSpotOrder(e,t,i,s,r,a):await this.createContractOrder(e,t,i,s,r,a)}async createSpotOrder(e,t,i,s,a=void 0,n={}){await this.loadMarkets();const d=this.market(e),h={symbol:d.id,side:i.toUpperCase(),type:t.toUpperCase()};let c,l;[l,n]=this.handleMarginModeAndParams("createOrder",n);const u=void 0!==l?"LEVER":"SPOT";if(h.bizType=u,"market"===t){if(c=this.safeStringUpper(n,"timeInForce","FOK"),"buy"===i){const t=this.safeString(n,"cost");n=this.omit(n,"cost");if(this.safeBool(this.options,"createMarketBuyOrderRequiresPrice",!0)){if(void 0===a&&void 0===t)throw new o.InvalidOrder(this.id+" createOrder() requires a price argument or cost in params for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter");{const i=this.numberToString(s),o=this.numberToString(a);let n;n=void 0!==a?r.Y.stringMul(i,o):t,h.quoteQty=this.costToPrecision(e,n)}}else{const i=void 0!==t?t:s;h.quoteQty=this.costToPrecision(e,i)}}}else c=this.safeStringUpper(n,"timeInForce","GTC"),h.price=this.priceToPrecision(e,a);"sell"!==i&&"limit"!==t||(h.quantity=this.amountToPrecision(e,s)),h.timeInForce=c;const f=await this.privateSpotPostOrder(this.extend(h,n)),p=this.safeValue(f,"result",{});return this.parseOrder(p,d)}async createContractOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n={symbol:o.id,origQty:this.amountToPrecision(e,s)},d=this.safeStringUpper(a,"timeInForce");void 0!==d&&(n.timeInForce=d);const h=this.safeValue(a,"reduceOnly",!1);if("buy"===i){const e=h?"SHORT":"LONG";n.positionSide=e}else{const e=h?"LONG":"SHORT";n.positionSide=e}let c;const l=this.safeNumber2(a,"triggerPrice","stopPrice"),u=this.safeNumber2(a,"stopLoss","triggerStopPrice"),f=this.safeNumber2(a,"takeProfit","triggerProfitPrice"),p=void 0!==l,m=void 0!==u,g=void 0!==f;if(void 0!==r&&(m||g||(n.price=this.priceToPrecision(e,r))),p){n.timeInForce=this.safeStringUpper(a,"timeInForce","GTC"),n.triggerPriceType=this.safeString(a,"triggerPriceType","LATEST_PRICE"),n.orderSide=i.toUpperCase(),n.stopPrice=this.priceToPrecision(e,l);const s="market"===t?"STOP_MARKET":"STOP";n.entrustType=s,a=this.omit(a,"triggerPrice"),o.linear?c=await this.privateLinearPostFutureTradeV1EntrustCreatePlan(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1EntrustCreatePlan(this.extend(n,a)))}else m||g?(m?n.triggerStopPrice=this.priceToPrecision(e,u):n.triggerProfitPrice=this.priceToPrecision(e,f),a=this.omit(a,["stopLoss","takeProfit"]),o.linear?c=await this.privateLinearPostFutureTradeV1EntrustCreateProfit(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1EntrustCreateProfit(this.extend(n,a)))):(n.orderSide=i.toUpperCase(),n.orderType=t.toUpperCase(),o.linear?c=await this.privateLinearPostFutureTradeV1OrderCreate(this.extend(n,a)):o.inverse&&(c=await this.privateInversePostFutureTradeV1OrderCreate(this.extend(n,a))));return this.parseOrder(c,o)}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={};let a,o,n;[a,i]=this.handleMarketTypeAndParams("fetchOrder",s,i),[o,i]=this.handleSubTypeAndParams("fetchOrder",s,i);const d=this.safeValue(i,"stop"),h=this.safeValue(i,"stopLossTakeProfit");d?r.entrustId=e:h?r.profitId=e:r.orderId=e,d?(i=this.omit(i,"stop"),n="inverse"===o?await this.privateInverseGetFutureTradeV1EntrustPlanDetail(this.extend(r,i)):await this.privateLinearGetFutureTradeV1EntrustPlanDetail(this.extend(r,i))):h?(i=this.omit(i,"stopLossTakeProfit"),n="inverse"===o?await this.privateInverseGetFutureTradeV1EntrustProfitDetail(this.extend(r,i)):await this.privateLinearGetFutureTradeV1EntrustProfitDetail(this.extend(r,i))):n="inverse"===o?await this.privateInverseGetFutureTradeV1OrderDetail(this.extend(r,i)):"linear"===o||"swap"===a||"future"===a?await this.privateLinearGetFutureTradeV1OrderDetail(this.extend(r,i)):await this.privateSpotGetOrderOrderId(this.extend(r,i));const c=this.safeValue(n,"result",{});return this.parseOrder(c,s)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,o,n,d;void 0!==e&&(a=this.market(e),r.symbol=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i),[o,s]=this.handleMarketTypeAndParams("fetchOrders",a,s),[n,s]=this.handleSubTypeAndParams("fetchOrders",a,s);if(this.safeValue2(s,"trigger","stop"))s=this.omit(s,["trigger","stop"]),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustPlanListHistory(this.extend(r,s)):await this.privateLinearGetFutureTradeV1EntrustPlanListHistory(this.extend(r,s));else if("inverse"===n)d=await this.privateInverseGetFutureTradeV1OrderListHistory(this.extend(r,s));else if("linear"===n||"swap"===o||"future"===o)d=await this.privateLinearGetFutureTradeV1OrderListHistory(this.extend(r,s));else{let e;[e,s]=this.handleMarginModeAndParams("fetchOrders",s);const t=void 0!==e?"LEVER":"SPOT";r.bizType=t,d=await this.privateSpotGetHistoryOrder(this.extend(r,s))}const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]);return this.parseOrders(c,a,t,i)}async fetchOrdersByStatus(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();let a,o,n,d,h={};void 0!==t&&(a=this.market(t),h.symbol=a.id),void 0!==s&&(h.size=s),void 0!==i&&(h.startTime=i),[o,r]=this.handleMarketTypeAndParams("fetchOrdersByStatus",a,r),[n,r]=this.handleSubTypeAndParams("fetchOrdersByStatus",a,r);const c=this.safeBool2(r,"stop","trigger"),l=this.safeValue(r,"stopLossTakeProfit");if("open"===e?c||l?h.state="NOT_TRIGGERED":"swap"===o&&(h.state="UNFINISHED"):h.state="closed"===e?c||l?"TRIGGERED":"FILLED":"canceled"===e?c||l?"USER_REVOCATION":"CANCELED":e,(c||l||void 0!==n||"swap"===o||"future"===o)&&(void 0!==i&&(h.startTime=i),void 0!==s&&(h.size=s)),c)r=this.omit(r,["stop","trigger"]),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustPlanList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1EntrustPlanList(this.extend(h,r));else if(l)r=this.omit(r,"stopLossTakeProfit"),d="inverse"===n?await this.privateInverseGetFutureTradeV1EntrustProfitList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1EntrustProfitList(this.extend(h,r));else if(void 0!==n||"swap"===o||"future"===o)d="inverse"===n?await this.privateInverseGetFutureTradeV1OrderList(this.extend(h,r)):await this.privateLinearGetFutureTradeV1OrderList(this.extend(h,r));else{let t;[t,r]=this.handleMarginModeAndParams("fetchOrdersByStatus",r);const a=void 0!==t?"LEVER":"SPOT";h.bizType=a,"open"!==e?(void 0!==i&&(h.startTime=i),void 0!==s&&(h=this.omit(h,"size"),h.limit=s),d=await this.privateSpotGetHistoryOrder(this.extend(h,r))):d=await this.privateSpotGetOpenOrder(this.extend(h,r))}let u=[];const f=this.safeDict(d,"result");return u=void 0!==f?this.safeList(f,"items",[]):this.safeList(d,"result"),this.parseOrders(u,a,i,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("open",e,t,i,s)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("closed",e,t,i,s)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("canceled",e,t,i,s)}async cancelOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={};let a,o,n;[a,i]=this.handleMarketTypeAndParams("cancelOrder",s,i),[o,i]=this.handleSubTypeAndParams("cancelOrder",s,i);const d=this.safeValue2(i,"trigger","stop"),h=this.safeValue(i,"stopLossTakeProfit");d?r.entrustId=e:h?r.profitId=e:r.orderId=e,d?(i=this.omit(i,["trigger","stop"]),n="inverse"===o?await this.privateInversePostFutureTradeV1EntrustCancelPlan(this.extend(r,i)):await this.privateLinearPostFutureTradeV1EntrustCancelPlan(this.extend(r,i))):h?(i=this.omit(i,"stopLossTakeProfit"),n="inverse"===o?await this.privateInversePostFutureTradeV1EntrustCancelProfitStop(this.extend(r,i)):await this.privateLinearPostFutureTradeV1EntrustCancelProfitStop(this.extend(r,i))):n="inverse"===o?await this.privateInversePostFutureTradeV1OrderCancel(this.extend(r,i)):"linear"===o||"swap"===a||"future"===a?await this.privateLinearPostFutureTradeV1OrderCancel(this.extend(r,i)):await this.privateSpotDeleteOrderOrderId(this.extend(r,i));const c=void 0!==o||"swap"===a||"future"===a?n:this.safeValue(n,"result",{});return this.parseOrder(c,s)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i={};let s,r,a,o;void 0!==e&&(s=this.market(e),i.symbol=s.id),[r,t]=this.handleMarketTypeAndParams("cancelAllOrders",s,t),[a,t]=this.handleSubTypeAndParams("cancelAllOrders",s,t);const n=this.safeValue2(t,"trigger","stop"),d=this.safeValue(t,"stopLossTakeProfit");if(n)t=this.omit(t,["trigger","stop"]),o="inverse"===a?await this.privateInversePostFutureTradeV1EntrustCancelAllPlan(this.extend(i,t)):await this.privateLinearPostFutureTradeV1EntrustCancelAllPlan(this.extend(i,t));else if(d)t=this.omit(t,"stopLossTakeProfit"),o="inverse"===a?await this.privateInversePostFutureTradeV1EntrustCancelAllProfitStop(this.extend(i,t)):await this.privateLinearPostFutureTradeV1EntrustCancelAllProfitStop(this.extend(i,t));else if("inverse"===a)o=await this.privateInversePostFutureTradeV1OrderCancelAll(this.extend(i,t));else if("linear"===a||"swap"===r||"future"===r)o=await this.privateLinearPostFutureTradeV1OrderCancelAll(this.extend(i,t));else{let e;[e,t]=this.handleMarginModeAndParams("cancelAllOrders",t);const s=void 0!==e?"LEVER":"SPOT";i.bizType=s,o=await this.privateSpotDeleteOpenOrder(this.extend(i,t))}return[this.safeOrder(o)]}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s={orderIds:e};let r,a;if(void 0!==t&&(r=this.market(t)),[a,i]=this.handleSubTypeAndParams("cancelOrders",r,i),void 0!==a)throw new o.NotSupported(this.id+" cancelOrders() does not support swap and future orders, only spot orders are accepted");const n=await this.privateSpotDeleteBatchOrder(this.extend(s,i));return[this.safeOrder(n)]}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol"),s="result"in e||"positionSide"in e?"contract":"spot";t=this.safeMarket(i,t,void 0,s);const a=this.safeSymbol(i,t,void 0,s),o=this.safeInteger2(e,"time","createdTime"),n=this.safeNumber(e,"origQty"),d="spot"===s?n:r.Y.stringMul(this.numberToString(n),this.numberToString(t.contractSize)),h=this.safeNumber(e,"executedQty"),c="spot"===s?h:r.Y.stringMul(this.numberToString(h),this.numberToString(t.contractSize)),l=this.safeInteger(e,"updatedTime");return this.safeOrder({info:e,id:this.safeStringN(e,["orderId","result","cancelId","entrustId","profitId"]),clientOrderId:this.safeString2(e,"clientOrderId","clientModifyId"),timestamp:o,datetime:this.iso8601(o),lastTradeTimestamp:l,lastUpdateTimestamp:l,symbol:a,type:this.safeStringLower2(e,"type","orderType"),timeInForce:this.safeString(e,"timeInForce"),postOnly:void 0,side:this.safeStringLower2(e,"side","orderSide"),price:this.safeNumber(e,"price"),triggerPrice:this.safeNumber(e,"stopPrice"),stopLoss:this.safeNumber(e,"triggerStopPrice"),takeProfit:this.safeNumber(e,"triggerProfitPrice"),amount:d,filled:c,remaining:this.safeNumber(e,"leavingQty"),cost:void 0,average:this.safeNumber(e,"avgPrice"),status:this.parseOrderStatus(this.safeString(e,"state")),fee:{currency:this.safeCurrencyCode(this.safeString(e,"feeCurrency")),cost:this.safeNumber(e,"fee")},trades:void 0},t)}parseOrderStatus(e){return this.safeString({NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELED:"canceled",REJECTED:"rejected",EXPIRED:"expired",UNFINISHED:"open",NOT_TRIGGERED:"open",TRIGGERING:"open",TRIGGERED:"closed",USER_REVOCATION:"canceled",PLATFORM_REVOCATION:"rejected",HISTORY:"expired"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a,n,d,h;if(void 0!==e&&(a=this.currency(e)),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i),[n,s]=this.handleMarketTypeAndParams("fetchLedger",void 0,s),[d,s]=this.handleSubTypeAndParams("fetchLedger",void 0,s),"inverse"===d)h=await this.privateInverseGetFutureUserV1BalanceBills(this.extend(r,s));else{if("linear"!==d&&"swap"!==n&&"future"!==n)throw new o.NotSupported(this.id+" fetchLedger() does not support spot transactions, only swap and future wallet transactions are supported");h=await this.privateLinearGetFutureUserV1BalanceBills(this.extend(r,s))}const c=this.safeValue(h,"result",{}),l=this.safeValue(c,"items",[]);return this.parseLedger(l,a,t,i)}parseLedgerEntry(e,t=void 0){const i="ADD"===this.safeString(e,"side")?"in":"out",s=this.safeString(e,"coin");t=this.safeCurrency(s,t);const r=this.safeInteger(e,"createdTime");return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:i,account:void 0,referenceId:void 0,referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(s,t),amount:this.safeNumber(e,"amount"),timestamp:r,datetime:this.iso8601(r),before:void 0,after:this.safeNumber(e,"afterAmount"),status:void 0,fee:{currency:void 0,cost:void 0}},t)}parseLedgerEntryType(e){return this.safeString({EXCHANGE:"transfer",CLOSE_POSITION:"trade",TAKE_OVER:"trade",MERGE:"trade",QIANG_PING_MANAGER:"fee",FUND:"fee",FEE:"fee",ADL:"auto-deleveraging"},e,e)}async fetchDepositAddress(e,t={}){let i;await this.loadMarkets(),[i,t]=this.handleNetworkCodeAndParams(t);const s=this.currency(e),r=this.networkCodeToId(i,e);this.checkRequiredArgument("fetchDepositAddress",r,"network");const a={currency:s.id,chain:r},o=await this.privateSpotGetDepositAddress(this.extend(a,t)),n=this.safeValue(o,"result",{});return this.parseDepositAddress(n,s)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address");return this.checkAddress(i),{info:e,currency:this.safeCurrencyCode(void 0,t),network:void 0,address:i,tag:this.safeString(e,"memo")}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.privateSpotGetDepositHistory(this.extend(r,s)),n=this.safeValue(o,"result",{}),d=this.safeValue(n,"items",[]);return this.parseTransactions(d,a,t,i,s)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.currency=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.privateSpotGetWithdrawHistory(this.extend(r,s)),n=this.safeValue(o,"result",{}),d=this.safeValue(n,"items",[]);return this.parseTransactions(d,a,t,i,s)}async withdraw(e,t,i,s=void 0,r={}){this.checkAddress(i),await this.loadMarkets();const a=this.currency(e);let o;[s,r]=this.handleWithdrawTagAndParams(s,r),[o,r]=this.handleNetworkCodeAndParams(r);const n=this.safeValue(this.options,"networks",{}),d=this.safeString2(n,o,e,e),h={currency:a.id,chain:d,amount:this.currencyToPrecision(e,t),address:i};void 0!==s&&(h.memo=s);const c=await this.privateSpotPostWithdraw(this.extend(h,r)),l=this.safeValue(c,"result",{});return this.parseTransaction(l,a)}parseTransaction(e,t=void 0){const i="fromAddr"in e?"deposit":"withdraw",s=this.safeInteger(e,"createdTime"),r=this.safeString(e,"address"),a=this.safeString(e,"memo"),o=this.safeCurrencyCode(this.safeString(e,"currency"),t),n=this.safeNumber(e,"fee"),d=void 0!==n?o:void 0,h=this.safeString(e,"chain");return{info:e,id:this.safeString(e,"id"),txid:this.safeString(e,"transactionId"),timestamp:s,datetime:this.iso8601(s),updated:void 0,addressFrom:this.safeString(e,"fromAddr"),addressTo:r,address:r,tagFrom:void 0,tagTo:void 0,tag:a,type:i,amount:this.safeNumber(e,"amount"),currency:o,network:this.networkIdToCode(h,o),status:this.parseTransactionStatus(this.safeString(e,"status")),comment:a,fee:{currency:d,cost:n,rate:void 0},internal:void 0}}parseTransactionStatus(e){return this.safeString({SUBMIT:"pending",REVIEW:"pending",AUDITED:"pending",PENDING:"pending",CANCEL:"canceled",FAIL:"failed",SUCCESS:"ok"},e,e)}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new o.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");const s=this.safeString(i,"positionSide");if(this.checkRequiredArgument("setLeverage",s,"positionSide",["LONG","SHORT"]),e<1||e>125)throw new o.BadRequest(this.id+" setLeverage() leverage should be between 1 and 125");await this.loadMarkets();const r=this.market(t);if(!r.contract)throw new o.BadSymbol(this.id+" setLeverage() supports contract markets only");const a={symbol:r.id,positionSide:s,leverage:e};let n,d;return[n,i]=this.handleSubTypeAndParams("setLeverage",r,i),d="inverse"===n?await this.privateInversePostFutureUserV1PositionAdjustLeverage(this.extend(a,i)):await this.privateLinearPostFutureUserV1PositionAdjustLeverage(this.extend(a,i)),d}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"ADD",i)}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"SUB",i)}async modifyMarginHelper(e,t,i,s={}){const r=this.safeString(s,"positionSide");this.checkRequiredArgument("setLeverage",r,"positionSide",["LONG","SHORT"]),await this.loadMarkets();const a=this.market(e),o={symbol:a.id,margin:t,type:i,positionSide:r};let n,d;return[n,s]=this.handleSubTypeAndParams("modifyMarginHelper",a,s),d="inverse"===n?await this.privateInversePostFutureUserV1PositionMargin(this.extend(o,s)):await this.privateLinearPostFutureUserV1PositionMargin(this.extend(o,s)),this.parseMarginModification(d,a)}parseMarginModification(e,t=void 0){return{info:e,type:void 0,amount:void 0,code:void 0,symbol:this.safeSymbol(void 0,t),status:void 0,marginMode:void 0,total:void 0,timestamp:void 0,datetime:void 0}}async fetchLeverageTiers(e=void 0,t={}){let i,s;await this.loadMarkets(),[i,t]=this.handleSubTypeAndParams("fetchLeverageTiers",void 0,t),s="inverse"===i?await this.publicInverseGetFutureMarketV1PublicLeverageBracketList(t):await this.publicLinearGetFutureMarketV1PublicLeverageBracketList(t);const r=this.safeValue(s,"result",[]);return e=this.marketSymbols(e),this.parseLeverageTiers(r,e,"symbol")}parseLeverageTiers(e,t=void 0,i=void 0){const s={};for(let i=0;i<e.length;i++){const r=e[i],a=this.safeString(r,"symbol"),o=this.safeMarket(a,void 0,"_","contract"),n=this.safeSymbol(a,o);void 0!==t?this.inArray(n,t)&&(s[n]=this.parseMarketLeverageTiers(r,o)):s[n]=this.parseMarketLeverageTiers(e[i],o)}return s}async fetchMarketLeverageTiers(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchMarketLeverageTiers",i,t),a="inverse"===r?await this.publicInverseGetFutureMarketV1PublicLeverageBracketDetail(this.extend(s,t)):await this.publicLinearGetFutureMarketV1PublicLeverageBracketDetail(this.extend(s,t));const o=this.safeValue(a,"result",{});return this.parseMarketLeverageTiers(o,i)}parseMarketLeverageTiers(e,t=void 0){const i=[],s=this.safeValue(e,"leverageBrackets",[]);for(let r=0;r<s.length;r++){const a=s[r],o=this.safeString(e,"symbol");t=this.safeMarket(o,t,"_","contract"),i.push({tier:this.safeInteger(a,"bracket"),symbol:this.safeSymbol(o,t,"_","contract"),currency:t.settle,minNotional:this.safeNumber(s[r-1],"maxNominalValue",0),maxNotional:this.safeNumber(a,"maxNominalValue"),maintenanceMarginRate:this.safeNumber(a,"maintMarginRate"),maxLeverage:this.safeNumber(a,"maxLeverage"),info:a})}return i}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new o.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const r=this.market(e);if(!r.swap)throw new o.BadSymbol(this.id+" fetchFundingRateHistory() supports swap contracts only");const a={symbol:r.id};let n,d;void 0!==i&&(a.limit=i),[n,s]=this.handleSubTypeAndParams("fetchFundingRateHistory",r,s),d="inverse"===n?await this.publicInverseGetFutureMarketV1PublicQFundingRateRecord(this.extend(a,s)):await this.publicLinearGetFutureMarketV1PublicQFundingRateRecord(this.extend(a,s));const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e],i=this.safeString(t,"symbol"),s=this.safeSymbol(i,r),a=this.safeInteger(t,"createdTime");l.push({info:t,symbol:s,fundingRate:this.safeNumber(t,"fundingRate"),timestamp:a,datetime:this.iso8601(a)})}const u=this.sortBy(l,"timestamp");return this.filterBySymbolSinceLimit(u,r.symbol,t,i)}async fetchFundingInterval(e,t={}){return await this.fetchFundingRate(e,t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.swap)throw new o.BadSymbol(this.id+" fetchFundingRate() supports swap contracts only");const s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchFundingRate",i,t),a="inverse"===r?await this.publicInverseGetFutureMarketV1PublicQFundingRate(this.extend(s,t)):await this.publicLinearGetFutureMarketV1PublicQFundingRate(this.extend(s,t));const n=this.safeValue(a,"result",{});return this.parseFundingRate(n,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,"_","swap"),r=this.safeInteger(e,"nextCollectionTime");let a=this.safeString(e,"collectionInternal");return void 0!==a&&(a+="h"),{info:e,symbol:s,markPrice:void 0,indexPrice:void 0,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:void 0,datetime:void 0,fundingRate:this.safeNumber(e,"fundingRate"),fundingTimestamp:r,fundingDatetime:this.iso8601(r),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:a}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e);if(!r.swap)throw new o.BadSymbol(this.id+" fetchFundingHistory() supports swap contracts only");const a={symbol:r.id};let n,d;void 0!==t&&(a.startTime=t),void 0!==i&&(a.limit=i),[n,s]=this.handleSubTypeAndParams("fetchFundingHistory",r,s),d="inverse"===n?await this.privateInverseGetFutureUserV1BalanceFundingRateList(this.extend(a,s)):await this.privateLinearGetFutureUserV1BalanceFundingRateList(this.extend(a,s));const h=this.safeValue(d,"result",{}),c=this.safeValue(h,"items",[]),l=[];for(let e=0;e<c.length;e++){const t=c[e];l.push(this.parseFundingHistory(t,r))}const u=this.sortBy(l,"timestamp");return this.filterBySinceLimit(u,t,i)}parseFundingHistory(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t,"_","swap"),r=this.safeString(e,"coin"),a=this.safeCurrencyCode(r),o=this.safeInteger(e,"createdTime");return{info:e,symbol:s,code:a,timestamp:o,datetime:this.iso8601(o),id:this.safeString(e,"id"),amount:this.safeNumber(e,"cast")}}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r,a;[r,t]=this.handleSubTypeAndParams("fetchPosition",i,t),a="inverse"===r?await this.privateInverseGetFutureUserV1PositionList(this.extend(s,t)):await this.privateLinearGetFutureUserV1PositionList(this.extend(s,t));const o=this.safeValue(a,"result",[]);for(let e=0;e<o.length;e++){const t=o[e],i=this.safeString(t,"symbol"),s=this.safeMarket(i,void 0,void 0,"contract");if("0"!==this.safeString(t,"positionSize"))return this.parsePosition(t,s)}}async fetchPositions(e=void 0,t={}){let i,s;await this.loadMarkets(),[i,t]=this.handleSubTypeAndParams("fetchPositions",void 0,t),s="inverse"===i?await this.privateInverseGetFutureUserV1PositionList(t):await this.privateLinearGetFutureUserV1PositionList(t);const r=this.safeValue(s,"result",[]),a=[];for(let e=0;e<r.length;e++){const t=r[e],i=this.safeString(t,"symbol"),s=this.safeMarket(i,void 0,void 0,"contract");a.push(this.parsePosition(t,s))}return this.filterByArrayPositions(a,"symbol",e,!1)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t,void 0,"contract");const s=this.safeSymbol(i,t,void 0,"contract"),r="CROSSED"===this.safeString(e,"positionType")?"cross":"isolated",a=this.safeNumber(e,"isolatedMargin");return this.safePosition({info:e,id:void 0,symbol:s,timestamp:void 0,datetime:void 0,hedged:void 0,side:this.safeStringLower(e,"positionSide"),contracts:this.safeNumber(e,"positionSize"),contractSize:t.contractSize,entryPrice:this.safeNumber(e,"entryPrice"),markPrice:void 0,notional:void 0,leverage:this.safeInteger(e,"leverage"),collateral:a,initialMargin:a,maintenanceMargin:void 0,initialMarginPercentage:void 0,maintenanceMarginPercentage:void 0,unrealizedPnl:void 0,liquidationPrice:void 0,marginMode:r,percentage:void 0,marginRatio:void 0})}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeValue(this.options,"accountsById"),n=this.safeString(o,i,i),d=this.safeString(o,s,s),h=this.currencyToPrecision(e,t),c={bizId:this.uuid(),currency:a.id,amount:h,from:n,to:d},l=await this.privateSpotPostBalanceTransfer(this.extend(c,r));return this.parseTransfer(l,a)}parseTransfer(e,t=void 0){return{info:e,id:this.safeString(e,"result"),timestamp:void 0,datetime:void 0,currency:void 0,amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new o.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");await this.loadMarkets();const s=this.market(t);if(s.spot)throw new o.BadSymbol(this.id+" setMarginMode() supports contract markets only");if("isolated"!==(e=e.toLowerCase())&&"cross"!==e)throw new o.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");e="cross"===e?"CROSSED":"ISOLATED";const r=this.safeStringUpper(i,"positionSide");if(void 0===r)throw new o.ArgumentsRequired(this.id+' setMarginMode() requires a positionSide parameter, either "LONG" or "SHORT"');const a={positionType:e,positionSide:r,symbol:s.id};return await this.privateLinearPostFutureUserV1PositionChangeType(this.extend(a,i))}async editOrder(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===r)throw new o.ArgumentsRequired(this.id+" editOrder() requires an amount argument");await this.loadMarkets();const d=this.market(t),h={},c=this.safeNumber2(n,"stopLoss","triggerStopPrice"),l=this.safeNumber2(n,"takeProfit","triggerProfitPrice");n=this.omit(n,["stopLoss","takeProfit"]);const u=void 0!==c,f=void 0!==l;let p;if(u||f?h.profitId=e:(h.orderId=e,h.price=this.priceToPrecision(t,a)),d.swap){let e;u?h.triggerStopPrice=this.priceToPrecision(t,c):void 0!==l?h.triggerProfitPrice=this.priceToPrecision(t,l):h.origQty=this.amountToPrecision(t,r),[e,n]=this.handleSubTypeAndParams("editOrder",d,n),p="inverse"===e?u||f?await this.privateInversePostFutureTradeV1EntrustUpdateProfitStop(this.extend(h,n)):await this.privateInversePostFutureTradeV1OrderUpdate(this.extend(h,n)):u||f?await this.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(this.extend(h,n)):await this.privateLinearPostFutureTradeV1OrderUpdate(this.extend(h,n))}else h.quantity=this.amountToPrecision(t,r),p=await this.privateSpotPutOrderOrderId(this.extend(h,n));const m=d.swap?p:this.safeDict(p,"result",{});return this.parseOrder(m,d)}handleErrors(e,t,i,s,r,a,n,d,h){const c=this.safeStringUpper2(n,"msgInfo","mc");if(void 0!==c&&"SUCCESS"!==c){const e=this.id+" "+a,t=this.safeValue(n,"error",{}),i=this.safeString(n,"mc"),s=this.safeString(t,"code",i),r=this.safeString(n,"msgInfo"),d=this.safeString(t,"msg",r);throw this.throwExactlyMatchedException(this.exceptions.exact,s,e),this.throwBroadlyMatchedException(this.exceptions.broad,d,e),new o.ExchangeError(e)}}sign(e,t=[],i="GET",s={},r=void 0,a=void 0){const o="private"===t[0],d=t[1],h="/"+this.implodeParams(e,s);let c;c="spot"===d||"user"===d?o?"/"+this.version+h:"/"+this.version+"/public"+h:h;let l=this.urls.api[d]+c;const u=this.omit(s,this.extractParams(e)),f=this.urlencode(this.keysort(u));if(r={"Content-Type":"application/json"},o){this.checkRequiredCredentials();const t=this.safeString(this.options,"recvWindow"),s=this.safeString(u,"recvWindow",t),o=this.numberToString(this.nonce());if(a=u,"/v4/order"===c||"/future/trade/v1/order/create"===c||"/future/trade/v1/entrust/create-plan"===c||"/future/trade/v1/entrust/create-profit"===c||"/future/trade/v1/order/create-batch"===c){const e="CCXT";c.indexOf("future")>-1?a.clientMedia=e:a.media=e}let h,p="GET"===i||"order/{orderId}"===e||"ws-token"===e;"PUT"===i&&"spot"===d&&(p=!1),a=p?void 0:this.json(a),"spot"===d||"user"===d?(h="xt-validate-algorithms=HmacSHA256&xt-validate-appkey="+this.apiKey+"&xt-validate-recvwindow="+s+"&xt-validate-timestamp="+o,p?f?(l+="?"+f,h+="#"+i+"#"+c+"#"+this.rawencode(this.keysort(u))):h+="#"+i+"#"+c:h+="#"+i+"#"+c+"#"+a,r["xt-validate-algorithms"]="HmacSHA256",r["xt-validate-recvwindow"]=s):(h="xt-validate-appkey="+this.apiKey+"&xt-validate-timestamp="+o,"GET"===i?f?(l+="?"+f,h+="#"+c+"#"+f):h+="#"+c:h+="#"+c+"#"+a);const m=this.hmac(this.encode(h),this.encode(this.secret),n.s);r["xt-validate-appkey"]=this.apiKey,r["xt-validate-timestamp"]=o,r["xt-validate-signature"]=m}else f&&(l+="?"+f);return{url:l,method:i,body:a,headers:r}}}},87469:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(13578),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"yobit",name:"YoBit",countries:["RU"],rateLimit:2e3,version:"3",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0,ws:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpg",api:{public:"https://yobit.net/api",private:"https://yobit.net/tapi"},www:"https://www.yobit.net",doc:"https://www.yobit.net/en/api/",fees:"https://www.yobit.net/en/fees/"},api:{public:{get:{"depth/{pair}":1,info:1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{ActiveOrders:1,CancelOrder:1,GetDepositAddress:1,getInfo:1,OrderInfo:1,Trade:1,TradeHistory:1,WithdrawCoinsToAddress:1}}},fees:{trading:{maker:.002,taker:.002},funding:{withdraw:{}}},commonCurrencies:{AIR:"AirCoin",ANI:"ANICoin",ANT:"AntsCoin",ATMCHA:"ATM",ASN:"Ascension",AST:"Astral",ATM:"Autumncoin",AUR:"AuroraCoin",BAB:"Babel",BAN:"BANcoin",BCC:"BCH",BCS:"BitcoinStake",BITS:"Bitstar",BLN:"Bulleon",BNS:"Benefit Bonus Coin",BOT:"BOTcoin",BON:"BONES",BPC:"BitcoinPremium",BST:"BitStone",BTS:"Bitshares2",CAT:"BitClave",CBC:"CryptoBossCoin",CMT:"CometCoin",COIN:"Coin.com",COV:"Coven Coin",COVX:"COV",CPC:"Capricoin",CREDIT:"Creditbit",CS:"CryptoSpots",DCT:"Discount",DFT:"DraftCoin",DGD:"DarkGoldCoin",DIRT:"DIRTY",DROP:"FaucetCoin",DSH:"DASH",EGC:"EverGreenCoin",EGG:"EggCoin",EKO:"EkoCoin",ENTER:"ENTRC",EPC:"ExperienceCoin",ESC:"EdwardSnowden",EUROPE:"EUROP",EXT:"LifeExtension",FUND:"FUNDChains",FUNK:"FUNKCoin",FX:"FCoin",GCC:"GlobalCryptocurrency",GEN:"Genstake",GENE:"Genesiscoin",GMR:"Gimmer",GOLD:"GoldMint",GOT:"Giotto Coin",GSX:"GlowShares",GT:"GTcoin",HTML5:"HTML",HYPERX:"HYPER",ICN:"iCoin",INSANE:"INSN",JNT:"JointCoin",JPC:"JupiterCoin",JWL:"Jewels",KNC:"KingN Coin",LBTCX:"LiteBitcoin",LIZI:"LiZi",LOC:"LocoCoin",LOCX:"LOC",LUNYR:"LUN",LUN:"LunarCoin",LUNA:"Luna Coin",MASK:"Yobit MASK",MDT:"Midnight",MEME:"Memez Token",MIS:"MIScoin",MM:"MasterMint",NAV:"NavajoCoin",NBT:"NiceBytes",OMG:"OMGame",ONX:"Onix",PAC:"$PAC",PLAY:"PlayCoin",PIVX:"Darknet",PURE:"PurePOS",PUTIN:"PutinCoin",SPACE:"Spacecoin",STK:"StakeCoin",SUB:"Subscriptio",PAY:"EPAY",PLC:"Platin Coin",RAI:"RaiderCoin",RCN:"RCoin",REP:"Republicoin",RUR:"RUB",SBTC:"Super Bitcoin",SMC:"SmartCoin",SOLO:"SoloCoin",SOUL:"SoulCoin",STAR:"StarCoin",SUPER:"SuperCoin",TNS:"Transcodium",TTC:"TittieCoin",UNI:"Universe",UST:"Uservice",VOL:"VolumeCoin",XIN:"XINCoin",XMT:"SummitCoin",XRA:"Ratecoin",BCHN:"BSV"},options:{maxUrlLength:2048,fetchOrdersRequiresSymbol:!0,networks:{ETH:"ERC20",TRX:"TRC20",BSC:"BEP20"}},precisionMode:o.kb,exceptions:{exact:{803:r.InvalidOrder,804:r.InvalidOrder,805:r.InvalidOrder,806:r.InvalidOrder,807:r.InvalidOrder,831:r.InsufficientFunds,832:r.InsufficientFunds,833:r.OrderNotFound},broad:{"Invalid pair name":r.ExchangeError,"invalid api key":r.AuthenticationError,"invalid sign":r.AuthenticationError,"api key dont have trade permission":r.AuthenticationError,"invalid parameter":r.InvalidOrder,"invalid order":r.InvalidOrder,"The given order has already been cancelled":r.InvalidOrder,"Requests too often":r.DDoSProtection,"not available":r.ExchangeNotAvailable,"data unavailable":r.ExchangeNotAvailable,"external service unavailable":r.ExchangeNotAvailable,"Total transaction amount":r.InvalidOrder,"The given order has already been closed and cannot be cancelled":r.InvalidOrder,"Insufficient funds":r.InsufficientFunds,"invalid key":r.AuthenticationError,"invalid nonce":r.InvalidNonce,"Total order amount is less than minimal amount":r.InvalidOrder,"Rate Limited":r.RateLimitExceeded}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},orders:{}})}parseBalance(e){const t=this.safeDict(e,"return",{}),i=this.safeInteger(t,"server_time"),s={info:e,timestamp:i,datetime:this.iso8601(i)},r=this.safeDict(t,"funds",{}),a=this.safeDict(t,"funds_incl_orders",{}),o=Object.keys(this.extend(r,a));for(let e=0;e<o.length;e++){const t=o[e],i=this.safeCurrencyCode(t),n=this.account();n.free=this.safeString(r,t),n.total=this.safeString(a,t),s[i]=n}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchMarkets(e={}){const t=await this.publicGetInfo(e),i=this.safeDict(t,"pairs",{}),s=Object.keys(i),r=[];for(let e=0;e<s.length;e++){const t=s[e],o=i[t],[n,d]=t.split("_");let h=n.toUpperCase(),c=d.toUpperCase();h=this.safeCurrencyCode(h),c=this.safeCurrencyCode(c);const l=this.safeInteger(o,"hidden");let u=this.safeString(o,"fee");u=a.Y.stringDiv(u,"100"),r.push({id:t,symbol:h+"/"+c,base:h,quote:c,settle:void 0,baseId:n,quoteId:d,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:0===l,contract:!1,linear:void 0,inverse:void 0,taker:this.parseNumber(u),maker:this.parseNumber(u),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(o,"decimal_places"))),price:this.parseNumber(this.parsePrecision(this.safeString(o,"decimal_places")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(o,"min_amount"),max:this.safeNumber(o,"max_amount")},price:{min:this.safeNumber(o,"min_price"),max:this.safeNumber(o,"max_price")},cost:{min:this.safeNumber(o,"min_total"),max:void 0}},created:void 0,info:o})}return r}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),a={pair:s.id};void 0!==t&&(a.limit=t);const o=await this.publicGetDepthPair(this.extend(a,i));if(!(s.id in o))throw new r.ExchangeError(this.id+" "+s.symbol+" order book is empty or not available");const n=o[s.id];return this.parseOrderBook(n,e)}async fetchOrderBooks(e=void 0,t=void 0,i={}){let s;if(await this.loadMarkets(),void 0===e){if(s=this.ids.join("-"),s.length>2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else s=this.marketIds(e),s=s.join("-");const a={pair:s};void 0!==t&&(a.limit=t);const o=await this.publicGetDepthPair(this.extend(a,i)),n={};s=Object.keys(o);for(let e=0;e<s.length;e++){const t=s[e],i=this.safeSymbol(t);n[i]=this.parseOrderBook(o[t],i)}return n}parseTicker(e,t=void 0){const i=this.safeTimestamp(e,"updated"),s=this.safeString(e,"last");return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:s,last:s,previousClose:void 0,change:void 0,percentage:void 0,average:this.safeString(e,"avg"),baseVolume:this.safeString(e,"vol_cur"),quoteVolume:this.safeString(e,"vol"),info:e},t)}async fetchTickersHelper(e,t={}){const i={pair:e},s=await this.publicGetTickerPair(this.extend(i,t)),r={},a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e],i=s[t],o=this.safeMarket(t);r[o.symbol]=this.parseTicker(i,o)}return r}async fetchTickers(e=void 0,t={}){let i;if([i,t]=this.handleParamBool(t,"all",!1),void 0===e&&!i)throw new r.ArgumentsRequired(this.id+' fetchTickers() requires "symbols" argument or use `params["all"] = true` to send multiple requests for all markets');await this.loadMarkets();const s=[],a=this.safeInteger(this.options,"maxUrlLength",2048);if(i){e=this.symbols;let i="";for(let e=0;e<this.ids.length;e++){i+=(""===i?"":"-")+this.ids[e],i.length>a&&(s.push(this.fetchTickersHelper(i,t)),i="")}""!==i&&s.push(this.fetchTickersHelper(i,t))}else{e=this.marketSymbols(e);const i=this.marketIds(e),o=i.length,n=i.join("-"),d=n.length+40;if(d>a)throw new r.ArgumentsRequired(this.id+" fetchTickers() is being requested for "+o.toString()+" markets (which has an URL length of "+d.toString()+" characters), but it exceedes max URL length ("+a.toString()+"), please pass limisted symbols array to fetchTickers to fit in one request");s.push(this.fetchTickersHelper(n,t))}const o=await Promise.all(s);let n={};for(let t=0;t<o.length;t++){const i=this.filterByArrayTickers(o[t],"symbol",e);n=this.extend(n,i)}return n}async fetchTicker(e,t={}){return(await this.fetchTickers([e],t))[e]}parseTrade(e,t=void 0){const i=this.safeTimestamp(e,"timestamp");let s=this.safeString(e,"type");"ask"===s?s="sell":"bid"===s&&(s="buy");const r=this.safeString2(e,"rate","price"),a=this.safeString2(e,"trade_id","tid"),o=this.safeString(e,"order_id"),n=this.safeString(e,"pair"),d=this.safeSymbol(n,t),h=this.safeString(e,"amount"),c=this.parseNumber(r),l=this.parseNumber(h),u="limit";let f;const p=this.safeNumber(e,"commission");if(void 0!==p){const t=this.safeString(e,"commissionCurrency");f={cost:p,currency:this.safeCurrencyCode(t)}}if(void 0!==this.safeString(e,"is_your_order")&&void 0===f){const e=this.calculateFee(d,u,s,l,c,"taker");f={currency:this.safeString(e,"currency"),cost:this.safeString(e,"cost"),rate:this.safeString(e,"rate")}}return this.safeTrade({id:a,order:o,timestamp:i,datetime:this.iso8601(i),symbol:d,type:u,side:s,takerOrMaker:void 0,price:r,amount:h,cost:void 0,fee:f,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};void 0!==i&&(a.limit=i);const o=await this.publicGetTradesPair(this.extend(a,s));if(Array.isArray(o)){if(0===o.length)return[]}const n=this.safeList(o,r.id,[]);return this.parseTrades(n,r,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.publicGetInfo(e),i=this.safeDict(t,"pairs",{}),s=Object.keys(i),r={};for(let e=0;e<s.length;e++){const t=s[e],o=this.safeDict(i,t,{}),n=this.safeSymbol(t,void 0,"_"),d=this.safeString(o,"fee_buyer"),h=this.safeString(o,"fee_seller"),c=this.parseNumber(a.Y.stringDiv(d,"100")),l=this.parseNumber(a.Y.stringDiv(h,"100"));r[n]={info:o,symbol:n,taker:c,maker:l,percentage:!0,tierBased:!1}}return r}async createOrder(e,t,i,s,a=void 0,o={}){if("market"===t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");await this.loadMarkets();const n=this.market(e),d={pair:n.id,type:i,amount:this.amountToPrecision(e,s),rate:this.priceToPrecision(e,a)},h=await this.privatePostTrade(this.extend(d,o)),c=this.safeDict(h,"return");return this.parseOrder(c,n)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={order_id:parseInt(e)},r=await this.privatePostCancelOrder(this.extend(s,i)),a=this.safeDict(r,"return",{});return this.parseOrder(a)}parseOrderStatus(e){return this.safeString({0:"open",1:"closed",2:"canceled",3:"open"},e,e)}parseOrder(e,t=void 0){let i=this.safeString2(e,"id","order_id"),s=this.parseOrderStatus(this.safeString(e,"status","open"));"0"===i&&(i=this.safeString(e,"init_order_id"),s="closed");const r=this.safeTimestamp2(e,"timestamp_created","server_time"),a=this.safeString(e,"pair"),o=this.safeSymbol(a,t),n=this.safeString(e,"start_amount"),d=this.safeString2(e,"amount","remains"),h=this.safeString(e,"received","0.0"),c=this.safeString(e,"rate"),l=this.safeString(e,"type");return this.safeOrder({info:e,id:i,clientOrderId:void 0,symbol:o,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,type:"limit",timeInForce:void 0,postOnly:void 0,side:l,price:c,triggerPrice:void 0,cost:void 0,amount:n,remaining:d,filled:h,status:s,fee:undefined,average:void 0,trades:void 0},t)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={order_id:parseInt(e)},r=await this.privatePostOrderInfo(this.extend(s,i));e=e.toString();const a=this.safeDict(r,"return",{});return this.parseOrder(this.extend({id:e},a[e]))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a={};if(void 0!==e){const t=this.market(e);a.pair=t.id}const o=await this.privatePostActiveOrders(this.extend(a,s)),n=this.safeDict(o,"return",{});return this.parseOrders(n,undefined,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={pair:a.id};void 0!==i&&(o.count=i),void 0!==t&&(o.since=this.parseToInt(t/1e3));const n=await this.privatePostTradeHistory(this.extend(o,s)),d=this.safeDict(n,"return",{}),h=Object.keys(d),c=[];for(let e=0;e<h.length;e++){const t=this.safeString(h,e),i=this.parseTrade(this.extend(d[t],{trade_id:t}),a);c.push(i)}return this.filterBySymbolSinceLimit(c,a.symbol,t,i)}async createDepositAddress(e,t={}){const i=await this.fetchDepositAddress(e,this.extend({need_new:1},t)),s=this.safeString(i,"address");return this.checkAddress(s),{currency:e,address:s,tag:void 0,network:void 0,info:i.info}}async fetchDepositAddress(e,t={}){await this.loadMarkets();let i=this.currency(e).id;const s=this.safeDict(this.options,"networks",{});let r=this.safeStringUpper(t,"network");r=this.safeString(s,r,r),void 0!==r&&("ERC20"!==r&&(i+=r.toLowerCase()),t=this.omit(t,"network"));const a={coinName:i,need_new:0},o=await this.privatePostGetDepositAddress(this.extend(a,t)),n=this.safeString(o.return,"address");return this.checkAddress(n),{info:o,currency:e,network:void 0,address:n,tag:void 0}}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),this.checkAddress(i),await this.loadMarkets();const o={coinName:this.currency(e).id,amount:t,address:i};if(void 0!==s)throw new r.ExchangeError(this.id+" withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.");return{info:await this.privatePostWithdrawCoinsToAddress(this.extend(o,a)),id:void 0,txid:void 0,type:void 0,currency:void 0,network:void 0,amount:void 0,status:void 0,timestamp:void 0,datetime:void 0,address:void 0,addressFrom:void 0,addressTo:void 0,tag:void 0,tagFrom:void 0,tagTo:void 0,updated:void 0,comment:void 0,fee:{currency:void 0,cost:void 0,rate:void 0}}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t];const d=this.omit(s,this.extractParams(e));if("private"===t){this.checkRequiredCredentials();const t=this.nonce();a=this.urlencode(this.extend({nonce:t,method:e},d));const i=this.hmac(this.encode(a),this.encode(this.secret),n.Zf);r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:i}}else"public"===t?(o+="/"+this.version+"/"+this.implodeParams(e,s),Object.keys(d).length&&(o+="?"+this.urlencode(d))):(o+="/"+this.implodeParams(e,s),"GET"===i?Object.keys(d).length&&(o+="?"+this.urlencode(d)):Object.keys(d).length&&(a=this.json(d),r={"Content-Type":"application/json"}));return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n&&"success"in n){let e=this.safeValue(n,"success");if("string"==typeof e&&(e="true"===e||"1"===e),!e){const e=this.safeString(n,"code"),t=this.safeString(n,"error"),i=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,i),this.throwExactlyMatchedException(this.exceptions.exact,t,i),this.throwBroadlyMatchedException(this.exceptions.broad,t,i),new r.ExchangeError(i)}}}}},1530:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(58291),r=i(62079),a=i(85147),o=i(51579),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zaif",name:"Zaif",countries:["JP"],rateLimit:100,version:"1",has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelOrder:!0,createMarketOrder:!1,createOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766927-39ca2ada-5eeb-11e7-972f-1b4199518ca6.jpg",api:{rest:"https://api.zaif.jp"},www:"https://zaif.jp",doc:["https://techbureau-api-document.readthedocs.io/ja/latest/index.html","https://corp.zaif.jp/api-docs","https://corp.zaif.jp/api-docs/api_links","https://www.npmjs.com/package/zaif.jp","https://github.com/you21979/node-zaif"],fees:"https://zaif.jp/fee?lang=en"},fees:{trading:{percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0")}},api:{public:{get:{"depth/{pair}":1,"currencies/{pair}":1,"currencies/all":1,"currency_pairs/{pair}":1,"currency_pairs/all":1,"last_price/{pair}":1,"ticker/{pair}":1,"trades/{pair}":1}},private:{post:{active_orders:5,cancel_order:5,deposit_history:5,get_id_info:5,get_info:10,get_info2:5,get_personal_info:5,trade:5,trade_history:50,withdraw:5,withdraw_history:5}},ecapi:{post:{createInvoice:1,getInvoice:1,getInvoiceIdsByOrderNumber:1,cancelInvoice:1}},tlapi:{post:{get_positions:66,position_history:66,active_positions:5,create_position:33,change_position:33,cancel_position:33}},fapi:{get:{"groups/{group_id}":1,"last_price/{group_id}/{pair}":1,"ticker/{group_id}/{pair}":1,"trades/{group_id}/{pair}":1,"depth/{group_id}/{pair}":1}}},options:{},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!0,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:void 0,fetchOpenOrders:{marginMode:!0,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"unsupported currency_pair":r.BadRequest},broad:{}}})}async fetchMarkets(e={}){const t=await this.publicGetCurrencyPairsAll(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"currency_pair"),i=this.safeString(e,"name"),[s,r]=i.split("/"),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r);return{id:t,symbol:a+"/"+o,base:a,quote:o,settle:void 0,baseId:s,quoteId:r,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"item_unit_step"),price:this.parseNumber(this.parsePrecision(this.safeString(e,"aux_unit_point")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"item_unit_min"),max:void 0},price:{min:this.safeNumber(e,"aux_unit_min"),max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}parseBalance(e){const t=this.safeValue(e,"return",{}),i=this.safeValue(t,"deposit"),s={info:e,timestamp:void 0,datetime:void 0},r=this.safeValue(t,"funds",{}),a=Object.keys(r);for(let e=0;e<a.length;e++){const t=a[e],o=this.safeCurrencyCode(t),n=this.safeString(r,t),d=this.account();d.free=n,d.total=n,void 0!==i&&t in i&&(d.total=this.safeString(i,t)),s[o]=d}return this.safeBalance(s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privatePostGetInfo(e);return this.parseBalance(t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={pair:s.id},a=await this.publicGetDepthPair(this.extend(r,i));return this.parseOrderBook(a,s.symbol)}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeString(e,"vwap"),r=this.safeString(e,"volume"),o=a.Y.stringMul(r,s),n=this.safeString(e,"last");return this.safeTicker({symbol:i,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"bid"),bidVolume:void 0,ask:this.safeString(e,"ask"),askVolume:void 0,vwap:s,open:void 0,close:n,last:n,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:r,quoteVolume:o,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pair:i.id},r=await this.publicGetTickerPair(this.extend(s,t));return this.parseTicker(r,i)}parseTrade(e,t=void 0){let i=this.safeString(e,"trade_type");i="bid"===i?"buy":"sell";const s=this.safeTimestamp(e,"date"),r=this.safeString2(e,"id","tid"),a=this.safeString(e,"price"),o=this.safeString(e,"amount"),n=this.safeString(e,"currency_pair"),d=this.safeSymbol(n,t,"_");return this.safeTrade({id:r,info:e,timestamp:s,datetime:this.iso8601(s),symbol:d,type:void 0,side:i,order:void 0,takerOrMaker:void 0,price:a,amount:o,cost:void 0,fee:void 0},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id};let o=await this.publicGetTradesPair(this.extend(a,s));if(1===o.length){const e=o[0];Object.keys(e).length||(o=[])}return this.parseTrades(o,r,t,i)}async createOrder(e,t,i,s,a=void 0,o={}){if(await this.loadMarkets(),"limit"!==t)throw new r.ExchangeError(this.id+" createOrder() allows limit orders only");const n=this.market(e),d={currency_pair:n.id,action:"buy"===i?"bid":"ask",amount:s,price:a},h=await this.privatePostTrade(this.extend(d,o));return this.safeOrder({info:h,id:h.return.order_id.toString()},n)}async cancelOrder(e,t=void 0,i={}){const s={order_id:e},r=await this.privatePostCancelOrder(this.extend(s,i)),a=this.safeDict(r,"return");return this.parseOrder(a)}parseOrder(e,t=void 0){let i=this.safeString(e,"action");i="bid"===i?"buy":"sell";const s=this.safeTimestamp(e,"timestamp"),r=this.safeString(e,"currency_pair"),a=this.safeSymbol(r,t,"_"),o=this.safeString(e,"price"),n=this.safeString(e,"amount"),d=this.safeString2(e,"id","order_id");return this.safeOrder({id:d,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,status:"open",symbol:a,type:"limit",timeInForce:void 0,postOnly:void 0,side:i,price:o,triggerPrice:void 0,cost:void 0,amount:n,filled:void 0,remaining:void 0,trades:void 0,fee:void 0,info:e,average:void 0},t)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const o=await this.privatePostActiveOrders(this.extend(a,s));return this.parseOrders(o.return,r,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.market(e),a.currency_pair=r.id);const o=await this.privatePostTradeHistory(this.extend(a,s));return this.parseOrders(o.return,r,t,i)}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),this.checkAddress(i),await this.loadMarkets();const o=this.currency(e);if("JPY"===e)throw new r.ExchangeError(this.id+" withdraw() does not allow "+e+" withdrawals");const n={currency:o.id,amount:t,address:i};void 0!==s&&(n.message=s);const d=await this.privatePostWithdraw(this.extend(n,a)),h=this.safeDict(d,"return");return this.parseTransaction(h,o)}parseTransaction(e,t=void 0){let i;t=this.safeCurrency(void 0,t);const s=this.safeValue(e,"fee");return void 0!==s&&(i={cost:s,currency:t.code}),{id:this.safeString(e,"id"),txid:this.safeString(e,"txid"),timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:i,info:e}}customNonce(){const e=this.numberToString(this.milliseconds()/1e3);return parseFloat(e).toFixed(8)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api.rest+"/";if("public"===t)o+="api/"+this.version+"/"+this.implodeParams(e,s);else if("fapi"===t)o+="fapi/"+this.version+"/"+this.implodeParams(e,s);else{this.checkRequiredCredentials(),o+="ecapi"===t?"ecapi":"tlapi"===t?"tlapi":"tapi";const i=this.customNonce();a=this.urlencode(this.extend({method:e,nonce:i},s)),r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:this.hmac(this.encode(a),this.encode(this.secret),n.Zf)}}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.id+" "+o,l=this.safeString(n,"error");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c);if(!this.safeBool(n,"success",!0))throw new r.ExchangeError(c)}}},20285:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarafza",name:"Zarafza",countries:["IR"],rateLimit:1e3,version:"v2",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.zarafza.com"},www:"https://zarafza.com",doc:"https://api.zarafza.com/v2/prices"},api:{public:{get:{"v2/prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV2Prices(e);return[this.parseMarket(t)]}parseMarket(e){const t=this.safeDict(e,"data",{}),i=this.safeDict(t,"G18",{}),s=this.safeDict(i,"sell",{});return{id:"G18",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"G18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(s,"price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:i}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV2Prices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV2Prices(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeDict(e,"data",{}),s=this.safeDict(i,"G18",{}),r=this.safeDict(s,"buy",{}),a=this.safeDict(s,"sell",{}),o=this.safeNumber(a,"price"),n=this.safeNumber(r,"price");let d=o;return void 0!==n&&(void 0===d||n>d)&&(d=n),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:o,bidVolume:void 0,ask:n,askVolume:void 0,vwap:void 0,open:void 0,close:d,last:d,previousClose:void 0,change:void 0,percentage:this.safeNumber(a,"change"),average:void 0,baseVolume:this.safeNumber(s,"volume"),quoteVolume:void 0,info:s},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},57562:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarminex",name:"Zarminex",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api.zarminex.ir"},www:"https://zarminex.ir",doc:"https://api.zarminex.ir/function_url/"},api:{public:{get:{function_url:1}}}})}async fetchMarkets(e={}){const t=await this.publicGetFunctionUrl(e);return[this.parseMarket(t)]}parseMarket(e){return{id:"XAU18IRT",symbol:"XAU18/IRT",base:"XAU18",quote:"IRT",settle:void 0,baseId:"XAU18",quoteId:"IRT",settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"cached_price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetFunctionUrl(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetFunctionUrl(t),s=this.market("XAU18/IRT"),r=this.parseTicker(i,s),a={};return a[r.symbol]=r,this.filterByArrayTickers(a,"symbol",e)}parseTicker(e,t=void 0){let i=this.safeNumber(e,"buy"),s=this.safeNumber(e,"sell");void 0!==i&&(i/=10),void 0!==s&&(s/=10);let r=i;return void 0!==s&&(void 0===r||s>r)&&(r=s),this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:void 0,low:void 0,bid:i,bidVolume:void 0,ask:s,askVolume:void 0,vwap:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},93290:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarniv",name:"Zarniv",countries:["IR"],rateLimit:1e3,version:"1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://zarniv.ir"},www:"https://zarniv.ir",doc:"https://zarniv.ir/user/get_gold_price/"},api:{public:{get:{"user/get_gold_price":1,"user/get_silver_price":1}}}})}fetchPrice(e,t={}){return"gold"===e?this.publicGetUserGetGoldPrice(t):this.publicGetUserGetSilverPrice(t)}async fetchMarkets(e={}){const t=await this.fetchPrice("gold",e),i=await this.fetchPrice("silver",e);return[this.parseMarketEntry(t,"gold"),this.parseMarketEntry(i,"silver")]}parseMarketEntry(e,t){let i="XAG-1G";"gold"===t&&(i="XAU18");const s="IRT";return{id:i+s,symbol:i+"/"+s,base:i,quote:s,settle:void 0,baseId:t,quoteId:s,settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"base_price_per_gram"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.fetchPrice(i.baseId,t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.fetchPrice("gold",t),s=await this.fetchPrice("silver",t),r=this.market("XAU18/IRT"),a=this.market("XAG-1G/IRT"),o=this.parseTicker(i,r),n=this.parseTicker(s,a),d={};return d[o.symbol]=o,d[n.symbol]=n,this.filterByArrayTickers(d,"symbol",e)}parseTicker(e,t=void 0){const i=this.safeString(e,"server_time");let s;void 0!==i&&(s=this.parse8601(i+"+03:30"));const r=this.safeNumber(e,"buy_price_per_gram"),a=this.safeNumber(e,"sell_price_per_gram");let o=r;return void 0!==a&&(void 0===o||a>o)&&(o=a),this.safeTicker({symbol:t.symbol,timestamp:s,datetime:void 0,high:void 0,low:void 0,bid:r,bidVolume:void 0,ask:a,askVolume:void 0,vwap:void 0,open:void 0,close:o,last:o,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:void 0,info:e},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},30528:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(72961);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zarpin",name:"Zarpin",countries:["IR"],rateLimit:1e3,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,fetchMarkets:!0,fetchTicker:!0,fetchTickers:!0,otc:!0},options:{defaultType:"otc"},urls:{api:{public:"https://api-khazaneh.zarpin.com"},www:"https://zarpin.com",doc:"https://api-khazaneh.zarpin.com/v1/prc/prices"},api:{public:{get:{"v1/prc/prices":1}}}})}async fetchMarkets(e={}){const t=await this.publicGetV1PrcPrices(e);return this.parseMarkets(t)}parseMarkets(e){let t=[];Array.isArray(e)&&(t=e);const i=[];for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"code");"GOLD_IRT"!==r&&"SILVER_IRT"!==r||i.push(this.parseMarket(s))}return i}parseMarket(e){const t=this.safeString(e,"code");let i="XAG-1G";"GOLD_IRT"===t&&(i="XAU18");const s="IRT";return{id:t,symbol:i+"/"+s,base:i,quote:s,settle:void 0,baseId:t,quoteId:s,settleId:void 0,type:"otc",spot:!1,margin:!1,swap:!1,future:!1,option:!1,active:void 0!==this.safeNumber(e,"price"),contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:void 0,price:void 0},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.publicGetV1PrcPrices(t);return this.parseTicker(s,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e));const i=await this.publicGetV1PrcPrices(t),s=this.parseMarkets(i),r={};for(let e=0;e<s.length;e++){const t=this.parseTicker(i,s[e]);r[t.symbol]=t}return this.filterByArrayTickers(r,"symbol",e)}parseTicker(e,t=void 0){let i=[];Array.isArray(e)&&(i=e);let s={};for(let e=0;e<i.length;e++){const r=i[e];if(this.safeString(r,"code")===t.baseId){s=r;break}}return this.safeTicker({symbol:t.symbol,timestamp:void 0,datetime:void 0,high:this.safeNumber(s,"max_24h_price"),low:this.safeNumber(s,"min_24h_price"),bid:this.safeNumber(s,"price"),bidVolume:void 0,ask:this.safeNumber(s,"price"),askVolume:void 0,vwap:void 0,open:this.safeNumber(s,"price_at_in_last_24h"),close:this.safeNumber(s,"price"),last:this.safeNumber(s,"price"),previousClose:this.safeNumber(s,"price_at_in_last_24h"),change:void 0,percentage:this.safeNumber(s,"price_change_24h"),average:void 0,baseVolume:void 0,quoteVolume:void 0,info:s},t)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/"+this.implodeParams(e,s);const n=this.omit(s,this.extractParams(e));return Object.keys(n).length&&(o+="?"+this.urlencode(n)),{url:o,method:i,body:a,headers:{Accept:"application/json"}}}}},46022:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(65517),r=i(62079),a=i(51579),o=i(85147),n=i(37481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"zonda",name:"Zonda",countries:["EE"],rateLimit:1e3,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:void 0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchOrderBooks:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:void 0,fetchTransfer:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:void 0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"60","3m":"180","5m":"300","15m":"900","30m":"1800","1h":"3600","2h":"7200","4h":"14400","6h":"21600","12h":"43200","1d":"86400","3d":"259200","1w":"604800"},hostname:"zondacrypto.exchange",urls:{referral:"https://auth.zondaglobal.com/ref/jHlbB4mIkdS1",logo:"https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg",www:"https://zondaglobal.com",api:{public:"https://{hostname}/API/Public",private:"https://{hostname}/API/Trading/tradingApi.php",v1_01Public:"https://api.{hostname}/rest",v1_01Private:"https://api.{hostname}/rest"},doc:["https://docs.zondacrypto.exchange/","https://github.com/BitBayNet/API"],support:"https://zondaglobal.com/en/helpdesk/zonda-exchange",fees:"https://zondaglobal.com/legal/zonda-exchange/fees"},api:{public:{get:["{id}/all","{id}/market","{id}/orderbook","{id}/ticker","{id}/trades"]},private:{post:["info","trade","cancel","orderbook","orders","transfer","withdraw","history","transactions"]},v1_01Public:{get:["trading/ticker","trading/ticker/{symbol}","trading/stats","trading/stats/{symbol}","trading/orderbook/{symbol}","trading/transactions/{symbol}","trading/candle/history/{symbol}/{resolution}"]},v1_01Private:{get:["api_payments/deposits/crypto/addresses","payments/withdrawal/{detailId}","payments/deposit/{detailId}","trading/offer","trading/stop/offer","trading/config/{symbol}","trading/history/transactions","balances/BITBAY/history","balances/BITBAY/balance","fiat_cantor/rate/{baseId}/{quoteId}","fiat_cantor/history","client_payments/v2/customer/crypto/{currency}/channels/deposit","client_payments/v2/customer/crypto/{currency}/channels/withdrawal","client_payments/v2/customer/crypto/deposit/fee","client_payments/v2/customer/crypto/withdrawal/fee"],post:["trading/offer/{symbol}","trading/stop/offer/{symbol}","trading/config/{symbol}","balances/BITBAY/balance","balances/BITBAY/balance/transfer/{source}/{destination}","fiat_cantor/exchange","api_payments/withdrawals/crypto","api_payments/withdrawals/fiat","client_payments/v2/customer/crypto/deposit","client_payments/v2/customer/crypto/withdrawal"],delete:["trading/offer/{symbol}/{id}/{side}/{price}","trading/stop/offer/{symbol}/{id}/{side}/{price}"],put:["balances/BITBAY/balance/{id}"]}},fees:{trading:{maker:this.parseNumber("0.0"),taker:this.parseNumber("0.001"),percentage:!0,tierBased:!1},fiat:{maker:this.parseNumber("0.0030"),taker:this.parseNumber("0.0043"),percentage:!0,tierBased:!0,tiers:{taker:[[this.parseNumber("0.0043"),this.parseNumber("0")],[this.parseNumber("0.0042"),this.parseNumber("1250")],[this.parseNumber("0.0041"),this.parseNumber("3750")],[this.parseNumber("0.0040"),this.parseNumber("7500")],[this.parseNumber("0.0039"),this.parseNumber("10000")],[this.parseNumber("0.0038"),this.parseNumber("15000")],[this.parseNumber("0.0037"),this.parseNumber("20000")],[this.parseNumber("0.0036"),this.parseNumber("25000")],[this.parseNumber("0.0035"),this.parseNumber("37500")],[this.parseNumber("0.0034"),this.parseNumber("50000")],[this.parseNumber("0.0033"),this.parseNumber("75000")],[this.parseNumber("0.0032"),this.parseNumber("100000")],[this.parseNumber("0.0031"),this.parseNumber("150000")],[this.parseNumber("0.0030"),this.parseNumber("200000")],[this.parseNumber("0.0029"),this.parseNumber("250000")],[this.parseNumber("0.0028"),this.parseNumber("375000")],[this.parseNumber("0.0027"),this.parseNumber("500000")],[this.parseNumber("0.0026"),this.parseNumber("625000")],[this.parseNumber("0.0025"),this.parseNumber("875000")]],maker:[[this.parseNumber("0.0030"),this.parseNumber("0")],[this.parseNumber("0.0029"),this.parseNumber("1250")],[this.parseNumber("0.0028"),this.parseNumber("3750")],[this.parseNumber("0.0028"),this.parseNumber("7500")],[this.parseNumber("0.0027"),this.parseNumber("10000")],[this.parseNumber("0.0026"),this.parseNumber("15000")],[this.parseNumber("0.0025"),this.parseNumber("20000")],[this.parseNumber("0.0025"),this.parseNumber("25000")],[this.parseNumber("0.0024"),this.parseNumber("37500")],[this.parseNumber("0.0023"),this.parseNumber("50000")],[this.parseNumber("0.0023"),this.parseNumber("75000")],[this.parseNumber("0.0022"),this.parseNumber("100000")],[this.parseNumber("0.0021"),this.parseNumber("150000")],[this.parseNumber("0.0021"),this.parseNumber("200000")],[this.parseNumber("0.0020"),this.parseNumber("250000")],[this.parseNumber("0.0019"),this.parseNumber("375000")],[this.parseNumber("0.0018"),this.parseNumber("500000")],[this.parseNumber("0.0018"),this.parseNumber("625000")],[this.parseNumber("0.0017"),this.parseNumber("875000")]]}},funding:{withdraw:{}}},options:{fetchTickerMethod:"v1_01PublicGetTradingTickerSymbol",fetchTickersMethod:"v1_01PublicGetTradingTicker",fiatCurrencies:["EUR","USD","GBP","PLN"],transfer:{fillResponseFromRequest:!0}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerDirection:!1,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb,exceptions:{400:r.ExchangeError,401:r.InvalidOrder,402:r.InvalidOrder,403:r.InvalidOrder,404:r.InvalidOrder,405:r.InvalidOrder,406:r.InsufficientFunds,408:r.InvalidOrder,501:r.AuthenticationError,502:r.AuthenticationError,503:r.InvalidNonce,504:r.ExchangeError,505:r.AuthenticationError,506:r.AccountSuspended,509:r.ExchangeError,510:r.BadSymbol,FUNDS_NOT_SUFFICIENT:r.InsufficientFunds,OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS:r.InvalidOrder,OFFER_NOT_FOUND:r.OrderNotFound,OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED:r.OrderImmediatelyFillable,ACTION_LIMIT_EXCEEDED:r.RateLimitExceeded,UNDER_MAINTENANCE:r.OnMaintenance,REQUEST_TIMESTAMP_TOO_OLD:r.InvalidNonce,PERMISSIONS_NOT_SUFFICIENT:r.PermissionDenied,INVALID_STOP_RATE:r.InvalidOrder,TIMEOUT:r.ExchangeError,RESPONSE_TIMEOUT:r.ExchangeError,ACTION_BLOCKED:r.PermissionDenied,INVALID_HASH_SIGNATURE:r.AuthenticationError},commonCurrencies:{GGC:"Global Game Coin"}})}async fetchMarkets(e={}){const t=await this.v1_01PublicGetTradingTicker(e),i=this.safeValue(t,"items",{}),s=Object.values(i);return this.parseMarkets(s)}parseMarket(e){const t=this.safeValue(e,"market",{}),i=this.safeString(t,"code"),s=this.safeValue(t,"first",{}),r=this.safeValue(t,"second",{}),a=this.safeString(s,"currency"),o=this.safeString(r,"currency"),n=this.safeCurrencyCode(a),d=this.safeCurrencyCode(o);let h=this.safeValue(this.fees,"trading",{});const c=this.safeValue(this.options,"fiatCurrencies",[]);return(this.inArray(n,c)||this.inArray(d,c))&&(h=this.safeValue(this.fees,"fiat",{})),{id:i,symbol:n+"/"+d,base:n,quote:d,settle:void 0,baseId:a,quoteId:o,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(h,"taker"),maker:this.safeNumber(h,"maker"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,optionType:void 0,strike:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(s,"scale"))),price:this.parseNumber(this.parsePrecision(this.safeString(r,"scale")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(s,"minOffer"),max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=await this.v1_01PrivateGetTradingOffer(this.extend({},s)),a=this.safeList(r,"items",[]);return this.parseOrders(a,void 0,t,i,{status:"open"})}parseOrder(e,t=void 0){const i=this.safeString(e,"market"),s=this.safeSymbol(i,t,"-"),r=this.safeInteger(e,"time"),a=this.safeString(e,"startAmount"),o=this.safeString(e,"currentAmount"),n=this.safeValue(e,"postOnly");return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:void 0,info:e,timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,status:void 0,symbol:s,type:this.safeString(e,"mode"),timeInForce:void 0,postOnly:n,side:this.safeStringLower(e,"offerType"),price:this.safeString(e,"rate"),triggerPrice:void 0,amount:a,cost:void 0,filled:void 0,remaining:o,average:void 0,fee:void 0,trades:void 0},t)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};if(e){const t=[this.marketId(e)];e=this.symbol(e),r.markets=t}const a={query:this.json(this.extend(r,s))},o=await this.v1_01PrivateGetTradingHistoryTransactions(a),n=this.safeValue(o,"items"),d=this.parseTrades(n,void 0,t,i);return void 0===e?d:this.filterBySymbol(d,e)}parseBalance(e){const t=this.safeValue(e,"balances");if(void 0===t)throw new r.ExchangeError(this.id+" empty balance response "+this.json(e));const i={info:e};for(let e=0;e<t.length;e++){const s=t[e],r=this.safeString(s,"currency"),a=this.safeCurrencyCode(r),o=this.account();o.used=this.safeString(s,"lockedFunds"),o.free=this.safeString(s,"availableFunds"),i[a]=o}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1_01PrivateGetBalancesBITBAYBalance(e);return this.parseBalance(t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={symbol:s.id},a=await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(r,i)),o=this.safeValue(a,"buy",[]),n=this.safeValue(a,"sell",[]),d=this.safeInteger(a,"timestamp");return{symbol:s.symbol,bids:this.parseBidsAsks(o,"ra","ca"),asks:this.parseBidsAsks(n,"ra","ca"),timestamp:d,datetime:this.iso8601(d),nonce:this.safeInteger(a,"seqNo")}}parseTicker(e,t=void 0){const i=this.safeValue(e,"market"),s=this.safeString2(i,"code","m");t=this.safeMarket(s,t);const r=this.safeInteger(e,"time"),a=this.safeValue(e,"rate");return this.safeTicker({symbol:this.safeSymbol(s,t),timestamp:r,datetime:this.iso8601(r),high:this.safeString(e,"h"),low:this.safeString(e,"l"),bid:this.safeNumber(e,"highestBid"),bidVolume:void 0,ask:this.safeNumber(e,"lowestAsk"),askVolume:void 0,vwap:void 0,open:this.safeString(e,"r24h"),close:a,last:a,previousClose:this.safeValue(e,"previousRate"),change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"v"),quoteVolume:void 0,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},a="v1_01PublicGetTradingTickerSymbol",o=this.safeString(this.options,"fetchTickerMethod",a),n=this.safeString2(t,"method","fetchTickerMethod",o);let d;if(n===a)d=await this.v1_01PublicGetTradingTickerSymbol(this.extend(s,t));else{if("v1_01PublicGetTradingStatsSymbol"!==n)throw new r.BadRequest(this.id+' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');d=await this.v1_01PublicGetTradingStatsSymbol(this.extend(s,t))}const h=this.safeValue2(d,"ticker","stats");return this.parseTicker(h,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i="v1_01PublicGetTradingTicker",s=this.safeString(this.options,"fetchTickersMethod",i),a=this.safeString2(t,"method","fetchTickersMethod",s);let o;if(a===i)o=await this.v1_01PublicGetTradingTicker(t);else{if("v1_01PublicGetTradingStats"!==a)throw new r.BadRequest(this.id+' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');o=await this.v1_01PublicGetTradingStats(t)}const n=this.safeDict(o,"items");return this.parseTickers(n,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r=[];if(void 0!==e){const t=this.currency(e);r.push(t.id)}let a={balanceCurrencies:r};void 0!==t&&(a.fromTime=t),void 0!==i&&(a.limit=i),a=this.extend(a,s);const o=(await this.v1_01PrivateGetBalancesBITBAYHistory({query:this.json(a)})).items;return this.parseLedger(o,void 0,t,i)}parseLedgerEntry(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeValue(e,"balance",{}),r=this.safeString(s,"currency");t=this.safeCurrency(r,t);const a=this.safeValue(e,"change",{});let n=this.safeString(a,"total"),d="in";o.Y.stringLt(n,"0")&&(d="out",n=o.Y.stringNeg(n));const h=this.safeValue(e,"fundsBefore",{}),c=this.safeValue(e,"fundsAfter",{});return this.safeLedgerEntry({info:e,id:this.safeString(e,"historyId"),direction:d,account:void 0,referenceId:this.safeString(e,"detailId"),referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:this.safeCurrencyCode(r),amount:this.parseNumber(n),before:this.safeNumber(h,"total"),after:this.safeNumber(c,"total"),status:"ok",timestamp:i,datetime:this.iso8601(i),fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({ADD_FUNDS:"transaction",BITCOIN_GOLD_FORK:"transaction",CREATE_BALANCE:"transaction",FUNDS_MIGRATION:"transaction",WITHDRAWAL_LOCK_FUNDS:"transaction",WITHDRAWAL_SUBTRACT_FUNDS:"transaction",WITHDRAWAL_UNLOCK_FUNDS:"transaction",TRANSACTION_COMMISSION_OUTCOME:"fee",TRANSACTION_COMMISSION_RETURN:"fee",TRANSACTION_OFFER_ABORTED_RETURN:"trade",TRANSACTION_OFFER_COMPLETED_RETURN:"trade",TRANSACTION_POST_INCOME:"trade",TRANSACTION_POST_OUTCOME:"trade",TRANSACTION_PRE_LOCKING:"trade"},e,e)}parseOHLCV(e,t=void 0){const i=this.safeValue(e,1,{});return[this.safeInteger(e,0),this.safeNumber(i,"o"),this.safeNumber(i,"h"),this.safeNumber(i,"l"),this.safeNumber(i,"c"),this.safeNumber(i,"v")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={symbol:a.baseId+"-"+a.quoteId,resolution:this.safeString(this.timeframes,t,t)},n=(s=void 0===s?100:Math.min(s,11e3))*this.parseTimeframe(t)*1e3;void 0===i?(o.to=this.milliseconds(),o.from=o.to-n):(o.from=i,o.to=this.sum(o.from,n));const d=await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(o,r)),h=this.safeList(d,"items",[]);return this.parseOHLCVs(h,a,t,i,s)}parseTrade(e,t=void 0){const i=this.safeInteger2(e,"time","t"),s=this.safeStringLower2(e,"userAction","ty"),r=this.safeValue(e,"wasTaker");let a;void 0!==r&&(a=r?"taker":"maker");const o=this.safeString2(e,"rate","r"),n=this.safeString2(e,"amount","a"),d=this.safeString(e,"commissionValue"),h=this.safeString(e,"market"),c=(t=this.safeMarket(h,t,"-")).symbol;let l;if(void 0!==d){l={currency:"buy"===s?t.base:t.quote,cost:d}}const u=this.safeString(e,"offerId");let f;return void 0!==u&&(f=u?"limit":"market"),this.safeTrade({id:this.safeString(e,"id"),order:u,timestamp:i,datetime:this.iso8601(i),symbol:c,type:f,side:s,price:o,amount:n,cost:void 0,takerOrMaker:a,fee:l,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.baseId+"-"+r.quoteId};void 0!==t&&(a.fromTime=t-1),void 0!==i&&(a.limit=i);const o=await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(a,s)),n=this.safeList(o,"items");return this.parseTrades(n,r,t,i)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d=n.baseId+"-"+n.quoteId;s=parseFloat(this.amountToPrecision(e,s));const h={symbol:d,offerType:i.toUpperCase(),amount:s},c=this.safeValue2(o,"stopPrice","stopLossPrice"),l=void 0!==c,u="limit"===t,f="market"===t,p="stop-limit"===t||u&&l,m="stop-market"===t||f&&l,g=p||m;if(u||p)h.rate=this.priceToPrecision(e,a),h.mode=p?"stop-limit":"limit";else{if(!f&&!m)throw new r.ExchangeError(this.id+" createOrder() invalid type");h.mode=m?"stop-market":"market"}let v;if(o=this.omit(o,["stopPrice","stopLossPrice"]),g){if(!l)throw new r.ExchangeError(this.id+" createOrder() zonda requires `triggerPrice` parameter for stop-limit or stop-market orders");h.stopRate=this.priceToPrecision(e,c),v=await this.v1_01PrivatePostTradingStopOfferSymbol(this.extend(h,o))}else v=await this.v1_01PrivatePostTradingOfferSymbol(this.extend(h,o));const y=this.safeString2(v,"offerId","stopOfferId"),b=this.safeBool(v,"completed",!1)?"closed":"open",w=this.safeValue(v,"transactions");return this.safeOrder({id:y,info:v,timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,status:b,symbol:e,type:t,side:i,price:a,amount:s,cost:void 0,filled:void 0,remaining:void 0,average:void 0,fee:void 0,trades:w,clientOrderId:void 0})}async cancelOrder(e,t=void 0,i={}){const s=this.safeString(i,"side");if(void 0===s)throw new r.ExchangeError(this.id+' cancelOrder() requires a `side` parameter ("buy" or "sell")');const a=this.safeValue(i,"price");if(void 0===a)throw new r.ExchangeError(this.id+" cancelOrder() requires a `price` parameter (float or string)");await this.loadMarkets();const o=this.market(t),n={symbol:o.baseId+"-"+o.quoteId,id:e,side:s,price:a},d=await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(n,i));return this.parseOrder(d)}isFiat(e){return this.safeBool({USD:!0,EUR:!0,PLN:!0},e,!1)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"currency"),s=this.safeString(e,"address");return this.checkAddress(s),{info:e,currency:this.safeCurrencyCode(i,t),network:void 0,address:s,tag:this.safeString(e,"tag")}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={currency:i.id},r=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(s,t)),a=this.safeValue(r,"data"),o=this.safeDict(a,0);return this.parseDepositAddress(o,i)}async fetchDepositAddresses(e=void 0,t={}){await this.loadMarkets();const i=await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(t),s=this.safeList(i,"data");return this.parseDepositAddresses(s,e)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o={source:i,destination:s,currency:e,funds:this.currencyToPrecision(e,t)},n=await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(o,r)),d=this.parseTransfer(n,a),h=this.safeValue(this.options,"transfer",{});return this.safeBool(h,"fillResponseFromRequest",!0)&&(d.amount=t),d}parseTransfer(e,t=void 0){const i=this.safeString(e,"status"),s=this.safeValue(e,"from",{}),r=this.safeString(s,"id"),a=this.safeValue(e,"to",{}),o=this.safeString(a,"id"),n=this.safeString(s,"currency");return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(n,t),amount:void 0,fromAccount:r,toAccount:o,status:this.parseTransferStatus(i)}}parseTransferStatus(e){return this.safeString({Ok:"ok",Fail:"failed"},e,e)}async withdraw(e,t,i,s=void 0,r={}){let a;[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const o=this.currency(e),n={currency:o.id,amount:t,address:i};this.isFiat(e)?a=await this.v1_01PrivatePostApiPaymentsWithdrawalsFiat(this.extend(n,r)):(void 0!==s&&(n.tag=s),a=await this.v1_01PrivatePostApiPaymentsWithdrawalsCrypto(this.extend(n,r)));const d=this.safeDict(a,"data");return this.parseTransaction(d,o)}parseTransaction(e,t=void 0){return t=this.safeCurrency(void 0,t),{id:this.safeString(e,"id"),txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:t.code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:void 0,info:e}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.implodeHostname(this.urls.api[t]);if("public"===t){const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s)+".json",Object.keys(t).length&&(o+="?"+this.urlencode(t))}else if("v1_01Public"===t){const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s),Object.keys(t).length&&(o+="?"+this.urlencode(t))}else if("v1_01Private"===t){this.checkRequiredCredentials();const t=this.omit(s,this.extractParams(e));o+="/"+this.implodeParams(e,s);const d=this.milliseconds().toString();let h;"POST"!==i?(Object.keys(t).length&&(o+="?"+this.urlencode(t)),h=this.apiKey+d):void 0===a&&(a=this.json(t),h=this.apiKey+d+a),r={"Request-Timestamp":d,"Operation-Id":this.uuid(),"API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(h),this.encode(this.secret),n.Zf),"Content-Type":"application/json"}}else this.checkRequiredCredentials(),a=this.urlencode(this.extend({method:e,moment:this.nonce()},s)),r={"Content-Type":"application/x-www-form-urlencoded","API-Key":this.apiKey,"API-Hash":this.hmac(this.encode(a),this.encode(this.secret),n.Zf)};return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0!==n){if("code"in n){const e=this.safeString(n,"code"),t=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions,e,t),new r.ExchangeError(t)}if("status"in n){if("Fail"===this.safeString(n,"status")){const e=this.safeValue(n,"errors"),t=this.id+" "+o;for(let i=0;i<e.length;i++){const s=e[i];this.throwExactlyMatchedException(this.exceptions,s,t)}throw new r.ExchangeError(t)}}}}}},51591:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},43544:e=>{var t=String.prototype.replace,i=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return t.call(e,i,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},64580:(e,t,i)=>{var s=i(71603),r=i(43437),a=i(43544);e.exports={formats:a,parse:r,stringify:s}},43437:(e,t,i)=>{var s=i(83247),r=Object.prototype.hasOwnProperty,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:s.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},o=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},n=function(e,t,i){if(e){var s=i.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,o=/(\[[^[\]]*])/.exec(s),n=o?s.slice(0,o.index):s,d=[];if(n){if(!i.plainObjects&&r.call(Object.prototype,n)&&!i.allowPrototypes)return;d.push(n)}for(var h=0;null!==(o=a.exec(s))&&h<i.depth;){if(h+=1,!i.plainObjects&&r.call(Object.prototype,o[1].slice(1,-1))&&!i.allowPrototypes)return;d.push(o[1])}return o&&d.push("["+s.slice(o.index)+"]"),function(e,t,i){for(var s=t,r=e.length-1;r>=0;--r){var a,o=e[r];if("[]"===o&&i.parseArrays)a=[].concat(s);else{a=i.plainObjects?Object.create(null):{};var n="["===o.charAt(0)&&"]"===o.charAt(o.length-1)?o.slice(1,-1):o,d=parseInt(n,10);i.parseArrays||""!==n?!isNaN(d)&&o!==n&&String(d)===n&&d>=0&&i.parseArrays&&d<=i.arrayLimit?(a=[])[d]=s:a[n]=s:a={0:s}}s=a}return s}(d,t,i)}};e.exports=function(e,t){var i=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||s.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth?e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return i.plainObjects?Object.create(null):{};for(var d="string"==typeof e?function(e,t){var i,n={},d=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,h=t.parameterLimit===1/0?void 0:t.parameterLimit,c=d.split(t.delimiter,h),l=-1,u=t.charset;if(t.charsetSentinel)for(i=0;i<c.length;++i)0===c[i].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[i]?u="utf-8":"utf8=%26%2310003%3B"===c[i]&&(u="iso-8859-1"),l=i,i=c.length);for(i=0;i<c.length;++i)if(i!==l){var f,p,m=c[i],g=m.indexOf("]="),v=-1===g?m.indexOf("="):g+1;-1===v?(f=t.decoder(m,a.decoder,u),p=t.strictNullHandling?null:""):(f=t.decoder(m.slice(0,v),a.decoder,u),p=t.decoder(m.slice(v+1),a.decoder,u)),p&&t.interpretNumericEntities&&"iso-8859-1"===u&&(p=o(p)),p&&t.comma&&p.indexOf(",")>-1&&(p=p.split(",")),r.call(n,f)?n[f]=s.combine(n[f],p):n[f]=p}return n}(e,i):e,h=i.plainObjects?Object.create(null):{},c=Object.keys(d),l=0;l<c.length;++l){var u=c[l],f=n(u,d[u],i);h=s.merge(h,f,i)}return s.compact(h)}},71603:(e,t,i)=>{var s=i(83247),r=i(43544),a=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},n=Array.isArray,d=Array.prototype.push,h=function(e,t){d.apply(e,n(t)?t:[t])},c=Date.prototype.toISOString,l={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:s.encode,encodeValuesOnly:!1,formatter:r.formatters[r.default],indices:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},u=function e(t,i,r,a,o,d,c,u,f,p,m,g,v){var y=t;if("function"==typeof c?y=c(i,y):y instanceof Date?y=p(y):"comma"===r&&n(y)&&(y=y.join(",")),null===y){if(a)return d&&!g?d(i,l.encoder,v):i;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||s.isBuffer(y))return d?[m(g?i:d(i,l.encoder,v))+"="+m(d(y,l.encoder,v))]:[m(i)+"="+m(String(y))];var b,w=[];if(void 0===y)return w;if(n(c))b=c;else{var k=Object.keys(y);b=u?k.sort(u):k}for(var S=0;S<b.length;++S){var O=b[S];o&&null===y[O]||(n(y)?h(w,e(y[O],"function"==typeof r?r(i,O):i,r,a,o,d,c,u,f,p,m,g,v)):h(w,e(y[O],i+(f?"."+O:"["+O+"]"),r,a,o,d,c,u,f,p,m,g,v)))}return w};e.exports=function(e,t){var i,s=e,d=function(e){if(!e)return l;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||l.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=r.default;if(void 0!==e.format){if(!a.call(r.formatters,e.format))throw new TypeError("Unknown format option provided.");i=e.format}var s=r.formatters[i],o=l.filter;return("function"==typeof e.filter||n(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:l.addQueryPrefix,allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,delimiter:void 0===e.delimiter?l.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:l.encode,encoder:"function"==typeof e.encoder?e.encoder:l.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:l.encodeValuesOnly,filter:o,formatter:s,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:l.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:l.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling}}(t);"function"==typeof d.filter?s=(0,d.filter)("",s):n(d.filter)&&(i=d.filter);var c,f=[];if("object"!=typeof s||null===s)return"";c=t&&t.arrayFormat in o?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=o[c];i||(i=Object.keys(s)),d.sort&&i.sort(d.sort);for(var m=0;m<i.length;++m){var g=i[m];d.skipNulls&&null===s[g]||h(f,u(s[g],g,p,d.strictNullHandling,d.skipNulls,d.encode?d.encoder:null,d.filter,d.sort,d.allowDots,d.serializeDate,d.formatter,d.encodeValuesOnly,d.charset))}var v=f.join(d.delimiter),y=!0===d.addQueryPrefix?"?":"";return d.charsetSentinel&&("iso-8859-1"===d.charset?y+="utf8=%26%2310003%3B&":y+="utf8=%E2%9C%93&"),v.length>0?y+v:""}},83247:e=>{var t=Object.prototype.hasOwnProperty,i=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),r=function(e,t){for(var i=t&&t.plainObjects?Object.create(null):{},s=0;s<e.length;++s)void 0!==e[s]&&(i[s]=e[s]);return i};e.exports={arrayToObject:r,assign:function(e,t){return Object.keys(t).reduce((function(e,i){return e[i]=t[i],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],s=[],r=0;r<t.length;++r)for(var a=t[r],o=a.obj[a.prop],n=Object.keys(o),d=0;d<n.length;++d){var h=n[d],c=o[h];"object"==typeof c&&null!==c&&-1===s.indexOf(c)&&(t.push({obj:o,prop:h}),s.push(c))}return function(e){for(;e.length>1;){var t=e.pop(),s=t.obj[t.prop];if(i(s)){for(var r=[],a=0;a<s.length;++a)void 0!==s[a]&&r.push(s[a]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,i){var s=e.replace(/\+/g," ");if("iso-8859-1"===i)return s.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(s)}catch(e){return s}},encode:function(e,t,i){if(0===e.length)return e;var r="string"==typeof e?e:String(e);if("iso-8859-1"===i)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var a="",o=0;o<r.length;++o){var n=r.charCodeAt(o);45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?a+=r.charAt(o):n<128?a+=s[n]:n<2048?a+=s[192|n>>6]+s[128|63&n]:n<55296||n>=57344?a+=s[224|n>>12]+s[128|n>>6&63]+s[128|63&n]:(o+=1,n=65536+((1023&n)<<10|1023&r.charCodeAt(o)),a+=s[240|n>>18]+s[128|n>>12&63]+s[128|n>>6&63]+s[128|63&n])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(s,a,o){if(!a)return s;if("object"!=typeof a){if(i(s))s.push(a);else{if(!s||"object"!=typeof s)return[s,a];(o&&(o.plainObjects||o.allowPrototypes)||!t.call(Object.prototype,a))&&(s[a]=!0)}return s}if(!s||"object"!=typeof s)return[s].concat(a);var n=s;return i(s)&&!i(a)&&(n=r(s,o)),i(s)&&i(a)?(a.forEach((function(i,r){if(t.call(s,r)){var a=s[r];a&&"object"==typeof a&&i&&"object"==typeof i?s[r]=e(a,i,o):s.push(i)}else s[r]=i})),s):Object.keys(a).reduce((function(i,s){var r=a[s];return t.call(i,s)?i[s]=e(i[s],r,o):i[s]=r,i}),n)}}},64350:(e,t,i)=>{i.d(t,{HM:()=>L,Wt:()=>R});var s=Uint8Array,r=Uint16Array,a=Uint32Array,o=new s([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),n=new s([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),d=new s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=function(e,t){for(var i=new r(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var o=new a(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)o[n]=n-i[s]<<5|s;return[i,o]},c=h(o,2),l=c[0],u=c[1];l[28]=258,u[258]=28;for(var f=h(n,0),p=f[0],m=(f[1],new r(32768)),g=0;g<32768;++g){var v=(43690&g)>>>1|(21845&g)<<1;v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4,m[g]=((65280&v)>>>8|(255&v)<<8)>>>1}var y=function(e,t,i){for(var s=e.length,a=0,o=new r(t);a<s;++a)e[a]&&++o[e[a]-1];var n,d=new r(t);for(a=0;a<t;++a)d[a]=d[a-1]+o[a-1]<<1;if(i){n=new r(1<<t);var h=15-t;for(a=0;a<s;++a)if(e[a])for(var c=a<<4|e[a],l=t-e[a],u=d[e[a]-1]++<<l,f=u|(1<<l)-1;u<=f;++u)n[m[u]>>>h]=c}else for(n=new r(s),a=0;a<s;++a)e[a]&&(n[a]=m[d[e[a]-1]++]>>>15-e[a]);return n},b=new s(288);for(g=0;g<144;++g)b[g]=8;for(g=144;g<256;++g)b[g]=9;for(g=256;g<280;++g)b[g]=7;for(g=280;g<288;++g)b[g]=8;var w=new s(32);for(g=0;g<32;++g)w[g]=5;var k=y(b,9,1),S=y(w,5,1),O=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},T=function(e,t,i){var s=t/8|0;return(e[s]|e[s+1]<<8)>>(7&t)&i},P=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},M=function(e){return(e+7)/8|0},I=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var o=new(2==e.BYTES_PER_ELEMENT?r:4==e.BYTES_PER_ELEMENT?a:s)(i-t);return o.set(e.subarray(t,i)),o},x=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],A=function(e,t,i){var s=new Error(t||x[e]);if(s.code=e,Error.captureStackTrace&&Error.captureStackTrace(s,A),!i)throw s;return s},C=function(e,t,i){var r=e.length;if(!r||i&&i.f&&!i.l)return t||new s(0);var a=!t||i,h=!i||i.i;i||(i={}),t||(t=new s(3*r));var c=function(e){var i=t.length;if(e>i){var r=new s(Math.max(2*i,e));r.set(t),t=r}},u=i.f||0,f=i.p||0,m=i.b||0,g=i.l,v=i.d,b=i.m,w=i.n,x=8*r;do{if(!g){u=T(e,f,1);var C=T(e,f+1,3);if(f+=3,!C){var _=e[(G=M(f)+4)-4]|e[G-3]<<8,B=G+_;if(B>r){h&&A(0);break}a&&c(m+_),t.set(e.subarray(G,B),m),i.b=m+=_,i.p=f=8*B,i.f=u;continue}if(1==C)g=k,v=S,b=9,w=5;else if(2==C){var E=T(e,f,31)+257,L=T(e,f+10,15)+4,R=E+T(e,f+5,31)+1;f+=14;for(var N=new s(R),D=new s(19),q=0;q<L;++q)D[d[q]]=T(e,f+3*q,7);f+=3*L;var V=O(D),F=(1<<V)-1,H=y(D,V,1);for(q=0;q<R;){var G,U=H[T(e,f,F)];if(f+=15&U,(G=U>>>4)<16)N[q++]=G;else{var W=0,j=0;for(16==G?(j=3+T(e,f,3),f+=2,W=N[q-1]):17==G?(j=3+T(e,f,7),f+=3):18==G&&(j=11+T(e,f,127),f+=7);j--;)N[q++]=W}}var z=N.subarray(0,E),K=N.subarray(E);b=O(z),w=O(K),g=y(z,b,1),v=y(K,w,1)}else A(1);if(f>x){h&&A(0);break}}a&&c(m+131072);for(var Y=(1<<b)-1,X=(1<<w)-1,Q=f;;Q=f){var Z=(W=g[P(e,f)&Y])>>>4;if((f+=15&W)>x){h&&A(0);break}if(W||A(2),Z<256)t[m++]=Z;else{if(256==Z){Q=f,g=null;break}var $=Z-254;if(Z>264){var J=o[q=Z-257];$=T(e,f,(1<<J)-1)+l[q],f+=J}var ee=v[P(e,f)&X],te=ee>>>4;ee||A(3),f+=15ⅇK=p[te];if(te>3){J=n[te];K+=P(e,f)&(1<<J)-1,f+=J}if(f>x){h&&A(0);break}a&&c(m+131072);for(var ie=m+$;m<ie;m+=4)t[m]=t[m-K],t[m+1]=t[m+1-K],t[m+2]=t[m+2-K],t[m+3]=t[m+3-K];m=ie}}i.l=g,i.p=Q,i.b=m,i.f=u,g&&(u=1,i.m=b,i.d=v,i.n=w)}while(!u);return m==t.length?t:I(t,0,m)},_=new s(0),B=function(e){31==e[0]&&139==e[1]&&8==e[2]||A(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=e[10]|2+(e[11]<<8));for(var s=(t>>3&1)+(t>>4&1);s>0;s-=!e[i++]);return i+(2&t)},E=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0};function L(e,t=void 0){return C(e,t)}function R(e,t=void 0){return C(e.subarray(B(e),-8),t||new s(E(e)))}var N="undefined"!=typeof TextDecoder&&new TextDecoder;try{N.decode(_,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout},56378:(e,t,i)=>{i.d(t,{b:()=>s});
|
|
27
27
|
/*!
|
|
28
28
|
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
|
|
29
29
|
Code licensed under the BSD License:
|
|
30
30
|
http://developer.yahoo.com/yui/license.html
|
|
31
31
|
version: 2.9.0
|
|
32
32
|
*/
|
|
33
|
-
var s={};s.lang={extend:function(e,t,i){if(!t||!e)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var s=function(){};if(s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t),i){var r;for(r in i)e.prototype[r]=i[r];var a=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(a=function(e,t){for(r=0;r<o.length;r+=1){var i=o[r],s=t[i];"function"==typeof s&&s!=Object.prototype[i]&&(e[i]=s)}})}catch(e){}a(e.prototype,i)}}}},40917:(e,t,i)=>{function s(e,t){if(t&&t.multiple&&!Array.isArray(e))throw new Error("Invalid argument type: Expected an Array to serialize multiple values.");const i=4294967296;let s,r,a=new Uint8Array(128),o=0;if(t&&t.multiple)for(let t=0;t<e.length;t++)n(e[t]);else n(e);return a.subarray(0,o);function n(e,a){switch(typeof e){case"undefined":d(e);break;case"boolean":!function(e){c(e?195:194)}(e);break;case"number":!function(e){if(isFinite(e)&&Math.floor(e)===e)if(e>=0&&e<=127)c(e);else if(e<0&&e>=-32)c(e);else if(e>0&&e<=255)l([204,e]);else if(e>=-128&&e<=127)l([208,e]);else if(e>0&&e<=65535)l([205,e>>>8,e]);else if(e>=-32768&&e<=32767)l([209,e>>>8,e]);else if(e>0&&e<=4294967295)l([206,e>>>24,e>>>16,e>>>8,e]);else if(e>=-2147483648&&e<=2147483647)l([210,e>>>24,e>>>16,e>>>8,e]);else if(e>0&&e<=0x10000000000000000){let t=e/i,s=e%i;l([207,t>>>24,t>>>16,t>>>8,t,s>>>24,s>>>16,s>>>8,s])}else e>=-0x8000000000000000&&e<=0x8000000000000000?(c(211),u(e)):l(e<0?[211,128,0,0,0,0,0,0,0]:[207,255,255,255,255,255,255,255,255]);else r||(s=new ArrayBuffer(8),r=new DataView(s)),r.setFloat64(0,e),c(203),l(new Uint8Array(s))}(e);break;case"string":!function(e){let t=function(e){let t=!0,i=e.length;for(let s=0;s<i;s++)if(e.charCodeAt(s)>127){t=!1;break}let s=0,r=new Uint8Array(e.length*(t?1:4));for(let t=0;t!==i;t++){let a=e.charCodeAt(t);if(a<128)r[s++]=a;else{if(a<2048)r[s++]=a>>6|192;else{if(a>55295&&a<56320){if(++t>=i)throw new Error("UTF-8 encode: incomplete surrogate pair");let o=e.charCodeAt(t);if(o<56320||o>57343)throw new Error("UTF-8 encode: second surrogate character 0x"+o.toString(16)+" at index "+t+" out of range");a=65536+((1023&a)<<10)+(1023&o),r[s++]=a>>18|240,r[s++]=a>>12&63|128}else r[s++]=a>>12|224;r[s++]=a>>6&63|128}r[s++]=63&a|128}}return t?r:r.subarray(0,s)}(e),i=t.length;i<=31?c(160+i):l(i<=255?[217,i]:i<=65535?[218,i>>>8,i]:[219,i>>>24,i>>>16,i>>>8,i]);l(t)}(e);break;case"object":null===e?d(e):e instanceof Date?function(e){let t=e.getTime()/1e3;if(0===e.getMilliseconds()&&t>=0&&t<4294967296)l([214,255,t>>>24,t>>>16,t>>>8,t]);else if(t>=0&&t<17179869184){let s=1e6*e.getMilliseconds();l([215,255,s>>>22,s>>>14,s>>>6,s<<2>>>0|t/i,t>>>24,t>>>16,t>>>8,t])}else{let i=1e6*e.getMilliseconds();l([199,12,255,i>>>24,i>>>16,i>>>8,i]),u(t)}}(e):Array.isArray(e)?h(e):e instanceof Uint8Array||e instanceof Uint8ClampedArray?function(e){let t=e.length;l(t<=15?[196,t]:t<=65535?[197,t>>>8,t]:[198,t>>>24,t>>>16,t>>>8,t]);l(e)}(e):e instanceof Int8Array||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array?h(e):function(e){let t=0;for(let i in e)void 0!==e[i]&&t++;t<=15?c(128+t):l(t<=65535?[222,t>>>8,t]:[223,t>>>24,t>>>16,t>>>8,t]);for(let t in e){let i=e[t];void 0!==i&&(n(t),n(i))}}(e);break;default:if(a||!t||!t.invalidTypeReplacement)throw new Error("Invalid argument type: The type '"+typeof e+"' cannot be serialized.");"function"==typeof t.invalidTypeReplacement?n(t.invalidTypeReplacement(e),!0):n(t.invalidTypeReplacement,!0)}}function d(e){c(192)}function h(e){let t=e.length;t<=15?c(144+t):l(t<=65535?[220,t>>>8,t]:[221,t>>>24,t>>>16,t>>>8,t]);for(let i=0;i<t;i++)n(e[i])}function c(e){if(a.length<o+1){let e=2*a.length;for(;e<o+1;)e*=2;let t=new Uint8Array(e);t.set(a),a=t}a[o]=e,o++}function l(e){if(a.length<o+e.length){let t=2*a.length;for(;t<o+e.length;)t*=2;let i=new Uint8Array(t);i.set(a),a=i}a.set(e,o),o+=e.length}function u(e){let t,s;e>=0?(t=e/i,s=e%i):(e++,t=Math.abs(e)/i,s=Math.abs(e)%i,t=~t,s=~s),l([t>>>24,t>>>16,t>>>8,t,s>>>24,s>>>16,s>>>8,s])}}i.d(t,{l:()=>s})},47661:(e,t,i)=>{let s;i.d(t,{$s:()=>I,Ay:()=>ge,H3:()=>oe,JF:()=>_,KR:()=>F,qj:()=>C});const r=new Array(128).fill(void 0);function a(e){return r[e]}r.push(void 0,null,!0,!1);let o=r.length;function n(e){const t=a(e);return function(e){e<132||(r[e]=o,o=e)}(e),t}function d(e){o===r.length&&r.push(r.length+1);const t=o;return o=r[t],r[t]=e,t}const h="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&h.decode();let c=null;function l(){return null!==c&&0!==c.byteLength||(c=new Uint8Array(s.memory.buffer)),c}function u(e,t){return e>>>=0,h.decode(l().subarray(e,e+t))}function f(e){return null==e}let p=null;let m=null;function g(){return null!==m&&0!==m.byteLength||(m=new Int32Array(s.memory.buffer)),m}let v=0;const y="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},b="function"==typeof y.encodeInto?function(e,t){return y.encodeInto(e,t)}:function(e,t){const i=y.encode(e);return t.set(i),{read:e.length,written:i.length}};function w(e,t,i){if(void 0===i){const i=y.encode(e),s=t(i.length,1)>>>0;return l().subarray(s,s+i.length).set(i),v=i.length,s}let s=e.length,r=t(s,1)>>>0;const a=l();let o=0;for(;o<s;o++){const t=e.charCodeAt(o);if(t>127)break;a[r+o]=t}if(o!==s){0!==o&&(e=e.slice(o)),r=i(r,s,s=o+3*e.length,1)>>>0;const t=l().subarray(r+o,r+s);o+=b(e,t).written,r=i(r,s,o,1)>>>0}return v=o,r}let k=null;function S(e){const t=typeof e;if("number"==t||"boolean"==t||null==e)return`${e}`;if("string"==t)return`"${e}"`;if("symbol"==t){const t=e.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=e.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(e)){const t=e.length;let i="[";t>0&&(i+=S(e[0]));for(let s=1;s<t;s++)i+=", "+S(e[s]);return i+="]",i}const i=/\[object ([^\]]+)\]/.exec(toString.call(e));let s;if(!(i.length>1))return toString.call(e);if(s=i[1],"Object"==s)try{return"Object("+JSON.stringify(e)+")"}catch(e){return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:s}const O="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>{s.__wbindgen_export_2.get(e.dtor)(e.a,e.b)}));function T(e,t,i,r){const a={a:e,b:t,cnt:1,dtor:i},o=(...e)=>{a.cnt++;const t=a.a;a.a=0;try{return r(t,a.b,...e)}finally{0==--a.cnt?(s.__wbindgen_export_2.get(a.dtor)(t,a.b),O.unregister(a)):a.a=t}};return o.original=a,O.register(o,a,a),o}function P(e,t){s.__wbindgen_export_3(e,t)}function M(e,t,i){s.__wbindgen_export_4(e,t,d(i))}function I(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16);s.newRpcSignerWithProvider(r,d(e));var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return Q.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}function x(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`);return e.ptr}let A=null;function C(e){x(e,oe);var t=e.__destroy_into_raw();const i=s.newTransfer(t);return re.__wrap(i)}function _(e){x(e,F);var t=e.__destroy_into_raw();const i=s.newContract(t);return q.__wrap(i)}function B(e,t){try{return e.apply(this,t)}catch(e){s.__wbindgen_export_6(d(e))}}Object.freeze({Success:0,0:"Success",Failed:1,1:"Failed",Pending:2,2:"Pending"}),Object.freeze({OnChain:0,0:"OnChain",EthECDSA:1,1:"EthECDSA",EthCREATE2:2,2:"EthCREATE2"}),Object.freeze({Eth:0,0:"Eth",Eip1271:1,1:"Eip1271",Stark:2,2:"Stark"}),Object.freeze({Deposit:1,1:"Deposit",FullExit:5,5:"FullExit",ChangePubKey:6,6:"ChangePubKey",Transfer:4,4:"Transfer",Withdraw:3,3:"Withdraw",ForcedExit:7,7:"ForcedExit",OrderMatching:8,8:"OrderMatching",AutoDeleveraging:11,11:"AutoDeleveraging",ContractMatching:9,9:"ContractMatching",Funding:13,13:"Funding",Liquidation:10,10:"Liquidation",UpdateGlobalVar:12,12:"UpdateGlobalVar"}),Object.freeze({Latest:0,0:"Latest",Finalized:1,1:"Finalized",Safe:2,2:"Safe",Earliest:3,3:"Earliest",Pending:4,4:"Pending",Number:5,5:"Number"}),Object.freeze({FeeAccount:0,0:"FeeAccount",InsuranceFundAccount:1,1:"InsuranceFundAccount",MarginInfo:2,2:"MarginInfo",FundingInfos:3,3:"FundingInfos",ContractInfo:4,4:"ContractInfo"}),Object.freeze({AccountId:0,0:"AccountId",Address:1,1:"Address"}),"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_accountquery_free(e>>>0)));const E="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_autodeleveraging_free(e>>>0)));class L{static __wrap(e){e>>>=0;const t=Object.create(L.prototype);return t.__wbg_ptr=e,E.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,E.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_autodeleveraging_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.autodeleveraging_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.autodeleveraging_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_autodeleveragingbuilder_free(e>>>0)));const R="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_changepubkey_free(e>>>0)));class N{static __wrap(e){e>>>=0;const t=Object.create(N.prototype);return t.__wbg_ptr=e,R.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,R.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_changepubkey_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.changepubkey_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getChangePubkeyMessage(e,t){let i,r;try{const f=s.__wbindgen_add_to_stack_pointer(-16),p=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),m=v;s.changepubkey_getChangePubkeyMessage(f,this.__wbg_ptr,e,p,m);var a=g()[f/4+0],o=g()[f/4+1],d=g()[f/4+2],h=g()[f/4+3],c=a,l=o;if(h)throw c=0,l=0,n(d);return i=c,r=l,u(c,l)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(i,r,1)}}getEthSignMsg(e,t){let i,r;try{const n=s.__wbindgen_add_to_stack_pointer(-16);s.changepubkey_getEthSignMsg(n,this.__wbg_ptr,e,t);var a=g()[n/4+0],o=g()[n/4+1];return i=a,r=o,u(a,o)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(i,r,1)}}setEthAuthData(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.changepubkey_setEthAuthData(r,this.__wbg_ptr,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return n(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.changepubkey_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_changepubkeybuilder_free(e>>>0)));const D="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contract_free(e>>>0)));class q{static __wrap(e){e>>>=0;const t=Object.create(q.prototype);return t.__wbg_ptr=e,D.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,D.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contract_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.contract_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.contract_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const V="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contractbuilder_free(e>>>0)));class F{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contractbuilder_free(e)}constructor(e,t,i,r,a,o,d,h,c,l,u){try{const m=s.__wbindgen_add_to_stack_pointer(-16),y=w(o,s.__wbindgen_export_0,s.__wbindgen_export_1),b=v,k=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),S=v;s.contractbuilder_new(m,e,t,i,r,a,y,b,k,S,h,c,l,u);var f=g()[m/4+0],p=g()[m/4+1];if(g()[m/4+2])throw n(p);return this.__wbg_ptr=f>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}build(){const e=this.__destroy_into_raw(),t=s.contractbuilder_build(e);return q.__wrap(t)}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractinfo_free(e>>>0)));const H="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contractmatching_free(e>>>0)));class G{static __wrap(e){e>>>=0;const t=Object.create(G.prototype);return t.__wbg_ptr=e,H.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contractmatching_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.contractmatching_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.contractmatching_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractmatchingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractprice_free(e>>>0)));const U="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_create2data_free(e>>>0)));class W{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,U.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_create2data_free(e)}constructor(e,t,i){try{const o=s.__wbindgen_add_to_stack_pointer(-16),d=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),h=v,c=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),l=v,u=w(i,s.__wbindgen_export_0,s.__wbindgen_export_1),f=v;s.create2data_new(o,d,h,c,l,u,f);var r=g()[o/4+0],a=g()[o/4+1];if(g()[o/4+2])throw n(a);return this.__wbg_ptr=r>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}salt(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.create2data_salt(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.create2data_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_ethtxoption_free(e>>>0)));const j="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_forcedexit_free(e>>>0)));class z{static __wrap(e){e>>>=0;const t=Object.create(z.prototype);return t.__wbg_ptr=e,j.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,j.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_forcedexit_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.forcedexit_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.forcedexit_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_forcedexitbuilder_free(e>>>0)));const K="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_funding_free(e>>>0)));class Y{static __wrap(e){e>>>=0;const t=Object.create(Y.prototype);return t.__wbg_ptr=e,K.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,K.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_funding_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.funding_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.funding_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_fundingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_fundinginfo_free(e>>>0)));const X="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_jsonrpcsigner_free(e>>>0)));class Q{static __wrap(e){e>>>=0;const t=Object.create(Q.prototype);return t.__wbg_ptr=e,X.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,X.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_jsonrpcsigner_free(e)}initZklinkSigner(e){var t=f(e)?0:w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),i=v;return n(s.jsonrpcsigner_initZklinkSigner(this.__wbg_ptr,t,i))}getPubkey(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_getPubkey(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}pubkeyHash(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_pubkeyHash(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}address(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_address(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];let r;return 0!==e&&(r=u(e,t).slice(),s.__wbindgen_export_5(e,1*t,1)),r}finally{s.__wbindgen_add_to_stack_pointer(16)}}signatureSeed(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_signatureSeed(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}signChangePubkeyWithOnchain(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,N);var t=e.__destroy_into_raw();s.jsonrpcsigner_signChangePubkeyWithOnchain(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signChangePubkeyWithEthEcdsaAuth(e){x(e,N);var t=e.__destroy_into_raw();return n(s.jsonrpcsigner_signChangePubkeyWithEthEcdsaAuth(this.__wbg_ptr,t))}signChangePubkeyWithCreate2DataAuth(e,t){try{const d=s.__wbindgen_add_to_stack_pointer(-16);x(e,N);var i=e.__destroy_into_raw();x(t,W);var r=t.__destroy_into_raw();s.jsonrpcsigner_signChangePubkeyWithCreate2DataAuth(d,this.__wbg_ptr,i,r);var a=g()[d/4+0],o=g()[d/4+1];if(g()[d/4+2])throw n(o);return n(a)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signTransfer(e,t){x(e,re);var i=e.__destroy_into_raw();const r=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),a=v;return n(s.jsonrpcsigner_signTransfer(this.__wbg_ptr,i,r,a))}createSignedOrder(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ee);var t=e.__destroy_into_raw();s.jsonrpcsigner_createSignedOrder(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signOrderMatching(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ie);var t=e.__destroy_into_raw();s.jsonrpcsigner_signOrderMatching(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signWithdraw(e,t){x(e,ce);var i=e.__destroy_into_raw();const r=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),a=v;return n(s.jsonrpcsigner_signWithdraw(this.__wbg_ptr,i,r,a))}signForcedExit(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,z);var t=e.__destroy_into_raw();s.jsonrpcsigner_signForcedExit(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signAutoDeleveraging(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,L);var t=e.__destroy_into_raw();s.jsonrpcsigner_signAutoDeleveraging(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}createSignedContract(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,q);var t=e.__destroy_into_raw();s.jsonrpcsigner_createSignedContract(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signContractMatching(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,G);var t=e.__destroy_into_raw();s.jsonrpcsigner_signContractMatching(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signFunding(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,Y);var t=e.__destroy_into_raw();s.jsonrpcsigner_signFunding(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signLiquidation(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,$);var t=e.__destroy_into_raw();s.jsonrpcsigner_signLiquidation(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signMusig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=function(e,t){const i=t(1*e.length,1)>>>0;return l().set(e,i/1),v=e.length,i}(e,s.__wbindgen_export_0),o=v;s.jsonrpcsigner_signMusig(r,this.__wbg_ptr,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return de.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getZkLinkSigner(){const e=s.jsonrpcsigner_getZkLinkSigner(this.__wbg_ptr);return ue.__wrap(e)}}const Z="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_liquidation_free(e>>>0)));class ${static __wrap(e){e>>>=0;const t=Object.create($.prototype);return t.__wbg_ptr=e,Z.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_liquidation_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.liquidation_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.liquidation_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_liquidationbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_margininfo_free(e>>>0)));const J="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_order_free(e>>>0)));class ee{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,J.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_order_free(e)}constructor(e,t,i,r,a,o,d,h,c,l,u,f){try{const y=s.__wbindgen_add_to_stack_pointer(-16),b=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),k=v,S=w(h,s.__wbindgen_export_0,s.__wbindgen_export_1),O=v;s.order_new(y,e,t,i,r,a,o,b,k,S,O,c,l,u,f);var p=g()[y/4+0],m=g()[y/4+1];if(g()[y/4+2])throw n(m);return this.__wbg_ptr=p>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.order_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.order_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const te="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_ordermatching_free(e>>>0)));class ie{static __wrap(e){e>>>=0;const t=Object.create(ie.prototype);return t.__wbg_ptr=e,te.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,te.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_ordermatching_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.ordermatching_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_ordermatchingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_parameter_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_requestarguments_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_rpcclient_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_spotpriceinfo_free(e>>>0)));const se="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_transfer_free(e>>>0)));class re{static __wrap(e){e>>>=0;const t=Object.create(re.prototype);return t.__wbg_ptr=e,se.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,se.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_transfer_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.transfer_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getEthSignMsg(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.transfer_getEthSignMsg(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.transfer_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const ae="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_transferbuilder_free(e>>>0)));class oe{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ae.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_transferbuilder_free(e)}constructor(e,t,i,r,a,o,d,h,c){try{const p=s.__wbindgen_add_to_stack_pointer(-16),m=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),y=v,b=w(o,s.__wbindgen_export_0,s.__wbindgen_export_1),k=v,S=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),O=v;s.transferbuilder_new(p,e,m,y,i,r,a,b,k,S,O,h,!f(c),f(c)?0:c);var l=g()[p/4+0],u=g()[p/4+1];if(g()[p/4+2])throw n(u);return this.__wbg_ptr=l>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}build(){const e=this.__destroy_into_raw(),t=s.transferbuilder_build(e);return re.__wrap(t)}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_txlayer1signature_free(e>>>0)));const ne="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_txzklinksignature_free(e>>>0)));class de{static __wrap(e){e>>>=0;const t=Object.create(de.prototype);return t.__wbg_ptr=e,ne.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ne.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_txzklinksignature_free(e)}constructor(e,t){try{const a=s.__wbindgen_add_to_stack_pointer(-16),o=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v,h=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),c=v;s.txzklinksignature_new(a,o,d,h,c);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return this.__wbg_ptr=i>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}pubKey(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.txzklinksignature_pubKey(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}signature(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.txzklinksignature_signature(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_updateglobalvar_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_updateglobalvarbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_wallet_free(e>>>0)));const he="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_withdraw_free(e>>>0)));class ce{static __wrap(e){e>>>=0;const t=Object.create(ce.prototype);return t.__wbg_ptr=e,he.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_withdraw_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.withdraw_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getEthSignMsg(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.withdraw_getEthSignMsg(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.withdraw_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_withdrawbuilder_free(e>>>0)));const le="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_zklinksigner_free(e>>>0)));class ue{static __wrap(e){e>>>=0;const t=Object.create(ue.prototype);return t.__wbg_ptr=e,le.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,le.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_zklinksigner_free(e)}static ethSig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.zklinksigner_ethSig(r,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return ue.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}static starknetSig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.zklinksigner_starknetSig(r,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return ue.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_zklinktx_free(e>>>0)));function fe(){const e={wbg:{}};return e.wbg.__wbindgen_object_drop_ref=function(e){n(e)},e.wbg.__wbg_request_aa80f2dd90291bcc=function(){return B((function(e,t){return d(a(e).request(n(t)))}),arguments)},e.wbg.__wbg_signMessage_31620e519ceecf94=function(){return B((function(e,t){return d(a(e).signMessage(a(t)))}),arguments)},e.wbg.__wbindgen_number_new=function(e){return d(e)},e.wbg.__wbindgen_string_new=function(e,t){return d(u(e,t))},e.wbg.__wbindgen_is_undefined=function(e){return void 0===a(e)},e.wbg.__wbindgen_in=function(e,t){return a(e)in a(t)},e.wbg.__wbindgen_boolean_get=function(e){const t=a(e);return"boolean"==typeof t?t?1:0:2},e.wbg.__wbindgen_is_bigint=function(e){return"bigint"==typeof a(e)},e.wbg.__wbindgen_number_get=function(e,t){const i=a(t),r="number"==typeof i?i:void 0;(null!==p&&0!==p.byteLength||(p=new Float64Array(s.memory.buffer)),p)[e/8+1]=f(r)?0:r,g()[e/4+0]=!f(r)},e.wbg.__wbindgen_bigint_from_i64=function(e){return d(e)},e.wbg.__wbindgen_jsval_eq=function(e,t){return a(e)===a(t)},e.wbg.__wbindgen_string_get=function(e,t){const i=a(t),r="string"==typeof i?i:void 0;var o=f(r)?0:w(r,s.__wbindgen_export_0,s.__wbindgen_export_1),n=v;g()[e/4+1]=n,g()[e/4+0]=o},e.wbg.__wbindgen_is_object=function(e){const t=a(e);return"object"==typeof t&&null!==t},e.wbg.__wbindgen_bigint_from_u64=function(e){return d(BigInt.asUintN(64,e))},e.wbg.__wbindgen_object_clone_ref=function(e){return d(a(e))},e.wbg.__wbindgen_as_number=function(e){return+a(e)},e.wbg.__wbindgen_error_new=function(e,t){return d(new Error(u(e,t)))},e.wbg.__wbg_performance_eeefc685c9bc38b4=function(e){return d(a(e).performance)},e.wbg.__wbg_now_e0d8ec93dd25766a=function(e){return a(e).now()},e.wbg.__wbg_selectedAddress_e88960714bb47d11=function(e,t){const i=a(t).selectedAddress;var r=f(i)?0:w(i,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;g()[e/4+1]=o,g()[e/4+0]=r},e.wbg.__wbg_address_b7ff4a10022d02d8=function(e,t){const i=w(a(t).address,s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbindgen_jsval_loose_eq=function(e,t){return a(e)==a(t)},e.wbg.__wbg_String_389b54bd9d25375f=function(e,t){const i=w(String(a(t)),s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbg_getwithrefkey_4a92a5eca60879b9=function(e,t){return d(a(e)[a(t)])},e.wbg.__wbg_set_9182712abebf82ef=function(e,t,i){a(e)[n(t)]=n(i)},e.wbg.__wbindgen_cb_drop=function(e){const t=n(e).original;if(1==t.cnt--)return t.a=0,!0;return!1},e.wbg.__wbg_clearTimeout_76877dbc010e786d=function(e){return d(clearTimeout(n(e)))},e.wbg.__wbg_setTimeout_75cb9b6991a4031d=function(){return B((function(e,t){return d(setTimeout(a(e),t))}),arguments)},e.wbg.__wbg_fetch_6a2624d7f767e331=function(e){return d(fetch(a(e)))},e.wbg.__wbg_fetch_693453ca3f88c055=function(e,t){return d(a(e).fetch(a(t)))},e.wbg.__wbg_new_7a20246daa6eec7e=function(){return B((function(){return d(new Headers)}),arguments)},e.wbg.__wbg_append_aa3f462f9e2b5ff2=function(){return B((function(e,t,i,s,r){a(e).append(u(t,i),u(s,r))}),arguments)},e.wbg.__wbg_newwithstrandinit_f581dff0d19a8b03=function(){return B((function(e,t,i){return d(new Request(u(e,t),a(i)))}),arguments)},e.wbg.__wbg_signal_3c701f5f40a5f08d=function(e){return d(a(e).signal)},e.wbg.__wbg_new_0ae46f44b7485bb2=function(){return B((function(){return d(new AbortController)}),arguments)},e.wbg.__wbg_abort_2c4fb490d878d2b2=function(e){a(e).abort()},e.wbg.__wbg_instanceof_Response_4c3b1446206114d1=function(e){let t;try{t=a(e)instanceof Response}catch(e){t=!1}return t},e.wbg.__wbg_url_83a6a4f65f7a2b38=function(e,t){const i=w(a(t).url,s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbg_status_d6d47ad2837621eb=function(e){return a(e).status},e.wbg.__wbg_headers_24def508a7518df9=function(e){return d(a(e).headers)},e.wbg.__wbg_arrayBuffer_5b2688e3dd873fed=function(){return B((function(e){return d(a(e).arrayBuffer())}),arguments)},e.wbg.__wbg_queueMicrotask_481971b0d87f3dd4=function(e){queueMicrotask(a(e))},e.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6=function(e){return d(a(e).queueMicrotask)},e.wbg.__wbindgen_is_function=function(e){return"function"==typeof a(e)},e.wbg.__wbg_crypto_58f13aa23ffcb166=function(e){return d(a(e).crypto)},e.wbg.__wbg_process_5b786e71d465a513=function(e){return d(a(e).process)},e.wbg.__wbg_versions_c2ab80650590b6a2=function(e){return d(a(e).versions)},e.wbg.__wbg_node_523d7bd03ef69fba=function(e){return d(a(e).node)},e.wbg.__wbindgen_is_string=function(e){return"string"==typeof a(e)},e.wbg.__wbg_require_2784e593a4674877=function(){return B((function(){return d(module.require)}),arguments)},e.wbg.__wbg_msCrypto_abcb1295e768d1f2=function(e){return d(a(e).msCrypto)},e.wbg.__wbg_randomFillSync_a0d98aa11c81fe89=function(){return B((function(e,t){a(e).randomFillSync(n(t))}),arguments)},e.wbg.__wbg_getRandomValues_504510b5564925af=function(){return B((function(e,t){a(e).getRandomValues(a(t))}),arguments)},e.wbg.__wbg_get_bd8e338fbd5f5cc8=function(e,t){return d(a(e)[t>>>0])},e.wbg.__wbg_length_cd7af8117672b8b8=function(e){return a(e).length},e.wbg.__wbg_new_16b304a2cfa7ff4a=function(){return d(new Array)},e.wbg.__wbg_newnoargs_e258087cd0daa0ea=function(e,t){return d(new Function(u(e,t)))},e.wbg.__wbg_new_d9bc3a0147634640=function(){return d(new Map)},e.wbg.__wbg_next_40fc327bfc8770e6=function(e){return d(a(e).next)},e.wbg.__wbg_next_196c84450b364254=function(){return B((function(e){return d(a(e).next())}),arguments)},e.wbg.__wbg_done_298b57d23c0fc80c=function(e){return a(e).done},e.wbg.__wbg_value_d93c65011f51a456=function(e){return d(a(e).value)},e.wbg.__wbg_iterator_2cee6dadfd956dfa=function(){return d(Symbol.iterator)},e.wbg.__wbg_get_e3c254076557e348=function(){return B((function(e,t){return d(Reflect.get(a(e),a(t)))}),arguments)},e.wbg.__wbg_call_27c0f87801dedf93=function(){return B((function(e,t){return d(a(e).call(a(t)))}),arguments)},e.wbg.__wbg_new_72fb9a18b5ae2624=function(){return d(new Object)},e.wbg.__wbg_self_ce0dbfc45cf2f5be=function(){return B((function(){return d(self.self)}),arguments)},e.wbg.__wbg_window_c6fb939a7f436783=function(){return B((function(){return d(window.window)}),arguments)},e.wbg.__wbg_globalThis_d1e6af4856ba331b=function(){return B((function(){return d(globalThis.globalThis)}),arguments)},e.wbg.__wbg_global_207b558942527489=function(){return B((function(){return d(global.global)}),arguments)},e.wbg.__wbg_set_d4638f722068f043=function(e,t,i){a(e)[t>>>0]=n(i)},e.wbg.__wbg_isArray_2ab64d95e09ea0ae=function(e){return Array.isArray(a(e))},e.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2=function(e){let t;try{t=a(e)instanceof ArrayBuffer}catch(e){t=!1}return t},e.wbg.__wbg_call_b3ca7c6051f9bec1=function(){return B((function(e,t,i){return d(a(e).call(a(t),a(i)))}),arguments)},e.wbg.__wbg_set_8417257aaedc936b=function(e,t,i){return d(a(e).set(a(t),a(i)))},e.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2=function(e){return Number.isSafeInteger(a(e))},e.wbg.__wbg_entries_95cc2c823b285a09=function(e){return d(Object.entries(a(e)))},e.wbg.__wbg_new_81740750da40724f=function(e,t){try{var i={a:e,b:t};const r=new Promise(((e,t)=>{const r=i.a;i.a=0;try{return function(e,t,i,r){s.__wbindgen_export_7(e,t,d(i),d(r))}(r,i.b,e,t)}finally{i.a=r}}));return d(r)}finally{i.a=i.b=0}},e.wbg.__wbg_resolve_b0083a7967828ec8=function(e){return d(Promise.resolve(a(e)))},e.wbg.__wbg_then_0c86a60e8fcfe9f6=function(e,t){return d(a(e).then(a(t)))},e.wbg.__wbg_then_a73caa9a87991566=function(e,t,i){return d(a(e).then(a(t),a(i)))},e.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){return d(a(e).buffer)},e.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(e,t,i){return d(new Uint8Array(a(e),t>>>0,i>>>0))},e.wbg.__wbg_new_63b92bc8671ed464=function(e){return d(new Uint8Array(a(e)))},e.wbg.__wbg_set_a47bac70306a19a7=function(e,t,i){a(e).set(a(t),i>>>0)},e.wbg.__wbg_length_c20a40f15020d68a=function(e){return a(e).length},e.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(e){let t;try{t=a(e)instanceof Uint8Array}catch(e){t=!1}return t},e.wbg.__wbg_newwithlength_e9b4878cebadb3d3=function(e){return d(new Uint8Array(e>>>0))},e.wbg.__wbg_subarray_a1f73cd4b5b42fe1=function(e,t,i){return d(a(e).subarray(t>>>0,i>>>0))},e.wbg.__wbg_has_0af94d20077affa2=function(){return B((function(e,t){return Reflect.has(a(e),a(t))}),arguments)},e.wbg.__wbg_set_1f9b04f170055d33=function(){return B((function(e,t,i){return Reflect.set(a(e),a(t),a(i))}),arguments)},e.wbg.__wbg_stringify_8887fe74e1c50d81=function(){return B((function(e){return d(JSON.stringify(a(e)))}),arguments)},e.wbg.__wbindgen_bigint_get_as_i64=function(e,t){const i=a(t),r="bigint"==typeof i?i:void 0;(null!==k&&0!==k.byteLength||(k=new BigInt64Array(s.memory.buffer)),k)[e/8+1]=f(r)?BigInt(0):r,g()[e/4+0]=!f(r)},e.wbg.__wbindgen_debug_string=function(e,t){const i=w(S(a(t)),s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbindgen_throw=function(e,t){throw new Error(u(e,t))},e.wbg.__wbindgen_memory=function(){return d(s.memory)},e.wbg.__wbindgen_closure_wrapper3897=function(e,t,i){return d(T(e,t,699,P))},e.wbg.__wbindgen_closure_wrapper7350=function(e,t,i){return d(T(e,t,1724,M))},e}function pe(e,t){return s=e.exports,me.__wbindgen_wasm_module=t,k=null,p=null,m=null,A=null,c=null,s}async function me(e){if(void 0!==s)return s;void 0===e&&(e="https://qa.omni.apex.exchange/api/v3/download/zklink-sdk-web_bg.wasm");const t=fe();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:i,module:r}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}{const i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}}(await e,t);return pe(i,r)}const ge=me}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var i=a[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(i,s){if(1&s&&(i=this(i)),8&s)return i;if("object"==typeof i&&i){if(4&s&&i.__esModule)return i;if(16&s&&"function"==typeof i.then)return i}var r=Object.create(null);o.r(r);var a={};e=e||[null,t({}),t([]),t(t)];for(var n=2&s&&i;"object"==typeof n&&!~e.indexOf(n);n=t(n))Object.getOwnPropertyNames(n).forEach((e=>a[e]=()=>i[e]));return a.default=()=>i,o.d(r,a),r},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,i)=>(o.f[i](e,t),t)),[])),o.u=e=>e+".ccxt.browser.min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i={},s="ccxt:",o.l=(e,t,r,a)=>{if(i[e])i[e].push(t);else{var n,d;if(void 0!==r)for(var h=document.getElementsByTagName("script"),c=0;c<h.length;c++){var l=h[c];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==s+r){n=l;break}}n||(d=!0,(n=document.createElement("script")).charset="utf-8",n.timeout=120,o.nc&&n.setAttribute("nonce",o.nc),n.setAttribute("data-webpack",s+r),n.src=e),i[e]=[t];var u=(t,s)=>{n.onerror=n.onload=null,clearTimeout(f);var r=i[e];if(delete i[e],n.parentNode&&n.parentNode.removeChild(n),r&&r.forEach((e=>e(s))),t)return t(s)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),d&&document.head.appendChild(n)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=i[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={792:0};o.f.j=(t,i)=>{var s=o.o(e,t)?e[t]:void 0;if(0!==s)if(s)i.push(s[2]);else{var r=new Promise(((i,r)=>s=e[t]=[i,r]));i.push(s[2]=r);var a=o.p+o.u(t),n=new Error;o.l(a,(i=>{if(o.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var r=i&&("load"===i.type?"missing":i.type),a=i&&i.target&&i.target.src;n.message="Loading chunk "+t+" failed.\n("+r+": "+a+")",n.name="ChunkLoadError",n.type=r,n.request=a,s[1](n)}}),"chunk-"+t,t)}};var t=(t,i)=>{var s,r,[a,n,d]=i,h=0;if(a.some((t=>0!==e[t]))){for(s in n)o.o(n,s)&&(o.m[s]=n[s]);if(d)d(o)}for(t&&t(i);h<a.length;h++)r=a[h],o.o(e,r)&&e[r]&&e[r][0](),e[r]=0},i=self.webpackChunkccxt=self.webpackChunkccxt||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var n={};o.r(n),o.d(n,{AccountNotEnabled:()=>l.AccountNotEnabled,AccountSuspended:()=>l.AccountSuspended,AddressPending:()=>l.AddressPending,ArgumentsRequired:()=>l.ArgumentsRequired,AuthenticationError:()=>l.AuthenticationError,BadRequest:()=>l.BadRequest,BadResponse:()=>l.BadResponse,BadSymbol:()=>l.BadSymbol,BaseError:()=>l.BaseError,CancelPending:()=>l.CancelPending,ChecksumError:()=>l.ChecksumError,ContractUnavailable:()=>l.ContractUnavailable,DDoSProtection:()=>l.DDoSProtection,DuplicateOrderId:()=>l.DuplicateOrderId,Exchange:()=>d.k,ExchangeClosedByUser:()=>l.ExchangeClosedByUser,ExchangeError:()=>l.ExchangeError,ExchangeNotAvailable:()=>l.ExchangeNotAvailable,InsufficientFunds:()=>l.InsufficientFunds,InvalidAddress:()=>l.InvalidAddress,InvalidNonce:()=>l.InvalidNonce,InvalidOrder:()=>l.InvalidOrder,InvalidProxySettings:()=>l.InvalidProxySettings,ManualInteractionNeeded:()=>l.ManualInteractionNeeded,MarginModeAlreadySet:()=>l.MarginModeAlreadySet,MarketClosed:()=>l.MarketClosed,NetworkError:()=>l.NetworkError,NoChange:()=>l.NoChange,NotSupported:()=>l.NotSupported,NullResponse:()=>l.NullResponse,OnMaintenance:()=>l.OnMaintenance,OperationFailed:()=>l.OperationFailed,OperationRejected:()=>l.OperationRejected,OrderImmediatelyFillable:()=>l.OrderImmediatelyFillable,OrderNotCached:()=>l.OrderNotCached,OrderNotFillable:()=>l.OrderNotFillable,OrderNotFound:()=>l.OrderNotFound,PermissionDenied:()=>l.PermissionDenied,Precise:()=>h.Y,RateLimitExceeded:()=>l.RateLimitExceeded,RequestTimeout:()=>l.RequestTimeout,RestrictedLocation:()=>l.RestrictedLocation,UnsubscribeError:()=>l.UnsubscribeError,abantether:()=>u.A,afratether:()=>f.A,alpaca:()=>p.A,apex:()=>m.A,ariomex:()=>g.A,arzinja:()=>v.A,arzplus:()=>y.A,asacoine:()=>b.A,ascendex:()=>w.A,asretether:()=>k.A,baazar:()=>S.A,bequant:()=>O.A,bidarz:()=>T.A,bigone:()=>P.A,binance:()=>M.A,binancecoinm:()=>I.A,binanceus:()=>x.A,binanceusdm:()=>A.A,bingx:()=>C.A,bit24:()=>_.A,bit2c:()=>B.A,bitbank:()=>E.A,bitbarg:()=>L.A,bitbns:()=>R.A,bitfinex:()=>N.A,bitflyer:()=>D.A,bitget:()=>q.A,bithumb:()=>V.A,bitimen:()=>F.A,bitir:()=>H.A,bitmart:()=>G.A,bitmex:()=>U.A,bitopro:()=>W.A,bitpin:()=>j.A,bitrue:()=>z.A,bitso:()=>K.A,bitstamp:()=>Y.A,bitteam:()=>X.A,bittrade:()=>Q.A,bitunix:()=>Z.A,bitvavo:()=>$.A,bitwana:()=>J.A,blockchaincom:()=>ee.A,blofin:()=>te.A,btcalpha:()=>ie.A,btcbox:()=>se.A,btcmarkets:()=>re.A,btcturk:()=>ae.A,bybit:()=>oe.A,bydfi:()=>ne.A,cafearz:()=>de.A,cex:()=>he.A,changefa:()=>ce.A,coinbase:()=>le.A,coinbaseadvanced:()=>ue.A,coinbaseexchange:()=>fe.A,coinbaseinternational:()=>pe.A,coincatch:()=>me.A,coincheck:()=>ge.A,coinex:()=>ve.A,coinmate:()=>ye.A,coinmetro:()=>be.A,coinone:()=>we.A,coinsph:()=>ke.A,coinspot:()=>Se.A,cryptocom:()=>Oe.A,cryptomus:()=>Te.A,daric:()=>Pe.A,default:()=>Ks,defx:()=>Me.A,delta:()=>Ie.A,deribit:()=>xe.A,derive:()=>Ae.A,digifinex:()=>Ce.A,digikalagold:()=>_e.A,ellipx:()=>Be.A,errors:()=>l,eterex:()=>Ee.A,exchanges:()=>js,excoino:()=>Le.A,exino:()=>Re.A,exir:()=>Ne.A,exmo:()=>De.A,exnovin:()=>qe.A,farhadexchange:()=>Ve.A,fmfwio:()=>Fe.A,foxbit:()=>He.A,functions:()=>c,gate:()=>Ge.A,gateio:()=>Ue.A,gemini:()=>We.A,gerami:()=>je.A,goldika:()=>ze.A,goldis:()=>Ke.A,hamrahgold:()=>Ye.A,hamtapay:()=>Xe.A,hashkey:()=>Qe.A,hibachi:()=>Ze.A,hitbtc:()=>$e.A,hitobit:()=>Je.A,hollaex:()=>et.A,htx:()=>tt.A,huobi:()=>it.A,hyperliquid:()=>st.A,independentreserve:()=>rt.A,indodax:()=>at.A,iranexchange:()=>ot.A,jibitex:()=>nt.A,kcex:()=>dt.A,kifpoolme:()=>ht.A,kraken:()=>ct.A,krakenfutures:()=>lt.A,kucoin:()=>ut.A,kucoinfutures:()=>ft.A,latoken:()=>pt.A,lbank:()=>mt.A,luno:()=>gt.A,mazdax:()=>vt.A,melligold:()=>yt.A,mercado:()=>bt.A,mexc:()=>wt.A,milligold:()=>kt.A,modetrade:()=>St.A,myokx:()=>Ot.A,ndax:()=>Tt.A,nobitex:()=>Pt.A,novadax:()=>Mt.A,oceanex:()=>It.A,okcoin:()=>xt.A,okexchange:()=>At.A,okx:()=>Ct.A,okxus:()=>_t.A,ompfinex:()=>Bt.A,onetrading:()=>Et.A,ourbit:()=>Lt.A,oxfun:()=>Rt.A,p2b:()=>Nt.A,paradex:()=>Dt.A,paymium:()=>qt.A,phemex:()=>Vt.A,pingi:()=>Ft.A,poloniex:()=>Ht.A,pooleno:()=>Gt.A,poulyar:()=>Ut.A,pro:()=>zs,probit:()=>Wt.A,raastin:()=>jt.A,ramzinex:()=>zt.A,saraf:()=>Kt.A,sarmayex:()=>Yt.A,sarrafex:()=>Xt.A,tabdeal:()=>Qt.A,talaavan:()=>Zt.A,talapp:()=>$t.A,talasea:()=>Jt.A,technogold:()=>ei.A,tehran_exchange:()=>ti.A,tetherland:()=>ii.A,timex:()=>si.A,tokocrypto:()=>ri.A,toobit:()=>ai.A,tradeogre:()=>oi.A,twox:()=>ni.A,ubitex:()=>di.A,upbit:()=>hi.A,version:()=>Ws,vertex:()=>ci.A,wallex:()=>li.A,wallgold:()=>ui.A,wavesexchange:()=>fi.A,whitebit:()=>pi.A,woo:()=>mi.A,woofipro:()=>gi.A,xt:()=>vi.A,yobit:()=>yi.A,zaif:()=>bi.A,zarafza:()=>wi.A,zarminex:()=>ki.A,zarniv:()=>Si.A,zarpin:()=>Oi.A,zonda:()=>Ti.A});var d=o(72961),h=o(85147),c=o(15095),l=o(62079),u=o(51656),f=o(95566),p=o(77930),m=o(64920),g=o(83761),v=o(16371),y=o(2065),b=o(41421),w=o(71411),k=o(56077),S=o(28929),O=o(49002),T=o(56882),P=o(58698),M=o(13192),I=o(51510),x=o(68228),A=o(72171),C=o(72480),_=o(61183),B=o(72342),E=o(17399),L=o(82799),R=o(26328),N=o(88657),D=o(41787),q=o(67757),V=o(60357),F=o(84456),H=o(39314),G=o(31837),U=o(99523),W=o(72753),j=o(9558),z=o(99061),K=o(93019),Y=o(382),X=o(60112),Q=o(92263),Z=o(60587),$=o(83727),J=o(37420),ee=o(73205),te=o(42520),ie=o(53413),se=o(75376),re=o(34936),ae=o(59265),oe=o(45462),ne=o(5e3),de=o(25226),he=o(78846),ce=o(86257),le=o(17504),ue=o(63278),fe=o(4293),pe=o(1558),me=o(20570),ge=o(22741),ve=o(39344),ye=o(6016),be=o(18692),we=o(65377),ke=o(52692),Se=o(51669),Oe=o(56068),Te=o(30870),Pe=o(55557),Me=o(26077),Ie=o(41080),xe=o(72591),Ae=o(71839),Ce=o(30779),_e=o(3062),Be=o(71962),Ee=o(36415),Le=o(89335),Re=o(23833),Ne=o(9098),De=o(57057),qe=o(99169),Ve=o(6711),Fe=o(63042),He=o(60448),Ge=o(99403),Ue=o(28403),We=o(58823),je=o(37459),ze=o(52067),Ke=o(32814),Ye=o(38499),Xe=o(9369),Qe=o(62937),Ze=o(95106),$e=o(37996),Je=o(675),et=o(24455),tt=o(59946),it=o(70063),st=o(1936),rt=o(44162),at=o(17325),ot=o(15073),nt=o(60835),dt=o(71199),ht=o(93644),ct=o(18042),lt=o(32300),ut=o(41397),ft=o(86217),pt=o(8146),mt=o(13144),gt=o(59248),vt=o(70509),yt=o(10361),bt=o(46419),wt=o(92403),kt=o(98301),St=o(85345),Ot=o(78982),Tt=o(82079),Pt=o(51561),Mt=o(38473),It=o(13805),xt=o(87915),At=o(79),Ct=o(93660),_t=o(63536),Bt=o(848),Et=o(43573),Lt=o(16469),Rt=o(66358),Nt=o(94998),Dt=o(76993),qt=o(43280),Vt=o(29075),Ft=o(88785),Ht=o(30288),Gt=o(28920),Ut=o(31562),Wt=o(27418),jt=o(79614),zt=o(30676),Kt=o(99451),Yt=o(55822),Xt=o(59702),Qt=o(35619),Zt=o(90200),$t=o(30236),Jt=o(43829),ei=o(80501),ti=o(67496),ii=o(77497),si=o(66213),ri=o(42490),ai=o(90237),oi=o(45887),ni=o(58586),di=o(73551),hi=o(90930),ci=o(84910),li=o(88633),ui=o(56314),fi=o(57073),pi=o(75336),mi=o(40669),gi=o(99641),vi=o(55344),yi=o(87469),bi=o(1530),wi=o(20285),ki=o(57562),Si=o(93290),Oi=o(30528),Ti=o(46022),Pi=o(46810),Mi=o(40136),Ii=o(36419),xi=o(29338),Ai=o(19544),Ci=o(40902),_i=o(88788),Bi=o(68251),Ei=o(89456),Li=o(98657),Ri=o(90205),Ni=o(96181),Di=o(53069),qi=o(43731),Vi=o(54401),Fi=o(43333),Hi=o(73326),Gi=o(82391),Ui=o(11327),Wi=o(78693),ji=o(61672),zi=o(8518),Ki=o(93774),Yi=o(98160),Xi=o(45918),Qi=o(11925),Zi=o(998),$i=o(3242),Ji=o(85317),es=o(49088),ts=o(58673),is=o(6292),ss=o(28717),rs=o(77791),as=o(82127),os=o(65233),ns=o(19195),ds=o(75843),hs=o(40375),cs=o(21481),ls=o(54524),us=o(48247),fs=o(63898),ps=o(86335),ms=o(53984),gs=o(70098),vs=o(99050),ys=o(46396),bs=o(84965),ws=o(90905),ks=o(21736),Ss=o(22208),Os=o(89219),Ts=o(80049),Ps=o(23062),Ms=o(63887),Is=o(16187),xs=o(8588),As=o(83296),Cs=o(64357),_s=o(550),Bs=o(44934),Es=o(51057),Ls=o(51619),Rs=o(83456),Ns=o(25738),Ds=o(28719),qs=o(65794),Vs=o(10910),Fs=o(14712),Hs=o(65869),Gs=o(28713),Us=o(22368);const Ws="4.22.0";d.k.ccxtVersion=Ws;const js={abantether:u.A,afratether:f.A,alpaca:p.A,apex:m.A,ariomex:g.A,arzinja:v.A,arzplus:y.A,asacoine:b.A,ascendex:w.A,asretether:k.A,baazar:S.A,bequant:O.A,bidarz:T.A,bigone:P.A,binance:M.A,binancecoinm:I.A,binanceus:x.A,binanceusdm:A.A,bingx:C.A,bit24:_.A,bit2c:B.A,bitbank:E.A,bitbarg:L.A,bitbns:R.A,bitfinex:N.A,bitflyer:D.A,bitget:q.A,bithumb:V.A,bitimen:F.A,bitir:H.A,bitmart:G.A,bitmex:U.A,bitopro:W.A,bitpin:j.A,bitrue:z.A,bitso:K.A,bitstamp:Y.A,bitteam:X.A,bittrade:Q.A,bitunix:Z.A,bitvavo:$.A,bitwana:J.A,blockchaincom:ee.A,blofin:te.A,btcalpha:ie.A,btcbox:se.A,btcmarkets:re.A,btcturk:ae.A,bybit:oe.A,bydfi:ne.A,cafearz:de.A,cex:he.A,changefa:ce.A,coinbase:le.A,coinbaseadvanced:ue.A,coinbaseexchange:fe.A,coinbaseinternational:pe.A,coincatch:me.A,coincheck:ge.A,coinex:ve.A,coinmate:ye.A,coinmetro:be.A,coinone:we.A,coinsph:ke.A,coinspot:Se.A,cryptocom:Oe.A,cryptomus:Te.A,daric:Pe.A,defx:Me.A,delta:Ie.A,deribit:xe.A,derive:Ae.A,digifinex:Ce.A,digikalagold:_e.A,ellipx:Be.A,eterex:Ee.A,excoino:Le.A,exino:Re.A,exir:Ne.A,exmo:De.A,exnovin:qe.A,farhadexchange:Ve.A,fmfwio:Fe.A,foxbit:He.A,gate:Ge.A,gateio:Ue.A,gemini:We.A,gerami:je.A,goldika:ze.A,goldis:Ke.A,hamrahgold:Ye.A,hamtapay:Xe.A,hashkey:Qe.A,hibachi:Ze.A,hitbtc:$e.A,hitobit:Je.A,hollaex:et.A,htx:tt.A,huobi:it.A,hyperliquid:st.A,independentreserve:rt.A,indodax:at.A,iranexchange:ot.A,jibitex:nt.A,kcex:dt.A,kifpoolme:ht.A,kraken:ct.A,krakenfutures:lt.A,kucoin:ut.A,kucoinfutures:ft.A,latoken:pt.A,lbank:mt.A,luno:gt.A,mazdax:vt.A,melligold:yt.A,mercado:bt.A,mexc:wt.A,milligold:kt.A,modetrade:St.A,myokx:Ot.A,ndax:Tt.A,nobitex:Pt.A,novadax:Mt.A,oceanex:It.A,okcoin:xt.A,okexchange:At.A,okx:Ct.A,okxus:_t.A,ompfinex:Bt.A,onetrading:Et.A,ourbit:Lt.A,oxfun:Rt.A,p2b:Nt.A,paradex:Dt.A,paymium:qt.A,phemex:Vt.A,pingi:Ft.A,poloniex:Ht.A,pooleno:Gt.A,poulyar:Ut.A,probit:Wt.A,raastin:jt.A,ramzinex:zt.A,saraf:Kt.A,sarmayex:Yt.A,sarrafex:Xt.A,tabdeal:Qt.A,talaavan:Zt.A,talapp:$t.A,talasea:Jt.A,technogold:ei.A,tehran_exchange:ti.A,tetherland:ii.A,timex:si.A,tokocrypto:ri.A,toobit:ai.A,tradeogre:oi.A,twox:ni.A,ubitex:di.A,upbit:hi.A,vertex:ci.A,wallex:li.A,wallgold:ui.A,wavesexchange:fi.A,whitebit:pi.A,woo:mi.A,woofipro:gi.A,xt:vi.A,yobit:yi.A,zaif:bi.A,zarafza:wi.A,zarminex:ki.A,zarniv:Si.A,zarpin:Oi.A,zonda:Ti.A},zs={alpaca:Pi.A,apex:Mi.A,ascendex:Ii.A,bequant:xi.A,binance:Ai.A,binancecoinm:Ci.A,binanceus:_i.A,binanceusdm:Bi.A,bingx:Ei.A,bitfinex:Li.A,bitget:Ri.A,bithumb:Ni.A,bitmart:Di.A,bitmex:qi.A,bitopro:Vi.A,bitrue:Fi.A,bitstamp:Hi.A,bittrade:Gi.A,bitvavo:Ui.A,blockchaincom:Wi.A,blofin:ji.A,bybit:zi.A,cex:Ki.A,coinbase:Yi.A,coinbaseadvanced:Xi.A,coinbaseexchange:Qi.A,coinbaseinternational:Zi.A,coincatch:$i.A,coincheck:Ji.A,coinex:es.A,coinone:ts.A,cryptocom:is.A,defx:ss.A,deribit:rs.A,derive:as.A,exmo:os.A,gate:ns.A,gateio:ds.A,gemini:hs.A,hashkey:cs.A,hitbtc:ls.A,hollaex:us.A,htx:fs.A,huobi:ps.A,hyperliquid:ms.A,independentreserve:gs.A,kraken:vs.A,krakenfutures:ys.A,kucoin:bs.A,kucoinfutures:ws.A,lbank:ks.A,luno:Ss.A,mexc:Os.A,modetrade:Ts.A,myokx:Ps.A,ndax:Ms.A,okcoin:Is.A,okx:xs.A,okxus:As.A,onetrading:Cs.A,oxfun:_s.A,p2b:Bs.A,paradex:Es.A,phemex:Ls.A,poloniex:Rs.A,probit:Ns.A,tradeogre:Ds.A,upbit:qs.A,vertex:Vs.A,whitebit:Fs.A,woo:Hs.A,woofipro:Gs.A,xt:Us.A};for(const e in zs);zs.exchanges=Object.keys(zs),zs.Exchange=d.k;const Ks=Object.assign({version:Ws,Exchange:d.k,Precise:h.Y,exchanges:Object.keys(js),pro:zs},js,c,l);self.ccxt=n})();
|
|
33
|
+
var s={};s.lang={extend:function(e,t,i){if(!t||!e)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var s=function(){};if(s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t),i){var r;for(r in i)e.prototype[r]=i[r];var a=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(a=function(e,t){for(r=0;r<o.length;r+=1){var i=o[r],s=t[i];"function"==typeof s&&s!=Object.prototype[i]&&(e[i]=s)}})}catch(e){}a(e.prototype,i)}}}},40917:(e,t,i)=>{function s(e,t){if(t&&t.multiple&&!Array.isArray(e))throw new Error("Invalid argument type: Expected an Array to serialize multiple values.");const i=4294967296;let s,r,a=new Uint8Array(128),o=0;if(t&&t.multiple)for(let t=0;t<e.length;t++)n(e[t]);else n(e);return a.subarray(0,o);function n(e,a){switch(typeof e){case"undefined":d(e);break;case"boolean":!function(e){c(e?195:194)}(e);break;case"number":!function(e){if(isFinite(e)&&Math.floor(e)===e)if(e>=0&&e<=127)c(e);else if(e<0&&e>=-32)c(e);else if(e>0&&e<=255)l([204,e]);else if(e>=-128&&e<=127)l([208,e]);else if(e>0&&e<=65535)l([205,e>>>8,e]);else if(e>=-32768&&e<=32767)l([209,e>>>8,e]);else if(e>0&&e<=4294967295)l([206,e>>>24,e>>>16,e>>>8,e]);else if(e>=-2147483648&&e<=2147483647)l([210,e>>>24,e>>>16,e>>>8,e]);else if(e>0&&e<=0x10000000000000000){let t=e/i,s=e%i;l([207,t>>>24,t>>>16,t>>>8,t,s>>>24,s>>>16,s>>>8,s])}else e>=-0x8000000000000000&&e<=0x8000000000000000?(c(211),u(e)):l(e<0?[211,128,0,0,0,0,0,0,0]:[207,255,255,255,255,255,255,255,255]);else r||(s=new ArrayBuffer(8),r=new DataView(s)),r.setFloat64(0,e),c(203),l(new Uint8Array(s))}(e);break;case"string":!function(e){let t=function(e){let t=!0,i=e.length;for(let s=0;s<i;s++)if(e.charCodeAt(s)>127){t=!1;break}let s=0,r=new Uint8Array(e.length*(t?1:4));for(let t=0;t!==i;t++){let a=e.charCodeAt(t);if(a<128)r[s++]=a;else{if(a<2048)r[s++]=a>>6|192;else{if(a>55295&&a<56320){if(++t>=i)throw new Error("UTF-8 encode: incomplete surrogate pair");let o=e.charCodeAt(t);if(o<56320||o>57343)throw new Error("UTF-8 encode: second surrogate character 0x"+o.toString(16)+" at index "+t+" out of range");a=65536+((1023&a)<<10)+(1023&o),r[s++]=a>>18|240,r[s++]=a>>12&63|128}else r[s++]=a>>12|224;r[s++]=a>>6&63|128}r[s++]=63&a|128}}return t?r:r.subarray(0,s)}(e),i=t.length;i<=31?c(160+i):l(i<=255?[217,i]:i<=65535?[218,i>>>8,i]:[219,i>>>24,i>>>16,i>>>8,i]);l(t)}(e);break;case"object":null===e?d(e):e instanceof Date?function(e){let t=e.getTime()/1e3;if(0===e.getMilliseconds()&&t>=0&&t<4294967296)l([214,255,t>>>24,t>>>16,t>>>8,t]);else if(t>=0&&t<17179869184){let s=1e6*e.getMilliseconds();l([215,255,s>>>22,s>>>14,s>>>6,s<<2>>>0|t/i,t>>>24,t>>>16,t>>>8,t])}else{let i=1e6*e.getMilliseconds();l([199,12,255,i>>>24,i>>>16,i>>>8,i]),u(t)}}(e):Array.isArray(e)?h(e):e instanceof Uint8Array||e instanceof Uint8ClampedArray?function(e){let t=e.length;l(t<=15?[196,t]:t<=65535?[197,t>>>8,t]:[198,t>>>24,t>>>16,t>>>8,t]);l(e)}(e):e instanceof Int8Array||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array?h(e):function(e){let t=0;for(let i in e)void 0!==e[i]&&t++;t<=15?c(128+t):l(t<=65535?[222,t>>>8,t]:[223,t>>>24,t>>>16,t>>>8,t]);for(let t in e){let i=e[t];void 0!==i&&(n(t),n(i))}}(e);break;default:if(a||!t||!t.invalidTypeReplacement)throw new Error("Invalid argument type: The type '"+typeof e+"' cannot be serialized.");"function"==typeof t.invalidTypeReplacement?n(t.invalidTypeReplacement(e),!0):n(t.invalidTypeReplacement,!0)}}function d(e){c(192)}function h(e){let t=e.length;t<=15?c(144+t):l(t<=65535?[220,t>>>8,t]:[221,t>>>24,t>>>16,t>>>8,t]);for(let i=0;i<t;i++)n(e[i])}function c(e){if(a.length<o+1){let e=2*a.length;for(;e<o+1;)e*=2;let t=new Uint8Array(e);t.set(a),a=t}a[o]=e,o++}function l(e){if(a.length<o+e.length){let t=2*a.length;for(;t<o+e.length;)t*=2;let i=new Uint8Array(t);i.set(a),a=i}a.set(e,o),o+=e.length}function u(e){let t,s;e>=0?(t=e/i,s=e%i):(e++,t=Math.abs(e)/i,s=Math.abs(e)%i,t=~t,s=~s),l([t>>>24,t>>>16,t>>>8,t,s>>>24,s>>>16,s>>>8,s])}}i.d(t,{l:()=>s})},47661:(e,t,i)=>{let s;i.d(t,{$s:()=>I,Ay:()=>ge,H3:()=>oe,JF:()=>_,KR:()=>F,qj:()=>C});const r=new Array(128).fill(void 0);function a(e){return r[e]}r.push(void 0,null,!0,!1);let o=r.length;function n(e){const t=a(e);return function(e){e<132||(r[e]=o,o=e)}(e),t}function d(e){o===r.length&&r.push(r.length+1);const t=o;return o=r[t],r[t]=e,t}const h="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&h.decode();let c=null;function l(){return null!==c&&0!==c.byteLength||(c=new Uint8Array(s.memory.buffer)),c}function u(e,t){return e>>>=0,h.decode(l().subarray(e,e+t))}function f(e){return null==e}let p=null;let m=null;function g(){return null!==m&&0!==m.byteLength||(m=new Int32Array(s.memory.buffer)),m}let v=0;const y="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},b="function"==typeof y.encodeInto?function(e,t){return y.encodeInto(e,t)}:function(e,t){const i=y.encode(e);return t.set(i),{read:e.length,written:i.length}};function w(e,t,i){if(void 0===i){const i=y.encode(e),s=t(i.length,1)>>>0;return l().subarray(s,s+i.length).set(i),v=i.length,s}let s=e.length,r=t(s,1)>>>0;const a=l();let o=0;for(;o<s;o++){const t=e.charCodeAt(o);if(t>127)break;a[r+o]=t}if(o!==s){0!==o&&(e=e.slice(o)),r=i(r,s,s=o+3*e.length,1)>>>0;const t=l().subarray(r+o,r+s);o+=b(e,t).written,r=i(r,s,o,1)>>>0}return v=o,r}let k=null;function S(e){const t=typeof e;if("number"==t||"boolean"==t||null==e)return`${e}`;if("string"==t)return`"${e}"`;if("symbol"==t){const t=e.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=e.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(e)){const t=e.length;let i="[";t>0&&(i+=S(e[0]));for(let s=1;s<t;s++)i+=", "+S(e[s]);return i+="]",i}const i=/\[object ([^\]]+)\]/.exec(toString.call(e));let s;if(!(i.length>1))return toString.call(e);if(s=i[1],"Object"==s)try{return"Object("+JSON.stringify(e)+")"}catch(e){return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:s}const O="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>{s.__wbindgen_export_2.get(e.dtor)(e.a,e.b)}));function T(e,t,i,r){const a={a:e,b:t,cnt:1,dtor:i},o=(...e)=>{a.cnt++;const t=a.a;a.a=0;try{return r(t,a.b,...e)}finally{0==--a.cnt?(s.__wbindgen_export_2.get(a.dtor)(t,a.b),O.unregister(a)):a.a=t}};return o.original=a,O.register(o,a,a),o}function P(e,t){s.__wbindgen_export_3(e,t)}function M(e,t,i){s.__wbindgen_export_4(e,t,d(i))}function I(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16);s.newRpcSignerWithProvider(r,d(e));var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return Q.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}function x(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`);return e.ptr}let A=null;function C(e){x(e,oe);var t=e.__destroy_into_raw();const i=s.newTransfer(t);return re.__wrap(i)}function _(e){x(e,F);var t=e.__destroy_into_raw();const i=s.newContract(t);return q.__wrap(i)}function B(e,t){try{return e.apply(this,t)}catch(e){s.__wbindgen_export_6(d(e))}}Object.freeze({Success:0,0:"Success",Failed:1,1:"Failed",Pending:2,2:"Pending"}),Object.freeze({OnChain:0,0:"OnChain",EthECDSA:1,1:"EthECDSA",EthCREATE2:2,2:"EthCREATE2"}),Object.freeze({Eth:0,0:"Eth",Eip1271:1,1:"Eip1271",Stark:2,2:"Stark"}),Object.freeze({Deposit:1,1:"Deposit",FullExit:5,5:"FullExit",ChangePubKey:6,6:"ChangePubKey",Transfer:4,4:"Transfer",Withdraw:3,3:"Withdraw",ForcedExit:7,7:"ForcedExit",OrderMatching:8,8:"OrderMatching",AutoDeleveraging:11,11:"AutoDeleveraging",ContractMatching:9,9:"ContractMatching",Funding:13,13:"Funding",Liquidation:10,10:"Liquidation",UpdateGlobalVar:12,12:"UpdateGlobalVar"}),Object.freeze({Latest:0,0:"Latest",Finalized:1,1:"Finalized",Safe:2,2:"Safe",Earliest:3,3:"Earliest",Pending:4,4:"Pending",Number:5,5:"Number"}),Object.freeze({FeeAccount:0,0:"FeeAccount",InsuranceFundAccount:1,1:"InsuranceFundAccount",MarginInfo:2,2:"MarginInfo",FundingInfos:3,3:"FundingInfos",ContractInfo:4,4:"ContractInfo"}),Object.freeze({AccountId:0,0:"AccountId",Address:1,1:"Address"}),"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_accountquery_free(e>>>0)));const E="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_autodeleveraging_free(e>>>0)));class L{static __wrap(e){e>>>=0;const t=Object.create(L.prototype);return t.__wbg_ptr=e,E.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,E.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_autodeleveraging_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.autodeleveraging_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.autodeleveraging_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_autodeleveragingbuilder_free(e>>>0)));const R="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_changepubkey_free(e>>>0)));class N{static __wrap(e){e>>>=0;const t=Object.create(N.prototype);return t.__wbg_ptr=e,R.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,R.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_changepubkey_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.changepubkey_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getChangePubkeyMessage(e,t){let i,r;try{const f=s.__wbindgen_add_to_stack_pointer(-16),p=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),m=v;s.changepubkey_getChangePubkeyMessage(f,this.__wbg_ptr,e,p,m);var a=g()[f/4+0],o=g()[f/4+1],d=g()[f/4+2],h=g()[f/4+3],c=a,l=o;if(h)throw c=0,l=0,n(d);return i=c,r=l,u(c,l)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(i,r,1)}}getEthSignMsg(e,t){let i,r;try{const n=s.__wbindgen_add_to_stack_pointer(-16);s.changepubkey_getEthSignMsg(n,this.__wbg_ptr,e,t);var a=g()[n/4+0],o=g()[n/4+1];return i=a,r=o,u(a,o)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(i,r,1)}}setEthAuthData(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.changepubkey_setEthAuthData(r,this.__wbg_ptr,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return n(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.changepubkey_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_changepubkeybuilder_free(e>>>0)));const D="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contract_free(e>>>0)));class q{static __wrap(e){e>>>=0;const t=Object.create(q.prototype);return t.__wbg_ptr=e,D.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,D.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contract_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.contract_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.contract_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const V="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contractbuilder_free(e>>>0)));class F{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contractbuilder_free(e)}constructor(e,t,i,r,a,o,d,h,c,l,u){try{const m=s.__wbindgen_add_to_stack_pointer(-16),y=w(o,s.__wbindgen_export_0,s.__wbindgen_export_1),b=v,k=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),S=v;s.contractbuilder_new(m,e,t,i,r,a,y,b,k,S,h,c,l,u);var f=g()[m/4+0],p=g()[m/4+1];if(g()[m/4+2])throw n(p);return this.__wbg_ptr=f>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}build(){const e=this.__destroy_into_raw(),t=s.contractbuilder_build(e);return q.__wrap(t)}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractinfo_free(e>>>0)));const H="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_contractmatching_free(e>>>0)));class G{static __wrap(e){e>>>=0;const t=Object.create(G.prototype);return t.__wbg_ptr=e,H.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_contractmatching_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.contractmatching_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.contractmatching_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractmatchingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_contractprice_free(e>>>0)));const U="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_create2data_free(e>>>0)));class W{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,U.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_create2data_free(e)}constructor(e,t,i){try{const o=s.__wbindgen_add_to_stack_pointer(-16),d=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),h=v,c=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),l=v,u=w(i,s.__wbindgen_export_0,s.__wbindgen_export_1),f=v;s.create2data_new(o,d,h,c,l,u,f);var r=g()[o/4+0],a=g()[o/4+1];if(g()[o/4+2])throw n(a);return this.__wbg_ptr=r>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}salt(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.create2data_salt(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.create2data_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_ethtxoption_free(e>>>0)));const j="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_forcedexit_free(e>>>0)));class z{static __wrap(e){e>>>=0;const t=Object.create(z.prototype);return t.__wbg_ptr=e,j.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,j.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_forcedexit_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.forcedexit_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.forcedexit_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_forcedexitbuilder_free(e>>>0)));const K="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_funding_free(e>>>0)));class Y{static __wrap(e){e>>>=0;const t=Object.create(Y.prototype);return t.__wbg_ptr=e,K.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,K.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_funding_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.funding_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.funding_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_fundingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_fundinginfo_free(e>>>0)));const X="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_jsonrpcsigner_free(e>>>0)));class Q{static __wrap(e){e>>>=0;const t=Object.create(Q.prototype);return t.__wbg_ptr=e,X.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,X.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_jsonrpcsigner_free(e)}initZklinkSigner(e){var t=f(e)?0:w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),i=v;return n(s.jsonrpcsigner_initZklinkSigner(this.__wbg_ptr,t,i))}getPubkey(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_getPubkey(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}pubkeyHash(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_pubkeyHash(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}address(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_address(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];let r;return 0!==e&&(r=u(e,t).slice(),s.__wbindgen_export_5(e,1*t,1)),r}finally{s.__wbindgen_add_to_stack_pointer(16)}}signatureSeed(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.jsonrpcsigner_signatureSeed(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}signChangePubkeyWithOnchain(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,N);var t=e.__destroy_into_raw();s.jsonrpcsigner_signChangePubkeyWithOnchain(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signChangePubkeyWithEthEcdsaAuth(e){x(e,N);var t=e.__destroy_into_raw();return n(s.jsonrpcsigner_signChangePubkeyWithEthEcdsaAuth(this.__wbg_ptr,t))}signChangePubkeyWithCreate2DataAuth(e,t){try{const d=s.__wbindgen_add_to_stack_pointer(-16);x(e,N);var i=e.__destroy_into_raw();x(t,W);var r=t.__destroy_into_raw();s.jsonrpcsigner_signChangePubkeyWithCreate2DataAuth(d,this.__wbg_ptr,i,r);var a=g()[d/4+0],o=g()[d/4+1];if(g()[d/4+2])throw n(o);return n(a)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signTransfer(e,t){x(e,re);var i=e.__destroy_into_raw();const r=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),a=v;return n(s.jsonrpcsigner_signTransfer(this.__wbg_ptr,i,r,a))}createSignedOrder(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ee);var t=e.__destroy_into_raw();s.jsonrpcsigner_createSignedOrder(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signOrderMatching(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ie);var t=e.__destroy_into_raw();s.jsonrpcsigner_signOrderMatching(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signWithdraw(e,t){x(e,ce);var i=e.__destroy_into_raw();const r=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),a=v;return n(s.jsonrpcsigner_signWithdraw(this.__wbg_ptr,i,r,a))}signForcedExit(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,z);var t=e.__destroy_into_raw();s.jsonrpcsigner_signForcedExit(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signAutoDeleveraging(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,L);var t=e.__destroy_into_raw();s.jsonrpcsigner_signAutoDeleveraging(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}createSignedContract(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,q);var t=e.__destroy_into_raw();s.jsonrpcsigner_createSignedContract(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signContractMatching(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,G);var t=e.__destroy_into_raw();s.jsonrpcsigner_signContractMatching(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signFunding(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,Y);var t=e.__destroy_into_raw();s.jsonrpcsigner_signFunding(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signLiquidation(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,$);var t=e.__destroy_into_raw();s.jsonrpcsigner_signLiquidation(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}signMusig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=function(e,t){const i=t(1*e.length,1)>>>0;return l().set(e,i/1),v=e.length,i}(e,s.__wbindgen_export_0),o=v;s.jsonrpcsigner_signMusig(r,this.__wbg_ptr,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return de.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getZkLinkSigner(){const e=s.jsonrpcsigner_getZkLinkSigner(this.__wbg_ptr);return ue.__wrap(e)}}const Z="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_liquidation_free(e>>>0)));class ${static __wrap(e){e>>>=0;const t=Object.create($.prototype);return t.__wbg_ptr=e,Z.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_liquidation_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.liquidation_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.liquidation_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_liquidationbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_margininfo_free(e>>>0)));const J="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_order_free(e>>>0)));class ee{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,J.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_order_free(e)}constructor(e,t,i,r,a,o,d,h,c,l,u,f){try{const y=s.__wbindgen_add_to_stack_pointer(-16),b=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),k=v,S=w(h,s.__wbindgen_export_0,s.__wbindgen_export_1),O=v;s.order_new(y,e,t,i,r,a,o,b,k,S,O,c,l,u,f);var p=g()[y/4+0],m=g()[y/4+1];if(g()[y/4+2])throw n(m);return this.__wbg_ptr=p>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.order_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.order_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const te="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_ordermatching_free(e>>>0)));class ie{static __wrap(e){e>>>=0;const t=Object.create(ie.prototype);return t.__wbg_ptr=e,te.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,te.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_ordermatching_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.ordermatching_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_ordermatchingbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_parameter_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_requestarguments_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_rpcclient_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_spotpriceinfo_free(e>>>0)));const se="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_transfer_free(e>>>0)));class re{static __wrap(e){e>>>=0;const t=Object.create(re.prototype);return t.__wbg_ptr=e,se.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,se.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_transfer_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.transfer_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getEthSignMsg(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.transfer_getEthSignMsg(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.transfer_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}const ae="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_transferbuilder_free(e>>>0)));class oe{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ae.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_transferbuilder_free(e)}constructor(e,t,i,r,a,o,d,h,c){try{const p=s.__wbindgen_add_to_stack_pointer(-16),m=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),y=v,b=w(o,s.__wbindgen_export_0,s.__wbindgen_export_1),k=v,S=w(d,s.__wbindgen_export_0,s.__wbindgen_export_1),O=v;s.transferbuilder_new(p,e,m,y,i,r,a,b,k,S,O,h,!f(c),f(c)?0:c);var l=g()[p/4+0],u=g()[p/4+1];if(g()[p/4+2])throw n(u);return this.__wbg_ptr=l>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}build(){const e=this.__destroy_into_raw(),t=s.transferbuilder_build(e);return re.__wrap(t)}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_txlayer1signature_free(e>>>0)));const ne="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_txzklinksignature_free(e>>>0)));class de{static __wrap(e){e>>>=0;const t=Object.create(de.prototype);return t.__wbg_ptr=e,ne.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ne.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_txzklinksignature_free(e)}constructor(e,t){try{const a=s.__wbindgen_add_to_stack_pointer(-16),o=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v,h=w(t,s.__wbindgen_export_0,s.__wbindgen_export_1),c=v;s.txzklinksignature_new(a,o,d,h,c);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return this.__wbg_ptr=i>>>0,this}finally{s.__wbindgen_add_to_stack_pointer(16)}}pubKey(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.txzklinksignature_pubKey(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}signature(){let e,t;try{const a=s.__wbindgen_add_to_stack_pointer(-16);s.txzklinksignature_signature(a,this.__wbg_ptr);var i=g()[a/4+0],r=g()[a/4+1];return e=i,t=r,u(i,r)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(e,t,1)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_updateglobalvar_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_updateglobalvarbuilder_free(e>>>0)));"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_wallet_free(e>>>0)));const he="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_withdraw_free(e>>>0)));class ce{static __wrap(e){e>>>=0;const t=Object.create(ce.prototype);return t.__wbg_ptr=e,he.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_withdraw_free(e)}jsValue(){try{const i=s.__wbindgen_add_to_stack_pointer(-16);s.withdraw_jsValue(i,this.__wbg_ptr);var e=g()[i/4+0],t=g()[i/4+1];if(g()[i/4+2])throw n(t);return n(e)}finally{s.__wbindgen_add_to_stack_pointer(16)}}getEthSignMsg(e){let t,i;try{const o=s.__wbindgen_add_to_stack_pointer(-16),n=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),d=v;s.withdraw_getEthSignMsg(o,this.__wbg_ptr,n,d);var r=g()[o/4+0],a=g()[o/4+1];return t=r,i=a,u(r,a)}finally{s.__wbindgen_add_to_stack_pointer(16),s.__wbindgen_export_5(t,i,1)}}sign(e){try{const a=s.__wbindgen_add_to_stack_pointer(-16);x(e,ue);var t=e.__destroy_into_raw();s.withdraw_sign(a,this.__wbg_ptr,t);var i=g()[a/4+0],r=g()[a/4+1];if(g()[a/4+2])throw n(r);return n(i)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_withdrawbuilder_free(e>>>0)));const le="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>s.__wbg_zklinksigner_free(e>>>0)));class ue{static __wrap(e){e>>>=0;const t=Object.create(ue.prototype);return t.__wbg_ptr=e,le.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,le.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_zklinksigner_free(e)}static ethSig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.zklinksigner_ethSig(r,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return ue.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}static starknetSig(e){try{const r=s.__wbindgen_add_to_stack_pointer(-16),a=w(e,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;s.zklinksigner_starknetSig(r,a,o);var t=g()[r/4+0],i=g()[r/4+1];if(g()[r/4+2])throw n(i);return ue.__wrap(t)}finally{s.__wbindgen_add_to_stack_pointer(16)}}}"undefined"==typeof FinalizationRegistry||new FinalizationRegistry((e=>s.__wbg_zklinktx_free(e>>>0)));function fe(){const e={wbg:{}};return e.wbg.__wbindgen_object_drop_ref=function(e){n(e)},e.wbg.__wbg_request_aa80f2dd90291bcc=function(){return B((function(e,t){return d(a(e).request(n(t)))}),arguments)},e.wbg.__wbg_signMessage_31620e519ceecf94=function(){return B((function(e,t){return d(a(e).signMessage(a(t)))}),arguments)},e.wbg.__wbindgen_number_new=function(e){return d(e)},e.wbg.__wbindgen_string_new=function(e,t){return d(u(e,t))},e.wbg.__wbindgen_is_undefined=function(e){return void 0===a(e)},e.wbg.__wbindgen_in=function(e,t){return a(e)in a(t)},e.wbg.__wbindgen_boolean_get=function(e){const t=a(e);return"boolean"==typeof t?t?1:0:2},e.wbg.__wbindgen_is_bigint=function(e){return"bigint"==typeof a(e)},e.wbg.__wbindgen_number_get=function(e,t){const i=a(t),r="number"==typeof i?i:void 0;(null!==p&&0!==p.byteLength||(p=new Float64Array(s.memory.buffer)),p)[e/8+1]=f(r)?0:r,g()[e/4+0]=!f(r)},e.wbg.__wbindgen_bigint_from_i64=function(e){return d(e)},e.wbg.__wbindgen_jsval_eq=function(e,t){return a(e)===a(t)},e.wbg.__wbindgen_string_get=function(e,t){const i=a(t),r="string"==typeof i?i:void 0;var o=f(r)?0:w(r,s.__wbindgen_export_0,s.__wbindgen_export_1),n=v;g()[e/4+1]=n,g()[e/4+0]=o},e.wbg.__wbindgen_is_object=function(e){const t=a(e);return"object"==typeof t&&null!==t},e.wbg.__wbindgen_bigint_from_u64=function(e){return d(BigInt.asUintN(64,e))},e.wbg.__wbindgen_object_clone_ref=function(e){return d(a(e))},e.wbg.__wbindgen_as_number=function(e){return+a(e)},e.wbg.__wbindgen_error_new=function(e,t){return d(new Error(u(e,t)))},e.wbg.__wbg_performance_eeefc685c9bc38b4=function(e){return d(a(e).performance)},e.wbg.__wbg_now_e0d8ec93dd25766a=function(e){return a(e).now()},e.wbg.__wbg_selectedAddress_e88960714bb47d11=function(e,t){const i=a(t).selectedAddress;var r=f(i)?0:w(i,s.__wbindgen_export_0,s.__wbindgen_export_1),o=v;g()[e/4+1]=o,g()[e/4+0]=r},e.wbg.__wbg_address_b7ff4a10022d02d8=function(e,t){const i=w(a(t).address,s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbindgen_jsval_loose_eq=function(e,t){return a(e)==a(t)},e.wbg.__wbg_String_389b54bd9d25375f=function(e,t){const i=w(String(a(t)),s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbg_getwithrefkey_4a92a5eca60879b9=function(e,t){return d(a(e)[a(t)])},e.wbg.__wbg_set_9182712abebf82ef=function(e,t,i){a(e)[n(t)]=n(i)},e.wbg.__wbindgen_cb_drop=function(e){const t=n(e).original;if(1==t.cnt--)return t.a=0,!0;return!1},e.wbg.__wbg_clearTimeout_76877dbc010e786d=function(e){return d(clearTimeout(n(e)))},e.wbg.__wbg_setTimeout_75cb9b6991a4031d=function(){return B((function(e,t){return d(setTimeout(a(e),t))}),arguments)},e.wbg.__wbg_fetch_6a2624d7f767e331=function(e){return d(fetch(a(e)))},e.wbg.__wbg_fetch_693453ca3f88c055=function(e,t){return d(a(e).fetch(a(t)))},e.wbg.__wbg_new_7a20246daa6eec7e=function(){return B((function(){return d(new Headers)}),arguments)},e.wbg.__wbg_append_aa3f462f9e2b5ff2=function(){return B((function(e,t,i,s,r){a(e).append(u(t,i),u(s,r))}),arguments)},e.wbg.__wbg_newwithstrandinit_f581dff0d19a8b03=function(){return B((function(e,t,i){return d(new Request(u(e,t),a(i)))}),arguments)},e.wbg.__wbg_signal_3c701f5f40a5f08d=function(e){return d(a(e).signal)},e.wbg.__wbg_new_0ae46f44b7485bb2=function(){return B((function(){return d(new AbortController)}),arguments)},e.wbg.__wbg_abort_2c4fb490d878d2b2=function(e){a(e).abort()},e.wbg.__wbg_instanceof_Response_4c3b1446206114d1=function(e){let t;try{t=a(e)instanceof Response}catch(e){t=!1}return t},e.wbg.__wbg_url_83a6a4f65f7a2b38=function(e,t){const i=w(a(t).url,s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbg_status_d6d47ad2837621eb=function(e){return a(e).status},e.wbg.__wbg_headers_24def508a7518df9=function(e){return d(a(e).headers)},e.wbg.__wbg_arrayBuffer_5b2688e3dd873fed=function(){return B((function(e){return d(a(e).arrayBuffer())}),arguments)},e.wbg.__wbg_queueMicrotask_481971b0d87f3dd4=function(e){queueMicrotask(a(e))},e.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6=function(e){return d(a(e).queueMicrotask)},e.wbg.__wbindgen_is_function=function(e){return"function"==typeof a(e)},e.wbg.__wbg_crypto_58f13aa23ffcb166=function(e){return d(a(e).crypto)},e.wbg.__wbg_process_5b786e71d465a513=function(e){return d(a(e).process)},e.wbg.__wbg_versions_c2ab80650590b6a2=function(e){return d(a(e).versions)},e.wbg.__wbg_node_523d7bd03ef69fba=function(e){return d(a(e).node)},e.wbg.__wbindgen_is_string=function(e){return"string"==typeof a(e)},e.wbg.__wbg_require_2784e593a4674877=function(){return B((function(){return d(module.require)}),arguments)},e.wbg.__wbg_msCrypto_abcb1295e768d1f2=function(e){return d(a(e).msCrypto)},e.wbg.__wbg_randomFillSync_a0d98aa11c81fe89=function(){return B((function(e,t){a(e).randomFillSync(n(t))}),arguments)},e.wbg.__wbg_getRandomValues_504510b5564925af=function(){return B((function(e,t){a(e).getRandomValues(a(t))}),arguments)},e.wbg.__wbg_get_bd8e338fbd5f5cc8=function(e,t){return d(a(e)[t>>>0])},e.wbg.__wbg_length_cd7af8117672b8b8=function(e){return a(e).length},e.wbg.__wbg_new_16b304a2cfa7ff4a=function(){return d(new Array)},e.wbg.__wbg_newnoargs_e258087cd0daa0ea=function(e,t){return d(new Function(u(e,t)))},e.wbg.__wbg_new_d9bc3a0147634640=function(){return d(new Map)},e.wbg.__wbg_next_40fc327bfc8770e6=function(e){return d(a(e).next)},e.wbg.__wbg_next_196c84450b364254=function(){return B((function(e){return d(a(e).next())}),arguments)},e.wbg.__wbg_done_298b57d23c0fc80c=function(e){return a(e).done},e.wbg.__wbg_value_d93c65011f51a456=function(e){return d(a(e).value)},e.wbg.__wbg_iterator_2cee6dadfd956dfa=function(){return d(Symbol.iterator)},e.wbg.__wbg_get_e3c254076557e348=function(){return B((function(e,t){return d(Reflect.get(a(e),a(t)))}),arguments)},e.wbg.__wbg_call_27c0f87801dedf93=function(){return B((function(e,t){return d(a(e).call(a(t)))}),arguments)},e.wbg.__wbg_new_72fb9a18b5ae2624=function(){return d(new Object)},e.wbg.__wbg_self_ce0dbfc45cf2f5be=function(){return B((function(){return d(self.self)}),arguments)},e.wbg.__wbg_window_c6fb939a7f436783=function(){return B((function(){return d(window.window)}),arguments)},e.wbg.__wbg_globalThis_d1e6af4856ba331b=function(){return B((function(){return d(globalThis.globalThis)}),arguments)},e.wbg.__wbg_global_207b558942527489=function(){return B((function(){return d(global.global)}),arguments)},e.wbg.__wbg_set_d4638f722068f043=function(e,t,i){a(e)[t>>>0]=n(i)},e.wbg.__wbg_isArray_2ab64d95e09ea0ae=function(e){return Array.isArray(a(e))},e.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2=function(e){let t;try{t=a(e)instanceof ArrayBuffer}catch(e){t=!1}return t},e.wbg.__wbg_call_b3ca7c6051f9bec1=function(){return B((function(e,t,i){return d(a(e).call(a(t),a(i)))}),arguments)},e.wbg.__wbg_set_8417257aaedc936b=function(e,t,i){return d(a(e).set(a(t),a(i)))},e.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2=function(e){return Number.isSafeInteger(a(e))},e.wbg.__wbg_entries_95cc2c823b285a09=function(e){return d(Object.entries(a(e)))},e.wbg.__wbg_new_81740750da40724f=function(e,t){try{var i={a:e,b:t};const r=new Promise(((e,t)=>{const r=i.a;i.a=0;try{return function(e,t,i,r){s.__wbindgen_export_7(e,t,d(i),d(r))}(r,i.b,e,t)}finally{i.a=r}}));return d(r)}finally{i.a=i.b=0}},e.wbg.__wbg_resolve_b0083a7967828ec8=function(e){return d(Promise.resolve(a(e)))},e.wbg.__wbg_then_0c86a60e8fcfe9f6=function(e,t){return d(a(e).then(a(t)))},e.wbg.__wbg_then_a73caa9a87991566=function(e,t,i){return d(a(e).then(a(t),a(i)))},e.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){return d(a(e).buffer)},e.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(e,t,i){return d(new Uint8Array(a(e),t>>>0,i>>>0))},e.wbg.__wbg_new_63b92bc8671ed464=function(e){return d(new Uint8Array(a(e)))},e.wbg.__wbg_set_a47bac70306a19a7=function(e,t,i){a(e).set(a(t),i>>>0)},e.wbg.__wbg_length_c20a40f15020d68a=function(e){return a(e).length},e.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(e){let t;try{t=a(e)instanceof Uint8Array}catch(e){t=!1}return t},e.wbg.__wbg_newwithlength_e9b4878cebadb3d3=function(e){return d(new Uint8Array(e>>>0))},e.wbg.__wbg_subarray_a1f73cd4b5b42fe1=function(e,t,i){return d(a(e).subarray(t>>>0,i>>>0))},e.wbg.__wbg_has_0af94d20077affa2=function(){return B((function(e,t){return Reflect.has(a(e),a(t))}),arguments)},e.wbg.__wbg_set_1f9b04f170055d33=function(){return B((function(e,t,i){return Reflect.set(a(e),a(t),a(i))}),arguments)},e.wbg.__wbg_stringify_8887fe74e1c50d81=function(){return B((function(e){return d(JSON.stringify(a(e)))}),arguments)},e.wbg.__wbindgen_bigint_get_as_i64=function(e,t){const i=a(t),r="bigint"==typeof i?i:void 0;(null!==k&&0!==k.byteLength||(k=new BigInt64Array(s.memory.buffer)),k)[e/8+1]=f(r)?BigInt(0):r,g()[e/4+0]=!f(r)},e.wbg.__wbindgen_debug_string=function(e,t){const i=w(S(a(t)),s.__wbindgen_export_0,s.__wbindgen_export_1),r=v;g()[e/4+1]=r,g()[e/4+0]=i},e.wbg.__wbindgen_throw=function(e,t){throw new Error(u(e,t))},e.wbg.__wbindgen_memory=function(){return d(s.memory)},e.wbg.__wbindgen_closure_wrapper3897=function(e,t,i){return d(T(e,t,699,P))},e.wbg.__wbindgen_closure_wrapper7350=function(e,t,i){return d(T(e,t,1724,M))},e}function pe(e,t){return s=e.exports,me.__wbindgen_wasm_module=t,k=null,p=null,m=null,A=null,c=null,s}async function me(e){if(void 0!==s)return s;void 0===e&&(e="https://qa.omni.apex.exchange/api/v3/download/zklink-sdk-web_bg.wasm");const t=fe();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:i,module:r}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}{const i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}}(await e,t);return pe(i,r)}const ge=me}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var i=a[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(i,s){if(1&s&&(i=this(i)),8&s)return i;if("object"==typeof i&&i){if(4&s&&i.__esModule)return i;if(16&s&&"function"==typeof i.then)return i}var r=Object.create(null);o.r(r);var a={};e=e||[null,t({}),t([]),t(t)];for(var n=2&s&&i;"object"==typeof n&&!~e.indexOf(n);n=t(n))Object.getOwnPropertyNames(n).forEach((e=>a[e]=()=>i[e]));return a.default=()=>i,o.d(r,a),r},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,i)=>(o.f[i](e,t),t)),[])),o.u=e=>e+".ccxt.browser.min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i={},s="ccxt:",o.l=(e,t,r,a)=>{if(i[e])i[e].push(t);else{var n,d;if(void 0!==r)for(var h=document.getElementsByTagName("script"),c=0;c<h.length;c++){var l=h[c];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==s+r){n=l;break}}n||(d=!0,(n=document.createElement("script")).charset="utf-8",n.timeout=120,o.nc&&n.setAttribute("nonce",o.nc),n.setAttribute("data-webpack",s+r),n.src=e),i[e]=[t];var u=(t,s)=>{n.onerror=n.onload=null,clearTimeout(f);var r=i[e];if(delete i[e],n.parentNode&&n.parentNode.removeChild(n),r&&r.forEach((e=>e(s))),t)return t(s)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),d&&document.head.appendChild(n)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=i[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={792:0};o.f.j=(t,i)=>{var s=o.o(e,t)?e[t]:void 0;if(0!==s)if(s)i.push(s[2]);else{var r=new Promise(((i,r)=>s=e[t]=[i,r]));i.push(s[2]=r);var a=o.p+o.u(t),n=new Error;o.l(a,(i=>{if(o.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var r=i&&("load"===i.type?"missing":i.type),a=i&&i.target&&i.target.src;n.message="Loading chunk "+t+" failed.\n("+r+": "+a+")",n.name="ChunkLoadError",n.type=r,n.request=a,s[1](n)}}),"chunk-"+t,t)}};var t=(t,i)=>{var s,r,[a,n,d]=i,h=0;if(a.some((t=>0!==e[t]))){for(s in n)o.o(n,s)&&(o.m[s]=n[s]);if(d)d(o)}for(t&&t(i);h<a.length;h++)r=a[h],o.o(e,r)&&e[r]&&e[r][0](),e[r]=0},i=self.webpackChunkccxt=self.webpackChunkccxt||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var n={};o.r(n),o.d(n,{AccountNotEnabled:()=>l.AccountNotEnabled,AccountSuspended:()=>l.AccountSuspended,AddressPending:()=>l.AddressPending,ArgumentsRequired:()=>l.ArgumentsRequired,AuthenticationError:()=>l.AuthenticationError,BadRequest:()=>l.BadRequest,BadResponse:()=>l.BadResponse,BadSymbol:()=>l.BadSymbol,BaseError:()=>l.BaseError,CancelPending:()=>l.CancelPending,ChecksumError:()=>l.ChecksumError,ContractUnavailable:()=>l.ContractUnavailable,DDoSProtection:()=>l.DDoSProtection,DuplicateOrderId:()=>l.DuplicateOrderId,Exchange:()=>d.k,ExchangeClosedByUser:()=>l.ExchangeClosedByUser,ExchangeError:()=>l.ExchangeError,ExchangeNotAvailable:()=>l.ExchangeNotAvailable,InsufficientFunds:()=>l.InsufficientFunds,InvalidAddress:()=>l.InvalidAddress,InvalidNonce:()=>l.InvalidNonce,InvalidOrder:()=>l.InvalidOrder,InvalidProxySettings:()=>l.InvalidProxySettings,ManualInteractionNeeded:()=>l.ManualInteractionNeeded,MarginModeAlreadySet:()=>l.MarginModeAlreadySet,MarketClosed:()=>l.MarketClosed,NetworkError:()=>l.NetworkError,NoChange:()=>l.NoChange,NotSupported:()=>l.NotSupported,NullResponse:()=>l.NullResponse,OnMaintenance:()=>l.OnMaintenance,OperationFailed:()=>l.OperationFailed,OperationRejected:()=>l.OperationRejected,OrderImmediatelyFillable:()=>l.OrderImmediatelyFillable,OrderNotCached:()=>l.OrderNotCached,OrderNotFillable:()=>l.OrderNotFillable,OrderNotFound:()=>l.OrderNotFound,PermissionDenied:()=>l.PermissionDenied,Precise:()=>h.Y,RateLimitExceeded:()=>l.RateLimitExceeded,RequestTimeout:()=>l.RequestTimeout,RestrictedLocation:()=>l.RestrictedLocation,UnsubscribeError:()=>l.UnsubscribeError,abantether:()=>u.A,afratether:()=>f.A,alpaca:()=>p.A,apex:()=>m.A,ariomex:()=>g.A,arzinja:()=>v.A,arzplus:()=>y.A,asacoine:()=>b.A,ascendex:()=>w.A,asretether:()=>k.A,baazar:()=>S.A,bequant:()=>O.A,bidarz:()=>T.A,bigone:()=>P.A,binance:()=>M.A,binancecoinm:()=>I.A,binanceus:()=>x.A,binanceusdm:()=>A.A,bingx:()=>C.A,bit24:()=>_.A,bit2c:()=>B.A,bitbank:()=>E.A,bitbarg:()=>L.A,bitbns:()=>R.A,bitfinex:()=>N.A,bitflyer:()=>D.A,bitget:()=>q.A,bithumb:()=>V.A,bitimen:()=>F.A,bitir:()=>H.A,bitmart:()=>G.A,bitmex:()=>U.A,bitopro:()=>W.A,bitpin:()=>j.A,bitrue:()=>z.A,bitso:()=>K.A,bitstamp:()=>Y.A,bitteam:()=>X.A,bittrade:()=>Q.A,bitunix:()=>Z.A,bitvavo:()=>$.A,bitwana:()=>J.A,blockchaincom:()=>ee.A,blofin:()=>te.A,btcalpha:()=>ie.A,btcbox:()=>se.A,btcmarkets:()=>re.A,btcturk:()=>ae.A,bybit:()=>oe.A,bydfi:()=>ne.A,cafearz:()=>de.A,cex:()=>he.A,changefa:()=>ce.A,coinbase:()=>le.A,coinbaseadvanced:()=>ue.A,coinbaseexchange:()=>fe.A,coinbaseinternational:()=>pe.A,coincatch:()=>me.A,coincheck:()=>ge.A,coinex:()=>ve.A,coinmate:()=>ye.A,coinmetro:()=>be.A,coinone:()=>we.A,coinsph:()=>ke.A,coinspot:()=>Se.A,cryptocom:()=>Oe.A,cryptomus:()=>Te.A,daric:()=>Pe.A,default:()=>Ys,defx:()=>Me.A,delta:()=>Ie.A,deribit:()=>xe.A,derive:()=>Ae.A,digifinex:()=>Ce.A,digikalagold:()=>_e.A,ellipx:()=>Be.A,errors:()=>l,eterex:()=>Ee.A,exchanges:()=>zs,excoino:()=>Le.A,exino:()=>Re.A,exir:()=>Ne.A,exmo:()=>De.A,exnovin:()=>qe.A,farhadexchange:()=>Ve.A,fmfwio:()=>Fe.A,foxbit:()=>He.A,functions:()=>c,gate:()=>Ge.A,gateio:()=>Ue.A,gemini:()=>We.A,gerami:()=>je.A,goldika:()=>ze.A,goldis:()=>Ke.A,hamrahgold:()=>Ye.A,hamtapay:()=>Xe.A,hashkey:()=>Qe.A,hibachi:()=>Ze.A,hitbtc:()=>$e.A,hitobit:()=>Je.A,hollaex:()=>et.A,htx:()=>tt.A,huobi:()=>it.A,hyperliquid:()=>st.A,independentreserve:()=>rt.A,indodax:()=>at.A,iranexchange:()=>ot.A,jibitex:()=>nt.A,kcex:()=>dt.A,kifpoolme:()=>ht.A,kraken:()=>ct.A,krakenfutures:()=>lt.A,kucoin:()=>ut.A,kucoinfutures:()=>ft.A,latoken:()=>pt.A,lbank:()=>mt.A,luno:()=>gt.A,mazdax:()=>vt.A,melligold:()=>yt.A,mercado:()=>bt.A,mexc:()=>wt.A,milligold:()=>kt.A,modetrade:()=>St.A,myokx:()=>Ot.A,ndax:()=>Tt.A,nobitex:()=>Pt.A,novadax:()=>Mt.A,oceanex:()=>It.A,okcoin:()=>xt.A,okexchange:()=>At.A,okx:()=>Ct.A,okxus:()=>_t.A,ompfinex:()=>Bt.A,onetrading:()=>Et.A,ourbit:()=>Lt.A,oxfun:()=>Rt.A,p2b:()=>Nt.A,paradex:()=>Dt.A,paymium:()=>qt.A,phemex:()=>Vt.A,pingi:()=>Ft.A,poloniex:()=>Ht.A,pooleno:()=>Gt.A,poulyar:()=>Ut.A,pro:()=>Ks,probit:()=>Wt.A,raastin:()=>jt.A,ramzinex:()=>zt.A,saraf:()=>Kt.A,sarmayex:()=>Yt.A,sarrafex:()=>Xt.A,swapwallet:()=>Qt.A,tabdeal:()=>Zt.A,talaavan:()=>$t.A,talapp:()=>Jt.A,talasea:()=>ei.A,technogold:()=>ti.A,tehran_exchange:()=>ii.A,tetherland:()=>si.A,timex:()=>ri.A,tokocrypto:()=>ai.A,toobit:()=>oi.A,tradeogre:()=>ni.A,twox:()=>di.A,ubitex:()=>hi.A,upbit:()=>ci.A,version:()=>js,vertex:()=>li.A,wallex:()=>ui.A,wallgold:()=>fi.A,wavesexchange:()=>pi.A,whitebit:()=>mi.A,woo:()=>gi.A,woofipro:()=>vi.A,xt:()=>yi.A,yobit:()=>bi.A,zaif:()=>wi.A,zarafza:()=>ki.A,zarminex:()=>Si.A,zarniv:()=>Oi.A,zarpin:()=>Ti.A,zonda:()=>Pi.A});var d=o(72961),h=o(85147),c=o(15095),l=o(62079),u=o(51656),f=o(95566),p=o(77930),m=o(64920),g=o(83761),v=o(16371),y=o(2065),b=o(41421),w=o(71411),k=o(56077),S=o(28929),O=o(49002),T=o(56882),P=o(58698),M=o(13192),I=o(51510),x=o(68228),A=o(72171),C=o(72480),_=o(61183),B=o(72342),E=o(17399),L=o(82799),R=o(26328),N=o(88657),D=o(41787),q=o(67757),V=o(60357),F=o(84456),H=o(39314),G=o(31837),U=o(99523),W=o(72753),j=o(9558),z=o(99061),K=o(93019),Y=o(382),X=o(60112),Q=o(92263),Z=o(60587),$=o(83727),J=o(37420),ee=o(73205),te=o(42520),ie=o(53413),se=o(75376),re=o(34936),ae=o(59265),oe=o(45462),ne=o(5e3),de=o(25226),he=o(78846),ce=o(86257),le=o(17504),ue=o(63278),fe=o(4293),pe=o(1558),me=o(20570),ge=o(22741),ve=o(39344),ye=o(6016),be=o(18692),we=o(65377),ke=o(52692),Se=o(51669),Oe=o(56068),Te=o(30870),Pe=o(55557),Me=o(26077),Ie=o(41080),xe=o(72591),Ae=o(71839),Ce=o(30779),_e=o(3062),Be=o(71962),Ee=o(36415),Le=o(89335),Re=o(23833),Ne=o(9098),De=o(57057),qe=o(99169),Ve=o(6711),Fe=o(63042),He=o(60448),Ge=o(99403),Ue=o(28403),We=o(58823),je=o(37459),ze=o(52067),Ke=o(32814),Ye=o(38499),Xe=o(9369),Qe=o(62937),Ze=o(95106),$e=o(37996),Je=o(675),et=o(24455),tt=o(59946),it=o(70063),st=o(1936),rt=o(44162),at=o(17325),ot=o(15073),nt=o(60835),dt=o(71199),ht=o(93644),ct=o(18042),lt=o(32300),ut=o(41397),ft=o(86217),pt=o(8146),mt=o(13144),gt=o(59248),vt=o(70509),yt=o(10361),bt=o(46419),wt=o(92403),kt=o(98301),St=o(85345),Ot=o(78982),Tt=o(82079),Pt=o(51561),Mt=o(38473),It=o(13805),xt=o(87915),At=o(79),Ct=o(93660),_t=o(63536),Bt=o(848),Et=o(43573),Lt=o(16469),Rt=o(66358),Nt=o(94998),Dt=o(76993),qt=o(43280),Vt=o(29075),Ft=o(88785),Ht=o(30288),Gt=o(28920),Ut=o(31562),Wt=o(27418),jt=o(79614),zt=o(30676),Kt=o(99451),Yt=o(55822),Xt=o(59702),Qt=o(7814),Zt=o(35619),$t=o(90200),Jt=o(30236),ei=o(43829),ti=o(80501),ii=o(67496),si=o(77497),ri=o(66213),ai=o(42490),oi=o(90237),ni=o(45887),di=o(58586),hi=o(73551),ci=o(90930),li=o(84910),ui=o(88633),fi=o(56314),pi=o(57073),mi=o(75336),gi=o(40669),vi=o(99641),yi=o(55344),bi=o(87469),wi=o(1530),ki=o(20285),Si=o(57562),Oi=o(93290),Ti=o(30528),Pi=o(46022),Mi=o(46810),Ii=o(40136),xi=o(36419),Ai=o(29338),Ci=o(19544),_i=o(40902),Bi=o(88788),Ei=o(68251),Li=o(89456),Ri=o(98657),Ni=o(90205),Di=o(96181),qi=o(53069),Vi=o(43731),Fi=o(54401),Hi=o(43333),Gi=o(73326),Ui=o(82391),Wi=o(11327),ji=o(78693),zi=o(61672),Ki=o(8518),Yi=o(93774),Xi=o(98160),Qi=o(45918),Zi=o(11925),$i=o(998),Ji=o(3242),es=o(85317),ts=o(49088),is=o(58673),ss=o(6292),rs=o(28717),as=o(77791),os=o(82127),ns=o(65233),ds=o(19195),hs=o(75843),cs=o(40375),ls=o(21481),us=o(54524),fs=o(48247),ps=o(63898),ms=o(86335),gs=o(53984),vs=o(70098),ys=o(99050),bs=o(46396),ws=o(84965),ks=o(90905),Ss=o(21736),Os=o(22208),Ts=o(89219),Ps=o(80049),Ms=o(23062),Is=o(63887),xs=o(16187),As=o(8588),Cs=o(83296),_s=o(64357),Bs=o(550),Es=o(44934),Ls=o(51057),Rs=o(51619),Ns=o(83456),Ds=o(25738),qs=o(28719),Vs=o(65794),Fs=o(10910),Hs=o(14712),Gs=o(65869),Us=o(28713),Ws=o(22368);const js="4.23.0";d.k.ccxtVersion=js;const zs={abantether:u.A,afratether:f.A,alpaca:p.A,apex:m.A,ariomex:g.A,arzinja:v.A,arzplus:y.A,asacoine:b.A,ascendex:w.A,asretether:k.A,baazar:S.A,bequant:O.A,bidarz:T.A,bigone:P.A,binance:M.A,binancecoinm:I.A,binanceus:x.A,binanceusdm:A.A,bingx:C.A,bit24:_.A,bit2c:B.A,bitbank:E.A,bitbarg:L.A,bitbns:R.A,bitfinex:N.A,bitflyer:D.A,bitget:q.A,bithumb:V.A,bitimen:F.A,bitir:H.A,bitmart:G.A,bitmex:U.A,bitopro:W.A,bitpin:j.A,bitrue:z.A,bitso:K.A,bitstamp:Y.A,bitteam:X.A,bittrade:Q.A,bitunix:Z.A,bitvavo:$.A,bitwana:J.A,blockchaincom:ee.A,blofin:te.A,btcalpha:ie.A,btcbox:se.A,btcmarkets:re.A,btcturk:ae.A,bybit:oe.A,bydfi:ne.A,cafearz:de.A,cex:he.A,changefa:ce.A,coinbase:le.A,coinbaseadvanced:ue.A,coinbaseexchange:fe.A,coinbaseinternational:pe.A,coincatch:me.A,coincheck:ge.A,coinex:ve.A,coinmate:ye.A,coinmetro:be.A,coinone:we.A,coinsph:ke.A,coinspot:Se.A,cryptocom:Oe.A,cryptomus:Te.A,daric:Pe.A,defx:Me.A,delta:Ie.A,deribit:xe.A,derive:Ae.A,digifinex:Ce.A,digikalagold:_e.A,ellipx:Be.A,eterex:Ee.A,excoino:Le.A,exino:Re.A,exir:Ne.A,exmo:De.A,exnovin:qe.A,farhadexchange:Ve.A,fmfwio:Fe.A,foxbit:He.A,gate:Ge.A,gateio:Ue.A,gemini:We.A,gerami:je.A,goldika:ze.A,goldis:Ke.A,hamrahgold:Ye.A,hamtapay:Xe.A,hashkey:Qe.A,hibachi:Ze.A,hitbtc:$e.A,hitobit:Je.A,hollaex:et.A,htx:tt.A,huobi:it.A,hyperliquid:st.A,independentreserve:rt.A,indodax:at.A,iranexchange:ot.A,jibitex:nt.A,kcex:dt.A,kifpoolme:ht.A,kraken:ct.A,krakenfutures:lt.A,kucoin:ut.A,kucoinfutures:ft.A,latoken:pt.A,lbank:mt.A,luno:gt.A,mazdax:vt.A,melligold:yt.A,mercado:bt.A,mexc:wt.A,milligold:kt.A,modetrade:St.A,myokx:Ot.A,ndax:Tt.A,nobitex:Pt.A,novadax:Mt.A,oceanex:It.A,okcoin:xt.A,okexchange:At.A,okx:Ct.A,okxus:_t.A,ompfinex:Bt.A,onetrading:Et.A,ourbit:Lt.A,oxfun:Rt.A,p2b:Nt.A,paradex:Dt.A,paymium:qt.A,phemex:Vt.A,pingi:Ft.A,poloniex:Ht.A,pooleno:Gt.A,poulyar:Ut.A,probit:Wt.A,raastin:jt.A,ramzinex:zt.A,saraf:Kt.A,sarmayex:Yt.A,sarrafex:Xt.A,swapwallet:Qt.A,tabdeal:Zt.A,talaavan:$t.A,talapp:Jt.A,talasea:ei.A,technogold:ti.A,tehran_exchange:ii.A,tetherland:si.A,timex:ri.A,tokocrypto:ai.A,toobit:oi.A,tradeogre:ni.A,twox:di.A,ubitex:hi.A,upbit:ci.A,vertex:li.A,wallex:ui.A,wallgold:fi.A,wavesexchange:pi.A,whitebit:mi.A,woo:gi.A,woofipro:vi.A,xt:yi.A,yobit:bi.A,zaif:wi.A,zarafza:ki.A,zarminex:Si.A,zarniv:Oi.A,zarpin:Ti.A,zonda:Pi.A},Ks={alpaca:Mi.A,apex:Ii.A,ascendex:xi.A,bequant:Ai.A,binance:Ci.A,binancecoinm:_i.A,binanceus:Bi.A,binanceusdm:Ei.A,bingx:Li.A,bitfinex:Ri.A,bitget:Ni.A,bithumb:Di.A,bitmart:qi.A,bitmex:Vi.A,bitopro:Fi.A,bitrue:Hi.A,bitstamp:Gi.A,bittrade:Ui.A,bitvavo:Wi.A,blockchaincom:ji.A,blofin:zi.A,bybit:Ki.A,cex:Yi.A,coinbase:Xi.A,coinbaseadvanced:Qi.A,coinbaseexchange:Zi.A,coinbaseinternational:$i.A,coincatch:Ji.A,coincheck:es.A,coinex:ts.A,coinone:is.A,cryptocom:ss.A,defx:rs.A,deribit:as.A,derive:os.A,exmo:ns.A,gate:ds.A,gateio:hs.A,gemini:cs.A,hashkey:ls.A,hitbtc:us.A,hollaex:fs.A,htx:ps.A,huobi:ms.A,hyperliquid:gs.A,independentreserve:vs.A,kraken:ys.A,krakenfutures:bs.A,kucoin:ws.A,kucoinfutures:ks.A,lbank:Ss.A,luno:Os.A,mexc:Ts.A,modetrade:Ps.A,myokx:Ms.A,ndax:Is.A,okcoin:xs.A,okx:As.A,okxus:Cs.A,onetrading:_s.A,oxfun:Bs.A,p2b:Es.A,paradex:Ls.A,phemex:Rs.A,poloniex:Ns.A,probit:Ds.A,tradeogre:qs.A,upbit:Vs.A,vertex:Fs.A,whitebit:Hs.A,woo:Gs.A,woofipro:Us.A,xt:Ws.A};for(const e in Ks);Ks.exchanges=Object.keys(Ks),Ks.Exchange=d.k;const Ys=Object.assign({version:js,Exchange:d.k,Precise:h.Y,exchanges:Object.keys(zs),pro:Ks},zs,c,l);self.ccxt=n})();
|