@sentio/sdk-bundle 2.44.7-rc.6 → 2.45.0
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/lib/aptos/builtin/0x1.js +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/index.js +1 -1
- package/lib/aptos/ext/aptos-dex.d.ts +7 -6
- package/lib/aptos/ext/aptos-dex.d.ts.map +1 -1
- package/lib/aptos/ext/index.d.ts +0 -1
- package/lib/aptos/ext/index.d.ts.map +1 -1
- package/lib/aptos/ext/index.js +1 -1
- package/lib/aptos/ext/index.js.map +1 -1
- package/lib/aptos/ext/token.d.ts +7 -5
- package/lib/aptos/ext/token.d.ts.map +1 -1
- package/lib/aptos/index.js +1 -1
- package/lib/chunk-5VBGX3LN.js +3 -0
- package/lib/chunk-5VBGX3LN.js.map +1 -0
- package/lib/{chunk-ZA6TPCBF.js → chunk-67L6M26C.js} +10 -10
- package/lib/chunk-67L6M26C.js.map +1 -0
- package/lib/{chunk-4D6ZDNWQ.js → chunk-DOTKHTBG.js} +2 -2
- package/lib/{chunk-VSUZQA42.js → chunk-DR4NZAPM.js} +2 -2
- package/lib/{chunk-PBVLDBCZ.js → chunk-G2KR5VKV.js} +2 -2
- package/lib/{chunk-5ZYA435U.js → chunk-JCUSXGHB.js} +2 -2
- package/lib/{chunk-Y5P74Z5H.js → chunk-SU5LVIL5.js} +2 -2
- package/lib/chunk-VJEZ2ZJ5.js +3 -0
- package/lib/chunk-VJEZ2ZJ5.js.map +1 -0
- package/lib/move/ext/coin.d.ts +15 -0
- package/lib/move/ext/coin.d.ts.map +1 -0
- package/lib/move/ext/index.d.ts +1 -1
- package/lib/move/ext/index.d.ts.map +1 -1
- package/lib/move/ext/index.js +1 -1
- package/lib/move/ext/move-dex.d.ts +4 -14
- package/lib/move/ext/move-dex.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +1 -1
- package/lib/sui/builtin/0x2.js +1 -1
- package/lib/sui/builtin/0x3.js +1 -1
- package/lib/sui/builtin/index.js +1 -1
- package/lib/sui/ext/coin.d.ts +5 -5
- package/lib/sui/ext/coin.d.ts.map +1 -1
- package/lib/sui/ext/index.js +1 -1
- package/lib/sui/ext/index.js.map +1 -1
- package/lib/sui/ext/move-dex.d.ts +6 -6
- package/lib/sui/ext/move-dex.d.ts.map +1 -1
- package/lib/sui/index.js +1 -1
- package/lib/testing/index.js +1 -1
- package/package.json +2 -2
- package/src/aptos/aptos-plugin.ts +2 -2
- package/src/aptos/ext/aptos-dex.ts +11 -10
- package/src/aptos/ext/index.ts +0 -1
- package/src/aptos/ext/token.ts +18 -10
- package/src/move/ext/coin.ts +17 -0
- package/src/move/ext/index.ts +1 -1
- package/src/move/ext/move-dex.ts +16 -19
- package/src/sui/ext/coin.ts +9 -12
- package/src/sui/ext/move-dex.ts +6 -5
- package/lib/aptos/ext/coin.d.ts +0 -12
- package/lib/aptos/ext/coin.d.ts.map +0 -1
- package/lib/chunk-5WK73P5V.js +0 -3
- package/lib/chunk-5WK73P5V.js.map +0 -1
- package/lib/chunk-6XQXL5OK.js +0 -3
- package/lib/chunk-6XQXL5OK.js.map +0 -1
- package/lib/chunk-ZA6TPCBF.js.map +0 -1
- package/lib/move/ext/coin-list.d.ts +0 -9
- package/lib/move/ext/coin-list.d.ts.map +0 -1
- package/src/aptos/ext/coin.ts +0 -1583
- package/src/move/ext/coin-list.ts +0 -14
- /package/lib/{chunk-4D6ZDNWQ.js.map → chunk-DOTKHTBG.js.map} +0 -0
- /package/lib/{chunk-VSUZQA42.js.map → chunk-DR4NZAPM.js.map} +0 -0
- /package/lib/{chunk-PBVLDBCZ.js.map → chunk-G2KR5VKV.js.map} +0 -0
- /package/lib/{chunk-5ZYA435U.js.map → chunk-JCUSXGHB.js.map} +0 -0
- /package/lib/{chunk-Y5P74Z5H.js.map → chunk-SU5LVIL5.js.map} +0 -0
package/src/move/ext/move-dex.ts
CHANGED
|
@@ -2,15 +2,7 @@ import { DecodedStruct, TypeDescriptor } from '@typemove/move'
|
|
|
2
2
|
import { BigDecimal } from '@sentio/bigdecimal'
|
|
3
3
|
import { Gauge } from '../../core/index.js'
|
|
4
4
|
import { MoveAccountContext, MoveContext } from '../move-context.js'
|
|
5
|
-
import { MoveCoinList } from './coin
|
|
6
|
-
|
|
7
|
-
export interface SimpleCoinInfo {
|
|
8
|
-
token_type: { type: string; account_address: string }
|
|
9
|
-
symbol: string
|
|
10
|
-
hippo_symbol?: string
|
|
11
|
-
decimals: number
|
|
12
|
-
bridge: string
|
|
13
|
-
}
|
|
5
|
+
import { MoveCoinList, BaseCoinInfo } from './coin.js'
|
|
14
6
|
|
|
15
7
|
export interface MovePoolAdaptor<StructType, T> {
|
|
16
8
|
getXReserve(pool: T): bigint
|
|
@@ -23,6 +15,7 @@ export interface MovePoolAdaptor<StructType, T> {
|
|
|
23
15
|
}
|
|
24
16
|
|
|
25
17
|
export class MoveDex<
|
|
18
|
+
TokenType extends BaseCoinInfo,
|
|
26
19
|
Network,
|
|
27
20
|
ModuleType,
|
|
28
21
|
StructType,
|
|
@@ -31,7 +24,7 @@ export class MoveDex<
|
|
|
31
24
|
AccountContextType extends MoveAccountContext<Network, ModuleType, StructType | EventType>,
|
|
32
25
|
T
|
|
33
26
|
> {
|
|
34
|
-
coinList: MoveCoinList<Network>
|
|
27
|
+
coinList: MoveCoinList<TokenType, Network>
|
|
35
28
|
poolAdaptor: MovePoolAdaptor<StructType, T>
|
|
36
29
|
volume: Gauge
|
|
37
30
|
volumeByCoin: Gauge
|
|
@@ -100,14 +93,14 @@ export class MoveDex<
|
|
|
100
93
|
this.volumeByCoin.record(ctx, resultX, {
|
|
101
94
|
coin: coinXInfo.symbol,
|
|
102
95
|
bridge: coinXInfo.bridge,
|
|
103
|
-
type: coinXInfo.
|
|
96
|
+
type: coinXInfo.type
|
|
104
97
|
})
|
|
105
98
|
}
|
|
106
99
|
if (resultY.gt(0)) {
|
|
107
100
|
this.volumeByCoin.record(ctx, resultY, {
|
|
108
101
|
coin: coinYInfo.symbol,
|
|
109
102
|
bridge: coinYInfo.bridge,
|
|
110
|
-
type: coinYInfo.
|
|
103
|
+
type: coinYInfo.type
|
|
111
104
|
})
|
|
112
105
|
}
|
|
113
106
|
result = resultX.plus(resultY).div(2)
|
|
@@ -152,23 +145,23 @@ export class MoveDex<
|
|
|
152
145
|
|
|
153
146
|
if (whitelistx) {
|
|
154
147
|
resultX = await this.coinList.calculateValueInUsd(coinx_amount, coinXInfo, timestamp, ctx.network)
|
|
155
|
-
let coinXTotal = volumeByCoin.get(coinXInfo.
|
|
148
|
+
let coinXTotal = volumeByCoin.get(coinXInfo.type)
|
|
156
149
|
if (!coinXTotal) {
|
|
157
150
|
coinXTotal = resultX
|
|
158
151
|
} else {
|
|
159
152
|
coinXTotal = coinXTotal.plus(resultX)
|
|
160
153
|
}
|
|
161
|
-
volumeByCoin.set(coinXInfo.
|
|
154
|
+
volumeByCoin.set(coinXInfo.type, coinXTotal)
|
|
162
155
|
}
|
|
163
156
|
if (whitelisty) {
|
|
164
157
|
resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network)
|
|
165
|
-
let coinYTotal = volumeByCoin.get(coinYInfo.
|
|
158
|
+
let coinYTotal = volumeByCoin.get(coinYInfo.type)
|
|
166
159
|
if (!coinYTotal) {
|
|
167
160
|
coinYTotal = resultY
|
|
168
161
|
} else {
|
|
169
162
|
coinYTotal = coinYTotal.plus(resultY)
|
|
170
163
|
}
|
|
171
|
-
volumeByCoin.set(coinYInfo.
|
|
164
|
+
volumeByCoin.set(coinYInfo.type, coinYTotal)
|
|
172
165
|
}
|
|
173
166
|
|
|
174
167
|
if (resultX.eq(0)) {
|
|
@@ -202,7 +195,7 @@ export class MoveDex<
|
|
|
202
195
|
this.tvlByCoin.record(ctx, v, {
|
|
203
196
|
coin: coinInfo.symbol,
|
|
204
197
|
bridge: coinInfo.bridge,
|
|
205
|
-
type: coinInfo.
|
|
198
|
+
type: coinInfo.type
|
|
206
199
|
})
|
|
207
200
|
}
|
|
208
201
|
}
|
|
@@ -218,8 +211,12 @@ export class MoveDex<
|
|
|
218
211
|
}
|
|
219
212
|
}
|
|
220
213
|
|
|
221
|
-
export async function moveGetPairValue<
|
|
222
|
-
|
|
214
|
+
export async function moveGetPairValue<
|
|
215
|
+
TokenType extends BaseCoinInfo,
|
|
216
|
+
Network,
|
|
217
|
+
ContextType extends MoveAccountContext<Network, any, any>
|
|
218
|
+
>(
|
|
219
|
+
coinList: MoveCoinList<TokenType, Network>,
|
|
223
220
|
ctx: ContextType,
|
|
224
221
|
coinx: string,
|
|
225
222
|
coiny: string,
|
package/src/sui/ext/coin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCoinInfo } from '../../move/ext/index.js'
|
|
2
2
|
import fetch from 'node-fetch'
|
|
3
3
|
import { accountTypeString, SPLITTER } from '../../move/index.js'
|
|
4
4
|
import { getPriceByType } from '../../utils/index.js'
|
|
@@ -7,7 +7,7 @@ import { SuiChainId } from '@sentio/chain'
|
|
|
7
7
|
import { getClient, SuiNetwork } from '../network.js'
|
|
8
8
|
import { CoinMetadata } from '@mysten/sui/client'
|
|
9
9
|
|
|
10
|
-
const WHITELISTED_COINS = new Map<string,
|
|
10
|
+
const WHITELISTED_COINS = new Map<string, BaseCoinInfo>()
|
|
11
11
|
|
|
12
12
|
export async function initCoinList() {
|
|
13
13
|
let list = DEFAULT_LIST.coinlist
|
|
@@ -48,10 +48,7 @@ function setCoinList(list: SuiCoinInfo[]) {
|
|
|
48
48
|
bridge = 'Wormhole'
|
|
49
49
|
}
|
|
50
50
|
WHITELISTED_COINS.set(info.address, {
|
|
51
|
-
|
|
52
|
-
type: info.address,
|
|
53
|
-
account_address: info.address.split('::')[0]
|
|
54
|
-
},
|
|
51
|
+
type: info.address,
|
|
55
52
|
symbol: info.symbol,
|
|
56
53
|
decimals: info.decimals,
|
|
57
54
|
bridge
|
|
@@ -69,13 +66,13 @@ export function whiteListed(coin: string): boolean {
|
|
|
69
66
|
return WHITELISTED_COINS.has(normalized)
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
export function getCoinInfo(type: string):
|
|
69
|
+
export function getCoinInfo(type: string): BaseCoinInfo {
|
|
73
70
|
const r = WHITELISTED_COINS.get(type)
|
|
74
71
|
if (!r) {
|
|
75
72
|
const parts = type.split('::')
|
|
76
73
|
// TDDO retrive from network
|
|
77
74
|
return {
|
|
78
|
-
|
|
75
|
+
type,
|
|
79
76
|
symbol: parts[2],
|
|
80
77
|
decimals: 8,
|
|
81
78
|
bridge: 'native'
|
|
@@ -86,7 +83,7 @@ export function getCoinInfo(type: string): SimpleCoinInfo {
|
|
|
86
83
|
|
|
87
84
|
const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata | null>>()
|
|
88
85
|
|
|
89
|
-
export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<
|
|
86
|
+
export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<BaseCoinInfo> {
|
|
90
87
|
const r = WHITELISTED_COINS.get(type)
|
|
91
88
|
if (!r) {
|
|
92
89
|
network = network || SuiChainId.SUI_MAINNET
|
|
@@ -104,7 +101,7 @@ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork
|
|
|
104
101
|
|
|
105
102
|
const parts = type.split(SPLITTER)
|
|
106
103
|
return {
|
|
107
|
-
|
|
104
|
+
type,
|
|
108
105
|
symbol: meta.symbol,
|
|
109
106
|
decimals: meta.decimals,
|
|
110
107
|
bridge: 'native'
|
|
@@ -126,8 +123,8 @@ export async function getPrice(coinType: string, timestamp: number): Promise<num
|
|
|
126
123
|
}
|
|
127
124
|
}
|
|
128
125
|
|
|
129
|
-
export async function calculateValueInUsd(n: bigint, coinInfo:
|
|
130
|
-
const price = await getPrice(coinInfo.
|
|
126
|
+
export async function calculateValueInUsd(n: bigint, coinInfo: BaseCoinInfo, timestamp: number) {
|
|
127
|
+
const price = await getPrice(coinInfo.type, timestamp)
|
|
131
128
|
const amount = n.scaleDown(coinInfo.decimals)
|
|
132
129
|
return amount.multipliedBy(price)
|
|
133
130
|
}
|
package/src/sui/ext/move-dex.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { BigDecimal } from '@sentio/bigdecimal'
|
|
2
2
|
import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'
|
|
3
|
-
import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor,
|
|
3
|
+
import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, BaseCoinInfo } from '../../move/ext/index.js'
|
|
4
4
|
import { SuiEvent, SuiMoveNormalizedModule, SuiMoveObject } from '@mysten/sui/client'
|
|
5
5
|
import { SuiNetwork } from '../network.js'
|
|
6
6
|
import { SuiContext, SuiObjectContext } from '../context.js'
|
|
7
7
|
|
|
8
8
|
export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>
|
|
9
9
|
|
|
10
|
-
export class CoinList implements MoveCoinList<SuiNetwork> {
|
|
11
|
-
calculateValueInUsd(amount: bigint, coinInfo:
|
|
10
|
+
export class CoinList implements MoveCoinList<BaseCoinInfo, SuiNetwork> {
|
|
11
|
+
calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise<BigDecimal> {
|
|
12
12
|
return calculateValueInUsd(amount, coinInfo, timestamp)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
getCoinInfo(type: string)
|
|
15
|
+
async getCoinInfo(type: string) {
|
|
16
16
|
return getCoinInfo(type)
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ export class CoinList implements MoveCoinList<SuiNetwork> {
|
|
|
20
20
|
return whiteListed(type)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
whitelistCoins(): Map<string,
|
|
23
|
+
whitelistCoins(): Map<string, BaseCoinInfo> {
|
|
24
24
|
return whitelistCoins()
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -28,6 +28,7 @@ export class CoinList implements MoveCoinList<SuiNetwork> {
|
|
|
28
28
|
export const SuiCoinList = new CoinList()
|
|
29
29
|
|
|
30
30
|
export class SuiDex<T> extends MoveDex<
|
|
31
|
+
BaseCoinInfo,
|
|
31
32
|
SuiNetwork,
|
|
32
33
|
SuiMoveNormalizedModule,
|
|
33
34
|
SuiMoveObject,
|
package/lib/aptos/ext/coin.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SimpleCoinInfo } from '../../move/ext/move-dex.js';
|
|
2
|
-
import { AptosNetwork } from '../network.js';
|
|
3
|
-
import { AptosChainId } from '@sentio/chain';
|
|
4
|
-
export declare function initCoinList(): Promise<void>;
|
|
5
|
-
export declare function whitelistCoins(): Map<string, SimpleCoinInfo>;
|
|
6
|
-
export declare function whiteListed(coin: string): boolean;
|
|
7
|
-
export declare function getCoinInfo(type: string): SimpleCoinInfo;
|
|
8
|
-
export declare function getCoinInfoWithFallback(type: string, network?: AptosNetwork): Promise<SimpleCoinInfo>;
|
|
9
|
-
export declare function getPrice(coinType: string, timestamp: number, network?: AptosChainId): Promise<number>;
|
|
10
|
-
export declare function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number, network?: AptosChainId): Promise<import("@sentio/bigdecimal").BigDecimal>;
|
|
11
|
-
export declare function delay(ms: number): Promise<unknown>;
|
|
12
|
-
//# sourceMappingURL=coin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/aptos/ext/coin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAa,MAAM,eAAe,CAAA;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,wBAAsB,YAAY,kBAYjC;AA6BD,wBAAgB,cAAc,gCAE7B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAaxD;AAID,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CA4B3G;AAED,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,eAA6B,GACnC,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,wBAAsB,mBAAmB,CACvC,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,eAA6B,oDAKrC;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B"}
|
package/lib/chunk-5WK73P5V.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{f as r}from"./chunk-B7YDBLBV.js";import{a as l}from"./chunk-44SAPBRK.js";import{i as b}from"./chunk-RVQBDYQ2.js";import{a as i,d as m}from"./chunk-RVK3H6V4.js";import{a as u}from"./chunk-QW2MPHP5.js";import{e as p}from"./chunk-6GD6B22G.js";var d=p(u(),1);var a=new Map;async function E(){let o=w.coinlist;try{o=(await(await l("https://raw.githubusercontent.com/solflare-wallet/sui-coinlist/master/sui-coinlist.json")).json()).coinlist}catch{console.warn("Can't not fetch newest coin list, use default list")}I(o)}function I(o){for(let e of o){if(e.address.startsWith("0x2::coin::Coin")||e.network!=="mainnet")continue;let s="native";e.name.includes("Celer")&&(s="Celer"),e.name.includes("LayerZero")&&(s="LayerZero"),e.name.includes("Wormhole")&&(s="Wormhole"),a.set(e.address,{token_type:{type:e.address,account_address:e.address.split("::")[0]},symbol:e.symbol,decimals:e.decimals,bridge:s})}}function N(){return a}function k(o){let[e,s,n]=o.split(i),t=[m(e),s,n].join(i);return a.has(t)}function B(o){let e=a.get(o);if(!e){let s=o.split("::");return{token_type:{type:o,account_address:s[0]},symbol:s[2],decimals:8,bridge:"native"}}return e}var g=new Map;async function R(o,e){let s=a.get(o);if(!s){e=e||d.SuiChainId.SUI_MAINNET;let n=e+"_"+o,t=g.get(n);t||(t=r(e).getCoinMetadata({coinType:o}),g.set(n,t));let c=await t;if(c===null)throw Error("Coin not existed "+n);let f=o.split(i);return{token_type:{type:o,account_address:f[0]},symbol:c.symbol,decimals:c.decimals,bridge:"native"}}return s}async function h(o,e){if(!k(o))return 0;let s=new Date(e/1e3);try{return await b(d.SuiChainId.SUI_MAINNET,o,s)||0}catch(n){throw console.log(JSON.stringify(n)),n}}async function D(o,e,s){let n=await h(e.token_type.type,s);return o.scaleDown(e.decimals).multipliedBy(n)}var w={name:"Sui Coin List",timestamp:"2022-12-01T13:34:30.145Z",logoURI:"https://s2.coinmarketcap.com/static/img/coins/128x128/20947.png",coinlist:[{network:"mainnet",address:"0x2::coin::Coin<0x2::sui::SUI>",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"testnet",address:"0x2::coin::Coin<0x2::sui::SUI>",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"devnet",address:"0x2::coin::Coin<0x2::sui::SUI>",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"mainnet",address:"0x2::sui::SUI",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"testnet",address:"0x2::sui::SUI",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"devnet",address:"0x2::sui::SUI",symbol:"SUI",name:"Sui Coin",decimals:9,logoURI:"https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg",tags:[],extensions:{coingeckoId:"sui"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST",symbol:"TEST",name:"Test Token",logoURI:"https://suiswap.app/images/token/suiswap-test.svg",tags:[],decimals:8,extensions:{}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT",symbol:"USDT",name:"Tether",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png",tags:[],decimals:8,extensions:{coingeckoId:"tether"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC",symbol:"USDC",name:"USD Coin",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"usd-coin"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL",symbol:"SOL",name:"Solana",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png",decimals:8,extensions:{coingeckoId:"solana"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC",symbol:"BTC",name:"Bitcoin",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"bitcoin"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI",symbol:"DAI",name:"DAI",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"dai"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB",symbol:"BNB",name:"BNB",logoURI:"https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png",decimals:8,tags:[],extensions:{coingeckoId:"binancecoin"}},{network:"testnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH",symbol:"ETH",name:"Ethereum",logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png",decimals:8,tags:[],extensions:{coingeckoId:"ethereum"}},{network:"testnet",address:"0x31b14985adb91360ed90a5786cb0956c83e7f275a8ae6123f38adab9d2b792b1::usdc::USDC",symbol:"USDC",name:"USD Coin",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"usd-coin"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST",symbol:"TEST",name:"Test Token",logoURI:"https://suiswap.app/images/token/suiswap-test.svg",tags:[],decimals:8,extensions:{}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT",symbol:"USDT",name:"Tether",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png",tags:[],decimals:8,extensions:{coingeckoId:"tether"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC",symbol:"USDC",name:"USD Coin",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"usd-coin"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL",symbol:"SOL",name:"Solana",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png",decimals:8,extensions:{coingeckoId:"solana"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC",symbol:"BTC",name:"Bitcoin",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"bitcoin"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI",symbol:"DAI",name:"DAI",logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png",decimals:8,tags:[],extensions:{coingeckoId:"dai"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB",symbol:"BNB",name:"BNB",logoURI:"https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png",decimals:8,tags:[],extensions:{coingeckoId:"binancecoin"}},{network:"devnet",address:"0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH",symbol:"ETH",name:"Ethereum",logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png",decimals:8,tags:[],extensions:{coingeckoId:"ethereum"}},{network:"mainnet",address:"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",symbol:"wETH",name:"Wrapped Ethereum (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png",tags:[],extensions:{coingeckoId:"ethereum"}},{network:"mainnet",address:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",symbol:"wUSDT",name:"Tether (Wormhole)",decimals:6,logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png",tags:[],extensions:{coingeckoId:"tether"}},{network:"mainnet",address:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",symbol:"wUSDC",name:"USD Coin (Wormhole)",decimals:6,logoURI:"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png",tags:[],extensions:{coingeckoId:"usd-coin"}},{network:"mainnet",address:"0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN",symbol:"wCELO",name:"Celo (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg",tags:[],extensions:{coingeckoId:"celo"}},{network:"mainnet",address:"0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN",symbol:"wMATIC",name:"Wrapped Matic (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png",tags:[],extensions:{coingeckoId:"matic-network"}},{network:"mainnet",address:"0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",symbol:"wBNB",name:"Wrapped BNB (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png",tags:[],extensions:{coingeckoId:"binancecoin"}},{network:"mainnet",address:"0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN",symbol:"wBTC",name:"Wrapped Bitcoin (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/1/large/bitcoin.png",tags:[],extensions:{coingeckoId:"bitcoin"}},{network:"mainnet",address:"0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN",symbol:"wAVAX",name:"Wrapped AVAX (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png",tags:[],extensions:{coingeckoId:"avalanche-2"}},{network:"mainnet",address:"0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN",symbol:"wFTM",name:"Wrapped Fantom (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/4001/large/Fantom_round.png",tags:[],extensions:{coingeckoId:"fantom"}},{network:"mainnet",address:"0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN",symbol:"wGLMR",name:"Wrapped GLMR (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/22459/large/glmr.png",tags:[],extensions:{coingeckoId:"moonbeam"}},{network:"mainnet",address:"0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN",symbol:"wSOL",name:"Wrapped Solana (Wormhole)",decimals:8,logoURI:"https://assets.coingecko.com/coins/images/4128/large/solana.png",tags:[],extensions:{coingeckoId:"solana"}},{network:"mainnet",address:"0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN",symbol:"wUSDCsol",name:"USD Coin Solana (Wormhole)",decimals:6,logoURI:"https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png",tags:[],extensions:{coingeckoId:"usd-coin"}}]};import("process").then(o=>o.stdout.write(""));export{E as a,N as b,k as c,B as d,R as e,h as f,D as g};
|
|
3
|
-
//# sourceMappingURL=chunk-5WK73P5V.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sui/ext/coin.ts"],"sourcesContent":["import { SimpleCoinInfo } from '../../move/ext/index.js'\nimport fetch from 'node-fetch'\nimport { accountTypeString, SPLITTER } from '../../move/index.js'\nimport { getPriceByType } from '../../utils/index.js'\nimport { SuiChainId } from '@sentio/chain'\n// import { validateAndNormalizeAddress } from '../utils.js'\nimport { getClient, SuiNetwork } from '../network.js'\nimport { CoinMetadata } from '@mysten/sui/client'\n\nconst WHITELISTED_COINS = new Map<string, SimpleCoinInfo>()\n\nexport async function initCoinList() {\n let list = DEFAULT_LIST.coinlist\n try {\n const resp = await fetch('https://raw.githubusercontent.com/solflare-wallet/sui-coinlist/master/sui-coinlist.json')\n list = ((await resp.json()) as any).coinlist\n } catch (e) {\n console.warn(\"Can't not fetch newest coin list, use default list\")\n }\n\n setCoinList(list)\n}\n\nexport interface SuiCoinInfo {\n network: string\n address: string\n symbol: string\n name: string\n decimals: number\n}\n\nfunction setCoinList(list: SuiCoinInfo[]) {\n for (const info of list) {\n if (info.address.startsWith('0x2::coin::Coin')) {\n continue\n }\n if (info.network !== 'mainnet') {\n continue\n }\n let bridge = 'native'\n if (info.name.includes('Celer')) {\n bridge = 'Celer'\n }\n if (info.name.includes('LayerZero')) {\n bridge = 'LayerZero'\n }\n if (info.name.includes('Wormhole')) {\n bridge = 'Wormhole'\n }\n WHITELISTED_COINS.set(info.address, {\n token_type: {\n type: info.address,\n account_address: info.address.split('::')[0]\n },\n symbol: info.symbol,\n decimals: info.decimals,\n bridge\n })\n }\n}\n\nexport function whitelistCoins() {\n return WHITELISTED_COINS\n}\n\nexport function whiteListed(coin: string): boolean {\n const [addr, module, type] = coin.split(SPLITTER)\n const normalized = [accountTypeString(addr), module, type].join(SPLITTER)\n return WHITELISTED_COINS.has(normalized)\n}\n\nexport function getCoinInfo(type: string): SimpleCoinInfo {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n const parts = type.split('::')\n // TDDO retrive from network\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: parts[2],\n decimals: 8,\n bridge: 'native'\n }\n }\n return r\n}\n\nconst COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata | null>>()\n\nexport async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n network = network || SuiChainId.SUI_MAINNET\n const key = network + '_' + type\n let promise = COIN_METADATA_CACHE.get(key)\n if (!promise) {\n const client = getClient(network)\n promise = client.getCoinMetadata({ coinType: type })\n COIN_METADATA_CACHE.set(key, promise)\n }\n const meta = await promise\n if (meta === null) {\n throw Error('Coin not existed ' + key)\n }\n\n const parts = type.split(SPLITTER)\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: meta.symbol,\n decimals: meta.decimals,\n bridge: 'native'\n }\n }\n return r\n}\n\nexport async function getPrice(coinType: string, timestamp: number): Promise<number> {\n if (!whiteListed(coinType)) {\n return 0.0\n }\n const date = new Date(timestamp / 1000)\n try {\n return (await getPriceByType(SuiChainId.SUI_MAINNET, coinType, date)) || 0\n } catch (error) {\n console.log(JSON.stringify(error))\n throw error\n }\n}\n\nexport async function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number) {\n const price = await getPrice(coinInfo.token_type.type, timestamp)\n const amount = n.scaleDown(coinInfo.decimals)\n return amount.multipliedBy(price)\n}\n\nconst DEFAULT_LIST = {\n name: 'Sui Coin List',\n timestamp: '2022-12-01T13:34:30.145Z',\n logoURI: 'https://s2.coinmarketcap.com/static/img/coins/128x128/20947.png',\n coinlist: [\n {\n network: 'mainnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'testnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'devnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'mainnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'testnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'devnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {}\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin'\n }\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum'\n }\n },\n {\n network: 'testnet',\n address: '0x31b14985adb91360ed90a5786cb0956c83e7f275a8ae6123f38adab9d2b792b1::usdc::USDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {}\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin'\n }\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum'\n }\n },\n {\n network: 'mainnet',\n address: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN',\n symbol: 'wETH',\n name: 'Wrapped Ethereum (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n tags: [],\n extensions: {\n coingeckoId: 'ethereum'\n }\n },\n {\n network: 'mainnet',\n address: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',\n symbol: 'wUSDT',\n name: 'Tether (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'tether'\n }\n },\n {\n network: 'mainnet',\n address: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',\n symbol: 'wUSDC',\n name: 'USD Coin (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin'\n }\n },\n {\n network: 'mainnet',\n address: '0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN',\n symbol: 'wCELO',\n name: 'Celo (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'celo'\n }\n },\n {\n network: 'mainnet',\n address: '0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN',\n symbol: 'wMATIC',\n name: 'Wrapped Matic (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'matic-network'\n }\n },\n {\n network: 'mainnet',\n address: '0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN',\n symbol: 'wBNB',\n name: 'Wrapped BNB (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin'\n }\n },\n {\n network: 'mainnet',\n address: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',\n symbol: 'wBTC',\n name: 'Wrapped Bitcoin (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/1/large/bitcoin.png',\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin'\n }\n },\n {\n network: 'mainnet',\n address: '0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN',\n symbol: 'wAVAX',\n name: 'Wrapped AVAX (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png',\n tags: [],\n extensions: {\n coingeckoId: 'avalanche-2'\n }\n },\n {\n network: 'mainnet',\n address: '0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN',\n symbol: 'wFTM',\n name: 'Wrapped Fantom (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4001/large/Fantom_round.png',\n tags: [],\n extensions: {\n coingeckoId: 'fantom'\n }\n },\n {\n network: 'mainnet',\n address: '0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN',\n symbol: 'wGLMR',\n name: 'Wrapped GLMR (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/22459/large/glmr.png',\n tags: [],\n extensions: {\n coingeckoId: 'moonbeam'\n }\n },\n {\n network: 'mainnet',\n address: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',\n symbol: 'wSOL',\n name: 'Wrapped Solana (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4128/large/solana.png',\n tags: [],\n extensions: {\n coingeckoId: 'solana'\n }\n },\n {\n network: 'mainnet',\n address: '0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN',\n symbol: 'wUSDCsol',\n name: 'USD Coin Solana (Wormhole)',\n decimals: 6,\n logoURI: 'https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin'\n }\n }\n ]\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";uPAIA,IAAAA,EAA2B,SAK3B,IAAMC,EAAoB,IAAI,IAE9B,eAAsBC,GAAe,CACnC,IAAIC,EAAOC,EAAa,SACxB,GAAI,CAEFD,GAAS,MADI,MAAME,EAAM,yFAAyF,GAC9F,KAAK,GAAW,QACtC,MAAE,CACA,QAAQ,KAAK,oDAAoD,CACnE,CAEAC,EAAYH,CAAI,CAClB,CAUA,S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AS,UACT,QAAS,gBACT,OAAQ,MACR,KAAM,WACN,SAAU,EACV,QAAS,kEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,KACf,CACF,EACA,CACE,QAAS,UACT,QAAS,gBACT,OAAQ,MACR,KAAM,WACN,SAAU,EACV,QAAS,kEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,KACf,CACF,EACA,CACE,QAAS,SACT,QAAS,gBACT,OAAQ,MACR,KAAM,WACN,SAAU,EACV,QAAS,kEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,KACf,CACF,EACA,CACE,QAAS,UACT,QAAS,sFACT,OAAQ,OACR,KAAM,aACN,QAAS,oDACT,KAAM,CAAC,EACP,SAAU,EACV,WAAY,CAAC,CACf,EACA,CACE,QAAS,UACT,QAAS,sFACT,OAAQ,OACR,KAAM,SACN,QACE,qIACF,KAAM,CAAC,EACP,SAAU,EACV,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,UACT,QAAS,sFACT,OAAQ,OACR,KAAM,WACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,qFACT,OAAQ,MACR,KAAM,SACN,QACE,oIACF,SAAU,EACV,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,UACT,QAAS,qFACT,OAAQ,MACR,KAAM,UACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,SACf,CACF,EACA,CACE,QAAS,UACT,QAAS,qFACT,OAAQ,MACR,KAAM,MACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,KACf,CACF,EACA,CACE,QAAS,UACT,QAAS,qFACT,OAAQ,MACR,KAAM,MACN,QAAS,uEACT,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,aACf,CACF,EACA,CACE,QAAS,UACT,QAAS,qFACT,OAAQ,MACR,KAAM,WACN,QAAS,mEACT,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,WACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,SACT,QAAS,sFACT,OAAQ,OACR,KAAM,aACN,QAAS,oDACT,KAAM,CAAC,EACP,SAAU,EACV,WAAY,CAAC,CACf,EACA,CACE,QAAS,SACT,QAAS,sFACT,OAAQ,OACR,KAAM,SACN,QACE,qIACF,KAAM,CAAC,EACP,SAAU,EACV,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,SACT,QAAS,sFACT,OAAQ,OACR,KAAM,WACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,SACT,QAAS,qFACT,OAAQ,MACR,KAAM,SACN,QACE,oIACF,SAAU,EACV,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,SACT,QAAS,qFACT,OAAQ,MACR,KAAM,UACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,SACf,CACF,EACA,CACE,QAAS,SACT,QAAS,qFACT,OAAQ,MACR,KAAM,MACN,QACE,qIACF,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,KACf,CACF,EACA,CACE,QAAS,SACT,QAAS,qFACT,OAAQ,MACR,KAAM,MACN,QAAS,uEACT,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,aACf,CACF,EACA,CACE,QAAS,SACT,QAAS,qFACT,OAAQ,MACR,KAAM,WACN,QAAS,mEACT,SAAU,EACV,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,8BACN,SAAU,EACV,QAAS,mEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,QACR,KAAM,oBACN,SAAU,EACV,QACE,qIACF,KAAM,CAAC,EACP,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,QACR,KAAM,sBACN,SAAU,EACV,QACE,qIACF,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,QACR,KAAM,kBACN,SAAU,EACV,QAAS,6EACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,MACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,SACR,KAAM,2BACN,SAAU,EACV,QAAS,4EACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,eACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,yBACN,SAAU,EACV,QAAS,uEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,aACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,6BACN,SAAU,EACV,QAAS,gEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,SACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,QACR,KAAM,0BACN,SAAU,EACV,QAAS,4FACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,aACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,4BACN,SAAU,EACV,QAAS,wEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,QACR,KAAM,0BACN,SAAU,EACV,QAAS,iEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,OACR,KAAM,4BACN,SAAU,EACV,QAAS,kEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,QACf,CACF,EACA,CACE,QAAS,UACT,QAAS,iFACT,OAAQ,WACR,KAAM,6BACN,SAAU,EACV,QAAS,yEACT,KAAM,CAAC,EACP,WAAY,CACV,YAAa,UACf,CACF,CACF,CACF,EACC,OAAO,SAAc,EAAE,KAAMkC,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["import_chain","WHITELISTED_COINS","initCoinList","list","DEFAULT_LIST","fetch","setCoinList","info","bridge","whitelistCoins","whiteListed","coin","addr","module","type","SPLITTER","normalized","accountTypeString","getCoinInfo","r","parts","COIN_METADATA_CACHE","getCoinInfoWithFallback","network","key","promise","getClient","meta","getPrice","coinType","timestamp","date","getPriceByType","error","calculateValueInUsd","n","coinInfo","price","p"]}
|
package/lib/chunk-6XQXL5OK.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-FC546GTB.js";import("process").then(s=>s.stdout.write(""));var I=class{coinList;poolAdaptor;volume;volumeByCoin;tvlAll;tvlByPool;tvlByCoin;constructor(o,t,i,r,p,a){this.volume=o,this.volumeByCoin=t,this.tvlAll=i,this.tvlByPool=p,this.tvlByCoin=r,this.poolAdaptor=a}async recordTradingVolume(o,t,i,r,p,a){let u=c(0),l=this.coinList.whiteListed(t),g=this.coinList.whiteListed(i);if(!l&&!g)return u;let e=await this.coinList.getCoinInfo(t),n=await this.coinList.getCoinInfo(i),m=o.getTimestamp(),d=c(0),f=c(0),C=await this.getPair(t,i),v=a?{...a,pair:C}:{pair:C};l&&(d=await this.coinList.calculateValueInUsd(r,e,m,o.network)),g&&(f=await this.coinList.calculateValueInUsd(p,n,m,o.network)),d.eq(0)&&(d=c(f)),f.eq(0)&&(f=c(d));let T=d.plus(f);return T.gt(0)&&this.volume.record(o,T,{...v,bridge:e.bridge}),d.gt(0)&&this.volumeByCoin.record(o,d,{coin:e.symbol,bridge:e.bridge,type:e.token_type.type}),f.gt(0)&&this.volumeByCoin.record(o,f,{coin:n.symbol,bridge:n.bridge,type:n.token_type.type}),u=d.plus(f).div(2),u}async syncPools(o,t,i){let r=await t.coder.filterAndDecodeStruct(this.poolAdaptor.poolType,o),p=new Map,a=t.getTimestamp();console.log("num of pools: ",r.length,a);let u=c(0);for(let l of r){let g=l.type_arguments[0],e=l.type_arguments[1],n=this.coinList.whiteListed(g),m=this.coinList.whiteListed(e);if(!n&&!m)continue;let d=await this.getPair(g,e),C={...this.poolAdaptor.getExtraPoolTags(l),pair:d},v=await this.coinList.getCoinInfo(g),T=await this.coinList.getCoinInfo(e),k=this.poolAdaptor.getXReserve(l.data_decoded),L=this.poolAdaptor.getYReserve(l.data_decoded),h=c(0),w=c(0);if(n){h=await this.coinList.calculateValueInUsd(k,v,a,t.network);let y=p.get(v.token_type.type);y?y=y.plus(h):y=h,p.set(v.token_type.type,y)}if(m){w=await this.coinList.calculateValueInUsd(L,T,a,t.network);let y=p.get(T.token_type.type);y?y=y.plus(w):y=w,p.set(T.token_type.type,y)}h.eq(0)&&(h=c(w)),w.eq(0)&&(w=c(h));let b=h.plus(w);b.isGreaterThan(0)&&this.tvlByPool.record(t,b,C),u=u.plus(b)}this.tvlAll.record(t,u),i&&i(r);for(let[l,g]of p){let e=this.coinList.whitelistCoins().get(l);if(!e)throw Error("unexpected coin "+l);g.isGreaterThan(0)&&this.tvlByCoin.record(t,g,{coin:e.symbol,bridge:e.bridge,type:e.token_type.type})}}async getPair(o,t){let i=await this.coinList.getCoinInfo(o),r=await this.coinList.getCoinInfo(t);return i.symbol.localeCompare(r.symbol)>0?`${r.symbol}-${i.symbol}`:`${i.symbol}-${r.symbol}`}};async function P(s,o,t,i,r,p){let a=s.whiteListed(t),u=s.whiteListed(i),l=await s.getCoinInfo(t),g=await s.getCoinInfo(i),e=o.getTimestamp(),n=c(0);if(!a||!u)return n;if(a){let m=await s.calculateValueInUsd(r,l,e,o.network);n=m,u||(n=n.plus(m))}if(u){let m=await s.calculateValueInUsd(p,g,e,o.network);a||(n=n.plus(m))}return n}import("process").then(s=>s.stdout.write(""));import("process").then(s=>s.stdout.write(""));export{I as a,P as b};
|
|
3
|
-
//# sourceMappingURL=chunk-6XQXL5OK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/move/ext/coin-list.ts","../src/move/ext/move-dex.ts","../src/move/ext/index.ts"],"sourcesContent":["import { BigDecimal } from '@sentio/bigdecimal'\nimport { SimpleCoinInfo } from './move-dex.js'\n\nexport interface MoveCoinList<Network> {\n whiteListed(type: string): boolean\n whitelistCoins(): Map<string, SimpleCoinInfo>\n getCoinInfo(type: string): SimpleCoinInfo\n calculateValueInUsd(\n amount: bigint,\n coinInfo: SimpleCoinInfo,\n timestamp: number,\n network: Network\n ): Promise<BigDecimal>\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","import { DecodedStruct, TypeDescriptor } from '@typemove/move'\nimport { BigDecimal } from '@sentio/bigdecimal'\nimport { Gauge } from '../../core/index.js'\nimport { MoveAccountContext, MoveContext } from '../move-context.js'\nimport { MoveCoinList } from './coin-list.js'\n\nexport interface SimpleCoinInfo {\n token_type: { type: string; account_address: string }\n symbol: string\n hippo_symbol?: string\n decimals: number\n bridge: string\n}\n\nexport interface MovePoolAdaptor<StructType, T> {\n getXReserve(pool: T): bigint\n\n getYReserve(pool: T): bigint\n\n getExtraPoolTags(pool: DecodedStruct<StructType, T>): any\n\n poolType: TypeDescriptor<T>\n}\n\nexport class MoveDex<\n Network,\n ModuleType,\n StructType,\n EventType,\n ContextType extends MoveContext<Network, ModuleType, StructType | EventType>,\n AccountContextType extends MoveAccountContext<Network, ModuleType, StructType | EventType>,\n T\n> {\n coinList: MoveCoinList<Network>\n poolAdaptor: MovePoolAdaptor<StructType, T>\n volume: Gauge\n volumeByCoin: Gauge\n tvlAll: Gauge\n tvlByPool: Gauge\n tvlByCoin: Gauge\n\n constructor(\n volume: Gauge,\n volumeByCoin: Gauge,\n tvlAll: Gauge,\n tvlByCoin: Gauge,\n tvlByPool: Gauge,\n poolAdaptor: MovePoolAdaptor<StructType, T>\n ) {\n this.volume = volume\n this.volumeByCoin = volumeByCoin\n this.tvlAll = tvlAll\n this.tvlByPool = tvlByPool\n this.tvlByCoin = tvlByCoin\n this.poolAdaptor = poolAdaptor\n }\n\n async recordTradingVolume(\n ctx: ContextType,\n coinx: string,\n coiny: string,\n coinXAmount: bigint,\n coinYAmount: bigint,\n extraLabels?: any\n ): Promise<BigDecimal> {\n let result = BigDecimal(0)\n\n const whitelistx = this.coinList.whiteListed(coinx)\n const whitelisty = this.coinList.whiteListed(coiny)\n if (!whitelistx && !whitelisty) {\n return result\n }\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n const timestamp = ctx.getTimestamp()\n let resultX = BigDecimal(0)\n let resultY = BigDecimal(0)\n const pair = await this.getPair(coinx, coiny)\n const baseLabels: Record<string, string> = extraLabels ? { ...extraLabels, pair } : { pair }\n if (whitelistx) {\n resultX = await this.coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network)\n }\n if (whitelisty) {\n resultY = await this.coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network)\n }\n if (resultX.eq(0)) {\n resultX = BigDecimal(resultY)\n }\n if (resultY.eq(0)) {\n resultY = BigDecimal(resultX)\n }\n const total = resultX.plus(resultY)\n if (total.gt(0)) {\n this.volume.record(ctx, total, {\n ...baseLabels,\n bridge: coinXInfo.bridge\n })\n }\n if (resultX.gt(0)) {\n this.volumeByCoin.record(ctx, resultX, {\n coin: coinXInfo.symbol,\n bridge: coinXInfo.bridge,\n type: coinXInfo.token_type.type\n })\n }\n if (resultY.gt(0)) {\n this.volumeByCoin.record(ctx, resultY, {\n coin: coinYInfo.symbol,\n bridge: coinYInfo.bridge,\n type: coinYInfo.token_type.type\n })\n }\n result = resultX.plus(resultY).div(2)\n return result\n }\n\n async syncPools(\n resources: StructType[],\n ctx: AccountContextType,\n poolsHandler?: (pools: DecodedStruct<StructType, T>[]) => Promise<void> | void\n ) {\n const pools = await ctx.coder.filterAndDecodeStruct(this.poolAdaptor.poolType, resources)\n\n const volumeByCoin = new Map<string, BigDecimal>()\n const timestamp = ctx.getTimestamp()\n\n console.log('num of pools: ', pools.length, timestamp)\n\n let tvlAllValue = BigDecimal(0)\n for (const pool of pools) {\n // savePool(ctx.version, pool.type_arguments)\n const coinx = pool.type_arguments[0]\n const coiny = pool.type_arguments[1]\n const whitelistx = this.coinList.whiteListed(coinx)\n const whitelisty = this.coinList.whiteListed(coiny)\n if (!whitelistx && !whitelisty) {\n continue\n }\n\n const pair = await this.getPair(coinx, coiny)\n const extraLabels = this.poolAdaptor.getExtraPoolTags(pool)\n const baseLabels: Record<string, string> = { ...extraLabels, pair }\n\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n\n const coinx_amount = this.poolAdaptor.getXReserve(pool.data_decoded)\n const coiny_amount = this.poolAdaptor.getYReserve(pool.data_decoded)\n\n let resultX = BigDecimal(0)\n let resultY = BigDecimal(0)\n\n if (whitelistx) {\n resultX = await this.coinList.calculateValueInUsd(coinx_amount, coinXInfo, timestamp, ctx.network)\n let coinXTotal = volumeByCoin.get(coinXInfo.token_type.type)\n if (!coinXTotal) {\n coinXTotal = resultX\n } else {\n coinXTotal = coinXTotal.plus(resultX)\n }\n volumeByCoin.set(coinXInfo.token_type.type, coinXTotal)\n }\n if (whitelisty) {\n resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network)\n let coinYTotal = volumeByCoin.get(coinYInfo.token_type.type)\n if (!coinYTotal) {\n coinYTotal = resultY\n } else {\n coinYTotal = coinYTotal.plus(resultY)\n }\n volumeByCoin.set(coinYInfo.token_type.type, coinYTotal)\n }\n\n if (resultX.eq(0)) {\n resultX = BigDecimal(resultY)\n }\n if (resultY.eq(0)) {\n resultY = BigDecimal(resultX)\n }\n\n const poolValue = resultX.plus(resultY)\n\n if (poolValue.isGreaterThan(0)) {\n this.tvlByPool.record(ctx, poolValue, baseLabels)\n }\n tvlAllValue = tvlAllValue.plus(poolValue)\n }\n this.tvlAll.record(ctx, tvlAllValue)\n\n if (poolsHandler) {\n poolsHandler(pools)\n }\n\n for (const [k, v] of volumeByCoin) {\n const coinInfo = this.coinList.whitelistCoins().get(k)\n if (!coinInfo) {\n throw Error('unexpected coin ' + k)\n }\n // const price = await getPrice(coinInfo, timestamp)\n // priceGauge.record(ctx, price, { coin: coinInfo.symbol })\n if (v.isGreaterThan(0)) {\n this.tvlByCoin.record(ctx, v, {\n coin: coinInfo.symbol,\n bridge: coinInfo.bridge,\n type: coinInfo.token_type.type\n })\n }\n }\n }\n\n async getPair(coinx: string, coiny: string): Promise<string> {\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n if (coinXInfo.symbol.localeCompare(coinYInfo.symbol) > 0) {\n return `${coinYInfo.symbol}-${coinXInfo.symbol}`\n }\n return `${coinXInfo.symbol}-${coinYInfo.symbol}`\n }\n}\n\nexport async function moveGetPairValue<Network, ContextType extends MoveAccountContext<Network, any, any>>(\n coinList: MoveCoinList<Network>,\n ctx: ContextType,\n coinx: string,\n coiny: string,\n coinXAmount: bigint,\n coinYAmount: bigint\n): Promise<BigDecimal> {\n const whitelistx = coinList.whiteListed(coinx)\n const whitelisty = coinList.whiteListed(coiny)\n const coinXInfo = await coinList.getCoinInfo(coinx)\n const coinYInfo = await coinList.getCoinInfo(coiny)\n const timestamp = ctx.getTimestamp()\n let result = BigDecimal(0.0)\n\n if (!whitelistx || !whitelisty) {\n return result\n }\n\n if (whitelistx) {\n const value = await coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network)\n result = value\n\n if (!whitelisty) {\n result = result.plus(value)\n }\n }\n if (whitelisty) {\n const value = await coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network)\n\n if (!whitelistx) {\n result = result.plus(value)\n }\n }\n\n return result\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './coin-list.js'\nexport * from './move-dex.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";wCAcC,OAAO,SAAc,EAAE,KAAMA,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC,ECU/C,IAAMC,EAAN,KAQL,CACA,SACA,YACA,OACA,aACA,OACA,UACA,UAEA,YACEC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,OAASL,EACd,KAAK,aAAeC,EACpB,KAAK,OAASC,EACd,KAAK,UAAYE,EACjB,KAAK,UAAYD,EACjB,KAAK,YAAcE,CACrB,CAEA,MAAM,oBACJC,EACAC,EACAC,EACAC,EACAC,EACAC,EACqB,CACrB,IAAIC,EAASC,EAAW,CAAC,EAEnBC,EAAa,KAAK,SAAS,YAAYP,CAAK,EAC5CQ,EAAa,KAAK,SAAS,YAAYP,CAAK,EAClD,GAAI,CAACM,GAAc,CAACC,EAClB,OAAOH,EAET,IAAMI,EAAY,MAAM,KAAK,SAAS,YAAYT,CAAK,EACjDU,EAAY,MAAM,KAAK,SAAS,YAAYT,CAAK,EACjDU,EAAYZ,EAAI,aAAa,EAC/Ba,EAAUN,EAAW,CAAC,EACtBO,EAAUP,EAAW,CAAC,EACpBQ,EAAO,MAAM,KAAK,QAAQd,EAAOC,CAAK,EACtCc,EAAqCX,EAAc,CAAE,GAAGA,EAAa,KAAAU,CAAK,EAAI,CAAE,KAAAA,CAAK,EACvFP,IACFK,EAAU,MAAM,KAAK,SAAS,oBAAoBV,EAAaO,EAAWE,EAAWZ,EAAI,OAAO,GAE9FS,IACFK,EAAU,MAAM,KAAK,SAAS,oBAAoBV,EAAaO,EAAWC,EAAWZ,EAAI,OAAO,GAE9Fa,EAAQ,GAAG,CAAC,IACdA,EAAUN,EAAWO,CAAO,GAE1BA,EAAQ,GAAG,CAAC,IAC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,KAAMA,EAAS,WAAW,IAC5B,CAAC,EAGP,CAEA,MAAM,QAAQ7B,EAAeC,EAAgC,CAC3D,IAAMQ,EAAY,MAAM,KAAK,SAAS,YAAYT,CAAK,EACjDU,EAAY,MAAM,KAAK,SAAS,YAAYT,CAAK,EACvD,OAAIQ,EAAU,OAAO,cAAcC,EAAU,MAAM,EAAI,EAC9C,GAAGA,EAAU,UAAUD,EAAU,SAEnC,GAAGA,EAAU,UAAUC,EAAU,QAC1C,CACF,EAEA,eAAsBoB,EACpBC,EACAhC,EACAC,EACAC,EACAC,EACAC,EACqB,CACrB,IAAMI,EAAawB,EAAS,YAAY/B,CAAK,EACvCQ,EAAauB,EAAS,YAAY9B,CAAK,EACvCQ,EAAY,MAAMsB,EAAS,YAAY/B,CAAK,EAC5CU,EAAY,MAAMqB,EAAS,YAAY9B,CAAK,EAC5CU,EAAYZ,EAAI,aAAa,EAC/BM,EAASC,EAAW,CAAG,EAE3B,GAAI,CAACC,GAAc,CAACC,EAClB,OAAOH,EAGT,GAAIE,EAAY,CACd,IAAMyB,EAAQ,MAAMD,EAAS,oBAAoB7B,EAAaO,EAAWE,EAAWZ,EAAI,OAAO,EAC/FM,EAAS2B,EAEJxB,IACHH,EAASA,EAAO,KAAK2B,CAAK,GAG9B,GAAIxB,EAAY,CACd,IAAMwB,EAAQ,MAAMD,EAAS,oBAAoB5B,EAAaO,EAAWC,EAAWZ,EAAI,OAAO,EAE1FQ,IACHF,EAASA,EAAO,KAAK2B,CAAK,GAI9B,OAAO3B,CACT,CACC,OAAO,SAAc,EAAE,KAAM4B,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC,EC/PrD,OAAO,SAAc,EAAE,KAAMC,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["p","MoveDex","volume","volumeByCoin","tvlAll","tvlByCoin","tvlByPool","poolAdaptor","ctx","coinx","coiny","coinXAmount","coinYAmount","extraLabels","result","BigDecimal","whitelistx","whitelisty","coinXInfo","coinYInfo","timestamp","resultX","resultY","pair","baseLabels","total","resources","poolsHandler","pools","tvlAllValue","pool","coinx_amount","coiny_amount","coinXTotal","coinYTotal","poolValue","k","v","coinInfo","moveGetPairValue","coinList","value","p","p"]}
|