UNPKG

@compendiumfi/pendax

Version:

connector for centralized cryptocurrency exchanges

1 lines 13.3 kB
const a2_0x7a02b5=a2_0x11b7;(function(_0x227d01,_0x5f2ee9){const _0x4d0782=a2_0x11b7,_0x439973=_0x227d01();while(!![]){try{const _0x1fcd87=parseInt(_0x4d0782(0xe1))/0x1*(parseInt(_0x4d0782(0x160))/0x2)+parseInt(_0x4d0782(0x11f))/0x3+-parseInt(_0x4d0782(0x13d))/0x4+-parseInt(_0x4d0782(0xfa))/0x5*(parseInt(_0x4d0782(0x118))/0x6)+parseInt(_0x4d0782(0xee))/0x7*(-parseInt(_0x4d0782(0x161))/0x8)+parseInt(_0x4d0782(0x13a))/0x9*(parseInt(_0x4d0782(0x119))/0xa)+-parseInt(_0x4d0782(0x10a))/0xb;if(_0x1fcd87===_0x5f2ee9)break;else _0x439973['push'](_0x439973['shift']());}catch(_0x4406d3){_0x439973['push'](_0x439973['shift']());}}}(a2_0x3b48,0xc94ad));import a2_0x9fa191 from'axios';import a2_0x1e050f from'crypto';import a2_0x266eb8 from'short-unique-id';import a2_0x69181c from'crypto-js';function a2_0x11b7(_0xb0af2c,_0x31ebb2){const _0x3b483f=a2_0x3b48();return a2_0x11b7=function(_0x11b70c,_0x12c801){_0x11b70c=_0x11b70c-0xd9;let _0x413506=_0x3b483f[_0x11b70c];return _0x413506;},a2_0x11b7(_0xb0af2c,_0x31ebb2);}import{midnight,dateDifferenceInMonths}from'../utils/date_utils.js';function a2_0x3b48(){const _0x27ec20=['stringify','getPositions','length','logPosts','orderId','kCQyl','placeTPSLOrder','logGets','4460vYhYDB','getFundsTranferHistory','/api/v1/market/mark-price','yDLYf','/api/v1/trade/cancel-tpsl','positionMode','GET','data','Utf8','NMOcj','getWithdrawHistory','EFMWJ','HmacSHA256','/api/v1/user/query-apikey','/api/v1/trade/batch-orders','amount','1569964cgraRm','/api/v1/market/funding-rate-history','margintype','sockets','instId','join','parse','exchangeid','authenticate','side','getMultipleLeverage','decrypt','/api/v1/trade/orders-pending','closePositions','4362YylGlN','1694310NxpuOX','getAffiliateInfo','key','dhsyTW5!ysh8IuysQKcG45','futuresMarginType','setPositionMode','4857591tWxprz','DKVgw','getActiveTPSLOrders','brokerId','getFundingRate','getOrderBook','usdt','getDepositHistory','placeMultipleOrders','exchangename','REIxO','kCgGU','enc','auystrAAS2iW85#s2@jdDC','getCandleSticks','placeOrder','fWFmQ','POST','PeuJr','/api/v1/trade/orders-history','getMarkPrice','authenticate\x20option\x20requires\x20valid\x20api\x20key\x20and\x20api\x20secret','exchange','getMarginMode','currency','size','name','81Nouvxn','VHJSc','push','5112216jBfhir','useProxy','addProxyObject','tpTriggerPrice','orderType','default','label','/api/v1/account/margin-mode','Proxy\x20port\x20required','checkParams','setLeverage','cancelOrder','lbMkQ','proxyUser','accountType','/api/v1/trade/close-position','setMarginMode','executeCall','/api/v1/trade/order-tpsl','No\x20response\x20from\x20exchange\x20-\x20double\x20check\x20parameters','secret','createSignature','cancelTPSLOrder','dec','getReferralCode','testnet','/api/v1/market/trades','proxy','proxyPort','auth','isMain','getApiKeyInfo','now','/api/v1/affiliate/invitees','FlVpz','100bgSKMw','8TxnIZl','url','createAuthHeader','/api/v1/trade/orders-tpsl-history','apiKey','/api/v1/market/books','getSubInvitees','/api/v1/affiliate/basic','/api/v1/affiliate/sub-invitees','passphrase','EgOEm','getTickers','/api/v1/trade/fills-history','getDirectInvites','getFundingRateHistory','/api/v1/account/positions','getTPSLOrderHistory','doLog','Base64','/api/v1/account/position-mode','getInstruments','filter','proxyAuth','1603gDciXm','apiSecret','publicApis','marginMode','/api/v1/asset/balances','getFuturesAccountBalance','5388cb1f51cec2e3','/api/v1/market/funding-rate','fromAccount','getPositionMode','proxyPass','getTrades','toAccount','2313297IuAQtZ','/api/v1/trade/cancel-order','ekMYh','subaccount'];a2_0x3b48=function(){return _0x27ec20;};return a2_0x3b48();}export class Blofin{['publicApis']=new Array();['ky']=a2_0x7a02b5(0x12c);['i']=a2_0x7a02b5(0x11c);[a2_0x7a02b5(0x10d)]={};['logGets']=![];[a2_0x7a02b5(0xf5)]=![];['logDeletes']=![];constructor(_0x4e3671){const _0x23f507=a2_0x7a02b5;this[_0x23f507(0x162)]='https://openapi.blofin.com';if(!(_0x4e3671[_0x23f507(0x156)]===null)&&_0x4e3671[_0x23f507(0x156)]===!![]){if(_0x23f507(0x149)==='dRoQO')return _0x546a69;else throw'testnet\x20option\x20set\x20to\x20true,\x20Blofin\x20currently\x20does\x20not\x20include\x20a\x20testnet\x20festure';}this[_0x23f507(0x112)]=_0x4e3671[_0x23f507(0x112)]===null?!![]:_0x4e3671['authenticate'],this[_0x23f507(0x139)]=_0x4e3671[_0x23f507(0x135)]['exchangename']==undefined?'blofin':_0x4e3671['exchange'][_0x23f507(0x128)],this[_0x23f507(0x111)]=_0x4e3671[_0x23f507(0x135)]['id'],this[_0x23f507(0x143)]=_0x4e3671[_0x23f507(0x143)];if(this[_0x23f507(0x112)]===!![]){if(!_0x4e3671[_0x23f507(0x11b)]||!_0x4e3671[_0x23f507(0x151)]||_0x4e3671[_0x23f507(0x11b)]==''||_0x4e3671[_0x23f507(0x151)]=='')throw _0x23f507(0x134);this[_0x23f507(0x165)]=_0x4e3671['key'],this[_0x23f507(0xe2)]=_0x4e3671[_0x23f507(0x151)],this['isMain']=_0x4e3671['subaccount']==undefined,this[_0x23f507(0xf1)]=this[_0x23f507(0x15b)]?'':_0x4e3671[_0x23f507(0xf1)],this['passphrase']=_0x4e3671[_0x23f507(0x16a)];}this[_0x23f507(0x11d)]=_0x4e3671['margintype']?_0x4e3671[_0x23f507(0x10c)]:_0x23f507(0x125),this[_0x23f507(0x13e)]=![];if(_0x4e3671[_0x23f507(0x13e)]){if(_0x4e3671[_0x23f507(0x158)]&&_0x4e3671[_0x23f507(0x158)]!=''){this[_0x23f507(0x13e)]=!![],this[_0x23f507(0x158)]=this[_0x23f507(0x162)],this['proxy']=_0x4e3671[_0x23f507(0x158)];if(_0x4e3671['proxyPort'])this[_0x23f507(0x159)]=_0x4e3671[_0x23f507(0x159)];else throw _0x23f507(0x145);}_0x4e3671[_0x23f507(0x14a)]&&(_0x23f507(0x13b)!==_0x23f507(0x13b)?_0x39be63(_0x23f507(0x150)):this[_0x23f507(0x14a)]=_0x4e3671[_0x23f507(0x14a)]),_0x4e3671[_0x23f507(0xeb)]&&(_0x23f507(0x15f)===_0x23f507(0x15f)?this['proxyPass']=_0x4e3671[_0x23f507(0xeb)]:_0x498ce5[_0x23f507(0x13c)](_0x3db60a+'='+_0x3a5963[_0x52d406])),_0x4e3671[_0x23f507(0xe0)]===!![]?this[_0x23f507(0xe0)]=!![]:this[_0x23f507(0xe0)]=![];}this[_0x23f507(0xe3)][_0x23f507(0x13c)](_0x23f507(0xde),_0x23f507(0x16c),_0x23f507(0x124),_0x23f507(0xec),_0x23f507(0x133),_0x23f507(0x123),'getFundingRateHistory',_0x23f507(0x12d));const _0x53aaac=[['getInstruments',_0x23f507(0x100),'/api/v1/market/instruments',[]],['getTickers',_0x23f507(0x100),'/api/v1/market/tickers',[]],[_0x23f507(0x124),_0x23f507(0x100),_0x23f507(0x166),[]],[_0x23f507(0xec),'GET',_0x23f507(0x157),[_0x23f507(0x10e)]],[_0x23f507(0x133),_0x23f507(0x100),_0x23f507(0xfc),['instId']],[_0x23f507(0x123),_0x23f507(0x100),_0x23f507(0xe8),[_0x23f507(0x10e)]],[_0x23f507(0x16f),_0x23f507(0x100),_0x23f507(0x10b),[_0x23f507(0x10e)]],[_0x23f507(0x12d),'GET','/api/v1/market/candles',[_0x23f507(0x10e)]],['getBalance',_0x23f507(0x100),_0x23f507(0xe5),[_0x23f507(0x14b)]],['fundsTransfer',_0x23f507(0x130),'/api/v1/asset/transfer',[_0x23f507(0x137),_0x23f507(0xe9),_0x23f507(0xed),_0x23f507(0x109)]],[_0x23f507(0xfb),_0x23f507(0x100),'/api/v1/asset/bills',[]],[_0x23f507(0x104),_0x23f507(0x100),'/api/v1/asset/withdrawal-history',[]],[_0x23f507(0x126),_0x23f507(0x100),'/api/v1/asset/deposit-history',[]],[_0x23f507(0xe6),_0x23f507(0x100),'/api/v1/account/balance',[]],[_0x23f507(0xf3),_0x23f507(0x100),_0x23f507(0xd9),[]],[_0x23f507(0x136),_0x23f507(0x100),_0x23f507(0x144),[]],[_0x23f507(0x14d),_0x23f507(0x130),'/api/v1/account/set-margin-mode',['marginMode']],[_0x23f507(0xea),_0x23f507(0x100),_0x23f507(0xdd),[]],[_0x23f507(0x11e),'POST',_0x23f507(0xdd),[_0x23f507(0xff)]],[_0x23f507(0x114),'GET','/api/v1/account/batch-leverage-info',[]],[_0x23f507(0x147),_0x23f507(0x130),'/api/v1/account/set-leverage',[_0x23f507(0x10e),'leverage']],[_0x23f507(0x148),_0x23f507(0x130),_0x23f507(0xef),[_0x23f507(0xf6)]],['cancelMultipleOrders','POST','/api/v1/trade/cancel-batch-orders',[]],[_0x23f507(0x153),'POST',_0x23f507(0xfe),[]],['getActiveOrders',_0x23f507(0x100),_0x23f507(0x116),[]],[_0x23f507(0x121),_0x23f507(0x100),'/api/v1/trade/orders-tpsl-pending',[]],[_0x23f507(0x117),'POST',_0x23f507(0x14c),['instId',_0x23f507(0xe4)]],['getOrderHistory',_0x23f507(0x100),_0x23f507(0x132),[]],[_0x23f507(0xda),_0x23f507(0x100),_0x23f507(0x164),[]],['getTradeHistory',_0x23f507(0x100),_0x23f507(0x16d),[]],[_0x23f507(0x11a),_0x23f507(0x100),_0x23f507(0x168),[]],[_0x23f507(0x155),'GET','/api/v1/affiliate/referral-code',[]],[_0x23f507(0x16e),_0x23f507(0x100),_0x23f507(0x15e),[]],[_0x23f507(0x167),_0x23f507(0x100),_0x23f507(0x169),[]],['getSubAffiliates',_0x23f507(0x100),'/api/v1/affiliate/sub-affiliates',[]],[_0x23f507(0x15c),_0x23f507(0x100),_0x23f507(0x107),[]]],_0x4feabd=[[_0x23f507(0x12e),'POST','/api/v1/trade/order',[_0x23f507(0x10e),_0x23f507(0xe4),_0x23f507(0x113),_0x23f507(0x141),_0x23f507(0x138)]],[_0x23f507(0x127),_0x23f507(0x130),_0x23f507(0x108),[]],[_0x23f507(0xf8),'POST',_0x23f507(0x14f),[_0x23f507(0x10e),_0x23f507(0xe4),'positionSide',_0x23f507(0x113),_0x23f507(0x140)]]];for(const _0x41b838 in _0x53aaac){if(_0x23f507(0x131)!==_0x23f507(0x105))this[_0x53aaac[_0x41b838][0x0]]=async _0x145df9=>{const _0x150a83=_0x23f507;if(_0x150a83(0x120)!==_0x150a83(0x120))this['proxyAuth']=!![];else{let _0x4a7159=await this[_0x150a83(0x14e)](_0x145df9,_0x53aaac[_0x41b838][0x1],_0x53aaac[_0x41b838][0x2],_0x53aaac[_0x41b838][0x3]);return _0x4a7159;}};else{if(this[_0x23f507(0x13e)]){let _0x1eabb0={'protocol':'https','host':this[_0x23f507(0x158)],'port':this[_0x23f507(0x159)]};this[_0x23f507(0xe0)]===!![]&&(_0x1eabb0[_0x23f507(0x15a)]={'username':this[_0x23f507(0x14a)],'password':this[_0x23f507(0xeb)]}),_0x1dc764[_0x23f507(0x158)]=_0x1eabb0;}return _0x4cae08;}}for(const _0x80a892 in _0x4feabd){this[_0x4feabd[_0x80a892][0x0]]=async _0x337751=>{const _0x5414c2=_0x23f507;_0x337751[_0x5414c2(0x122)]=_0x5414c2(0xe7);let _0x184d9b=await this[_0x5414c2(0x14e)](_0x337751,_0x4feabd[_0x80a892][0x1],_0x4feabd[_0x80a892][0x2],_0x4feabd[_0x80a892][0x3]);return _0x184d9b;};}}[a2_0x7a02b5(0x154)]=_0x40ec77=>{const _0x26e413=a2_0x7a02b5;if(_0x40ec77==null)return _0x26e413(0x16b)===_0x26e413(0xfd)?_0x29e963:undefined;const _0x575c2e=a2_0x69181c[_0x26e413(0x12b)][_0x26e413(0xdc)]['parse'](this['ky']),_0x1d9ce1=a2_0x69181c[_0x26e413(0x12b)][_0x26e413(0xdc)][_0x26e413(0x110)](this['i']);return a2_0x69181c['AES'][_0x26e413(0x115)](_0x40ec77,_0x575c2e,{'iv':_0x1d9ce1})['toString'](a2_0x69181c['enc'][_0x26e413(0x102)]);};async[a2_0x7a02b5(0x163)](_0x1cdcdd,_0x3e3734,_0x9ecb4f,_0x15a758){const _0x27dd5e=a2_0x7a02b5;let _0x4e1137=Date[_0x27dd5e(0x15d)]();const {randomUUID:_0x2c0d3b}=new a2_0x266eb8({'length':0x14});let _0x231a54=_0x2c0d3b(),_0x7c958d=await this['createSignature'](_0x1cdcdd,_0x3e3734,_0x4e1137,_0x231a54,_0x15a758,_0x9ecb4f),_0x4ff9b5={'ACCESS-KEY':this[_0x27dd5e(0x165)],'ACCESS-PASSPHRASE':this[_0x27dd5e(0x16a)],'ACCESS-NONCE':_0x231a54,'ACCESS-TIMESTAMP':String(_0x4e1137),'ACCESS-SIGN':_0x7c958d};return _0x4ff9b5;}async[a2_0x7a02b5(0x152)](_0xf606b3,_0x3ca801,_0x1d8f1d,_0x4b388b,_0x43bdc4,_0x58ce8e){const _0xef8d14=a2_0x7a02b5;let _0x2cd357=_0xf606b3+_0x3ca801+_0x43bdc4+_0x1d8f1d+_0x4b388b+_0x58ce8e,_0x31fab5=a2_0x69181c['enc']['Base64']['stringify'](a2_0x69181c['enc'][_0xef8d14(0x102)][_0xef8d14(0x110)](a2_0x69181c[_0xef8d14(0x106)](_0x2cd357,this[_0xef8d14(0xe2)])));return _0x31fab5;}['addProxyObject'](_0x103653){const _0x5c27e8=a2_0x7a02b5;if(this[_0x5c27e8(0x13e)]){if(_0x5c27e8(0x12f)!==_0x5c27e8(0x12a)){let _0xcc473c={'protocol':'https','host':this[_0x5c27e8(0x158)],'port':this[_0x5c27e8(0x159)]};this[_0x5c27e8(0xe0)]===!![]&&(_0xcc473c[_0x5c27e8(0x15a)]={'username':this[_0x5c27e8(0x14a)],'password':this[_0x5c27e8(0xeb)]}),_0x103653[_0x5c27e8(0x158)]=_0xcc473c;}else throw _0x5c27e8(0x145);}return _0x103653;}async[a2_0x7a02b5(0x146)](_0x264087,_0x4ec753){const _0x4ccfdc=a2_0x7a02b5;let _0x173527=_0x264087!=null?_0x4ec753[_0x4ccfdc(0xdf)](_0x47e8ff=>!Object['keys'](_0x264087)['includes'](_0x47e8ff)):_0x4ec753;if(_0x173527[_0x4ccfdc(0xf4)]!=0x0)throw{'message':'Missing\x20params:\x20'+_0x173527[_0x4ccfdc(0x10f)](',')};}async[a2_0x7a02b5(0x14e)](_0x2c63d0,_0x1ae7ef,_0x593343,_0x3919a1){const _0x2547f6=a2_0x7a02b5;await this['checkParams'](_0x2c63d0,_0x3919a1);let _0x37f341='',_0x3eeaaf='';if(_0x1ae7ef==_0x2547f6(0x100)){if(_0x2547f6(0xf7)===_0x2547f6(0xf0))throw{'message':'Missing\x20params:\x20'+_0x21e074[_0x2547f6(0x10f)](',')};else{let _0x2a0855=[];for(let _0x2a67f7 in _0x2c63d0){_0x2a0855[_0x2547f6(0x13c)](_0x2a67f7+'='+_0x2c63d0[_0x2a67f7]);}_0x37f341=_0x2a0855[_0x2547f6(0x10f)]('&'),_0x37f341!=''&&('NMOcj'!==_0x2547f6(0x103)?this[_0x2547f6(0xe0)]=![]:_0x37f341='?'+_0x37f341);}}else _0x3eeaaf=JSON[_0x2547f6(0xf2)](_0x2c63d0);let _0x4b1901={};this[_0x2547f6(0x112)]===!![]&&(_0x4b1901=await this[_0x2547f6(0x163)](_0x593343,_0x37f341,_0x3eeaaf,_0x1ae7ef));let _0x169dcd={'baseURL':this[_0x2547f6(0x162)],'url':_0x593343+_0x37f341,'method':_0x1ae7ef,'headers':_0x4b1901,'data':_0x1ae7ef==_0x2547f6(0x100)?{}:_0x2c63d0};_0x169dcd=this[_0x2547f6(0x13f)](_0x169dcd);try{if(_0x2547f6(0x129)===_0x2547f6(0x129)){const _0x41df06=await a2_0x9fa191(_0x169dcd);if(!_0x41df06){this[_0x2547f6(0xf9)]==!![]&&doLog(_0x2547f6(0x150));throw _0x2547f6(0x150);}return this[_0x2547f6(0xf9)]==!![]&&this[_0x2547f6(0xdb)]({'send':_0x169dcd,'level':_0x2547f6(0x142),'receive':{'code':_0x41df06[_0x2547f6(0x101)]['code'],'data':JSON[_0x2547f6(0xf2)](_0x41df06[_0x2547f6(0x101)][_0x2547f6(0x101)]),'msg':_0x41df06[_0x2547f6(0x101)]['msg']}}),{'code':_0x41df06['status'],'data':_0x41df06['data'],'msg':_0x41df06['statusText']};}else throw _0x2547f6(0x134);}catch(_0x29aae1){return _0x29aae1;}}}