UNPKG

@firefly-exchange/firefly-client

Version:

The Firefly Client Library allows traders to sign, create, retrieve and listen to orders on Firefly Exchange.

2 lines 6.27 MB
/*! For license information please see client.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Client",[],t):"object"==typeof exports?exports.Client=t():e.Client=t()}(self,(()=>(()=>{var e={6606:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(44738),t),i(r(47517),t),i(r(82091),t),i(r(33651),t),i(r(93190),t),i(r(59172),t),i(r(24874),t)},15212:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Balance=void 0;const a=i(r(44431)),o=r(82091),s=r(59172);class u{constructor(e,t,r,n,i){this.mro=new a.default(e),this.qPos=new a.default(t),this.margin=new a.default(r),this.oiOpen=new a.default(n),this.isPosPositive=i}static fromSolidity(e){return new u(e.mro,e.qPos,e.margin,e.oiOpen,e.isPosPositive)}static getPositionBalance(e,t){return n(this,void 0,void 0,(function*(){const r=yield t.getAccountBalance(e);return u.fromSolidity({mro:r.mro.toHexString(),qPos:r.qPos.toHexString(),margin:r.margin.toHexString(),oiOpen:r.oiOpen.toHexString(),isPosPositive:r.isPosPositive})}))}static getMarginBankBalance(e,t){return n(this,void 0,void 0,(function*(){const r=yield t.getAccountBankBalance(e);return new a.default(r.toHexString())}))}static getMarginRatio(e,t,r){let n;const i=t.times(e.qPos);if(e.isPosPositive){const t=e.oiOpen.minus(e.margin).minus(void 0===r?0:r).times(s.BIGNUMBER_BASE).dividedBy(i);n=s.BIGNUMBER_BASE.minus(t)}else n=e.oiOpen.plus(e.margin).plus(void 0===r?0:r).times(s.BIGNUMBER_BASE).dividedBy(i).minus(s.BIGNUMBER_BASE);return n}calcAvgPrice(){return this.qPos.isZero()?"0":this.oiOpen.dividedBy(this.qPos).shiftedBy(18).toFixed(0)}calcPositionDebt(){return this.isPosPositive?this.oiOpen.minus(this.margin):this.oiOpen.plus(this.margin)}calcLeverage(){return this.mro.isZero()?"0":(0,o.toBigNumberStr)(Math.round((0,o.bnStrToBaseNumber)((0,o.bnDiv)((0,o.numberToSolidityNumber)(1),this.mro))))}}t.Balance=u},79571:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OnboardingSigner=void 0;const a=i(r(37918)),o=r(68903);t.OnboardingSigner=class{static createOnboardSignature(e,t,r){var i,s;return n(this,void 0,void 0,(function*(){if(!t&&!r)throw Error("Invalid provider");if(t){const r=new a.default,n=null!==(i=r.utils.sha3(e))&&void 0!==i?i:"";return r.eth.accounts.sign(n,t).signature}const n=new a.default(r),u=new o.ethers.providers.Web3Provider(r).getSigner(),c=null!==(s=n.utils.sha3(e))&&void 0!==s?s:"";return yield n.eth.personal.sign(c,yield u.getAddress(),"")}))}static verifyOnboardSignature(e,t,r){var n;const i=new a.default,o=null!==(n=i.utils.sha3(t))&&void 0!==n?n:"";return i.eth.accounts.recover(o,r).toLowerCase()===e.toLowerCase()}}},44162:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OrderMathDTO=void 0;const i=n(r(44431));t.OrderMathDTO=class{constructor(e,t,r,n,a,o,s,u,c,p="0"){this.triggerPrice="0",this.symbol=e,this.orderType=t,this.isBuy=r,this.leverage=n,this.reduceOnly=a,this.postOnly=o,this.price=s,this.quantity=u,this.filledQty=c,this.openQty=new i.default(u).minus(new i.default(c)).toFixed(0),this.triggerPrice=p}}},61034:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OrderSigner=void 0;const a=i(r(44431)),o=i(r(37918)),s=r(93906),u=r(41611),c=r(93190),p=r(59172),m=r(87717);class l{constructor(e,t,r,n=p.DEFAULT_EIP712_DOMAIN_NAME){this.web3=e,this.networkId=t,this.address=r,this.eip712DomainName=n}getSignedOrder(e,t,r){return n(this,void 0,void 0,(function*(){const n=yield this.signOrder(e,t,r);return Object.assign(Object.assign({},e),{typedSignature:n})}))}signOrder(e,t,r){return n(this,void 0,void 0,(function*(){switch(t){case c.SigningMethod.Hash:case c.SigningMethod.UnsafeHash:case c.SigningMethod.Compatibility:const n=this.getOrderHash(e),i=yield this.web3.eth.sign(n,r||e.maker),a=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.DECIMAL);if(t===c.SigningMethod.Hash)return a;const o=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.NO_PREPEND);return t===c.SigningMethod.UnsafeHash||(0,u.hashHasValidSignature)(n,o,r||e.maker)?o:a;case c.SigningMethod.TypedData:case c.SigningMethod.HardhatTypedData:case c.SigningMethod.MetaMask:case c.SigningMethod.MetaMaskLatest:case c.SigningMethod.CoinbaseWallet:return this.ethSignTypedOrderInternal(e,t);default:throw new m.InvalidSignMethodError(`Invalid signing method ${t}`)}}))}signCancelOrder(e,t){return n(this,void 0,void 0,(function*(){return this.signCancelOrderByHash(this.getOrderHash(e),e.maker,t)}))}signCancelOrders(e,t){return n(this,void 0,void 0,(function*(){return this.signCancelOrdersByHash(e.map((e=>this.getOrderHash(e))),e[0].maker,t)}))}signCancelOrderByHash(e,t,r){return n(this,void 0,void 0,(function*(){switch(r){case c.SigningMethod.Hash:case c.SigningMethod.UnsafeHash:case c.SigningMethod.Compatibility:const n=this.orderHashToCancelOrderHash(e),i=yield this.web3.eth.sign(n,t),a=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.DECIMAL);if(r===c.SigningMethod.Hash)return a;const o=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.NO_PREPEND);return r===c.SigningMethod.UnsafeHash||(0,u.hashHasValidSignature)(n,o,t)?o:a;case c.SigningMethod.TypedData:case c.SigningMethod.MetaMask:case c.SigningMethod.MetaMaskLatest:case c.SigningMethod.CoinbaseWallet:return this.ethSignTypedCancelOrderInternal(e,t,r);default:throw new m.InvalidSignMethodError(`Invalid signing method ${r}`)}}))}signCancelOrdersByHash(e,t,r){return n(this,void 0,void 0,(function*(){switch(r){case c.SigningMethod.Hash:case c.SigningMethod.UnsafeHash:case c.SigningMethod.Compatibility:const n=this.orderHashToCancelOrdersHash(e),i=yield this.web3.eth.sign(n,t),a=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.DECIMAL);if(r===c.SigningMethod.Hash)return a;const o=(0,u.createTypedSignature)(i,c.SIGNATURE_TYPES.NO_PREPEND);return r===c.SigningMethod.UnsafeHash||(0,u.hashHasValidSignature)(n,o,t)?o:a;case c.SigningMethod.TypedData:case c.SigningMethod.MetaMask:case c.SigningMethod.MetaMaskLatest:case c.SigningMethod.CoinbaseWallet:return this.ethSignTypedCancelOrdersInternal(e,t,r);default:throw new m.InvalidSignMethodError(`Invalid signing method ${r}`)}}))}orderHasValidSignature(e){return(0,u.hashHasValidSignature)(this.getOrderHash(e),e.typedSignature,e.maker)}solidityOrderHasValidSignature(e){return(0,u.hashHasValidSignature)(this.getSolidityOrderHash(e),e.typedSignature,e.maker)}static rawOrderHasValidSignature(e,t){return(0,u.hashHasValidSignature)(l.getRawOrderHash(e,t),e.typedSignature,e.maker)}static orderByHashHasValidSignature(e,t,r){const n=(0,u.ecRecoverTypedSignature)(e,t);return(0,s.addressesAreEqual)(n,r)}cancelOrderHasValidSignature(e,t){return this.cancelOrderByHashHasValidSignature(this.getOrderHash(e),t,e.maker)}cancelOrdersHasValidSignature(e,t){return this.cancelOrdersByHashHasValidSignature(e.map((e=>this.getOrderHash(e))),t,e[0].maker)}cancelOrderByHashHasValidSignature(e,t,r){const n=this.orderHashToCancelOrderHash(e),i=(0,u.ecRecoverTypedSignature)(n,t);return(0,s.addressesAreEqual)(i,r)}cancelOrdersByHashHasValidSignature(e,t,r){const n=this.orderHashToCancelOrdersHash(e),i=(0,u.ecRecoverTypedSignature)(n,t);return(0,s.addressesAreEqual)(i,r)}getOrderHash(e){const t=o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_ORDER_STRUCT_STRING)||""},{t:"bytes32",v:l.getOrderFlags(e)},{t:"uint256",v:e.quantity.toFixed(0)},{t:"uint256",v:e.price.toFixed(0)},{t:"uint256",v:e.triggerPrice.toFixed(0)},{t:"uint256",v:e.leverage.toFixed(0)},{t:"bytes32",v:(0,s.addressToBytes32)(e.maker)},{t:"uint256",v:e.expiration.toFixed(0)});return t?(0,u.getEIP712Hash)(this.getDomainHash(),t):""}getSolidityOrderHash(e){const t=o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_ORDER_STRUCT_STRING)||""},{t:"bytes32",v:l.getOrderFlags(e)},{t:"uint256",v:e.quantity.toFixed(0)},{t:"uint256",v:e.price.toFixed(0)},{t:"uint256",v:e.triggerPrice.toFixed(0)},{t:"uint256",v:e.leverage.toFixed(0)},{t:"bytes32",v:(0,s.addressToBytes32)(e.maker)},{t:"uint256",v:e.expiration.toFixed(0)});return t?(0,u.getEIP712Hash)(this.getDomainHash(),t):""}static getRawOrderHash(e,t){const r=o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_ORDER_STRUCT_STRING)||""},{t:"bytes32",v:l.getOrderFlags(e)},{t:"uint256",v:e.quantity},{t:"uint256",v:e.price},{t:"uint256",v:e.triggerPrice},{t:"uint256",v:e.leverage},{t:"bytes32",v:(0,s.addressToBytes32)(e.maker)},{t:"uint256",v:e.expiration});return r?(0,u.getEIP712Hash)(t,r):""}orderHashToCancelOrderHash(e){const t=o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_CANCEL_ORDER_STRUCT_STRING)||""},{t:"bytes32",v:(0,s.hashString)("Cancel Orders")||""},{t:"bytes32",v:o.default.utils.soliditySha3({t:"bytes32",v:e})||""});return t?(0,u.getEIP712Hash)(this.getDomainHash(),t):""}orderHashToCancelOrdersHash(e){o.default.utils.soliditySha3();const t=o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_CANCEL_ORDER_STRUCT_STRING)||""},{t:"bytes32",v:(0,s.hashString)("Cancel Orders")||""},{t:"bytes32",v:o.default.utils.soliditySha3(...e.map((e=>({t:"bytes32",v:e}))))||""});return t?(0,u.getEIP712Hash)(this.getDomainHash(),t):""}getDomainHash(){return o.default.utils.soliditySha3({t:"bytes32",v:(0,s.hashString)(p.EIP712_DOMAIN_STRING)||""},{t:"bytes32",v:(0,s.hashString)(this.eip712DomainName)||""},{t:"bytes32",v:(0,s.hashString)(p.EIP712_DOMAIN_VERSION)||""},{t:"uint256",v:`${this.networkId}`},{t:"bytes32",v:(0,s.addressToBytes32)(this.address)})||""}orderToBytes(e){const t=l.orderToSolidity(e);return this.web3.eth.abi.encodeParameters(p.EIP712_ORDER_STRUCT.map((e=>e.type)),p.EIP712_ORDER_STRUCT.map((e=>t[e.name])))}static parseFlags(e){const t=new a.default(e,16).mod(8).toNumber();return{isBuy:0!=(1&t),isDecreaseOnly:0!=(2&t)}}toSolidityByteOrder(e){return this.web3.eth.abi.encodeParameters(p.EIP712_ORDER_SIGNATURE_TYPE_ARR,[l.getOrderFlags(e),e.quantity.toFixed(0),e.price.toFixed(0),e.triggerPrice.toFixed(0),e.leverage.toFixed(0),e.maker,e.expiration.toFixed(0)])}rawOrderToSolidityByteOrder(e){return this.web3.eth.abi.encodeParameters(p.EIP712_ORDER_SIGNATURE_TYPE_ARR,[l.getOrderFlags(e),e.quantity,e.price,e.triggerPrice,e.leverage,e.maker,e.expiration])}static orderToSolidity(e){return{flags:l.getOrderFlags(e),quantity:e.quantity.toFixed(0),price:e.price.toFixed(0),triggerPrice:e.triggerPrice.toFixed(0),leverage:e.leverage.toFixed(0),maker:e.maker,expiration:e.expiration.toFixed(0)}}getDomainData(){return{name:this.eip712DomainName,version:p.EIP712_DOMAIN_VERSION,chainId:this.networkId,verifyingContract:this.address}}ethSignTypedOrderInternal(e,t){return n(this,void 0,void 0,(function*(){const r=l.orderToSolidity(e),n={types:{EIP712Domain:p.EIP712_DOMAIN_STRUCT,Order:p.EIP712_ORDER_STRUCT},domain:this.getDomainData(),primaryType:"Order",message:r};return(0,u.ethSignTypedDataInternal)(this.web3.currentProvider,e.maker,n,t)}))}ethSignTypedCancelOrderInternal(e,t,r){return n(this,void 0,void 0,(function*(){const n={types:{EIP712Domain:p.EIP712_DOMAIN_STRUCT,CancelLimitOrder:p.EIP712_CANCEL_ORDER_STRUCT},domain:this.getDomainData(),primaryType:"CancelLimitOrder",message:{action:"Cancel Orders",orderHashes:[e]}};return(0,u.ethSignTypedDataInternal)(this.web3.currentProvider,t,n,r)}))}ethSignTypedCancelOrdersInternal(e,t,r){return n(this,void 0,void 0,(function*(){const n={types:{EIP712Domain:p.EIP712_DOMAIN_STRUCT,CancelLimitOrder:p.EIP712_CANCEL_ORDER_STRUCT},domain:this.getDomainData(),primaryType:"CancelLimitOrder",message:{action:"Cancel Orders",orderHashes:e}};return(0,u.ethSignTypedDataInternal)(this.web3.currentProvider,t,n,r)}))}static getOrderFlags(e){const t=0+(e.isBuy?p.ORDER_FLAGS.IS_BUY:0)+(e.reduceOnly?p.ORDER_FLAGS.IS_REDUCE_ONLY:0);return`0x${(0,s.bnToBytes8)(e.salt).slice(-15)}${t}`}}t.OrderSigner=l},42485:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Trader=void 0;const a=i(r(96486)),o=r(33651),s=r(82091),u=r(59172);class c{static makeLiquidateTradeData(e,t,r,n){return(0,s.combineHexStrings)((0,s.bnToBytes32)(e),(0,s.bnToBytes32)(n),(0,s.boolToBytes32)(t),(0,s.boolToBytes32)(r))}static makeADLTradeData(e,t,r){return(0,s.combineHexStrings)((0,s.bnToBytes32)(e),(0,s.boolToBytes32)(t),(0,s.boolToBytes32)(r))}static fillToTradeData(e,t,r,n,i){const a=e.orderToBytes(t),o=e.orderToBytes(r),c=t.typedSignature+u.ZERO_REPEAT_60,p=r.typedSignature+u.ZERO_REPEAT_60,m=e.web3.eth.abi.encodeParameters(["uint128","uint128"],[n.toFixed(0),i.toFixed(0)]);return(0,s.combineHexStrings)(a,o,m,c,p)}static fillSolidityByteOrderToTradeData(e,t,r,n,i,a,o){const c=n+u.ZERO_REPEAT_60,p=i+u.ZERO_REPEAT_60,m=e.web3.eth.abi.encodeParameters(["uint128","uint128"],[a.toFixed(0),o.toFixed(0)]);return(0,s.combineHexStrings)(t,r,m,c,p)}static setupNormalTrade(e,t,r,i,u,p){return n(this,void 0,void 0,(function*(){const n="string"==typeof r?r:yield r.getAddress(),m="string"==typeof i?i:yield i.getAddress(),l=a.default.chain([n,m]).map(a.default.toLower).sort().sortedUniq().value(),d=(null==p?void 0:p.takerOrder)||Object.assign(Object.assign({},u),{maker:n,isBuy:!u.isBuy});u.maker=m;const y=yield e.getSignedOrder(u,t),f=yield e.getSignedOrder(d,t),b=c.fillToTradeData(e,y,f,(null==p?void 0:p.quantity)?(0,s.toBigNumber)(null==p?void 0:p.quantity):o.BigNumber.min(u.quantity,d.quantity),u.price);return{accounts:l,data:{makerIndex:l.indexOf(m.toLowerCase()),takerIndex:l.indexOf(n.toLowerCase()),trader:e.address,data:b}}}))}static setupLiquidationTrade(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=c.makeLiquidateTradeData(e.quantity,e.isBuy,e.allOrNothing,e.leverage);return c._setupTrade(n,t,r,i)}))}static setupDeleveragingTrade(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=c.makeADLTradeData(e.quantity,e.isBuy,e.allOrNothing);return c._setupTrade(n,t,r,i)}))}static _setupTrade(e,t,r,i){return n(this,void 0,void 0,(function*(){const n="string"==typeof t?t:yield t.getAddress(),o="string"==typeof r?r:yield r.getAddress(),s=a.default.chain([n,o]).map(a.default.toLower).sort().sortedUniq().value();return{accounts:s,data:{makerIndex:s.indexOf(o.toLowerCase()),takerIndex:s.indexOf(n.toLowerCase()),trader:i,data:e}}}))}}t.Trader=c},87717:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidSignMethodError=void 0;class r extends Error{constructor(){super(...arguments),this.isnvalidTypeError=!0}}t.InvalidSignMethodError=r},96638:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidSignatureError=void 0;class r extends Error{constructor(){super(...arguments),this.isInvalidSignatureError=!0}}t.InvalidSignatureError=r},19186:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidTypeError=void 0;class r extends Error{constructor(){super(...arguments),this.isnvalidTypeError=!0}}t.InvalidTypeError=r},88022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidValueError=void 0;class r extends Error{constructor(){super(...arguments),this.isnvalidTypeError=!0}}t.InvalidValueError=r},563:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(96638),t),i(r(87717),t),i(r(19186),t),i(r(88022),t)},44738:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(61034),t),i(r(42485),t),i(r(15212),t),i(r(44162),t),i(r(79571),t)},59172:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ADDRESSES=t.BIGNUMBER_BASE=t.BASE_DECIMALS=t.PERSONAL_SIGN_DOMAIN_PARAMS=t.EIP712_DOMAIN_STRUCT=t.EIP712_DOMAIN_STRUCT_NO_CONTRACT=t.EIP712_DOMAIN_STRING_NO_CONTRACT=t.PREPEND_HEX=t.PREPEND_DEC=t.EIP712_CANCEL_ORDER_STRUCT_STRING=t.EIP712_CANCEL_ORDER_STRUCT=t.EIP712_ORDER_STRUCT_STRING=t.DEFAULT_EIP712_DOMAIN_NAME=t.EIP712_ORDER_SIGNATURE_TYPE_ARR=t.EIP712_DOMAIN_VERSION=t.EIP712_DOMAIN_STRING=t.INTEGERS=t.EIP712_ORDER_STRUCT=t.ZERO_REPEAT_60=t.ORDER_FLAGS=t.TRADER_FLAG_DELEVERAGING=t.TRADER_FLAG_LIQUIDATION=t.TRADER_FLAG_ORDERS=void 0;const i=n(r(44431)),a=new i.default(60),o=a.times(60),s=o.times(24),u=s.times(365);t.TRADER_FLAG_ORDERS=new i.default(1),t.TRADER_FLAG_LIQUIDATION=new i.default(2),t.TRADER_FLAG_DELEVERAGING=new i.default(4),t.ORDER_FLAGS={IS_BUY:1,IS_REDUCE_ONLY:2},t.ZERO_REPEAT_60="000000000000000000000000000000000000000000000000000000000000",t.EIP712_ORDER_STRUCT=[{type:"bytes8",name:"flags"},{type:"uint128",name:"quantity"},{type:"uint128",name:"price"},{type:"uint128",name:"triggerPrice"},{type:"uint128",name:"leverage"},{type:"address",name:"maker"},{type:"uint128",name:"expiration"}],t.INTEGERS={ONE_MINUTE_IN_SECONDS:a,ONE_HOUR_IN_SECONDS:o,ONE_DAY_IN_SECONDS:s,ONE_YEAR_IN_SECONDS:u,ZERO:new i.default(0),ONE:new i.default(1),ONES_255:new i.default("115792089237316195423570985008687907853269984665640564039457584007913129639935")},t.EIP712_DOMAIN_STRING="EIP712Domain(string name,string version,uint128 chainId,address verifyingContract)",t.EIP712_DOMAIN_VERSION="1.0",t.EIP712_ORDER_SIGNATURE_TYPE_ARR=["bytes8","uint128","uint128","uint128","uint128","address","uint128"],t.DEFAULT_EIP712_DOMAIN_NAME="IsolatedTrader",t.EIP712_ORDER_STRUCT_STRING="Order(bytes8 flags,uint128 quantity,uint128 price,uint128 triggerPrice,uint128 leverage,address maker,uint128 expiration)",t.EIP712_CANCEL_ORDER_STRUCT=[{type:"string",name:"action"},{type:"bytes32[]",name:"orderHashes"}],t.EIP712_CANCEL_ORDER_STRUCT_STRING="CancelLimitOrder(string action,bytes32[] orderHashes)",t.PREPEND_DEC="Ethereum Signed Message:\n32",t.PREPEND_HEX="Ethereum Signed Message:\n ",t.EIP712_DOMAIN_STRING_NO_CONTRACT="EIP712Domain(string name,string version,uint128 chainId)",t.EIP712_DOMAIN_STRUCT_NO_CONTRACT=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint128"}],t.EIP712_DOMAIN_STRUCT=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint128"},{name:"verifyingContract",type:"address"}],t.PERSONAL_SIGN_DOMAIN_PARAMS=["name","version","chainId"],t.BASE_DECIMALS=18,t.BIGNUMBER_BASE=new i.default(1).shiftedBy(t.BASE_DECIMALS),t.ADDRESSES={ZERO:"0x0000000000000000000000000000000000000000"}},75197:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChainlinkAggregator__factory=void 0;const n=r(68903);class i extends n.ContractFactory{constructor(e){super(a,o,e)}attach(e){return super.attach(e)}connect(e){return super.connect(e)}static connect(e,t){return new n.Contract(e,a,t)}}t.ChainlinkAggregator__factory=i;const a=[{inputs:[{internalType:"uint32",name:"_maximumGasPrice",type:"uint32"},{internalType:"uint32",name:"_reasonableGasPrice",type:"uint32"},{internalType:"uint32",name:"_microLinkPerEth",type:"uint32"},{internalType:"uint32",name:"_linkGweiPerObservation",type:"uint32"},{internalType:"uint32",name:"_linkGweiPerTransmission",type:"uint32"},{internalType:"contract LinkTokenInterface",name:"_link",type:"address"},{internalType:"int192",name:"_minAnswer",type:"int192"},{internalType:"int192",name:"_maxAnswer",type:"int192"},{internalType:"contract AccessControllerInterface",name:"_billingAccessController",type:"address"},{internalType:"contract AccessControllerInterface",name:"_requesterAccessController",type:"address"},{internalType:"uint8",name:"_decimals",type:"uint8"},{internalType:"string",name:"description",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"user",type:"address"}],name:"AddedAccess",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"int256",name:"current",type:"int256"},{indexed:!0,internalType:"uint256",name:"roundId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"updatedAt",type:"uint256"}],name:"AnswerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"contract AccessControllerInterface",name:"old",type:"address"},{indexed:!1,internalType:"contract AccessControllerInterface",name:"current",type:"address"}],name:"BillingAccessControllerSet",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint32",name:"maximumGasPrice",type:"uint32"},{indexed:!1,internalType:"uint32",name:"reasonableGasPrice",type:"uint32"},{indexed:!1,internalType:"uint32",name:"microLinkPerEth",type:"uint32"},{indexed:!1,internalType:"uint32",name:"linkGweiPerObservation",type:"uint32"},{indexed:!1,internalType:"uint32",name:"linkGweiPerTransmission",type:"uint32"}],name:"BillingSet",type:"event"},{anonymous:!1,inputs:[],name:"CheckAccessDisabled",type:"event"},{anonymous:!1,inputs:[],name:"CheckAccessEnabled",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint32",name:"previousConfigBlockNumber",type:"uint32"},{indexed:!1,internalType:"uint64",name:"configCount",type:"uint64"},{indexed:!1,internalType:"address[]",name:"signers",type:"address[]"},{indexed:!1,internalType:"address[]",name:"transmitters",type:"address[]"},{indexed:!1,internalType:"uint8",name:"threshold",type:"uint8"},{indexed:!1,internalType:"uint64",name:"encodedConfigVersion",type:"uint64"},{indexed:!1,internalType:"bytes",name:"encoded",type:"bytes"}],name:"ConfigSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract LinkTokenInterface",name:"_oldLinkToken",type:"address"},{indexed:!0,internalType:"contract LinkTokenInterface",name:"_newLinkToken",type:"address"}],name:"LinkTokenSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"roundId",type:"uint256"},{indexed:!0,internalType:"address",name:"startedBy",type:"address"},{indexed:!1,internalType:"uint256",name:"startedAt",type:"uint256"}],name:"NewRound",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint32",name:"aggregatorRoundId",type:"uint32"},{indexed:!1,internalType:"int192",name:"answer",type:"int192"},{indexed:!1,internalType:"address",name:"transmitter",type:"address"},{indexed:!1,internalType:"int192[]",name:"observations",type:"int192[]"},{indexed:!1,internalType:"bytes",name:"observers",type:"bytes"},{indexed:!1,internalType:"bytes32",name:"rawReportContext",type:"bytes32"}],name:"NewTransmission",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"transmitter",type:"address"},{indexed:!0,internalType:"address",name:"payee",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"contract LinkTokenInterface",name:"linkToken",type:"address"}],name:"OraclePaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"OwnershipTransferRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"transmitter",type:"address"},{indexed:!0,internalType:"address",name:"current",type:"address"},{indexed:!0,internalType:"address",name:"proposed",type:"address"}],name:"PayeeshipTransferRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"transmitter",type:"address"},{indexed:!0,internalType:"address",name:"previous",type:"address"},{indexed:!0,internalType:"address",name:"current",type:"address"}],name:"PayeeshipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"user",type:"address"}],name:"RemovedAccess",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"contract AccessControllerInterface",name:"old",type:"address"},{indexed:!1,internalType:"contract AccessControllerInterface",name:"current",type:"address"}],name:"RequesterAccessControllerSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"requester",type:"address"},{indexed:!1,internalType:"bytes16",name:"configDigest",type:"bytes16"},{indexed:!1,internalType:"uint32",name:"epoch",type:"uint32"},{indexed:!1,internalType:"uint8",name:"round",type:"uint8"}],name:"RoundRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract AggregatorValidatorInterface",name:"previousValidator",type:"address"},{indexed:!1,internalType:"uint32",name:"previousGasLimit",type:"uint32"},{indexed:!0,internalType:"contract AggregatorValidatorInterface",name:"currentValidator",type:"address"},{indexed:!1,internalType:"uint32",name:"currentGasLimit",type:"uint32"}],name:"ValidatorConfigSet",type:"event"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_transmitter",type:"address"}],name:"acceptPayeeship",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_user",type:"address"}],name:"addAccess",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"billingAccessController",outputs:[{internalType:"contract AccessControllerInterface",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"checkEnabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"description",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"disableAccessCheck",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"enableAccessCheck",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_roundId",type:"uint256"}],name:"getAnswer",outputs:[{internalType:"int256",name:"",type:"int256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBilling",outputs:[{internalType:"uint32",name:"maximumGasPrice",type:"uint32"},{internalType:"uint32",name:"reasonableGasPrice",type:"uint32"},{internalType:"uint32",name:"microLinkPerEth",type:"uint32"},{internalType:"uint32",name:"linkGweiPerObservation",type:"uint32"},{internalType:"uint32",name:"linkGweiPerTransmission",type:"uint32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLinkToken",outputs:[{internalType:"contract LinkTokenInterface",name:"linkToken",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint80",name:"_roundId",type:"uint80"}],name:"getRoundData",outputs:[{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"int256",name:"answer",type:"int256"},{internalType:"uint256",name:"startedAt",type:"uint256"},{internalType:"uint256",name:"updatedAt",type:"uint256"},{internalType:"uint80",name:"answeredInRound",type:"uint80"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_roundId",type:"uint256"}],name:"getTimestamp",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_user",type:"address"},{internalType:"bytes",name:"_calldata",type:"bytes"}],name:"hasAccess",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestAnswer",outputs:[{internalType:"int256",name:"",type:"int256"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestConfigDetails",outputs:[{internalType:"uint32",name:"configCount",type:"uint32"},{internalType:"uint32",name:"blockNumber",type:"uint32"},{internalType:"bytes16",name:"configDigest",type:"bytes16"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestRound",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestRoundData",outputs:[{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"int256",name:"answer",type:"int256"},{internalType:"uint256",name:"startedAt",type:"uint256"},{internalType:"uint256",name:"updatedAt",type:"uint256"},{internalType:"uint80",name:"answeredInRound",type:"uint80"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestTimestamp",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"latestTransmissionDetails",outputs:[{internalType:"bytes16",name:"configDigest",type:"bytes16"},{internalType:"uint32",name:"epoch",type:"uint32"},{internalType:"uint8",name:"round",type:"uint8"},{internalType:"int192",name:"latestAnswer",type:"int192"},{internalType:"uint64",name:"latestTimestamp",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"linkAvailableForPayment",outputs:[{internalType:"int256",name:"availableBalance",type:"int256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxAnswer",outputs:[{internalType:"int192",name:"",type:"int192"}],stateMutability:"view",type:"function"},{inputs:[],name:"minAnswer",outputs:[{internalType:"int192",name:"",type:"int192"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_signerOrTransmitter",type:"address"}],name:"oracleObservationCount",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_transmitter",type:"address"}],name:"owedPayment",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address payable",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_user",type:"address"}],name:"removeAccess",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"requestNewRound",outputs:[{internalType:"uint80",name:"",type:"uint80"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"requesterAccessController",outputs:[{internalType:"contract AccessControllerInterface",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint32",name:"_maximumGasPrice",type:"uint32"},{internalType:"uint32",name:"_reasonableGasPrice",type:"uint32"},{internalType:"uint32",name:"_microLinkPerEth",type:"uint32"},{internalType:"uint32",name:"_linkGweiPerObservation",type:"uint32"},{internalType:"uint32",name:"_linkGweiPerTransmission",type:"uint32"}],name:"setBilling",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract AccessControllerInterface",name:"_billingAccessController",type:"address"}],name:"setBillingAccessController",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address[]",name:"_signers",type:"address[]"},{internalType:"address[]",name:"_transmitters",type:"address[]"},{internalType:"uint8",name:"_threshold",type:"uint8"},{internalType:"uint64",name:"_encodedConfigVersion",type:"uint64"},{internalType:"bytes",name:"_encoded",type:"bytes"}],name:"setConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract LinkTokenInterface",name:"_linkToken",type:"address"},{internalType:"address",name:"_recipient",type:"address"}],name:"setLinkToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address[]",name:"_transmitters",type:"address[]"},{internalType:"address[]",name:"_payees",type:"address[]"}],name:"setPayees",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract AccessControllerInterface",name:"_requesterAccessController",type:"address"}],name:"setRequesterAccessController",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract AggregatorValidatorInterface",name:"_newValidator",type:"address"},{internalType:"uint32",name:"_newGasLimit",type:"uint32"}],name:"setValidatorConfig",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_to",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_transmitter",type:"address"},{internalType:"address",name:"_proposed",type:"address"}],name:"transferPayeeship",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"_report",type:"bytes"},{internalType:"bytes32[]",name:"_rs",type:"bytes32[]"},{internalType:"bytes32[]",name:"_ss",type:"bytes32[]"},{internalType:"bytes32",name:"_rawVs",type:"bytes32"}],name:"transmit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"transmitters",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"typeAndVersion",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[],name:"validatorConfig",outputs:[{internalType:"contract AggregatorValidatorInterface",name:"validator",type:"address"},{internalType:"uint32",name:"gasLimit",type:"uint32"}],stateMutability:"view",type:"function"},{inputs:[],name:"version",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_recipient",type:"address"},{internalType:"uint256",name:"_amount",type:"uint256"}],name:"withdrawFunds",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_transmitter",type:"address"}],name:"withdrawPayment",outputs:[],stateMutability:"nonpayable",type:"function"}],o="0x608060405234801561001057600080fd5b506004361061030a5760003560e01c80638e0566de1161019c578063c1075329116100ee578063e76d516811610097578063f2fde38b11610071578063f2fde38b14610cb6578063fbffd2c114610cdc578063feaf968c14610d025761030a565b8063e76d516814610c4e578063eb45716314610c56578063eb5dcd6c14610c885761030a565b8063dc7f0124116100c8578063dc7f012414610b9f578063e4902f8214610ba7578063e5fe457714610be45761030a565b8063c107532914610a57578063c980753914610a83578063d09dc33914610b975761030a565b80639e3ceeab11610150578063b5ab58dc1161012a578063b5ab58dc146109d8578063b633620c146109f5578063bd82470614610a125761030a565b80639e3ceeab14610966578063a118f2491461098c578063b121e147146109b25761030a565b8063996e829811610181578063996e8298146108295780639a6fc8f5146108315780639c849b30146108a45761030a565b80638e0566de146107d257806398e5b12a146108025761030a565b80636b14daf81161026057806381411834116102095780638823da6c116101e35780638823da6c1461077e5780638ac28d5a146107a45780638da5cb5b146107ca5761030a565b806381411834146106cd57806381ff7048146107255780638205bf6a146107765761030a565b80637284e4161161023a5780637284e416146106b557806379ba5097146106bd5780638038e4a1146106c55761030a565b80636b14daf8146105bf57806370da2f671461068957806370efdf2d146106915761030a565b8063313ce567116102c257806354fd4d501161029c57806354fd4d5014610482578063585aa7de1461048a578063668a0f02146105b75761030a565b8063313ce5671461042e5780634fb174701461044c57806350d25bcd1461047a5761030a565b8063181f5a77116102f3578063181f5a771461035157806322adbc78146103ce57806329937268146103ed5761030a565b80630a7569831461030f5780630eafb25b14610319575b600080fd5b610317610d0a565b005b61033f6004803603602081101561032f57600080fd5b50356001600160a01b0316610dc8565b60408051918252519081900360200190f35b610359610f13565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561039357818101518382015260200161037b565b50505050905090810190601f1680156103c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103d6610f33565b6040805160179290920b8252519081900360200190f35b6103f5610f57565b6040805163ffffffff96871681529486166020860152928516848401529084166060840152909216608082015290519081900360a00190f35b610436610fd4565b6040805160ff9092168252519081900360200190f35b6103176004803603604081101561046257600080fd5b506001600160a01b0381358116916020013516610ff8565b61033f6112dc565b61033f61137d565b610317600480360360a08110156104a057600080fd5b8101906020810181356401000000008111156104bb57600080fd5b8201836020820111156104cd57600080fd5b803590602001918460208302840111640100000000831117156104ef57600080fd5b91939092909160208101903564010000000081111561050d57600080fd5b82018360208201111561051f57600080fd5b8035906020019184602083028401116401000000008311171561054157600080fd5b9193909260ff8335169267ffffffffffffffff60208201351692919060608101906040013564010000000081111561057857600080fd5b82018360208201111561058a57600080fd5b803590602001918460018302840111640100000000831117156105ac57600080fd5b509092509050611382565b61033f611d5d565b610675600480360360408110156105d557600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611df9945050505050565b604080519115158252519081900360200190f35b6103d6611e21565b610699611e45565b604080516001600160a01b039092168252519081900360200190f35b610359611e54565b610317611ef0565b610317611fbe565b6106d561207d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156107115781810151838201526020016106f9565b505050509050019250505060405180910390f35b61072d6120df565b6040805163ffffffff94851681529290931660208301527fffffffffffffffffffffffffffffffff00000000000000000000000000000000168183015290519081900360600190f35b61033f612100565b6103176004803603602081101561079457600080fd5b50356001600160a01b031661219c565b610317600480360360208110156107ba57600080fd5b50356001600160a01b0316612293565b61069961230a565b6107da612319565b604080516001600160a01b03909316835263ffffffff90911660208301528051918290030190f35b61080a61235d565b6040805169ffffffffffffffffffff9092168252519081900360200190f35b6106996125b1565b61085a6004803603602081101561084757600080fd5b503569ffffffffffffffffffff166125c0565b604051808669ffffffffffffffffffff1681526020018581526020018481526020018381526020018269ffffffffffffffffffff1681526020019550505050505060405180910390f35b610317600480360360408110156108ba57600080fd5b8101906020810181356401000000008111156108d557600080fd5b8201836020820111156108e757600080fd5b8035906020019184602083028401116401000000008311171561090957600080fd5b91939092909160208101903564010000000081111561092757600080fd5b82018360208201111561093957600080fd5b8035906020019184602083028401116401000000008311171561095b57600080fd5b509092509050612675565b6103176004803603602081101561097c57600080fd5b50356001600160a01b03166128ae565b610317600480360360208110156109a257600080fd5b50356001600160a01b031661299c565b610317600480360360208110156109c857600080fd5b50356001600160a01b0316612a04565b61033f600480360360208110156109ee57600080fd5b5035612afd565b61033f60048036036020811015610a0b57600080fd5b5035612b9a565b610317600480360360a0811015610a2857600080fd5b5063ffffffff813581169160208101358216916040820135811691606081013582169160809091013516612c37565b61031760048036036040811015610a6d57600080fd5b506001600160a01b038135169060200135612d9d565b61031760048036036080811015610a9957600080fd5b810190602081018135640100000000811115610ab457600080fd5b820183602082011115610ac657600080fd5b80359060200191846001830284011164010000000083111715610ae857600080fd5b919390929091602081019035640100000000811115610b0657600080fd5b820183602082011115610b1857600080fd5b80359060200191846020830284011164010000000083111715610b3a57600080fd5b919390929091602081019035640100000000811115610b5857600080fd5b820183602082011115610b6a57600080fd5b80359060200191846020830284011164010000000083111715610b8c57600080fd5b9193509150356130c4565b61033f613fcd565b610675614077565b610bcd60048036036020811015610bbd57600080fd5b50356001600160a01b0316614080565b6040805161ffff9092168252519081900360200190f35b610bec61412d565b604080517fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616865263ffffffff909416602086015260ff9092168484015260170b606084015267ffffffffffffffff166080830152519081900360a00190f35b61069961421c565b61031760048036036040811015610c6c57600080fd5b5080356001600160a01b0316906020013563ffffffff1661422b565b61031760048036036040811015610c9e57600080fd5b506001600160a01b03813581169160200135166143c0565b61031760048036036020811015610ccc57600080fd5b50356001600160a01b031661451b565b61031760048036036020811015610cf257600080fd5b50356001600160a01b03166145e3565b61085a61464b565b6000546001600160a01b03163314610d69576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60315460ff1615610dc657603180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f3be8a977a014527b50ae38adda80b56911c267328965c98ddc385d248f53963890600090a15b565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff808216845285948401916101009004166002811115610e0a57fe5b6002811115610e1557fe5b9052509050600081602001516002811115610e2c57fe5b1415610e3c576000915050610f0e565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116938301939093526c01000000000000000000000000810483166060830181905270010000000000000000000000000000000090910490921660808201528251909160009160019060059060ff16601f8110610ec757fe5b601091828204019190066002029054906101000a900461ffff160361ffff1602633b9aca0002905060016009846000015160ff16601f8110610f0557fe5b01540301925050505b919050565b6060604051806060016040528060288152602001615cc460289139905090565b7f00000000000000000000000000000000000000000000000000000002540be40081565b6040805160a08101825260025463ffffffff808216808452640100000000830482166020850181905268010000000000000000840483169585018690526c01000000000000000000000000840483166060860181905270010000000000000000000000000000000090940490921660809094018490529490939290565b7f000000000000000000000000000000000000000000000000000000000000000881565b6000546001600160a01b03163314611057576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6003546001600160a01b0390811690831681141561107557506112d8565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b1580156110d457600080fd5b505afa1580156110e8573d6000803e3d6000fd5b505050506040513d60208110156110fe57600080fd5b5061110990506146fe565b6000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561115857600080fd5b505afa15801561116c573d6000803e3d6000fd5b505050506040513d602081101561118257600080fd5b5051604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820184905291519293509084169163a9059cbb916044808201926020929091908290030181600087803b1580156111f357600080fd5b505af1158015611207573d6000803e3d6000fd5b505050506040513d602081101561121d57600080fd5b5051611270576040805162461bcd60e51b815260206004820152601f60248201527f7472616e736665722072656d61696e696e672066756e6473206661696c656400604482015290519081900360640190fd5b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925560405190918416907f4966a50c93f855342ccf6c5c0d358b85b91335b2acedc7da0932f691f351711a90600090a350505b5050565b600061131f336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611370576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614aae565b905090565b600481565b868560ff8616601f8311156113de576040805162461bcd60e51b815260206004820152601060248201527f746f6f206d616e79207369676e65727300000000000000000000000000000000604482015290519081900360640190fd5b60008111611433576040805162461bcd60e51b815260206004820152601a60248201527f7468726573686f6c64206d75737420626520706f736974697665000000000000604482015290519081900360640190fd5b8183146114715760405162461bcd60e51b8152600401808060200182810382526024815260200180615cec6024913960400191505060405180910390fd5b8060030283116114c8576040805162461bcd60e51b815260206004820181905260248201527f6661756c74792d6f7261636c65207468726573686f6c6420746f6f2068696768604482015290519081900360640190fd5b6000546001600160a01b03163314611527576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602954156116cb57602980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101916000918390811061156457fe5b6000918252602082200154602a80546001600160a01b039092169350908490811061158b57fe5b6000918252602090912001546001600160a01b031690506115ab81614aea565b6001600160a01b0380831660009081526028602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009081169091559284168252902080549091169055602980548061160757fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055019055602a80548061166a57fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905501905550611527915050565b60005b8a811015611ad9576000602860008e8e858181106116e857fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561171e57fe5b14611770576040805162461bcd60e51b815260206004820152601760248201527f7265706561746564207369676e65722061646472657373000000000000000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260016020820152602860008e8e8581811061179757fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600281111561182257fe5b02179055506000915060079050818c8c8581811061183c57fe5b6001600160a01b03602091820293909301358316845283019390935260409091016000205416919091141590506118ba576040805162461bcd60e51b815260206004820152601160248201527f7061796565206d75737420626520736574000000000000000000000000000000604482015290519081900360640190fd5b6000602860008c8c858181106118cc57fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561190257fe5b14611954576040805162461bcd60e51b815260206004820152601c60248201527f7265706561746564207472616e736d6974746572206164647265737300000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260026020820152602860008c8c8581811061197b57fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100836002811115611a0657fe5b021790555090505060298c8c83818110611a1c57fe5b835460018101855560009485526020948590200180547fffffffffffffffffffffffff000000000000000000000000