@@ -27,6 +33,10 @@ export default defineComponent({
type: Array,
default: () => [],
},
+ itemsWrapperClasses: {
+ type: String,
+ default: ''
+ },
divided: {
type: Boolean,
default: false,
diff --git a/components/common/menu/Menu.vue b/components/common/menu/Menu.vue
index 1b74af4..67a64f1 100644
--- a/components/common/menu/Menu.vue
+++ b/components/common/menu/Menu.vue
@@ -14,7 +14,7 @@
diff --git a/components/swap/SwapCard.vue b/components/swap/SwapCard.vue
new file mode 100644
index 0000000..bbf5398
--- /dev/null
+++ b/components/swap/SwapCard.vue
@@ -0,0 +1,496 @@
+
+
+
Swap
+
+
+
+
token0Input.focus()">
+
+ {{
+ token0.symbol
+ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.symbol }}
+
+
+
+
+
+
+
+
+
+
+
~ {{ formatUsd(token0.amountUSD) }}
+
+
+ Balance: {{ formatDecimal(token0.balance) }} {{ token0.symbol }}
+
+
+
+
+
+
+
+
+
+
+ {{
+ token1.symbol
+ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.symbol }}
+
+
+
+
+
+
+
+
+
+
+
+ ~ {{ formatUsd(token1.amountUSD) }}
+ ({{ formatPercent(slippagePerc) }})
+
+
+
+ Balance: {{ formatDecimal(token1.balance) }} {{ token1.symbol }}
+
+
+
+
+
+
+
+
+
+
+
+ 1 {{ token1.symbol }} =
+ {{ formatDecimal(token0.amount / token1.amount, 7) }}
+ {{ token0.symbol }}
+
+
+
+
+ Slippage tolerance
+
+
+
+
+
+
+
+
+
+
+ 0.1%
+ 0.5%
+ 1%
+ 3%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Swap
+
+
+
+
+
diff --git a/composables/swap/use1InchSwap.ts b/composables/swap/use1InchSwap.ts
new file mode 100644
index 0000000..43a9846
--- /dev/null
+++ b/composables/swap/use1InchSwap.ts
@@ -0,0 +1,60 @@
+import { useBigNumber } from "../useBigNumber";
+import { useDSA } from "../useDSA";
+import { useFormatting } from "../useFormatting";
+import { useMath } from "../useMath";
+import { Network, useNetwork } from "../useNetwork";
+
+export const use1InchSwap = () => {
+ const { divWithDec } = useMath();
+ const { activeNetworkId } = useNetwork();
+ const { dsa, activeAccount } = useDSA();
+ const { isZero, ensureValue, gt, minus, times, plus, toBN } = useBigNumber();
+ const { formatPercent, getFractionDigits } = useFormatting();
+
+ /**
+ * @dev Get different sell spell, based on simulation mode on/offand account network .
+ * Shared params:
+ * @param {string} params.buyAddr - buying token address.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
+ * @param {string} params.sellAddr - selling token amount.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
+ * @param {number} params.sellAmt - selling token amount.
+ * @param {number} params.unitAmt - unit amount of buyAmt/sellAmt with slippage.
+ * @param {number} params.setId - set token amount at this ID in `InstaMemory` Contract.
+ *
+ * 1Inch related params:
+ * @param {string} params.calldata - data from 1inch API.
+ *
+ * 1Split related params(using in simulation mode):
+ * @param {number[]} params.distribution - distribution of swap across different dex.
+ * @param {number} params.disableDexes - disable a dex. (To disable none: 0)
+ * @param {number} params.getId - get token amount at this ID from `InstaMemory` Contract.
+ */
+ function getSellSpell({
+ buyAddr,
+ sellAddr,
+ sellAmt,
+ unitAmt,
+ calldata,
+ setId
+ }) {
+ if (
+ activeNetworkId.value === Network.Polygon ||
+ activeAccount.value.version == 2
+ ) {
+ return {
+ connector: "1INCH-A",
+ method: "sell",
+ args: [buyAddr, sellAddr, sellAmt, unitAmt, calldata, setId]
+ };
+ }
+
+ return {
+ connector: "oneInch",
+ method: "sellThree",
+ args: [buyAddr, sellAddr, sellAmt, unitAmt, calldata, setId]
+ };
+ }
+
+ return {
+ getSellSpell
+ };
+};
diff --git a/composables/useMath.ts b/composables/useMath.ts
new file mode 100644
index 0000000..09a9c08
--- /dev/null
+++ b/composables/useMath.ts
@@ -0,0 +1,66 @@
+import { useBigNumber } from './useBigNumber'
+
+const { pow, div, toBN, lt, isZero } = useBigNumber()
+
+export function useMath() {
+ // Convert bigNumber in string (use to save us from big number error on web3)
+ // TODO - start using big number library for it?
+ function bigNumInString(x) {
+ if (Math.abs(x) < 1.0) {
+ const e = parseInt(x.toString().split('e-')[1])
+ if (e) {
+ x *= Math.pow(10, e - 1)
+ x = '0.' + new Array(e).join('0') + x.toString().substring(2)
+ }
+ } else {
+ let e = parseInt(x.toString().split('+')[1])
+ if (e > 20) {
+ e -= 20
+ x /= Math.pow(10, e)
+ x += new Array(e + 1).join('0')
+ }
+ }
+ return x
+ }
+
+ // Use to convert large decimal into small. Eg:- number 321.242312 with power 3 = 321.242
+ function cleanDecimal(num, power) {
+ let MUL_DIV = 100
+ if (power || power === 0) {
+ MUL_DIV = 10 ** power
+ } else {
+ if (num < 0.01) MUL_DIV = 10 ** 6
+ if (num < 1) MUL_DIV = 10 ** 4
+ }
+ return Math.floor(Number(num) * MUL_DIV) / MUL_DIV
+ }
+
+ function roundDecimals(value) {
+ if (isZero(value)) return 0.0
+ if (lt(value, '0.001')) return cleanDecimal(toBN(value).toNumber(), 6)
+ if (lt(value, '0.01')) return cleanDecimal(toBN(value).toNumber(), 5)
+ if (lt(value, '0.1')) return cleanDecimal(toBN(value).toNumber(), 4)
+ if (lt(value, '1')) return cleanDecimal(toBN(value).toNumber(), 3)
+ return cleanDecimal(toBN(value).toNumber(), 3)
+ }
+
+ function divWithDec(num, power) {
+ power = typeof power !== 'undefined' ? power : 0
+ const divider = pow('10', power)
+ return div(num, divider).toFixed()
+ }
+
+ /**
+ * Checks divisor for 0. Returns 0 instead of NaN.
+ *
+ * @param {number} divident Divident.
+ * @param {number} divisor Divisor.
+ */
+ function safeDivide(divident, divisor) {
+ if (!divisor) return 0
+
+ return divident / divisor
+ }
+
+ return { bigNumInString, divWithDec, cleanDecimal, safeDivide, roundDecimals }
+}
diff --git a/ecosystem.config.js b/ecosystem.config.js
new file mode 100644
index 0000000..5ed647c
--- /dev/null
+++ b/ecosystem.config.js
@@ -0,0 +1,21 @@
+module.exports = {
+ apps: [
+ {
+ name: 'assembly',
+ exec_mode: 'cluster',
+ instances: 'max',
+ script: './node_modules/nuxt/bin/nuxt.js',
+ args: 'start',
+ env: {
+ NODE_ENV: 'production',
+ HOST: 'localhost',
+ PORT: 4000,
+ },
+ env_production: {
+ NODE_ENV: 'production',
+ PORT: '4000',
+ HOST: 'localhost'
+ },
+ },
+ ],
+}
diff --git a/package.json b/package.json
index 23b0e95..8c6631a 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"v-tooltip": "^2.1.3",
"vue-clipboard2": "^0.3.1",
"vue-composable": "^1.0.0-beta.23",
+ "waait": "^1.0.5",
"walletlink": "^2.1.6",
"web3": "^1.4.0",
"web3modal": "^1.9.3"
diff --git a/pages/1inch.vue b/pages/1inch.vue
new file mode 100644
index 0000000..387cf0e
--- /dev/null
+++ b/pages/1inch.vue
@@ -0,0 +1,189 @@
+
+
+
+
+
+ Apps
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/index.vue b/pages/index.vue
index 1069ee5..ff0288c 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -35,6 +35,7 @@ import { useNetwork } from "~/composables/useNetwork";
import AaveIcon from "~/assets/icons/aave.svg?inline";
import CompoundIcon from "~/assets/icons/compound.svg?inline";
import MakerIcon from "~/assets/icons/makerdao.svg?inline";
+import OneInchIcon from "~/assets/icons/1inch.svg?inline";
const appsPerNetwork = {
mainnet: [
@@ -58,6 +59,13 @@ const appsPerNetwork = {
name: "MakerDAO",
url: "/mainnet/maker",
description: "Collateralized Debt"
+ },
+ {
+ id: "1inch",
+ icon: OneInchIcon,
+ name: "1inch",
+ url: "/1inch",
+ description: "DEX Aggregator"
}
],
polygon: [
@@ -67,6 +75,13 @@ const appsPerNetwork = {
name: "Aave v2",
url: "/polygon/aave-v2",
description: "Lend and borrow straight from your Gnosis Safe"
+ },
+ {
+ id: "1inch",
+ icon: OneInchIcon,
+ name: "1inch",
+ url: "/1inch",
+ description: "DEX Aggregator"
}
]
};
diff --git a/yarn.lock b/yarn.lock
index 87924f9..b5275a2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11642,6 +11642,11 @@ vuex@^3.6.2:
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.6.2.tgz#236bc086a870c3ae79946f107f16de59d5895e71"
integrity sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw==
+waait@^1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/waait/-/waait-1.0.5.tgz#6a3c7aaa88bd0a1a545e9d47890b9595bebf9aa7"
+ integrity sha512-wp+unA4CpqxvBUKHHv8D86fK4jWByHAWyhEXXVHfVUZfK+16ylpj7hjQ58Z8j9ntu8XNukRQT8Fi5qbyJ8rkyw==
+
walletlink@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/walletlink/-/walletlink-2.1.6.tgz#4e48310af09bb0c940a156c26c1d0b1b9506ddb9"