@rabbitholegg/questdk-plugin-balancer
Advanced tools
Comparing version 1.0.0-alpha.46 to 1.0.0-alpha.47
# @rabbitholegg/questdk-plugin-balancer | ||
## 1.0.0-alpha.47 | ||
### Minor Changes | ||
- [#385](https://github.com/rabbitholegg/questdk-plugins/pull/385) [`72a86095`](https://github.com/rabbitholegg/questdk-plugins/commit/72a860954036856b073a2043dfc8614c200585d6) Thanks [@sammccord](https://github.com/sammccord)! - use vite for build tooling, reduce plugin size, improve build speeds | ||
### Patch Changes | ||
- Updated dependencies [[`1fa4bb52`](https://github.com/rabbitholegg/questdk-plugins/commit/1fa4bb5262cef6a1f434850b097b9aacc0d1e8ba), [`19d8db5c`](https://github.com/rabbitholegg/questdk-plugins/commit/19d8db5c5cafb4409dd469d22bdfc709d6d108aa), [`72a86095`](https://github.com/rabbitholegg/questdk-plugins/commit/72a860954036856b073a2043dfc8614c200585d6)]: | ||
- @rabbitholegg/questdk-plugin-utils@1.0.0-alpha.32 | ||
- @rabbitholegg/questdk@2.0.0-alpha.52 | ||
## 1.0.0-alpha.46 | ||
@@ -4,0 +16,0 @@ |
@@ -1,53 +0,2 @@ | ||
"use strict"; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Balancer = void 0; | ||
var _questdk = require("@rabbitholegg/questdk"); | ||
var _Balancer = require("./Balancer"); | ||
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
var Balancer = exports.Balancer = { | ||
pluginId: 'balancer', | ||
getSupportedTokenAddresses: _Balancer.getSupportedTokenAddresses, | ||
getSupportedChainIds: _Balancer.getSupportedChainIds, | ||
swap: _Balancer.swap, | ||
bridge: function () { | ||
var _bridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", new _questdk.PluginActionNotImplementedError()); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
})); | ||
function bridge() { | ||
return _bridge.apply(this, arguments); | ||
} | ||
return bridge; | ||
}(), | ||
mint: function () { | ||
var _mint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
return _context2.abrupt("return", new _questdk.PluginActionNotImplementedError()); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function mint() { | ||
return _mint.apply(this, arguments); | ||
} | ||
return mint; | ||
}() | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
(function(d,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@rabbitholegg/questdk"),require("@rabbitholegg/questdk-plugin-utils")):typeof define=="function"&&define.amd?define(["exports","@rabbitholegg/questdk","@rabbitholegg/questdk-plugin-utils"],p):(d=typeof globalThis<"u"?globalThis:d||self,p(d.QuestdkPluginBalancer={},d.questdk,d.questdkPluginUtils))})(this,function(d,p,u){"use strict";const X=[{inputs:[{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"uint256",name:"assetInIndex",type:"uint256"},{internalType:"uint256",name:"assetOutIndex",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.BatchSwapStep[]",name:"swaps",type:"tuple[]"},{internalType:"contract IAsset[]",name:"assets",type:"address[]"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"int256[]",name:"limits",type:"int256[]"},{internalType:"uint256",name:"deadline",type:"uint256"}],name:"batchSwap",outputs:[{internalType:"int256[]",name:"assetDeltas",type:"int256[]"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"poolId",type:"bytes32"},{internalType:"enum IVault.SwapKind",name:"kind",type:"uint8"},{internalType:"contract IAsset",name:"assetIn",type:"address"},{internalType:"contract IAsset",name:"assetOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes",name:"userData",type:"bytes"}],internalType:"struct IVault.SingleSwap",name:"singleSwap",type:"tuple"},{components:[{internalType:"address",name:"sender",type:"address"},{internalType:"bool",name:"fromInternalBalance",type:"bool"},{internalType:"address payable",name:"recipient",type:"address"},{internalType:"bool",name:"toInternalBalance",type:"bool"}],internalType:"struct IVault.FundManagement",name:"funds",type:"tuple"},{internalType:"uint256",name:"limit",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],name:"swap",outputs:[{internalType:"uint256",name:"amountCalculated",type:"uint256"}],stateMutability:"payable",type:"function"}],G="0xba12222222228d8ba445958a75a0704d566bf2c8",K="0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",Q=[u.Chains.ETHEREUM,u.Chains.OPTIMISM,u.Chains.POLYGON_POS,u.Chains.BASE,u.Chains.ARBITRUM_ONE];function w(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function T(e){return w(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Y="2.9.23",W=()=>`viem@${Y}`;class l extends Error{constructor(t,n={}){var i;super(),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ViemError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:W()});const r=n.cause instanceof l?n.cause.details:(i=n.cause)!=null&&i.message?n.cause.message:n.details,s=n.cause instanceof l&&n.cause.docsPath||n.docsPath;this.message=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://viem.sh${s}${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(` | ||
`),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=t}walk(t){return I(this,t)}}function I(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e?I(e.cause,t):t?null:e}class $ extends l{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SizeExceedsPaddingSizeError"})}}function y(e,{dir:t,size:n=32}={}){return typeof e=="string"?J(e,{dir:t,size:n}):Z(e,{dir:t,size:n})}function J(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new $({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function Z(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new $({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=t==="right";r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}class q extends l{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"IntegerOutOfRangeError"})}}class ee extends l{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SizeOverflowError"})}}function g(e,{size:t}){if(T(e)>t)throw new ee({givenSize:T(e),maxSize:t})}const te=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ne(e,t={}){return typeof e=="number"||typeof e=="bigint"?F(e,t):typeof e=="string"?ie(e,t):typeof e=="boolean"?re(e,t):D(e,t)}function re(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(g(n,{size:t.size}),y(n,{size:t.size})):n}function D(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=te[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(g(r,{size:t.size}),y(r,{dir:"right",size:t.size})):r}function F(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const c=typeof e=="bigint"?"n":"";throw new q({max:i?`${i}${c}`:void 0,min:`${o}${c}`,signed:n,size:r,value:`${e}${c}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?y(a,{size:r}):a}const se=new TextEncoder;function ie(e,t={}){const n=se.encode(e);return D(n,t)}const oe=new TextEncoder;function ae(e,t={}){return typeof e=="number"||typeof e=="bigint"?ue(e,t):typeof e=="boolean"?ce(e,t):w(e)?O(e,t):k(e,t)}function ce(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(g(n,{size:t.size}),y(n,{size:t.size})):n}const f={zero:48,nine:57,A:65,F:70,a:97,f:102};function S(e){if(e>=f.zero&&e<=f.nine)return e-f.zero;if(e>=f.A&&e<=f.F)return e-(f.A-10);if(e>=f.a&&e<=f.f)return e-(f.a-10)}function O(e,t={}){let n=e;t.size&&(g(n,{size:t.size}),n=y(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const c=S(r.charCodeAt(a++)),h=S(r.charCodeAt(a++));if(c===void 0||h===void 0)throw new l(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=c*16+h}return i}function ue(e,t){const n=F(e,t);return O(n)}function k(e,t={}){const n=oe.encode(e);return typeof t.size=="number"?(g(n,{size:t.size}),y(n,{dir:"right",size:t.size})):n}function z(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function L(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function M(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function fe(e,t){L(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const m=BigInt(2**32-1),P=BigInt(32);function de(e,t=!1){return t?{h:Number(e&m),l:Number(e>>P&m)}:{h:Number(e>>P&m)|0,l:Number(e&m)|0}}function le(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:o}=de(e[s],t);[n[s],r[s]]=[i,o]}return[n,r]}const pe=(e,t,n)=>e<<n|t>>>32-n,he=(e,t,n)=>t<<n|e>>>32-n,be=(e,t,n)=>t<<n-32|e>>>64-n,ye=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ge=e=>e instanceof Uint8Array,xe=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Ae(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function H(e){if(typeof e=="string"&&(e=Ae(e)),!ge(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}class me{clone(){return this._cloneInto()}}function Ce(e){const t=r=>e().update(H(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[_,N,j]=[[],[],[]],we=BigInt(0),x=BigInt(1),Ee=BigInt(2),Be=BigInt(7),Te=BigInt(256),Ie=BigInt(113);for(let e=0,t=x,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_.push(2*(5*r+n)),N.push((e+1)*(e+2)/2%64);let s=we;for(let i=0;i<7;i++)t=(t<<x^(t>>Be)*Ie)%Te,t&Ee&&(s^=x<<(x<<BigInt(i))-x);j.push(s)}const[$e,De]=le(j,!0),U=(e,t,n)=>n>32?be(e,t,n):pe(e,t,n),R=(e,t,n)=>n>32?ye(e,t,n):he(e,t,n);function Fe(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,h=n[c],b=n[c+1],Xe=U(h,b,1)^n[a],Ge=R(h,b,1)^n[a+1];for(let C=0;C<50;C+=10)e[o+C]^=Xe,e[o+C+1]^=Ge}let s=e[2],i=e[3];for(let o=0;o<24;o++){const a=N[o],c=U(s,i,a),h=R(s,i,a),b=_[o];s=e[b],i=e[b+1],e[b]=c,e[b+1]=h}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=$e[r],e[1]^=De[r]}n.fill(0)}class E extends me{constructor(t,n,r,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,z(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=xe(this.state)}keccak(){Fe(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){M(this);const{blockLen:n,state:r}=this;t=H(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){M(this,!1),L(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);t.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return z(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fe(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return t||(t=new E(n,r,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Se=((e,t,n)=>Ce(()=>new E(t,e,n)))(1,136,256/8);function Oe(e,t){const n=t||"hex",r=Se(w(e,{strict:!1})?ae(e):e);return n==="bytes"?r:ne(r)}class ke extends l{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAddressError"})}}class ze extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}set(t,n){return super.set(t,n),this.maxSize&&this.size>this.maxSize&&this.delete(this.keys().next().value),this}}function v(e,t){const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Oe(k(n),"bytes"),s=(t?n.substring(`${t}0x`.length):n).split("");for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&s[i]&&(s[i]=s[i].toUpperCase()),(r[i>>1]&15)>=8&&s[i+1]&&(s[i+1]=s[i+1].toUpperCase());return`0x${s.join("")}`}function V(e,t){if(!Me(e,{strict:!1}))throw new ke({address:e});return v(e,t)}const Le=/^0x[a-fA-F0-9]{40}$/,B=new ze(8192);function Me(e,t){const{strict:n=!0}=t??{};if(B.has(e))return B.get(e);const r=Le.test(e)?e.toLowerCase()===e?!0:n?v(e)===e:!0:!1;return B.set(e,r),r}const A="0x0000000000000000000000000000000000000000",Pe=(e,t)=>{const n=[];return e&&n.push({$first:V(e)}),t&&n.push({$last:V(t)}),{$and:n}},He=(e,t)=>{const n=[];if(e&&(typeof e=="object"?n.push({$first:e}):n.push({$first:{$gte:BigInt(e)}})),t){let r;if(typeof t=="object"){const[s,i]=Object.entries(t)[0];switch(s){case"$gte":r={$lte:BigInt(-i)};break;case"$lte":r={$gte:BigInt(-i)};break;case"$gt":r={$lt:BigInt(-i)};break;case"$lt":r={$gt:BigInt(-i)};break}}else r={$lte:BigInt(-t)};r&&n.push({$last:r})}return{$and:n}},_e=[A,"0x6B175474E89094C44Da98b954EedeAC495271d0F","0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0x5947BB275c521040051D82396192181b413227A3","0xc00e94Cb662C3520282E6f5717214004A7f26888","0xba100000625a3754423978a60c9317c58a424e3D","0x6810e776880C02933D47DB1b9fc05908e5386b96"],Ne=[A,"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1","0xFdb794692724153d1488CcdBE0C56c252596735F","0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6","0x4200000000000000000000000000000000000042","0x9e1028F5F1D5eDE59748FFceE5532509976840E0","0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x7F5c764cBc14f9669B88837ca1490cCa17c31607","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58","0x68f180fcCe6836688e9084f035309E29Bf0A2095","0x4200000000000000000000000000000000000006"],je=[A,"0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3","0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063","0xC3C7d422809852031b44ab29EEC9F1EfF2A58756","0x831753DD7087CaC61aB5644b308642cc1c33Dc13","0xb33EaAd8d922B1083446DC23f610c2567fB5180f","0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174","0xc2132D05D31c914a87C6611C10748AEb04B58e8F","0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6","0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619","0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"],Ue=[A,"0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1","0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22","0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb","0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","0x4200000000000000000000000000000000000006"],Re=[A,"0x912CE59144191C1204E64559FE8253a0e49E6548","0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8","0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a","0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60","0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9","0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f","0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"],ve={[u.Chains.ETHEREUM]:_e,[u.Chains.OPTIMISM]:Ne,[u.Chains.ARBITRUM_ONE]:Re,[u.Chains.POLYGON_POS]:je,[u.Chains.BASE]:Ue},Ve={pluginId:"balancer",getSupportedTokenAddresses:async e=>ve[e]??[],getSupportedChainIds:async()=>Q,swap:async e=>{const{chainId:t,contractAddress:n,tokenIn:r,tokenOut:s,amountIn:i,amountOut:o,recipient:a}=e;return p.compressJson({chainId:t,to:n??{$or:[G.toLowerCase(),K.toLowerCase()]},input:{$abiAbstract:X,$or:[{singleSwap:{assetIn:r,assetOut:s,amount:i},funds:{recipient:a}},{assets:Pe(r,s),limits:He(i,o),funds:{recipient:a}}]}})},bridge:async()=>new p.PluginActionNotImplementedError,mint:async()=>new p.PluginActionNotImplementedError};d.Balancer=Ve,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}); |
@@ -1,11 +0,805 @@ | ||
import { PluginActionNotImplementedError } from '@rabbitholegg/questdk'; | ||
import { swap, getSupportedChainIds, getSupportedTokenAddresses } from './Balancer'; | ||
export const Balancer = { | ||
pluginId: 'balancer', | ||
getSupportedTokenAddresses, | ||
getSupportedChainIds, | ||
swap, | ||
bridge: async () => new PluginActionNotImplementedError(), | ||
mint: async () => new PluginActionNotImplementedError() | ||
import { compressJson as G, PluginActionNotImplementedError as E } from "@rabbitholegg/questdk"; | ||
import { Chains as u } from "@rabbitholegg/questdk-plugin-utils"; | ||
const K = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "enum IVault.SwapKind", | ||
name: "kind", | ||
type: "uint8" | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: "bytes32", | ||
name: "poolId", | ||
type: "bytes32" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "assetInIndex", | ||
type: "uint256" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "assetOutIndex", | ||
type: "uint256" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256" | ||
}, | ||
{ | ||
internalType: "bytes", | ||
name: "userData", | ||
type: "bytes" | ||
} | ||
], | ||
internalType: "struct IVault.BatchSwapStep[]", | ||
name: "swaps", | ||
type: "tuple[]" | ||
}, | ||
{ | ||
internalType: "contract IAsset[]", | ||
name: "assets", | ||
type: "address[]" | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: "address", | ||
name: "sender", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "bool", | ||
name: "fromInternalBalance", | ||
type: "bool" | ||
}, | ||
{ | ||
internalType: "address payable", | ||
name: "recipient", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "bool", | ||
name: "toInternalBalance", | ||
type: "bool" | ||
} | ||
], | ||
internalType: "struct IVault.FundManagement", | ||
name: "funds", | ||
type: "tuple" | ||
}, | ||
{ | ||
internalType: "int256[]", | ||
name: "limits", | ||
type: "int256[]" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "deadline", | ||
type: "uint256" | ||
} | ||
], | ||
name: "batchSwap", | ||
outputs: [ | ||
{ | ||
internalType: "int256[]", | ||
name: "assetDeltas", | ||
type: "int256[]" | ||
} | ||
], | ||
stateMutability: "payable", | ||
type: "function" | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
components: [ | ||
{ | ||
internalType: "bytes32", | ||
name: "poolId", | ||
type: "bytes32" | ||
}, | ||
{ | ||
internalType: "enum IVault.SwapKind", | ||
name: "kind", | ||
type: "uint8" | ||
}, | ||
{ | ||
internalType: "contract IAsset", | ||
name: "assetIn", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "contract IAsset", | ||
name: "assetOut", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256" | ||
}, | ||
{ | ||
internalType: "bytes", | ||
name: "userData", | ||
type: "bytes" | ||
} | ||
], | ||
internalType: "struct IVault.SingleSwap", | ||
name: "singleSwap", | ||
type: "tuple" | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: "address", | ||
name: "sender", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "bool", | ||
name: "fromInternalBalance", | ||
type: "bool" | ||
}, | ||
{ | ||
internalType: "address payable", | ||
name: "recipient", | ||
type: "address" | ||
}, | ||
{ | ||
internalType: "bool", | ||
name: "toInternalBalance", | ||
type: "bool" | ||
} | ||
], | ||
internalType: "struct IVault.FundManagement", | ||
name: "funds", | ||
type: "tuple" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "limit", | ||
type: "uint256" | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "deadline", | ||
type: "uint256" | ||
} | ||
], | ||
name: "swap", | ||
outputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "amountCalculated", | ||
type: "uint256" | ||
} | ||
], | ||
stateMutability: "payable", | ||
type: "function" | ||
} | ||
], Y = "0xba12222222228d8ba445958a75a0704d566bf2c8", Q = "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", W = [ | ||
u.ETHEREUM, | ||
u.OPTIMISM, | ||
u.POLYGON_POS, | ||
u.BASE, | ||
u.ARBITRUM_ONE | ||
]; | ||
function w(e, { strict: t = !0 } = {}) { | ||
return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x"); | ||
} | ||
function B(e) { | ||
return w(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length; | ||
} | ||
const q = "2.9.23", J = () => `viem@${q}`; | ||
class l extends Error { | ||
constructor(t, n = {}) { | ||
var i; | ||
super(), Object.defineProperty(this, "details", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: void 0 | ||
}), Object.defineProperty(this, "docsPath", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: void 0 | ||
}), Object.defineProperty(this, "metaMessages", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: void 0 | ||
}), Object.defineProperty(this, "shortMessage", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: void 0 | ||
}), Object.defineProperty(this, "name", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: "ViemError" | ||
}), Object.defineProperty(this, "version", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: J() | ||
}); | ||
const r = n.cause instanceof l ? n.cause.details : (i = n.cause) != null && i.message ? n.cause.message : n.details, s = n.cause instanceof l && n.cause.docsPath || n.docsPath; | ||
this.message = [ | ||
t || "An error occurred.", | ||
"", | ||
...n.metaMessages ? [...n.metaMessages, ""] : [], | ||
...s ? [ | ||
`Docs: https://viem.sh${s}${n.docsSlug ? `#${n.docsSlug}` : ""}` | ||
] : [], | ||
...r ? [`Details: ${r}`] : [], | ||
`Version: ${this.version}` | ||
].join(` | ||
`), n.cause && (this.cause = n.cause), this.details = r, this.docsPath = s, this.metaMessages = n.metaMessages, this.shortMessage = t; | ||
} | ||
walk(t) { | ||
return k(this, t); | ||
} | ||
} | ||
function k(e, t) { | ||
return t != null && t(e) ? e : e && typeof e == "object" && "cause" in e ? k(e.cause, t) : t ? null : e; | ||
} | ||
class z extends l { | ||
constructor({ size: t, targetSize: n, type: r }) { | ||
super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`), Object.defineProperty(this, "name", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: "SizeExceedsPaddingSizeError" | ||
}); | ||
} | ||
} | ||
function b(e, { dir: t, size: n = 32 } = {}) { | ||
return typeof e == "string" ? Z(e, { dir: t, size: n }) : ee(e, { dir: t, size: n }); | ||
} | ||
function Z(e, { dir: t, size: n = 32 } = {}) { | ||
if (n === null) | ||
return e; | ||
const r = e.replace("0x", ""); | ||
if (r.length > n * 2) | ||
throw new z({ | ||
size: Math.ceil(r.length / 2), | ||
targetSize: n, | ||
type: "hex" | ||
}); | ||
return `0x${r[t === "right" ? "padEnd" : "padStart"](n * 2, "0")}`; | ||
} | ||
function ee(e, { dir: t, size: n = 32 } = {}) { | ||
if (n === null) | ||
return e; | ||
if (e.length > n) | ||
throw new z({ | ||
size: e.length, | ||
targetSize: n, | ||
type: "bytes" | ||
}); | ||
const r = new Uint8Array(n); | ||
for (let s = 0; s < n; s++) { | ||
const i = t === "right"; | ||
r[i ? s : n - s - 1] = e[i ? s : e.length - s - 1]; | ||
} | ||
return r; | ||
} | ||
class te extends l { | ||
constructor({ max: t, min: n, signed: r, size: s, value: i }) { | ||
super(`Number "${i}" is not in safe ${s ? `${s * 8}-bit ${r ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${n} to ${t})` : `(above ${n})`}`), Object.defineProperty(this, "name", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: "IntegerOutOfRangeError" | ||
}); | ||
} | ||
} | ||
class ne extends l { | ||
constructor({ givenSize: t, maxSize: n }) { | ||
super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`), Object.defineProperty(this, "name", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: "SizeOverflowError" | ||
}); | ||
} | ||
} | ||
function y(e, { size: t }) { | ||
if (B(e) > t) | ||
throw new ne({ | ||
givenSize: B(e), | ||
maxSize: t | ||
}); | ||
} | ||
const re = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")); | ||
function se(e, t = {}) { | ||
return typeof e == "number" || typeof e == "bigint" ? P(e, t) : typeof e == "string" ? ae(e, t) : typeof e == "boolean" ? ie(e, t) : L(e, t); | ||
} | ||
function ie(e, t = {}) { | ||
const n = `0x${Number(e)}`; | ||
return typeof t.size == "number" ? (y(n, { size: t.size }), b(n, { size: t.size })) : n; | ||
} | ||
function L(e, t = {}) { | ||
let n = ""; | ||
for (let s = 0; s < e.length; s++) | ||
n += re[e[s]]; | ||
const r = `0x${n}`; | ||
return typeof t.size == "number" ? (y(r, { size: t.size }), b(r, { dir: "right", size: t.size })) : r; | ||
} | ||
function P(e, t = {}) { | ||
const { signed: n, size: r } = t, s = BigInt(e); | ||
let i; | ||
r ? n ? i = (1n << BigInt(r) * 8n - 1n) - 1n : i = 2n ** (BigInt(r) * 8n) - 1n : typeof e == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER)); | ||
const o = typeof i == "bigint" && n ? -i - 1n : 0; | ||
if (i && s > i || s < o) { | ||
const c = typeof e == "bigint" ? "n" : ""; | ||
throw new te({ | ||
max: i ? `${i}${c}` : void 0, | ||
min: `${o}${c}`, | ||
signed: n, | ||
size: r, | ||
value: `${e}${c}` | ||
}); | ||
} | ||
const a = `0x${(n && s < 0 ? (1n << BigInt(r * 8)) + BigInt(s) : s).toString(16)}`; | ||
return r ? b(a, { size: r }) : a; | ||
} | ||
const oe = /* @__PURE__ */ new TextEncoder(); | ||
function ae(e, t = {}) { | ||
const n = oe.encode(e); | ||
return L(n, t); | ||
} | ||
const ce = /* @__PURE__ */ new TextEncoder(); | ||
function ue(e, t = {}) { | ||
return typeof e == "number" || typeof e == "bigint" ? le(e, t) : typeof e == "boolean" ? fe(e, t) : w(e) ? M(e, t) : U(e, t); | ||
} | ||
function fe(e, t = {}) { | ||
const n = new Uint8Array(1); | ||
return n[0] = Number(e), typeof t.size == "number" ? (y(n, { size: t.size }), b(n, { size: t.size })) : n; | ||
} | ||
const f = { | ||
zero: 48, | ||
nine: 57, | ||
A: 65, | ||
F: 70, | ||
a: 97, | ||
f: 102 | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
function T(e) { | ||
if (e >= f.zero && e <= f.nine) | ||
return e - f.zero; | ||
if (e >= f.A && e <= f.F) | ||
return e - (f.A - 10); | ||
if (e >= f.a && e <= f.f) | ||
return e - (f.a - 10); | ||
} | ||
function M(e, t = {}) { | ||
let n = e; | ||
t.size && (y(n, { size: t.size }), n = b(n, { dir: "right", size: t.size })); | ||
let r = n.slice(2); | ||
r.length % 2 && (r = `0${r}`); | ||
const s = r.length / 2, i = new Uint8Array(s); | ||
for (let o = 0, a = 0; o < s; o++) { | ||
const c = T(r.charCodeAt(a++)), d = T(r.charCodeAt(a++)); | ||
if (c === void 0 || d === void 0) | ||
throw new l(`Invalid byte sequence ("${r[a - 2]}${r[a - 1]}" in "${r}").`); | ||
i[o] = c * 16 + d; | ||
} | ||
return i; | ||
} | ||
function le(e, t) { | ||
const n = P(e, t); | ||
return M(n); | ||
} | ||
function U(e, t = {}) { | ||
const n = ce.encode(e); | ||
return typeof t.size == "number" ? (y(n, { size: t.size }), b(n, { dir: "right", size: t.size })) : n; | ||
} | ||
function I(e) { | ||
if (!Number.isSafeInteger(e) || e < 0) | ||
throw new Error(`Wrong positive integer: ${e}`); | ||
} | ||
function H(e, ...t) { | ||
if (!(e instanceof Uint8Array)) | ||
throw new Error("Expected Uint8Array"); | ||
if (t.length > 0 && !t.includes(e.length)) | ||
throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`); | ||
} | ||
function $(e, t = !0) { | ||
if (e.destroyed) | ||
throw new Error("Hash instance has been destroyed"); | ||
if (t && e.finished) | ||
throw new Error("Hash#digest() has already been called"); | ||
} | ||
function de(e, t) { | ||
H(e); | ||
const n = t.outputLen; | ||
if (e.length < n) | ||
throw new Error(`digestInto() expects output buffer of length at least ${n}`); | ||
} | ||
const g = /* @__PURE__ */ BigInt(2 ** 32 - 1), D = /* @__PURE__ */ BigInt(32); | ||
function pe(e, t = !1) { | ||
return t ? { h: Number(e & g), l: Number(e >> D & g) } : { h: Number(e >> D & g) | 0, l: Number(e & g) | 0 }; | ||
} | ||
function be(e, t = !1) { | ||
let n = new Uint32Array(e.length), r = new Uint32Array(e.length); | ||
for (let s = 0; s < e.length; s++) { | ||
const { h: i, l: o } = pe(e[s], t); | ||
[n[s], r[s]] = [i, o]; | ||
} | ||
return [n, r]; | ||
} | ||
const he = (e, t, n) => e << n | t >>> 32 - n, ye = (e, t, n) => t << n | e >>> 32 - n, xe = (e, t, n) => t << n - 32 | e >>> 64 - n, Ae = (e, t, n) => e << n - 32 | t >>> 64 - n; | ||
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
const ge = (e) => e instanceof Uint8Array, me = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), we = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; | ||
if (!we) | ||
throw new Error("Non little-endian hardware is not supported"); | ||
function Ce(e) { | ||
if (typeof e != "string") | ||
throw new Error(`utf8ToBytes expected string, got ${typeof e}`); | ||
return new Uint8Array(new TextEncoder().encode(e)); | ||
} | ||
function _(e) { | ||
if (typeof e == "string" && (e = Ce(e)), !ge(e)) | ||
throw new Error(`expected Uint8Array, got ${typeof e}`); | ||
return e; | ||
} | ||
class Ee { | ||
// Safe version that clones internal state | ||
clone() { | ||
return this._cloneInto(); | ||
} | ||
} | ||
function Be(e) { | ||
const t = (r) => e().update(_(r)).digest(), n = e(); | ||
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t; | ||
} | ||
const [N, j, R] = [[], [], []], Te = /* @__PURE__ */ BigInt(0), h = /* @__PURE__ */ BigInt(1), Ie = /* @__PURE__ */ BigInt(2), $e = /* @__PURE__ */ BigInt(7), De = /* @__PURE__ */ BigInt(256), Fe = /* @__PURE__ */ BigInt(113); | ||
for (let e = 0, t = h, n = 1, r = 0; e < 24; e++) { | ||
[n, r] = [r, (2 * n + 3 * r) % 5], N.push(2 * (5 * r + n)), j.push((e + 1) * (e + 2) / 2 % 64); | ||
let s = Te; | ||
for (let i = 0; i < 7; i++) | ||
t = (t << h ^ (t >> $e) * Fe) % De, t & Ie && (s ^= h << (h << /* @__PURE__ */ BigInt(i)) - h); | ||
R.push(s); | ||
} | ||
const [Se, Oe] = /* @__PURE__ */ be(R, !0), F = (e, t, n) => n > 32 ? xe(e, t, n) : he(e, t, n), S = (e, t, n) => n > 32 ? Ae(e, t, n) : ye(e, t, n); | ||
function ke(e, t = 24) { | ||
const n = new Uint32Array(10); | ||
for (let r = 24 - t; r < 24; r++) { | ||
for (let o = 0; o < 10; o++) | ||
n[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40]; | ||
for (let o = 0; o < 10; o += 2) { | ||
const a = (o + 8) % 10, c = (o + 2) % 10, d = n[c], p = n[c + 1], V = F(d, p, 1) ^ n[a], X = S(d, p, 1) ^ n[a + 1]; | ||
for (let A = 0; A < 50; A += 10) | ||
e[o + A] ^= V, e[o + A + 1] ^= X; | ||
} | ||
let s = e[2], i = e[3]; | ||
for (let o = 0; o < 24; o++) { | ||
const a = j[o], c = F(s, i, a), d = S(s, i, a), p = N[o]; | ||
s = e[p], i = e[p + 1], e[p] = c, e[p + 1] = d; | ||
} | ||
for (let o = 0; o < 50; o += 10) { | ||
for (let a = 0; a < 10; a++) | ||
n[a] = e[o + a]; | ||
for (let a = 0; a < 10; a++) | ||
e[o + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10]; | ||
} | ||
e[0] ^= Se[r], e[1] ^= Oe[r]; | ||
} | ||
n.fill(0); | ||
} | ||
class C extends Ee { | ||
// NOTE: we accept arguments in bytes instead of bits here. | ||
constructor(t, n, r, s = !1, i = 24) { | ||
if (super(), this.blockLen = t, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = i, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, I(r), 0 >= this.blockLen || this.blockLen >= 200) | ||
throw new Error("Sha3 supports only keccak-f1600 function"); | ||
this.state = new Uint8Array(200), this.state32 = me(this.state); | ||
} | ||
keccak() { | ||
ke(this.state32, this.rounds), this.posOut = 0, this.pos = 0; | ||
} | ||
update(t) { | ||
$(this); | ||
const { blockLen: n, state: r } = this; | ||
t = _(t); | ||
const s = t.length; | ||
for (let i = 0; i < s; ) { | ||
const o = Math.min(n - this.pos, s - i); | ||
for (let a = 0; a < o; a++) | ||
r[this.pos++] ^= t[i++]; | ||
this.pos === n && this.keccak(); | ||
} | ||
return this; | ||
} | ||
finish() { | ||
if (this.finished) | ||
return; | ||
this.finished = !0; | ||
const { state: t, suffix: n, pos: r, blockLen: s } = this; | ||
t[r] ^= n, n & 128 && r === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak(); | ||
} | ||
writeInto(t) { | ||
$(this, !1), H(t), this.finish(); | ||
const n = this.state, { blockLen: r } = this; | ||
for (let s = 0, i = t.length; s < i; ) { | ||
this.posOut >= r && this.keccak(); | ||
const o = Math.min(r - this.posOut, i - s); | ||
t.set(n.subarray(this.posOut, this.posOut + o), s), this.posOut += o, s += o; | ||
} | ||
return t; | ||
} | ||
xofInto(t) { | ||
if (!this.enableXOF) | ||
throw new Error("XOF is not possible for this instance"); | ||
return this.writeInto(t); | ||
} | ||
xof(t) { | ||
return I(t), this.xofInto(new Uint8Array(t)); | ||
} | ||
digestInto(t) { | ||
if (de(t, this), this.finished) | ||
throw new Error("digest() was already called"); | ||
return this.writeInto(t), this.destroy(), t; | ||
} | ||
digest() { | ||
return this.digestInto(new Uint8Array(this.outputLen)); | ||
} | ||
destroy() { | ||
this.destroyed = !0, this.state.fill(0); | ||
} | ||
_cloneInto(t) { | ||
const { blockLen: n, suffix: r, outputLen: s, rounds: i, enableXOF: o } = this; | ||
return t || (t = new C(n, r, s, o, i)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = i, t.suffix = r, t.outputLen = s, t.enableXOF = o, t.destroyed = this.destroyed, t; | ||
} | ||
} | ||
const ze = (e, t, n) => Be(() => new C(t, e, n)), Le = /* @__PURE__ */ ze(1, 136, 256 / 8); | ||
function Pe(e, t) { | ||
const n = t || "hex", r = Le(w(e, { strict: !1 }) ? ue(e) : e); | ||
return n === "bytes" ? r : se(r); | ||
} | ||
class Me extends l { | ||
constructor({ address: t }) { | ||
super(`Address "${t}" is invalid.`, { | ||
metaMessages: [ | ||
"- Address must be a hex value of 20 bytes (40 hex characters).", | ||
"- Address must match its checksum counterpart." | ||
] | ||
}), Object.defineProperty(this, "name", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: "InvalidAddressError" | ||
}); | ||
} | ||
} | ||
class Ue extends Map { | ||
constructor(t) { | ||
super(), Object.defineProperty(this, "maxSize", { | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0, | ||
value: void 0 | ||
}), this.maxSize = t; | ||
} | ||
set(t, n) { | ||
return super.set(t, n), this.maxSize && this.size > this.maxSize && this.delete(this.keys().next().value), this; | ||
} | ||
} | ||
function v(e, t) { | ||
const n = t ? `${t}${e.toLowerCase()}` : e.substring(2).toLowerCase(), r = Pe(U(n), "bytes"), s = (t ? n.substring(`${t}0x`.length) : n).split(""); | ||
for (let i = 0; i < 40; i += 2) | ||
r[i >> 1] >> 4 >= 8 && s[i] && (s[i] = s[i].toUpperCase()), (r[i >> 1] & 15) >= 8 && s[i + 1] && (s[i + 1] = s[i + 1].toUpperCase()); | ||
return `0x${s.join("")}`; | ||
} | ||
function O(e, t) { | ||
if (!_e(e, { strict: !1 })) | ||
throw new Me({ address: e }); | ||
return v(e, t); | ||
} | ||
const He = /^0x[a-fA-F0-9]{40}$/, m = /* @__PURE__ */ new Ue(8192); | ||
function _e(e, t) { | ||
const { strict: n = !0 } = t ?? {}; | ||
if (m.has(e)) | ||
return m.get(e); | ||
const r = He.test(e) ? e.toLowerCase() === e ? !0 : n ? v(e) === e : !0 : !1; | ||
return m.set(e, r), r; | ||
} | ||
const x = "0x0000000000000000000000000000000000000000", Ne = (e, t) => { | ||
const n = []; | ||
return e && n.push({ $first: O(e) }), t && n.push({ $last: O(t) }), { | ||
$and: n | ||
}; | ||
}, je = (e, t) => { | ||
const n = []; | ||
if (e && (typeof e == "object" ? n.push({ $first: e }) : n.push({ $first: { $gte: BigInt(e) } })), t) { | ||
let r; | ||
if (typeof t == "object") { | ||
const [s, i] = Object.entries(t)[0]; | ||
switch (s) { | ||
case "$gte": | ||
r = { $lte: BigInt(-i) }; | ||
break; | ||
case "$lte": | ||
r = { $gte: BigInt(-i) }; | ||
break; | ||
case "$gt": | ||
r = { $lt: BigInt(-i) }; | ||
break; | ||
case "$lt": | ||
r = { $gt: BigInt(-i) }; | ||
break; | ||
} | ||
} else | ||
r = { $lte: BigInt(-t) }; | ||
r && n.push({ $last: r }); | ||
} | ||
return { | ||
$and: n | ||
}; | ||
}, Re = [ | ||
x, | ||
// ETH | ||
"0x6B175474E89094C44Da98b954EedeAC495271d0F", | ||
// DAI | ||
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", | ||
// USDC | ||
"0xdAC17F958D2ee523a2206206994597C13D831ec7", | ||
// USDT | ||
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", | ||
// WBTC | ||
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", | ||
// WETH | ||
"0x5947BB275c521040051D82396192181b413227A3", | ||
// LINK | ||
"0xc00e94Cb662C3520282E6f5717214004A7f26888", | ||
// COMP | ||
"0xba100000625a3754423978a60c9317c58a424e3D", | ||
// BAL | ||
"0x6810e776880C02933D47DB1b9fc05908e5386b96" | ||
// GNO | ||
], ve = [ | ||
x, | ||
// ETH | ||
"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", | ||
// DAI | ||
"0xFdb794692724153d1488CcdBE0C56c252596735F", | ||
// LIDO | ||
"0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6", | ||
// LINK | ||
"0x4200000000000000000000000000000000000042", | ||
// OP | ||
"0x9e1028F5F1D5eDE59748FFceE5532509976840E0", | ||
// PERP | ||
"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", | ||
// USDC | ||
"0x7F5c764cBc14f9669B88837ca1490cCa17c31607", | ||
// USDCE | ||
"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58", | ||
// USDT | ||
"0x68f180fcCe6836688e9084f035309E29Bf0A2095", | ||
// WBTC | ||
"0x4200000000000000000000000000000000000006" | ||
// WETH | ||
], Ve = [ | ||
x, | ||
// MATIC | ||
"0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3", | ||
// BAL | ||
"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", | ||
// DAI | ||
"0xC3C7d422809852031b44ab29EEC9F1EfF2A58756", | ||
// LIDO | ||
"0x831753DD7087CaC61aB5644b308642cc1c33Dc13", | ||
// QUICK | ||
"0xb33EaAd8d922B1083446DC23f610c2567fB5180f", | ||
// UNI | ||
"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", | ||
// USDCE | ||
"0xc2132D05D31c914a87C6611C10748AEb04B58e8F", | ||
// USDT | ||
"0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", | ||
// WBTC | ||
"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", | ||
// WETH | ||
"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" | ||
// WMATIC | ||
], Xe = [ | ||
x, | ||
// ETH | ||
"0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1", | ||
// BAL | ||
"0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", | ||
// cbETH | ||
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", | ||
// DAI | ||
"0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", | ||
// USDbC | ||
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", | ||
// USDC | ||
"0x4200000000000000000000000000000000000006" | ||
// WETH | ||
], Ge = [ | ||
x, | ||
// ETH | ||
"0x912CE59144191C1204E64559FE8253a0e49E6548", | ||
// ARB | ||
"0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8", | ||
// BAL | ||
"0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a", | ||
// GMX | ||
"0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60", | ||
// LIDO | ||
"0xaf88d065e77c8cC2239327C5EDb3A432268e5831", | ||
// USDC | ||
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", | ||
// USDCE | ||
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", | ||
// USDT | ||
"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", | ||
// WBTC | ||
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" | ||
// WETH | ||
], Ke = { | ||
[u.ETHEREUM]: Re, | ||
[u.OPTIMISM]: ve, | ||
[u.ARBITRUM_ONE]: Ge, | ||
[u.POLYGON_POS]: Ve, | ||
[u.BASE]: Xe | ||
}, Ye = async (e) => { | ||
const { | ||
chainId: t, | ||
contractAddress: n, | ||
tokenIn: r, | ||
tokenOut: s, | ||
amountIn: i, | ||
amountOut: o, | ||
recipient: a | ||
} = e; | ||
return G({ | ||
chainId: t, | ||
to: n ?? { | ||
$or: [Y.toLowerCase(), Q.toLowerCase()] | ||
}, | ||
input: { | ||
$abiAbstract: K, | ||
$or: [ | ||
{ | ||
// swap | ||
singleSwap: { | ||
assetIn: r, | ||
assetOut: s, | ||
amount: i | ||
}, | ||
funds: { | ||
recipient: a | ||
} | ||
}, | ||
{ | ||
// batch swap | ||
assets: Ne(r, s), | ||
limits: je(i, o), | ||
funds: { | ||
recipient: a | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
}, Qe = async (e) => Ke[e] ?? [], We = async () => W, Ze = { | ||
pluginId: "balancer", | ||
getSupportedTokenAddresses: Qe, | ||
getSupportedChainIds: We, | ||
swap: Ye, | ||
bridge: async () => new E(), | ||
mint: async () => new E() | ||
}; | ||
export { | ||
Ze as Balancer | ||
}; |
{ | ||
"name": "@rabbitholegg/questdk-plugin-balancer", | ||
"version": "1.0.0-alpha.46", | ||
"version": "1.0.0-alpha.47", | ||
"description": "", | ||
"exports": { | ||
@@ -11,25 +12,17 @@ "require": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"description": "", | ||
"types": "./dist/types/index.d.ts", | ||
"typings": "./dist/types/index.d.ts", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"types": "./dist/types/index.d.ts", | ||
"typings": "./dist/types/index.d.ts", | ||
"devDependencies": { | ||
"tsconfig": "0.1.0-alpha.1" | ||
}, | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"@rabbitholegg/questdk-plugin-utils": "1.0.0-alpha.31", | ||
"@rabbitholegg/questdk": "2.0.0-alpha.51" | ||
"@rabbitholegg/questdk-plugin-utils": "1.0.0-alpha.32", | ||
"@rabbitholegg/questdk": "2.0.0-alpha.52" | ||
}, | ||
"scripts": { | ||
"build": "vite build && tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap --declarationDir ./dist/types", | ||
"bench": "vitest bench", | ||
"bench:ci": "CI=true vitest bench", | ||
"build": "pnpm build:types && pnpm build:esm && pnpm postbuild:esm && pnpm build:cjs && pnpm postbuild:cjs && BABEL_ENV=esmBundled pnpm rollup -c", | ||
"build:esm": "BABEL_ENV=esmUnbundled babel src --extensions '.ts' --out-dir 'dist/esm' --source-maps", | ||
"build:cjs": "BABEL_ENV=cjs babel src --extensions '.ts' --out-dir 'dist/cjs' --source-maps", | ||
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap", | ||
"clean": "rimraf dist", | ||
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json", | ||
"postbuild:esm": "echo '{\"type\":\"module\"}' > dist/esm/package.json", | ||
"format": "rome format . --write", | ||
@@ -36,0 +29,0 @@ "lint": "eslint .", |
{ | ||
"extends": "tsconfig/base.json", | ||
"extends": "../../tsconfig.json", | ||
"include": ["src"], | ||
@@ -13,5 +13,4 @@ "exclude": [ | ||
"sourceMap": true, | ||
"rootDir": "./src", | ||
"rootDir": "./src" | ||
} | ||
} |
{ | ||
"extends": "tsconfig/base.json", | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*", "src/chain-data.ts"], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
0
1
310041
48
2425
3
1
+ Added@rabbitholegg/questdk@2.0.0-alpha.52(transitive)
+ Added@rabbitholegg/questdk-plugin-utils@1.0.0-alpha.32(transitive)
- Removed@rabbitholegg/questdk@2.0.0-alpha.51(transitive)
- Removed@rabbitholegg/questdk-plugin-utils@1.0.0-alpha.31(transitive)
- Removedtslib@2.3.1(transitive)