@instadapp/avocado-base 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +64 -65
- package/abi/avoFactoryProxy.json +1 -1
- package/abi/forwarder.json +1 -1
- package/abi/multisigAgnosticForwarder.json +936 -937
- package/abi/multisigForwarder.json +680 -680
- package/app.vue +5 -5
- package/components/ActionLogo.vue +15 -15
- package/components/AuthorityAvatar.vue +8 -6
- package/components/ChainLogo.vue +19 -15
- package/components/CopyClipboard.vue +1 -1
- package/components/metadata/Bridge.vue +22 -23
- package/components/metadata/GasTopup.vue +14 -15
- package/components/metadata/Permit2.vue +12 -13
- package/eslint.config.mjs +14 -0
- package/nuxt.config.ts +4 -0
- package/package.json +6 -6
- package/server/utils/index.ts +4 -4
- package/utils/avocado.ts +17 -17
- package/utils/bignumber.ts +47 -36
- package/utils/formatter.ts +54 -60
- package/utils/helper.ts +33 -30
- package/utils/metadata.ts +366 -403
- package/utils/network.ts +40 -2
- package/utils/services.ts +11 -13
- package/utils/utils.d.ts +1 -0
package/app.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="container mx-auto">
|
|
3
3
|
Networks:
|
|
4
4
|
<ul class="grid grid-cols-5 gap-5">
|
|
5
|
-
<li
|
|
5
|
+
<li v-for="network in networks" :key="network.chainId" class="w-fit">
|
|
6
6
|
<p>
|
|
7
7
|
{{ network.name }}
|
|
8
8
|
</p>
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
</ul>
|
|
18
18
|
|
|
19
19
|
<ul class="grid grid-cols-5 gap-5 mt-20">
|
|
20
|
-
<li v-for="item in MetadataEnums">
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<li v-for="item in MetadataEnums" :key="item">
|
|
21
|
+
{{ item }}
|
|
22
|
+
<ActionLogo class="w-10 h-10" :action="item" />
|
|
23
23
|
</li>
|
|
24
24
|
</ul>
|
|
25
25
|
</div>
|
|
26
|
-
<ul
|
|
26
|
+
<ul />
|
|
27
27
|
</template>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import RefreshSVG from '../assets/images/icons/refresh.svg'
|
|
3
2
|
import BridgeSVG from '../assets/images/icons/bridge.svg'
|
|
4
|
-
import CrossTransferSVG from '../assets/images/icons/cross-transfer.svg'
|
|
5
|
-
import TransferSVG from '../assets/images/icons/transfer.svg'
|
|
6
|
-
import PlusCircleSVG from '../assets/images/icons/plus-circle.svg'
|
|
7
|
-
import StarsSVG from '../assets/images/icons/stars.svg'
|
|
8
|
-
import Trash2SVG from '../assets/images/icons/trash-2.svg'
|
|
9
3
|
import ChangeThresholdSVG from '../assets/images/icons/change-threshold.svg'
|
|
4
|
+
import CrossTransferSVG from '../assets/images/icons/cross-transfer.svg'
|
|
10
5
|
import DappSVG from '../assets/images/icons/dapp.svg'
|
|
11
6
|
import DeploySVG from '../assets/images/icons/deploy.svg'
|
|
12
7
|
import GasSVG from '../assets/images/icons/gas.svg'
|
|
8
|
+
import HammerSVG from '../assets/images/icons/hammer.svg'
|
|
13
9
|
import InstadappProSVG from '../assets/images/icons/instadapp-pro.svg'
|
|
14
10
|
import PermitSignSVG from '../assets/images/icons/permit-sign.svg'
|
|
11
|
+
import PlusCircleSVG from '../assets/images/icons/plus-circle.svg'
|
|
12
|
+
import RefreshSVG from '../assets/images/icons/refresh.svg'
|
|
15
13
|
import RejectProposalSVG from '../assets/images/icons/reject-proposal.svg'
|
|
14
|
+
import StarsSVG from '../assets/images/icons/stars.svg'
|
|
15
|
+
import TransferSVG from '../assets/images/icons/transfer.svg'
|
|
16
|
+
import Trash2SVG from '../assets/images/icons/trash-2.svg'
|
|
16
17
|
import UpgradeSVG from '../assets/images/icons/upgrade.svg'
|
|
17
|
-
import HammerSVG from '../assets/images/icons/hammer.svg'
|
|
18
18
|
|
|
19
19
|
defineProps<{
|
|
20
20
|
action: MetadataTypes
|
|
@@ -23,13 +23,13 @@ defineProps<{
|
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
25
|
<template>
|
|
26
|
-
<RefreshSVG
|
|
27
|
-
<BridgeSVG
|
|
28
|
-
<CrossTransferSVG
|
|
29
|
-
<TransferSVG
|
|
30
|
-
<PlusCircleSVG
|
|
31
|
-
<Trash2SVG
|
|
32
|
-
<RejectProposalSVG
|
|
26
|
+
<RefreshSVG v-if="action === 'swap'" class="text-primary" />
|
|
27
|
+
<BridgeSVG v-else-if="action === 'bridge'" class="text-primary" />
|
|
28
|
+
<CrossTransferSVG v-else-if="action === 'cross-transfer'" class="text-primary" />
|
|
29
|
+
<TransferSVG v-else-if="action === 'transfer'" class="text-primary" />
|
|
30
|
+
<PlusCircleSVG v-else-if="action === 'add-signers' || (action === 'auth' && !remove)" class="text-primary" />
|
|
31
|
+
<Trash2SVG v-else-if="action === 'remove-signers' || (action === 'auth' && remove)" class="text-[#EB5757]" />
|
|
32
|
+
<RejectProposalSVG v-else-if="action === 'rejection'" class="text-[#EB5757]" />
|
|
33
33
|
<ChangeThresholdSVG v-else-if="action === 'change-threshold'" />
|
|
34
34
|
<DappSVG v-else-if="action === 'dapp'" />
|
|
35
35
|
<DeploySVG v-else-if="action === 'deploy'" />
|
|
@@ -39,4 +39,4 @@ defineProps<{
|
|
|
39
39
|
<UpgradeSVG v-else-if="action === 'upgrade'" />
|
|
40
40
|
<HammerSVG v-else-if="action === 'tx-builder'" />
|
|
41
41
|
<StarsSVG v-else-if="action === 'mass'" />
|
|
42
|
-
</template>
|
|
42
|
+
</template>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
// @ts-expect-error
|
|
3
|
-
import * as XXH from 'xxhashjs'
|
|
3
|
+
import * as XXH from 'xxhashjs'
|
|
4
4
|
|
|
5
5
|
defineProps<{
|
|
6
6
|
address: string
|
|
7
|
-
}>()
|
|
7
|
+
}>()
|
|
8
8
|
|
|
9
|
-
const randomId = Math.random().toString(36).substr(2, 9)
|
|
9
|
+
const randomId = Math.random().toString(36).substr(2, 9)
|
|
10
10
|
|
|
11
11
|
function generateColor(address: string): string {
|
|
12
12
|
const hash = XXH.h32(address, 0xABCD).toNumber()
|
|
@@ -20,9 +20,11 @@ function generateColor(address: string): string {
|
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<template>
|
|
23
|
-
<svg
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
<svg
|
|
24
|
+
:style="{
|
|
25
|
+
color: generateColor(address),
|
|
26
|
+
}" width="30" height="30" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 30 30"
|
|
27
|
+
>
|
|
26
28
|
<g fill="currentColor" :clip-path="`url(#${randomId})`">
|
|
27
29
|
<rect width="30" height="30" fill-opacity=".4" rx="15" />
|
|
28
30
|
<ellipse cx="15.004" cy="26.399" rx="11.4" ry="6.6" />
|
package/components/ChainLogo.vue
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
chain?: ChainId | number | string
|
|
4
|
+
stroke?: boolean
|
|
5
|
+
}>()
|
|
6
|
+
|
|
7
|
+
const isNetworkNotAvailable = computed(() => !networks.some(network => String(network.chainId) === String(props.chain)))
|
|
8
|
+
</script>
|
|
9
|
+
|
|
1
10
|
<template>
|
|
2
11
|
<svg v-if="isNetworkNotAvailable" v-bind="$attrs" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
|
|
3
12
|
<rect width="20" height="20" fill="#334155" rx="10" />
|
|
4
|
-
<path
|
|
13
|
+
<path
|
|
14
|
+
fill="#97A2B7" fill-rule="evenodd"
|
|
5
15
|
d="M10 3.999A6 6 0 1 0 10 16a6 6 0 0 0 0-12.001Zm0 10.8a4.8 4.8 0 1 1 0-9.6 4.8 4.8 0 0 1 0 9.6ZM6.399 9.67A3.6 3.6 0 0 1 9.68 6.4a.3.3 0 0 1 .318.318v.6a.294.294 0 0 1-.264.282A2.4 2.4 0 0 0 7.6 9.735a.294.294 0 0 1-.3.264h-.6a.312.312 0 0 1-.222-.096.336.336 0 0 1-.078-.234Z"
|
|
6
|
-
clip-rule="evenodd"
|
|
16
|
+
clip-rule="evenodd"
|
|
17
|
+
/>
|
|
7
18
|
</svg>
|
|
8
|
-
<span
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
<span
|
|
20
|
+
v-else-if="stroke"
|
|
21
|
+
class="outline stroke-color outline-[#161E2D] outline-2 shrink-0 outline outline-offset-[-1.5px] rounded-full"
|
|
22
|
+
>
|
|
23
|
+
<img class="w-full h-full" :src="`https://cdn.instadapp.io/avocado/networks/${chain}.svg`">
|
|
11
24
|
</span>
|
|
12
|
-
<img v-else :src="`https://cdn.instadapp.io/avocado/networks/${chain}.svg`"
|
|
25
|
+
<img v-else :src="`https://cdn.instadapp.io/avocado/networks/${chain}.svg`">
|
|
13
26
|
</template>
|
|
14
|
-
|
|
15
|
-
<script lang="ts" setup>
|
|
16
|
-
const props = defineProps<{
|
|
17
|
-
chain?: ChainId | number | string;
|
|
18
|
-
stroke?: boolean;
|
|
19
|
-
}>();
|
|
20
|
-
|
|
21
|
-
const isNetworkNotAvailable = computed(() => !networks.some((network) => String(network.chainId) === String(props.chain)))
|
|
22
|
-
</script>
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
2
|
const props = defineProps<{
|
|
4
|
-
metadata: any
|
|
3
|
+
metadata: any
|
|
5
4
|
chain_id: number | string
|
|
6
|
-
}>()
|
|
5
|
+
}>()
|
|
7
6
|
|
|
8
|
-
const compact = inject('compact')
|
|
9
|
-
const tokens = inject<ITokenPrice[]>('tokens')
|
|
7
|
+
const compact = inject('compact')
|
|
8
|
+
const tokens = inject<ITokenPrice[]>('tokens')
|
|
10
9
|
|
|
11
|
-
const toToken = asyncComputed(() =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
10
|
+
const toToken = asyncComputed(() => {
|
|
11
|
+
if (Array.isArray(tokens) && !tokens.length)
|
|
12
|
+
return null
|
|
13
|
+
return fetchTokenByAddress(props.metadata?.toToken, props.metadata?.toChainId, tokens)
|
|
14
|
+
},
|
|
15
|
+
)
|
|
17
16
|
|
|
18
|
-
const fromToken = asyncComputed(() =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
17
|
+
const fromToken = asyncComputed(() => {
|
|
18
|
+
if (Array.isArray(tokens) && !tokens.length)
|
|
19
|
+
return null
|
|
20
|
+
return fetchTokenByAddress(props.metadata?.fromToken, props.chain_id, tokens)
|
|
21
|
+
},
|
|
22
|
+
)
|
|
24
23
|
|
|
25
24
|
const isTokensSame = computed(() => {
|
|
26
25
|
return toToken.value?.symbol === fromToken.value?.symbol
|
|
@@ -28,25 +27,25 @@ const isTokensSame = computed(() => {
|
|
|
28
27
|
|
|
29
28
|
const bridgeAmountFormatted = computed(() =>
|
|
30
29
|
formatDecimal(
|
|
31
|
-
fromWei(props.metadata?.amount, fromToken?.value?.decimals).toFixed()
|
|
32
|
-
)
|
|
33
|
-
)
|
|
30
|
+
fromWei(props.metadata?.amount, fromToken?.value?.decimals).toFixed(),
|
|
31
|
+
),
|
|
32
|
+
)
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
35
|
<template>
|
|
37
36
|
<div v-if="!toToken || !fromToken" class="rounded-5 w-24 h-4 loading-box" />
|
|
38
37
|
<div
|
|
39
|
-
class="flex gap-5 items-center"
|
|
40
38
|
v-if="toToken && fromToken"
|
|
39
|
+
class="flex gap-5 items-center"
|
|
41
40
|
>
|
|
42
41
|
<span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
43
42
|
<span class="inline-flex gap-2.5 items-center">
|
|
44
|
-
<img width="20" height="20" class="w-5 h-5" :src="fromToken.logo_url"
|
|
43
|
+
<img width="20" height="20" class="w-5 h-5" :src="fromToken.logo_url">
|
|
45
44
|
{{ bridgeAmountFormatted }}
|
|
46
45
|
<span class="uppercase">{{ fromToken?.symbol }}</span>
|
|
47
46
|
<SvgoBridge class="text-slate-400 w-4 h-4" />
|
|
48
47
|
<template v-if="!isTokensSame">
|
|
49
|
-
<img width="20" height="20" class="w-5 h-5" :src="toToken.logo_url"
|
|
48
|
+
<img width="20" height="20" class="w-5 h-5" :src="toToken.logo_url">
|
|
50
49
|
<span class="uppercase">{{ toToken?.symbol }}</span>
|
|
51
50
|
</template>
|
|
52
51
|
<span class="flex items-center gap-2.5">
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
2
|
const props = defineProps<{
|
|
4
|
-
metadata: any
|
|
3
|
+
metadata: any
|
|
5
4
|
chain_id: number | string
|
|
6
|
-
}>()
|
|
5
|
+
}>()
|
|
7
6
|
|
|
8
|
-
const tokens = inject<ITokenPrice[]>('tokens')
|
|
7
|
+
const tokens = inject<ITokenPrice[]>('tokens')
|
|
9
8
|
|
|
10
|
-
const token = asyncComputed(() =>
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const token = asyncComputed(() => {
|
|
10
|
+
if (Array.isArray(tokens) && !tokens.length)
|
|
11
|
+
return null
|
|
13
12
|
|
|
14
13
|
return fetchTokenByAddress(props.metadata?.token, props?.chain_id, tokens)
|
|
15
|
-
|
|
16
|
-
)
|
|
14
|
+
},
|
|
15
|
+
)
|
|
17
16
|
|
|
18
|
-
const compact = inject('compact')
|
|
17
|
+
const compact = inject('compact')
|
|
19
18
|
|
|
20
19
|
const formattedAmount = computed(() =>
|
|
21
20
|
formatDecimal(
|
|
22
|
-
fromWei(props.metadata?.amount, token?.value?.decimals).toFixed()
|
|
23
|
-
)
|
|
24
|
-
)
|
|
21
|
+
fromWei(props.metadata?.amount, token?.value?.decimals).toFixed(),
|
|
22
|
+
),
|
|
23
|
+
)
|
|
25
24
|
</script>
|
|
26
25
|
|
|
27
26
|
<template>
|
|
28
27
|
<div v-if="!token" class="rounded-5 w-24 h-4 loading-box" />
|
|
29
|
-
<div class="flex items-center gap-5"
|
|
28
|
+
<div v-else class="flex items-center gap-5">
|
|
30
29
|
<span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
31
30
|
<span class="inline-flex gap-2.5 items-center">
|
|
32
|
-
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url"
|
|
31
|
+
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url">
|
|
33
32
|
{{ formattedAmount }}
|
|
34
33
|
<span class="uppercase">{{ token?.symbol }}</span>
|
|
35
34
|
<SvgoGas class="w-4 h-4 text-slate-400 mx-2" />
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
2
|
const props = defineProps<{
|
|
4
|
-
metadata: any
|
|
3
|
+
metadata: any
|
|
5
4
|
chain_id: number | string
|
|
6
|
-
}>()
|
|
5
|
+
}>()
|
|
7
6
|
|
|
8
|
-
const tokens = inject<ITokenPrice[]>('tokens')
|
|
7
|
+
const tokens = inject<ITokenPrice[]>('tokens')
|
|
9
8
|
|
|
10
|
-
const token = asyncComputed(() =>
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const token = asyncComputed(() => {
|
|
10
|
+
if (Array.isArray(tokens) && !tokens.length)
|
|
11
|
+
return null
|
|
13
12
|
return fetchTokenByAddress(props.metadata?.token, props?.chain_id, tokens)
|
|
14
|
-
}
|
|
15
|
-
)
|
|
13
|
+
},
|
|
14
|
+
)
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
return new Date(timestamp * 1000).toLocaleString()
|
|
19
|
-
}
|
|
16
|
+
function calculateDate(timestamp: number) {
|
|
17
|
+
return new Date(timestamp * 1000).toLocaleString()
|
|
18
|
+
}
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
21
|
<template>
|
|
23
22
|
<div v-if="!token" class="rounded-5 w-24 h-4 loading-box" />
|
|
24
23
|
<div v-else class="inline-flex items-center gap-2 flex-wrap">
|
|
25
24
|
<span>Permit2 Allowance: </span>
|
|
26
|
-
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url"
|
|
25
|
+
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url">
|
|
27
26
|
<span class="capitalize">{{ token?.symbol }}</span>
|
|
28
27
|
to
|
|
29
28
|
<NuxtLink
|
package/eslint.config.mjs
CHANGED
|
@@ -4,6 +4,20 @@ import withNuxt from './.nuxt/eslint.config.mjs'
|
|
|
4
4
|
|
|
5
5
|
export default withNuxt(
|
|
6
6
|
antfu({
|
|
7
|
+
ignores: [
|
|
8
|
+
'*.png',
|
|
9
|
+
'*.ico',
|
|
10
|
+
'*.toml',
|
|
11
|
+
'*.yml',
|
|
12
|
+
'.github/',
|
|
13
|
+
'deployments/',
|
|
14
|
+
'*.patch',
|
|
15
|
+
'*.txt',
|
|
16
|
+
'Dockerfile',
|
|
17
|
+
'public/',
|
|
18
|
+
'contracts/',
|
|
19
|
+
'yarn.lock',
|
|
20
|
+
],
|
|
7
21
|
yaml: false,
|
|
8
22
|
rules: {
|
|
9
23
|
'style/max-statements-per-line': 'off',
|
package/nuxt.config.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
export default defineNuxtConfig({
|
|
5
5
|
modules: ['@nuxtjs/tailwindcss', 'nuxt-svgo', '@vueuse/nuxt', '@nuxt/eslint'],
|
|
6
|
+
|
|
6
7
|
svgo: {
|
|
7
8
|
defaultImport: 'component',
|
|
8
9
|
autoImportPath: './assets/images/icons',
|
|
@@ -10,6 +11,7 @@ export default defineNuxtConfig({
|
|
|
10
11
|
plugins: ['prefixIds'],
|
|
11
12
|
},
|
|
12
13
|
},
|
|
14
|
+
|
|
13
15
|
// vite: {
|
|
14
16
|
// plugins: [
|
|
15
17
|
// ViteComponents({
|
|
@@ -22,4 +24,6 @@ export default defineNuxtConfig({
|
|
|
22
24
|
standalone: false,
|
|
23
25
|
},
|
|
24
26
|
},
|
|
27
|
+
|
|
28
|
+
compatibilityDate: '2024-09-18',
|
|
25
29
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instadapp/avocado-base",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"types": "global.d.ts",
|
|
7
7
|
"engines": {
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"typecheck": "nuxi typecheck"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@antfu/eslint-config": "^
|
|
18
|
+
"@antfu/eslint-config": "^3.6.2",
|
|
19
19
|
"@vueuse/nuxt": "^10.2.0",
|
|
20
20
|
"bignumber.js": "^9.1.1",
|
|
21
21
|
"ethers": "^5.7.2",
|
|
22
|
-
"viem": "^2.
|
|
22
|
+
"viem": "^2.21.54",
|
|
23
23
|
"xxhashjs": "^0.2.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@nuxt/eslint": "^0.5.
|
|
26
|
+
"@nuxt/eslint": "^0.5.7",
|
|
27
27
|
"@nuxtjs/tailwindcss": "^6.12.1",
|
|
28
|
-
"nuxt": "3.13.
|
|
29
|
-
"nuxt-svgo": "^4.0.
|
|
28
|
+
"nuxt": "3.13.2",
|
|
29
|
+
"nuxt-svgo": "^4.0.6",
|
|
30
30
|
"vue-tippy": "^6.0.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/server/utils/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from '../../utils/avocado'
|
|
2
|
+
export * from '../../utils/bignumber'
|
|
3
|
+
export * from '../../utils/formatter'
|
|
4
|
+
export * from '../../utils/network'
|
package/utils/avocado.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export const AVO_PROD_CHAIN_ID = 634
|
|
2
|
-
export const AVO_PROD_CHAIN_NAME =
|
|
1
|
+
export const AVO_PROD_CHAIN_ID = 634
|
|
2
|
+
export const AVO_PROD_CHAIN_NAME = 'Avocado'
|
|
3
3
|
|
|
4
|
-
export const AVO_STAGING_CHAIN_ID = 63400
|
|
5
|
-
export const AVO_STAGING_CHAIN_NAME =
|
|
4
|
+
export const AVO_STAGING_CHAIN_ID = 63400
|
|
5
|
+
export const AVO_STAGING_CHAIN_NAME = 'Avocado Testnet'
|
|
6
6
|
|
|
7
|
-
export const AVO_PROD_EXPLORER_URL =
|
|
8
|
-
export const AVO_STAGING_EXPLORER_URL =
|
|
7
|
+
export const AVO_PROD_EXPLORER_URL = 'https://avoscan.co'
|
|
8
|
+
export const AVO_STAGING_EXPLORER_URL = 'https://explorer.avocado.instad.app'
|
|
9
9
|
|
|
10
|
-
export const AVO_PROD_FORWARDER_ADDR
|
|
11
|
-
|
|
12
|
-
export const AVO_STAGING_FORWARDER_ADDR
|
|
13
|
-
|
|
10
|
+
export const AVO_PROD_FORWARDER_ADDR
|
|
11
|
+
= '0x375F6B0CD12b34Dc28e34C26853a37012C24dDE5'
|
|
12
|
+
export const AVO_STAGING_FORWARDER_ADDR
|
|
13
|
+
= '0x8CDaAC0371a443985c6Faf07938dDAa7A5818674'
|
|
14
14
|
|
|
15
|
-
export const AVO_PROD_DEPOSIT_ADDRESS
|
|
16
|
-
|
|
17
|
-
export const AVO_STAGING_DEPOSIT_ADDRESS
|
|
18
|
-
|
|
15
|
+
export const AVO_PROD_DEPOSIT_ADDRESS
|
|
16
|
+
= '0xE8385fB3A5F15dED06EB5E20E5A81BF43115eb8E'
|
|
17
|
+
export const AVO_STAGING_DEPOSIT_ADDRESS
|
|
18
|
+
= '0x853e991d800Dfd6bC1F83AED3310e859482323dc'
|
|
19
19
|
|
|
20
|
-
export const AVO_PROD_RPC_URL =
|
|
20
|
+
export const AVO_PROD_RPC_URL = 'https://rpc.avocado.instadapp.io'
|
|
21
21
|
|
|
22
|
-
export const AVO_STAGING_RPC_URL =
|
|
22
|
+
export const AVO_STAGING_RPC_URL = 'https://rpc.avocado.instad.app'
|
|
23
23
|
|
|
24
|
-
export const blockQueryURL =
|
|
24
|
+
export const blockQueryURL = 'https://blockquery.instadapp.io'
|
package/utils/bignumber.ts
CHANGED
|
@@ -1,51 +1,62 @@
|
|
|
1
|
-
import { BigNumber } from
|
|
2
|
-
import { BigNumber as BN } from
|
|
1
|
+
import { BigNumber } from 'bignumber.js'
|
|
2
|
+
import { BigNumber as BN } from 'ethers'
|
|
3
3
|
|
|
4
|
-
type CombinedBigNumber = BigNumber | string | number
|
|
4
|
+
type CombinedBigNumber = BigNumber | string | number
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
new BigNumber(BN.isBigNumber(value) ? value.toString() : value)
|
|
8
|
-
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
toBN(a).
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
toBN(a).
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
export function toBN(value: BigNumber.Value | BN) {
|
|
7
|
+
return new BigNumber(BN.isBigNumber(value) ? value.toString() : value)
|
|
8
|
+
}
|
|
9
|
+
export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero()
|
|
10
|
+
export function times(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
11
|
+
return toBN(a).times(toBN(b))
|
|
12
|
+
}
|
|
13
|
+
export function minus(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
14
|
+
return toBN(a).minus(toBN(b))
|
|
15
|
+
}
|
|
16
|
+
export function plus(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
17
|
+
return toBN(a).plus(toBN(b))
|
|
18
|
+
}
|
|
19
|
+
export function lte(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
20
|
+
return toBN(a).lte(toBN(b))
|
|
21
|
+
}
|
|
22
|
+
export function gte(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
23
|
+
return toBN(a).gte(toBN(b))
|
|
24
|
+
}
|
|
25
|
+
export function div(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
26
|
+
return toBN(a).div(toBN(b))
|
|
27
|
+
}
|
|
28
|
+
export function lt(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
29
|
+
return toBN(a).lt(toBN(b))
|
|
30
|
+
}
|
|
31
|
+
export function gt(a: BigNumber.Value | BN, b: BigNumber.Value | BN) {
|
|
32
|
+
return toBN(a).gt(toBN(b))
|
|
33
|
+
}
|
|
34
|
+
export function ensureValue(value: any) {
|
|
35
|
+
if (!value)
|
|
36
|
+
return toBN('0')
|
|
37
|
+
if (toBN(value).isNaN())
|
|
38
|
+
return toBN('0')
|
|
28
39
|
|
|
29
|
-
return toBN(value)
|
|
30
|
-
}
|
|
31
|
-
export
|
|
32
|
-
return BigNumber.max(...args)
|
|
33
|
-
}
|
|
40
|
+
return toBN(value)
|
|
41
|
+
}
|
|
42
|
+
export function max(...args: BigNumber.Value[]) {
|
|
43
|
+
return BigNumber.max(...args)
|
|
44
|
+
}
|
|
34
45
|
|
|
35
46
|
export function pow(value: CombinedBigNumber, exponent: string | number) {
|
|
36
|
-
return toBN(value).pow(toBN(exponent))
|
|
47
|
+
return toBN(value).pow(toBN(exponent))
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
export function toWei(val: CombinedBigNumber, decimals: number): string {
|
|
40
|
-
const num = toBN(val)
|
|
41
|
-
const multiplier = pow(10, decimals)
|
|
42
|
-
return times(num, multiplier).toFixed(0)
|
|
51
|
+
const num = toBN(val)
|
|
52
|
+
const multiplier = pow(10, decimals)
|
|
53
|
+
return times(num, multiplier).toFixed(0)
|
|
43
54
|
}
|
|
44
55
|
|
|
45
56
|
export function fromWei(val: CombinedBigNumber, decimal = 18) {
|
|
46
|
-
return toBN(val).div(new BigNumber(10).pow(decimal))
|
|
57
|
+
return toBN(val).div(new BigNumber(10).pow(decimal))
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
export function abs(value: CombinedBigNumber) {
|
|
50
|
-
return toBN(value).abs()
|
|
61
|
+
return toBN(value).abs()
|
|
51
62
|
}
|