@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
|
@@ -0,0 +1,3 @@
|
|
|
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,l){this.volume=o,this.volumeByCoin=t,this.tvlAll=i,this.tvlByPool=p,this.tvlByCoin=r,this.poolAdaptor=l}async recordTradingVolume(o,t,i,r,p,l){let u=c(0),a=this.coinList.whiteListed(t),g=this.coinList.whiteListed(i);if(!a&&!g)return u;let e=await this.coinList.getCoinInfo(t),n=await this.coinList.getCoinInfo(i),d=o.getTimestamp(),m=c(0),f=c(0),C=await this.getPair(t,i),v=l?{...l,pair:C}:{pair:C};a&&(m=await this.coinList.calculateValueInUsd(r,e,d,o.network)),g&&(f=await this.coinList.calculateValueInUsd(p,n,d,o.network)),m.eq(0)&&(m=c(f)),f.eq(0)&&(f=c(m));let w=m.plus(f);return w.gt(0)&&this.volume.record(o,w,{...v,bridge:e.bridge}),m.gt(0)&&this.volumeByCoin.record(o,m,{coin:e.symbol,bridge:e.bridge,type:e.type}),f.gt(0)&&this.volumeByCoin.record(o,f,{coin:n.symbol,bridge:n.bridge,type:n.type}),u=m.plus(f).div(2),u}async syncPools(o,t,i){let r=await t.coder.filterAndDecodeStruct(this.poolAdaptor.poolType,o),p=new Map,l=t.getTimestamp();console.log("num of pools: ",r.length,l);let u=c(0);for(let a of r){let g=a.type_arguments[0],e=a.type_arguments[1],n=this.coinList.whiteListed(g),d=this.coinList.whiteListed(e);if(!n&&!d)continue;let m=await this.getPair(g,e),C={...this.poolAdaptor.getExtraPoolTags(a),pair:m},v=await this.coinList.getCoinInfo(g),w=await this.coinList.getCoinInfo(e),k=this.poolAdaptor.getXReserve(a.data_decoded),L=this.poolAdaptor.getYReserve(a.data_decoded),T=c(0),h=c(0);if(n){T=await this.coinList.calculateValueInUsd(k,v,l,t.network);let y=p.get(v.type);y?y=y.plus(T):y=T,p.set(v.type,y)}if(d){h=await this.coinList.calculateValueInUsd(L,w,l,t.network);let y=p.get(w.type);y?y=y.plus(h):y=h,p.set(w.type,y)}T.eq(0)&&(T=c(h)),h.eq(0)&&(h=c(T));let b=T.plus(h);b.isGreaterThan(0)&&this.tvlByPool.record(t,b,C),u=u.plus(b)}this.tvlAll.record(t,u),i&&i(r);for(let[a,g]of p){let e=this.coinList.whitelistCoins().get(a);if(!e)throw Error("unexpected coin "+a);g.isGreaterThan(0)&&this.tvlByCoin.record(t,g,{coin:e.symbol,bridge:e.bridge,type:e.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 A(s,o,t,i,r,p){let l=s.whiteListed(t),u=s.whiteListed(i),a=await s.getCoinInfo(t),g=await s.getCoinInfo(i),e=o.getTimestamp(),n=c(0);if(!l||!u)return n;if(l){let d=await s.calculateValueInUsd(r,a,e,o.network);n=d,u||(n=n.plus(d))}if(u){let d=await s.calculateValueInUsd(p,g,e,o.network);l||(n=n.plus(d))}return n}import("process").then(s=>s.stdout.write(""));import("process").then(s=>s.stdout.write(""));export{I as a,A as b};
|
|
3
|
+
//# sourceMappingURL=chunk-VJEZ2ZJ5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/move/ext/coin.ts","../src/move/ext/move-dex.ts","../src/move/ext/index.ts"],"sourcesContent":["import { BigDecimal } from '@sentio/bigdecimal'\n\nexport interface BaseCoinInfo {\n // token_type: { type: string; account_address: string }\n type: string\n symbol: string\n hippo_symbol?: string\n decimals: number\n bridge: string\n}\n\nexport interface MoveCoinList<TokenType extends BaseCoinInfo, Network> {\n whiteListed(type: string): boolean\n whitelistCoins(): Map<string, TokenType>\n getCoinInfo(type: string): Promise<TokenType>\n calculateValueInUsd(amount: bigint, coinInfo: TokenType, timestamp: number, network: Network): 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, BaseCoinInfo } from './coin.js'\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 TokenType extends BaseCoinInfo,\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<TokenType, 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.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.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.type)\n if (!coinXTotal) {\n coinXTotal = resultX\n } else {\n coinXTotal = coinXTotal.plus(resultX)\n }\n volumeByCoin.set(coinXInfo.type, coinXTotal)\n }\n if (whitelisty) {\n resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network)\n let coinYTotal = volumeByCoin.get(coinYInfo.type)\n if (!coinYTotal) {\n coinYTotal = resultY\n } else {\n coinYTotal = coinYTotal.plus(resultY)\n }\n volumeByCoin.set(coinYInfo.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.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<\n TokenType extends BaseCoinInfo,\n Network,\n ContextType extends MoveAccountContext<Network, any, any>\n>(\n coinList: MoveCoinList<TokenType, 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.js'\nexport * from './move-dex.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";wCAiBC,OAAO,SAAc,EAAE,KAAMA,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC,ECD/C,IAAMC,EAAN,KASL,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,EA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,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,EC5PrD,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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BigDecimal } from '@sentio/bigdecimal';
|
|
2
|
+
export interface BaseCoinInfo {
|
|
3
|
+
type: string;
|
|
4
|
+
symbol: string;
|
|
5
|
+
hippo_symbol?: string;
|
|
6
|
+
decimals: number;
|
|
7
|
+
bridge: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MoveCoinList<TokenType extends BaseCoinInfo, Network> {
|
|
10
|
+
whiteListed(type: string): boolean;
|
|
11
|
+
whitelistCoins(): Map<string, TokenType>;
|
|
12
|
+
getCoinInfo(type: string): Promise<TokenType>;
|
|
13
|
+
calculateValueInUsd(amount: bigint, coinInfo: TokenType, timestamp: number, network: Network): Promise<BigDecimal>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=coin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/move/ext/coin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,MAAM,WAAW,YAAY;IAE3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,YAAY,EAAE,OAAO;IACnE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAClC,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACxC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAC7C,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACnH"}
|
package/lib/move/ext/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/move/ext/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/move/ext/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA"}
|
package/lib/move/ext/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a,b}from"../../chunk-
|
|
2
|
+
import{a,b}from"../../chunk-VJEZ2ZJ5.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";export{a as MoveDex,b as moveGetPairValue};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,25 +2,15 @@ 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
|
-
export interface SimpleCoinInfo {
|
|
7
|
-
token_type: {
|
|
8
|
-
type: string;
|
|
9
|
-
account_address: string;
|
|
10
|
-
};
|
|
11
|
-
symbol: string;
|
|
12
|
-
hippo_symbol?: string;
|
|
13
|
-
decimals: number;
|
|
14
|
-
bridge: string;
|
|
15
|
-
}
|
|
5
|
+
import { MoveCoinList, BaseCoinInfo } from './coin.js';
|
|
16
6
|
export interface MovePoolAdaptor<StructType, T> {
|
|
17
7
|
getXReserve(pool: T): bigint;
|
|
18
8
|
getYReserve(pool: T): bigint;
|
|
19
9
|
getExtraPoolTags(pool: DecodedStruct<StructType, T>): any;
|
|
20
10
|
poolType: TypeDescriptor<T>;
|
|
21
11
|
}
|
|
22
|
-
export declare class MoveDex<Network, ModuleType, StructType, EventType, ContextType extends MoveContext<Network, ModuleType, StructType | EventType>, AccountContextType extends MoveAccountContext<Network, ModuleType, StructType | EventType>, T> {
|
|
23
|
-
coinList: MoveCoinList<Network>;
|
|
12
|
+
export declare class MoveDex<TokenType extends BaseCoinInfo, Network, ModuleType, StructType, EventType, ContextType extends MoveContext<Network, ModuleType, StructType | EventType>, AccountContextType extends MoveAccountContext<Network, ModuleType, StructType | EventType>, T> {
|
|
13
|
+
coinList: MoveCoinList<TokenType, Network>;
|
|
24
14
|
poolAdaptor: MovePoolAdaptor<StructType, T>;
|
|
25
15
|
volume: Gauge;
|
|
26
16
|
volumeByCoin: Gauge;
|
|
@@ -32,5 +22,5 @@ export declare class MoveDex<Network, ModuleType, StructType, EventType, Context
|
|
|
32
22
|
syncPools(resources: StructType[], ctx: AccountContextType, poolsHandler?: (pools: DecodedStruct<StructType, T>[]) => Promise<void> | void): Promise<void>;
|
|
33
23
|
getPair(coinx: string, coiny: string): Promise<string>;
|
|
34
24
|
}
|
|
35
|
-
export declare function moveGetPairValue<Network, ContextType extends MoveAccountContext<Network, any, any>>(coinList: MoveCoinList<Network>, ctx: ContextType, coinx: string, coiny: string, coinXAmount: bigint, coinYAmount: bigint): Promise<BigDecimal>;
|
|
25
|
+
export declare function moveGetPairValue<TokenType extends BaseCoinInfo, Network, ContextType extends MoveAccountContext<Network, any, any>>(coinList: MoveCoinList<TokenType, Network>, ctx: ContextType, coinx: string, coiny: string, coinXAmount: bigint, coinYAmount: bigint): Promise<BigDecimal>;
|
|
36
26
|
//# sourceMappingURL=move-dex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-dex.d.ts","sourceRoot":"","sources":["../../../src/move/ext/move-dex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"move-dex.d.ts","sourceRoot":"","sources":["../../../src/move/ext/move-dex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,WAAW,E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ACnB,WAAW,CAAC,EAAE,GAAG,GAChB,OAAO,CAAC,UAAU,CAAC;IAoDhB,SAAS,CACb,SAAS,EAAE,UAAU,EAAE,EACvB,GAAG,EAAE,kBAAkB,EACvB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IA2F1E,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ7D;AAED,wBAAsB,gBAAgB,CACpC,SAAS,SAAS,YAAY,EAC9B,OAAO,EACP,WAAW,SAAS,kBAAkB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,EAEzD,QAAQ,EAAE,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,EAC1C,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CA6BrB"}
|
package/lib/sui/builtin/0x1.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g,h}from"../../chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h}from"../../chunk-JCUSXGHB.js";import"../../chunk-DR4NZAPM.js";import"../../chunk-5VBGX3LN.js";import"../../chunk-KRL7DRXT.js";import"../../chunk-B7YDBLBV.js";import"../../chunk-44SAPBRK.js";import"../../chunk-P73GOPCF.js";import"../../chunk-6GMS6XU7.js";import"../../chunk-RVQBDYQ2.js";import"../../chunk-W4OBSPHA.js";import"../../chunk-RVK3H6V4.js";import"../../chunk-6VELGYNR.js";import"../../chunk-YX4LDK5Y.js";import"../../chunk-F7Q5QB6Q.js";import"../../chunk-OUOSDGWD.js";import"../../chunk-QW2MPHP5.js";import"../../chunk-24SCJPBI.js";import"../../chunk-GU4UN43Q.js";import"../../chunk-CA6DKOT2.js";import"../../chunk-NDC6HDQD.js";import"../../chunk-WZLM66YL.js";import"../../chunk-2BO4GGPL.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";export{a as ascii,b as bit_vector,c as fixed_point32,h as loadAllTypes,d as option,e as string_,f as type_name,g as uq32_32};
|
|
3
3
|
//# sourceMappingURL=0x1.js.map
|
package/lib/sui/builtin/0x2.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../chunk-
|
|
2
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../chunk-DOTKHTBG.js";import"../../chunk-JCUSXGHB.js";import"../../chunk-DR4NZAPM.js";import"../../chunk-5VBGX3LN.js";import"../../chunk-KRL7DRXT.js";import"../../chunk-B7YDBLBV.js";import"../../chunk-44SAPBRK.js";import"../../chunk-P73GOPCF.js";import"../../chunk-6GMS6XU7.js";import"../../chunk-RVQBDYQ2.js";import"../../chunk-W4OBSPHA.js";import"../../chunk-RVK3H6V4.js";import"../../chunk-6VELGYNR.js";import"../../chunk-YX4LDK5Y.js";import"../../chunk-F7Q5QB6Q.js";import"../../chunk-OUOSDGWD.js";import"../../chunk-QW2MPHP5.js";import"../../chunk-24SCJPBI.js";import"../../chunk-GU4UN43Q.js";import"../../chunk-CA6DKOT2.js";import"../../chunk-NDC6HDQD.js";import"../../chunk-WZLM66YL.js";import"../../chunk-2BO4GGPL.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";export{a as authenticator_state,b as bag,c as balance,d as bcs,e as bls12381,f as borrow,g as clock,h as coin,i as config,j as deny_list,k as display,l as dynamic_field,m as dynamic_object_field,n as groth16,o as group_ops,p as kiosk,q as kiosk_extension,r as linked_table,M as loadAllTypes,s as object_,t as object_bag,u as object_table,v as package_,w as pay,x as priority_queue,y as random,z as sui,A as table,B as table_vec,C as token,D as transfer,E as transfer_policy,F as tx_context,G as url,H as vec_map,I as vec_set,J as versioned,K as zklogin_verified_id,L as zklogin_verified_issuer};
|
|
3
3
|
//# sourceMappingURL=0x2.js.map
|
package/lib/sui/builtin/0x3.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l}from"../../chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"../../chunk-G2KR5VKV.js";import"../../chunk-DOTKHTBG.js";import"../../chunk-JCUSXGHB.js";import"../../chunk-DR4NZAPM.js";import"../../chunk-5VBGX3LN.js";import"../../chunk-KRL7DRXT.js";import"../../chunk-B7YDBLBV.js";import"../../chunk-44SAPBRK.js";import"../../chunk-P73GOPCF.js";import"../../chunk-6GMS6XU7.js";import"../../chunk-RVQBDYQ2.js";import"../../chunk-W4OBSPHA.js";import"../../chunk-RVK3H6V4.js";import"../../chunk-6VELGYNR.js";import"../../chunk-YX4LDK5Y.js";import"../../chunk-F7Q5QB6Q.js";import"../../chunk-OUOSDGWD.js";import"../../chunk-QW2MPHP5.js";import"../../chunk-24SCJPBI.js";import"../../chunk-GU4UN43Q.js";import"../../chunk-CA6DKOT2.js";import"../../chunk-NDC6HDQD.js";import"../../chunk-WZLM66YL.js";import"../../chunk-2BO4GGPL.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";export{a as genesis,l as loadAllTypes,b as stake_subsidy,c as staking_pool,d as storage_fund,e as sui_system,f as sui_system_state_inner,g as validator,h as validator_cap,i as validator_set,j as validator_wrapper,k as voting_power};
|
|
3
3
|
//# sourceMappingURL=0x3.js.map
|
package/lib/sui/builtin/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{m as x}from"../../chunk-
|
|
2
|
+
import{m as x}from"../../chunk-G2KR5VKV.js";import{N as t}from"../../chunk-DOTKHTBG.js";import{i as r}from"../../chunk-JCUSXGHB.js";import"../../chunk-DR4NZAPM.js";import"../../chunk-5VBGX3LN.js";import"../../chunk-KRL7DRXT.js";import"../../chunk-B7YDBLBV.js";import"../../chunk-44SAPBRK.js";import"../../chunk-P73GOPCF.js";import"../../chunk-6GMS6XU7.js";import"../../chunk-RVQBDYQ2.js";import"../../chunk-W4OBSPHA.js";import"../../chunk-RVK3H6V4.js";import"../../chunk-6VELGYNR.js";import"../../chunk-YX4LDK5Y.js";import"../../chunk-F7Q5QB6Q.js";import"../../chunk-OUOSDGWD.js";import"../../chunk-QW2MPHP5.js";import"../../chunk-24SCJPBI.js";import"../../chunk-GU4UN43Q.js";import"../../chunk-CA6DKOT2.js";import"../../chunk-NDC6HDQD.js";import"../../chunk-WZLM66YL.js";import"../../chunk-2BO4GGPL.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";import("process").then(o=>o.stdout.write(""));export{r as _0x1,t as _0x2,x as _0x3};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/sui/ext/coin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCoinInfo } from '../../move/ext/index.js';
|
|
2
2
|
import { SuiNetwork } from '../network.js';
|
|
3
3
|
export declare function initCoinList(): Promise<void>;
|
|
4
4
|
export interface SuiCoinInfo {
|
|
@@ -8,10 +8,10 @@ export interface SuiCoinInfo {
|
|
|
8
8
|
name: string;
|
|
9
9
|
decimals: number;
|
|
10
10
|
}
|
|
11
|
-
export declare function whitelistCoins(): Map<string,
|
|
11
|
+
export declare function whitelistCoins(): Map<string, BaseCoinInfo>;
|
|
12
12
|
export declare function whiteListed(coin: string): boolean;
|
|
13
|
-
export declare function getCoinInfo(type: string):
|
|
14
|
-
export declare function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<
|
|
13
|
+
export declare function getCoinInfo(type: string): BaseCoinInfo;
|
|
14
|
+
export declare function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<BaseCoinInfo>;
|
|
15
15
|
export declare function getPrice(coinType: string, timestamp: number): Promise<number>;
|
|
16
|
-
export declare function calculateValueInUsd(n: bigint, coinInfo:
|
|
16
|
+
export declare function calculateValueInUsd(n: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise<import("@sentio/bigdecimal").BigDecimal>;
|
|
17
17
|
//# sourceMappingURL=coin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/sui/ext/coin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/sui/ext/coin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAMtD,OAAO,EAAa,UAAU,EAAE,MAAM,eAAe,CAAA;AAKrD,wBAAsB,YAAY,kBAUjC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB;AA6BD,wBAAgB,cAAc,8BAE7B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAatD;AAID,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAyBvG;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWnF;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oDAI7F"}
|
package/lib/sui/ext/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as l,b as m}from"../../chunk-VJEZ2ZJ5.js";import{a as f,b as n,c as s,d as a,e as C,f as S,g as u}from"../../chunk-5VBGX3LN.js";import"../../chunk-B7YDBLBV.js";import"../../chunk-44SAPBRK.js";import"../../chunk-P73GOPCF.js";import"../../chunk-RVQBDYQ2.js";import"../../chunk-W4OBSPHA.js";import"../../chunk-RVK3H6V4.js";import"../../chunk-6VELGYNR.js";import"../../chunk-YX4LDK5Y.js";import"../../chunk-F7Q5QB6Q.js";import"../../chunk-OUOSDGWD.js";import"../../chunk-QW2MPHP5.js";import"../../chunk-24SCJPBI.js";import"../../chunk-GU4UN43Q.js";import"../../chunk-CA6DKOT2.js";import"../../chunk-NDC6HDQD.js";import"../../chunk-WZLM66YL.js";import"../../chunk-2BO4GGPL.js";import"../../chunk-FC546GTB.js";import"../../chunk-6GD6B22G.js";var r=class{calculateValueInUsd(t,e,i){return u(t,e,i)}async getCoinInfo(t){return a(t)}whiteListed(t){return s(t)}whitelistCoins(){return n()}},c=new r,p=class extends l{coinList=c};async function w(o,t,e,i,d){return m(c,o,t,e,i,d)}import("process").then(o=>o.stdout.write(""));import("process").then(o=>o.stdout.write(""));export{r as CoinList,c as SuiCoinList,p as SuiDex,u as calculateValueInUsd,a as getCoinInfo,C as getCoinInfoWithFallback,w as getPairValue,S as getPrice,f as initCoinList,s as whiteListed,n as whitelistCoins};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/sui/ext/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/sui/ext/move-dex.ts","../../../src/sui/ext/index.ts"],"sourcesContent":["import { BigDecimal } from '@sentio/bigdecimal'\nimport { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'\nimport { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor,
|
|
1
|
+
{"version":3,"sources":["../../../src/sui/ext/move-dex.ts","../../../src/sui/ext/index.ts"],"sourcesContent":["import { BigDecimal } from '@sentio/bigdecimal'\nimport { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'\nimport { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, BaseCoinInfo } from '../../move/ext/index.js'\nimport { SuiEvent, SuiMoveNormalizedModule, SuiMoveObject } from '@mysten/sui/client'\nimport { SuiNetwork } from '../network.js'\nimport { SuiContext, SuiObjectContext } from '../context.js'\n\nexport type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>\n\nexport class CoinList implements MoveCoinList<BaseCoinInfo, SuiNetwork> {\n calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise<BigDecimal> {\n return calculateValueInUsd(amount, coinInfo, timestamp)\n }\n\n async getCoinInfo(type: string) {\n return getCoinInfo(type)\n }\n\n whiteListed(type: string): boolean {\n return whiteListed(type)\n }\n\n whitelistCoins(): Map<string, BaseCoinInfo> {\n return whitelistCoins()\n }\n}\n\nexport const SuiCoinList = new CoinList()\n\nexport class SuiDex<T> extends MoveDex<\n BaseCoinInfo,\n SuiNetwork,\n SuiMoveNormalizedModule,\n SuiMoveObject,\n SuiEvent,\n SuiContext,\n SuiObjectContext,\n T\n> {\n coinList = SuiCoinList\n declare poolAdaptor: PoolAdaptor<T>\n}\n\nexport async function getPairValue(\n ctx: SuiContext,\n coinx: string,\n coiny: string,\n coinXAmount: bigint,\n coinYAmount: bigint\n): Promise<BigDecimal> {\n return moveGetPairValue(SuiCoinList, ctx, coinx, coiny, coinXAmount, coinYAmount)\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './coin.js'\nexport * from './move-dex.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";yuBASO,IAAMA,EAAN,KAAiE,CACtE,oBAAoBC,EAAgBC,EAAwBC,EAAwC,CAClG,OAAOC,EAAoBH,EAAQC,EAAUC,CAAS,CACxD,CAEA,MAAM,YAAYE,EAAc,CAC9B,OAAOC,EAAYD,CAAI,CACzB,CAEA,YAAYA,EAAuB,CACjC,OAAOE,EAAYF,CAAI,CACzB,CAEA,gBAA4C,CAC1C,OAAOG,EAAe,CACxB,CACF,EAEaC,EAAc,IAAIT,EAElBU,EAAN,cAAwBC,CAS7B,CACA,SAAWF,CAEb,EAEA,eAAsBG,EACpBC,EACAC,EACAC,EACAC,EACAC,EACqB,CACrB,OAAOC,EAAiBT,EAAaI,EAAKC,EAAOC,EAAOC,EAAaC,CAAW,CAClF,CACC,OAAO,SAAc,EAAE,KAAME,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC,EClDrD,OAAO,SAAc,EAAE,KAAMC,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["CoinList","amount","coinInfo","timestamp","calculateValueInUsd","type","getCoinInfo","whiteListed","whitelistCoins","SuiCoinList","SuiDex","MoveDex","getPairValue","ctx","coinx","coiny","coinXAmount","coinYAmount","moveGetPairValue","p","p"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BigDecimal } from '@sentio/bigdecimal';
|
|
2
|
-
import { MoveCoinList, MoveDex, MovePoolAdaptor,
|
|
2
|
+
import { MoveCoinList, MoveDex, MovePoolAdaptor, BaseCoinInfo } from '../../move/ext/index.js';
|
|
3
3
|
import { SuiEvent, SuiMoveNormalizedModule, SuiMoveObject } from '@mysten/sui/client';
|
|
4
4
|
import { SuiNetwork } from '../network.js';
|
|
5
5
|
import { SuiContext, SuiObjectContext } from '../context.js';
|
|
6
6
|
export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>;
|
|
7
|
-
export declare class CoinList implements MoveCoinList<SuiNetwork> {
|
|
8
|
-
calculateValueInUsd(amount: bigint, coinInfo:
|
|
9
|
-
getCoinInfo(type: string):
|
|
7
|
+
export declare class CoinList implements MoveCoinList<BaseCoinInfo, SuiNetwork> {
|
|
8
|
+
calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise<BigDecimal>;
|
|
9
|
+
getCoinInfo(type: string): Promise<BaseCoinInfo>;
|
|
10
10
|
whiteListed(type: string): boolean;
|
|
11
|
-
whitelistCoins(): Map<string,
|
|
11
|
+
whitelistCoins(): Map<string, BaseCoinInfo>;
|
|
12
12
|
}
|
|
13
13
|
export declare const SuiCoinList: CoinList;
|
|
14
|
-
export declare class SuiDex<T> extends MoveDex<SuiNetwork, SuiMoveNormalizedModule, SuiMoveObject, SuiEvent, SuiContext, SuiObjectContext, T> {
|
|
14
|
+
export declare class SuiDex<T> extends MoveDex<BaseCoinInfo, SuiNetwork, SuiMoveNormalizedModule, SuiMoveObject, SuiEvent, SuiContext, SuiObjectContext, T> {
|
|
15
15
|
coinList: CoinList;
|
|
16
16
|
poolAdaptor: PoolAdaptor<T>;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-dex.d.ts","sourceRoot":"","sources":["../../../src/sui/ext/move-dex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAoB,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"move-dex.d.ts","sourceRoot":"","sources":["../../../src/sui/ext/move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 -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a as e,b as f,c as g,d as h,e as i,f as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t}from"../chunk-
|
|
2
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t}from"../chunk-DR4NZAPM.js";import"../chunk-5VBGX3LN.js";import"../chunk-KRL7DRXT.js";import{e as b,f as c,g as d}from"../chunk-B7YDBLBV.js";import"../chunk-44SAPBRK.js";import"../chunk-P73GOPCF.js";import"../chunk-6GMS6XU7.js";import"../chunk-RVQBDYQ2.js";import"../chunk-W4OBSPHA.js";import{q as a}from"../chunk-RVK3H6V4.js";import"../chunk-6VELGYNR.js";import"../chunk-YX4LDK5Y.js";import"../chunk-F7Q5QB6Q.js";import"../chunk-OUOSDGWD.js";import"../chunk-QW2MPHP5.js";import"../chunk-24SCJPBI.js";import"../chunk-GU4UN43Q.js";import"../chunk-CA6DKOT2.js";import"../chunk-NDC6HDQD.js";import"../chunk-WZLM66YL.js";import"../chunk-2BO4GGPL.js";import"../chunk-FC546GTB.js";import"../chunk-6GD6B22G.js";export{a as BUILTIN_TYPES,e as MoveCoder,i as SuiAddressContext,n as SuiAddressProcessor,q as SuiAddressProcessorTemplate,k as SuiBaseProcessor,g as SuiContext,m as SuiGlobalProcessor,l as SuiModulesProcessor,b as SuiNetwork,h as SuiObjectChangeContext,j as SuiObjectContext,o as SuiObjectProcessor,r as SuiObjectProcessorTemplate,t as SuiPlugin,p as SuiWrappedObjectProcessor,s as SuiWrappedObjectProcessorTemplate,f as defaultMoveCoder,c as getClient,d as getRpcEndpoint};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/testing/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{b as F}from"../chunk-HDNVG6V3.js";import"../chunk-E2QT6K2E.js";import{g as _}from"../chunk-VSUZQA42.js";import"../chunk-5WK73P5V.js";import"../chunk-KRL7DRXT.js";import{e as g}from"../chunk-B7YDBLBV.js";import"../chunk-ZA6TPCBF.js";import{c as T}from"../chunk-CVQ72H2U.js";import"../chunk-7K2CQ73Y.js";import"../chunk-KUHMQRSY.js";import"../chunk-JLRCAHLL.js";import"../chunk-44SAPBRK.js";import"../chunk-P73GOPCF.js";import"../chunk-6GMS6XU7.js";import{b as M}from"../chunk-RVQBDYQ2.js";import"../chunk-WQ7UQGQE.js";import"../chunk-W4OBSPHA.js";import{a as D,d as u,n as E}from"../chunk-RVK3H6V4.js";import"../chunk-6VELGYNR.js";import"../chunk-YX4LDK5Y.js";import"../chunk-F7Q5QB6Q.js";import"../chunk-OUOSDGWD.js";import{a as m}from"../chunk-QW2MPHP5.js";import{D as a}from"../chunk-24SCJPBI.js";import"../chunk-GU4UN43Q.js";import"../chunk-CA6DKOT2.js";import"../chunk-NDC6HDQD.js";import"../chunk-WZLM66YL.js";import"../chunk-2BO4GGPL.js";import{a as L}from"../chunk-FC546GTB.js";import{e as h}from"../chunk-6GD6B22G.js";var U=h(m(),1);import{Endpoints as q,ProcessorServiceImpl as G,State as j}from"@sentio/runtime";var I=class{server;constructor(t){this.server=t}testEntryFunctionCall(t,e=T.MAIN_NET){return this.testEntryFunctionCalls([t],e)}testEntryFunctionCalls(t,e=T.MAIN_NET){let n=[];for(let r of t){let o=this.buildEntryFunctionCallBinding(r,e);if(!o)throw Error("Invalid test transaction: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildEntryFunctionCallBinding(t,e=T.MAIN_NET){let n=t.payload;for(let r of this.server.contractConfigs)if(r.contract?.chainId===e){for(let o of r.moveCallConfigs)for(let i of o.filters)if(u(r.contract.address)+"::"+i.function===n.function)return{data:{aptCall:{transaction:t}},handlerIds:[o.handlerId],handlerType:a.APT_CALL}}}testEvent(t,e=T.MAIN_NET){let n=this.buildEventBinding(t,e);if(!n)throw Error("Invalid test event: "+JSON.stringify(t));return this.server.processBinding(n)}buildEventBinding(t,e=T.MAIN_NET){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e){for(let r of n.moveEventConfigs)for(let o of r.filters)for(let i of t.events)if(u(n.contract.address)+"::"+o.type===E(i.type).qname)return{data:{aptEvent:{transaction:t}},handlerIds:[r.handlerId],handlerType:a.APT_EVENT}}}};import("process").then(s=>s.stdout.write(""));var v=class{server;constructor(t){this.server=t}testInstructions(t){return this.server.processBindings({bindings:t.map(e=>({data:{raw:new Uint8Array,solInstruction:e},handlerIds:[],handlerType:a.SOL_INSTRUCTION}))})}};import("process").then(s=>s.stdout.write(""));var f=h(m(),1),B=class{server;constructor(t){this.server=t}testTrace(t,e=f.EthChainId.ETHEREUM){return this.testTraces([t],e)}testTraces(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildTraceBinding(r,e);if(!o)throw Error("Invalid test trace: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildTraceBinding(t,e=f.EthChainId.ETHEREUM){if(t.type!=="call"||!t.action.input)throw Error("Invalid test trace: "+JSON.stringify(t));let n=t.action.input.slice(0,10);for(let r of this.server.contractConfigs)if(r.contract?.chainId===e&&!(t.action.to?.toLowerCase()!==r.contract?.address.toLowerCase()&&r.contract?.address!=="*")){for(let o of r.traceConfigs)if(o.signature==n)return{data:{ethTrace:{trace:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.ETH_TRACE}}}testLog(t,e=f.EthChainId.ETHEREUM){return this.testLogs([t],e)}testLogs(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildLogBinding(r,e);if(!o)throw Error("Invalid test log: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildLogBinding(t,e=f.EthChainId.ETHEREUM){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e&&!(t.address.toLowerCase()!==n.contract?.address.toLowerCase()&&n.contract?.address!=="*"))for(let r of n.logConfigs)for(let o of r.filters){let i=!0;for(let c in o.topics){let d=t.topics[c],l=o.topics[c].hashes;if(l.length!==0&&!l.find(p=>p.toLowerCase()===d.toLowerCase())){i=!1;break}}if(i)return{data:{ethLog:{log:t,timestamp:new Date}},handlerIds:[r.handlerId],handlerType:a.ETH_LOG}}}testAccountLog(t,e,n=f.EthChainId.ETHEREUM){return this.testAccountLogs(t,[e],n)}testAccountLogs(t,e,n=f.EthChainId.ETHEREUM){let r=[];for(let o of e){let i=this.buildAccountLogBinding(t,o,n);if(!i)throw Error("Invalid test log: "+JSON.stringify(o));r.push(i)}return this.server.processBindings({bindings:r})}buildAccountLogBinding(t,e,n=f.EthChainId.ETHEREUM){for(let r of this.server.accountConfigs)if(r.chainId===n&&t.toLowerCase()===r.address.toLowerCase())for(let o of r.logConfigs)for(let i of o.filters){let c=!0;for(let d in i.topics){let l=e.topics[d],p=i.topics[d].hashes;if(p.length!==0&&!p.find(w=>w.toLowerCase()===l.toLowerCase())){c=!1;break}}if(c)return{data:{ethLog:{log:e,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.ETH_LOG}}}testBlock(t,e=f.EthChainId.ETHEREUM){return this.testBlocks([t],e)}testBlocks(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildBlockBinding(r,e);if(!o)throw Error("Invalid test block: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildBlockBinding(t,e=f.EthChainId.ETHEREUM){let n={data:{ethBlock:{block:t}},handlerType:a.ETH_BLOCK,handlerIds:[]};for(let r of this.server.contractConfigs){if(r.contract?.chainId!==e)continue;let o=t.number;if(!(o<r.startBlock)&&!(r.endBlock!==0n&&o>=r.endBlock))for(let i of r.intervalConfigs)n.handlerIds.push(i.handlerId)}return n}};import("process").then(s=>s.stdout.write(""));var S=class{server;constructor(t){this.server=t}testEntryFunctionCall(t,e=g.MAIN_NET){return this.testEntryFunctionCalls([t],e)}testEntryFunctionCalls(t,e=g.MAIN_NET){let n=[];for(let r of t){let o=this.buildEntryFunctionCallBinding(r,e);if(!o)throw Error("Invalid test transaction: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildEntryFunctionCallBinding(t,e=g.MAIN_NET){let n=_(t);for(let r of n){let o=[u(r.package),r.module,r.function].join(D);for(let i of this.server.contractConfigs)if(i.contract?.chainId===e){for(let c of i.moveCallConfigs)for(let d of c.filters)if(u(i.contract.address)+"::"+d.function===o)return{data:{suiCall:{transaction:t,timestamp:new Date,slot:10000n}},handlerIds:[c.handlerId],handlerType:a.SUI_CALL}}}}testEvent(t,e=g.MAIN_NET){let n=this.buildEventBinding(t,e);if(!n)throw Error("Invalid test event: "+JSON.stringify(t));return this.server.processBinding(n)}testGlobalTransaction(t,e=g.MAIN_NET){let n=[];for(let o of this.server.contractConfigs)if(o.contract?.address==="*")for(let i of o.moveCallConfigs)i.filters.length===1&&i.filters[0].function===""&&n.push(i.handlerId);if(n.length===0)throw Error("Invalid test global transaction: "+JSON.stringify(t));let r={handlerIds:n,handlerType:a.SUI_CALL,data:{suiCall:{transaction:t,timestamp:t.timestampMs?new Date(t.timestampMs):new Date,slot:BigInt(t.checkpoint||0)}}};return this.server.processBinding(r)}buildEventBinding(t,e=g.MAIN_NET){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e){for(let r of n.moveEventConfigs)for(let o of r.filters)for(let i of t.events||[])if(u(n.contract.address)+"::"+o.type===E(i.type).qname)return{data:{suiEvent:{transaction:t,timestamp:new Date(t.timestampMs||0),slot:10000n}},handlerIds:[r.handlerId],handlerType:a.SUI_EVENT}}}};import("process").then(s=>s.stdout.write(""));var N=class{server;constructor(t){this.server=t}testOnTransaction(t,e=F.TEST_NET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test transaction: "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e){for(let o of r.fuelCallConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL},c=o.filters[0]?.function;if(c)for(let d of t.status.receipts||[])d.receiptType=="CALL"&&d.param1==c&&n.push(i);else n.push(i)}for(let o of r.fuelLogConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL},c=o.logIds;for(let d of t.status.receipts||[])if((d.receiptType=="LOG"||d.receiptType=="LOG_DATA")&&c.includes(d.rb)){n.push(i);break}}for(let o of r.assetConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL};n.push(i)}}return n}};import("process").then(s=>s.stdout.write(""));var R=h(m(),1),x={INJECTIVE_MAINNET:R.CosmosChainId.INJECTIVE_MAINNET,INJECTIVE_TESTNET:R.CosmosChainId.INJECTIVE_TESTNET};import("process").then(s=>s.stdout.write(""));var P=class{server;constructor(t){this.server=t}testOnTransaction(t,e=x.INJECTIVE_TESTNET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test transaction: "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e)for(let o of r.cosmosLogConfigs){let i={data:{cosmosCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.COSMOS_CALL},c=o.logFilters;for(let d of t.logs||[])if(d.events.find(l=>c.includes(l.type))){n.push(i);break}}return n}};import("process").then(s=>s.stdout.write(""));var O=h(m(),1),y=class{server;constructor(t){this.server=t}testOnEvents(t,e=O.StarknetChainId.STARKNET_SEPOLIA){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test : "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[],r=Array.isArray(t)?t:[t];for(let o of r)for(let i of this.server.contractConfigs)if(i.contract?.chainId===e)for(let c of i.starknetEventConfigs){let d={data:{starknetEvents:{result:o,timestamp:new Date}},handlerIds:[c.handlerId],handlerType:a.STARKNET_EVENT},l=c.filters,p=o.keys;for(let w of p)for(let J of l)if(J.keys.includes(w))return n.push(d),n}return n}};import("process").then(s=>s.stdout.write(""));var H=h(m(),1);var b=class{server;constructor(t){this.server=t}testOnTransactions(t,e=H.BTCChainId.BTC_TESTNET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test : "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e)for(let o of r.btcTransactionConfigs){let i={data:{btcTransaction:t},handlerIds:[o.handlerId],handlerType:a.BTC_TRANSACTION};n.push(i)}return n}};import("process").then(s=>s.stdout.write(""));var C={};function K(){j.reset()}var k=class{service;contractConfigs;accountConfigs;aptos;eth;solana;sui;fuel;cosmos;starknet;btc;constructor(t,e={}){K(),this.service=new G(t),this.aptos=new I(this),this.solana=new v(this),this.eth=new B(this),this.sui=new S(this),this.fuel=new N(this),this.cosmos=new P(this),this.starknet=new y(this),this.btc=new b(this);for(let n in U.CHAIN_MAP){let r=e[n]||"";q.INSTANCE.chainServer.set(n,r)}}async start(t={templateInstances:[]},e=C){let n=await this.service.start(t,e),r=await this.getConfig({});return this.contractConfigs=r.contractConfigs,this.accountConfigs=r.accountConfigs,n}stop(t,e=C){return this.service.stop(t,e)}getConfig(t,e=C){return this.service.getConfig(t,e)}processBindings(t,e=C){return this.service.processBindings(t,e)}processBinding(t,e=C){return this.service.processBindings({bindings:[t]},e)}processBindingsStream(t,e){throw new Error("Method not implemented.")}preprocessBindingsStream(t,e){throw new Error("Method not implemented.")}};import("process").then(s=>s.stdout.write(""));function A(s){if(s!==void 0){if(s.doubleValue!==void 0)return s.doubleValue;if(s.bigInteger!==void 0){let t=M(s.bigInteger.data);return s.bigInteger.negative&&(t=-t),t}if(s.bigDecimal!==void 0)return new L(s.bigDecimal)}}function X(s,t){if(s){for(let e of s.counters)if(e.metadata?.name===t)return A(e.metricValue)}}function z(s,t){if(s){for(let e of s.gauges)if(e.metadata?.name===t)return A(e.metricValue)}}import("process").then(s=>s.stdout.write(""));var V=h(m(),1);import{Endpoints as Q}from"@sentio/runtime";function W(s){let t=[];Array.isArray(s)||(s=[s]);for(let e of Object.keys(V.CHAIN_MAP)){let n="TEST_ENDPOINT_"+e,r=process.env[n];r&&(t.push(e),Q.INSTANCE.chainServer.set(e,r))}for(let e of s)if(!t.includes(e))return!1;return!0}import("process").then(s=>s.stdout.write(""));import("process").then(s=>s.stdout.write(""));export{A as MetricValueToNumber,k as TestProcessorServer,X as firstCounterValue,z as firstGaugeValue,W as loadTestProvidersFromEnv};
|
|
2
|
+
import{b as F}from"../chunk-HDNVG6V3.js";import"../chunk-E2QT6K2E.js";import{g as _}from"../chunk-DR4NZAPM.js";import"../chunk-5VBGX3LN.js";import"../chunk-KRL7DRXT.js";import{e as g}from"../chunk-B7YDBLBV.js";import"../chunk-67L6M26C.js";import{c as T}from"../chunk-CVQ72H2U.js";import"../chunk-7K2CQ73Y.js";import"../chunk-KUHMQRSY.js";import"../chunk-JLRCAHLL.js";import"../chunk-44SAPBRK.js";import"../chunk-P73GOPCF.js";import"../chunk-6GMS6XU7.js";import{b as M}from"../chunk-RVQBDYQ2.js";import"../chunk-WQ7UQGQE.js";import"../chunk-W4OBSPHA.js";import{a as D,d as u,n as E}from"../chunk-RVK3H6V4.js";import"../chunk-6VELGYNR.js";import"../chunk-YX4LDK5Y.js";import"../chunk-F7Q5QB6Q.js";import"../chunk-OUOSDGWD.js";import{a as m}from"../chunk-QW2MPHP5.js";import{D as a}from"../chunk-24SCJPBI.js";import"../chunk-GU4UN43Q.js";import"../chunk-CA6DKOT2.js";import"../chunk-NDC6HDQD.js";import"../chunk-WZLM66YL.js";import"../chunk-2BO4GGPL.js";import{a as L}from"../chunk-FC546GTB.js";import{e as h}from"../chunk-6GD6B22G.js";var U=h(m(),1);import{Endpoints as q,ProcessorServiceImpl as G,State as j}from"@sentio/runtime";var I=class{server;constructor(t){this.server=t}testEntryFunctionCall(t,e=T.MAIN_NET){return this.testEntryFunctionCalls([t],e)}testEntryFunctionCalls(t,e=T.MAIN_NET){let n=[];for(let r of t){let o=this.buildEntryFunctionCallBinding(r,e);if(!o)throw Error("Invalid test transaction: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildEntryFunctionCallBinding(t,e=T.MAIN_NET){let n=t.payload;for(let r of this.server.contractConfigs)if(r.contract?.chainId===e){for(let o of r.moveCallConfigs)for(let i of o.filters)if(u(r.contract.address)+"::"+i.function===n.function)return{data:{aptCall:{transaction:t}},handlerIds:[o.handlerId],handlerType:a.APT_CALL}}}testEvent(t,e=T.MAIN_NET){let n=this.buildEventBinding(t,e);if(!n)throw Error("Invalid test event: "+JSON.stringify(t));return this.server.processBinding(n)}buildEventBinding(t,e=T.MAIN_NET){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e){for(let r of n.moveEventConfigs)for(let o of r.filters)for(let i of t.events)if(u(n.contract.address)+"::"+o.type===E(i.type).qname)return{data:{aptEvent:{transaction:t}},handlerIds:[r.handlerId],handlerType:a.APT_EVENT}}}};import("process").then(s=>s.stdout.write(""));var v=class{server;constructor(t){this.server=t}testInstructions(t){return this.server.processBindings({bindings:t.map(e=>({data:{raw:new Uint8Array,solInstruction:e},handlerIds:[],handlerType:a.SOL_INSTRUCTION}))})}};import("process").then(s=>s.stdout.write(""));var f=h(m(),1),B=class{server;constructor(t){this.server=t}testTrace(t,e=f.EthChainId.ETHEREUM){return this.testTraces([t],e)}testTraces(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildTraceBinding(r,e);if(!o)throw Error("Invalid test trace: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildTraceBinding(t,e=f.EthChainId.ETHEREUM){if(t.type!=="call"||!t.action.input)throw Error("Invalid test trace: "+JSON.stringify(t));let n=t.action.input.slice(0,10);for(let r of this.server.contractConfigs)if(r.contract?.chainId===e&&!(t.action.to?.toLowerCase()!==r.contract?.address.toLowerCase()&&r.contract?.address!=="*")){for(let o of r.traceConfigs)if(o.signature==n)return{data:{ethTrace:{trace:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.ETH_TRACE}}}testLog(t,e=f.EthChainId.ETHEREUM){return this.testLogs([t],e)}testLogs(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildLogBinding(r,e);if(!o)throw Error("Invalid test log: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildLogBinding(t,e=f.EthChainId.ETHEREUM){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e&&!(t.address.toLowerCase()!==n.contract?.address.toLowerCase()&&n.contract?.address!=="*"))for(let r of n.logConfigs)for(let o of r.filters){let i=!0;for(let c in o.topics){let d=t.topics[c],l=o.topics[c].hashes;if(l.length!==0&&!l.find(p=>p.toLowerCase()===d.toLowerCase())){i=!1;break}}if(i)return{data:{ethLog:{log:t,timestamp:new Date}},handlerIds:[r.handlerId],handlerType:a.ETH_LOG}}}testAccountLog(t,e,n=f.EthChainId.ETHEREUM){return this.testAccountLogs(t,[e],n)}testAccountLogs(t,e,n=f.EthChainId.ETHEREUM){let r=[];for(let o of e){let i=this.buildAccountLogBinding(t,o,n);if(!i)throw Error("Invalid test log: "+JSON.stringify(o));r.push(i)}return this.server.processBindings({bindings:r})}buildAccountLogBinding(t,e,n=f.EthChainId.ETHEREUM){for(let r of this.server.accountConfigs)if(r.chainId===n&&t.toLowerCase()===r.address.toLowerCase())for(let o of r.logConfigs)for(let i of o.filters){let c=!0;for(let d in i.topics){let l=e.topics[d],p=i.topics[d].hashes;if(p.length!==0&&!p.find(w=>w.toLowerCase()===l.toLowerCase())){c=!1;break}}if(c)return{data:{ethLog:{log:e,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.ETH_LOG}}}testBlock(t,e=f.EthChainId.ETHEREUM){return this.testBlocks([t],e)}testBlocks(t,e=f.EthChainId.ETHEREUM){let n=[];for(let r of t){let o=this.buildBlockBinding(r,e);if(!o)throw Error("Invalid test block: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildBlockBinding(t,e=f.EthChainId.ETHEREUM){let n={data:{ethBlock:{block:t}},handlerType:a.ETH_BLOCK,handlerIds:[]};for(let r of this.server.contractConfigs){if(r.contract?.chainId!==e)continue;let o=t.number;if(!(o<r.startBlock)&&!(r.endBlock!==0n&&o>=r.endBlock))for(let i of r.intervalConfigs)n.handlerIds.push(i.handlerId)}return n}};import("process").then(s=>s.stdout.write(""));var S=class{server;constructor(t){this.server=t}testEntryFunctionCall(t,e=g.MAIN_NET){return this.testEntryFunctionCalls([t],e)}testEntryFunctionCalls(t,e=g.MAIN_NET){let n=[];for(let r of t){let o=this.buildEntryFunctionCallBinding(r,e);if(!o)throw Error("Invalid test transaction: "+JSON.stringify(r));n.push(o)}return this.server.processBindings({bindings:n})}buildEntryFunctionCallBinding(t,e=g.MAIN_NET){let n=_(t);for(let r of n){let o=[u(r.package),r.module,r.function].join(D);for(let i of this.server.contractConfigs)if(i.contract?.chainId===e){for(let c of i.moveCallConfigs)for(let d of c.filters)if(u(i.contract.address)+"::"+d.function===o)return{data:{suiCall:{transaction:t,timestamp:new Date,slot:10000n}},handlerIds:[c.handlerId],handlerType:a.SUI_CALL}}}}testEvent(t,e=g.MAIN_NET){let n=this.buildEventBinding(t,e);if(!n)throw Error("Invalid test event: "+JSON.stringify(t));return this.server.processBinding(n)}testGlobalTransaction(t,e=g.MAIN_NET){let n=[];for(let o of this.server.contractConfigs)if(o.contract?.address==="*")for(let i of o.moveCallConfigs)i.filters.length===1&&i.filters[0].function===""&&n.push(i.handlerId);if(n.length===0)throw Error("Invalid test global transaction: "+JSON.stringify(t));let r={handlerIds:n,handlerType:a.SUI_CALL,data:{suiCall:{transaction:t,timestamp:t.timestampMs?new Date(t.timestampMs):new Date,slot:BigInt(t.checkpoint||0)}}};return this.server.processBinding(r)}buildEventBinding(t,e=g.MAIN_NET){for(let n of this.server.contractConfigs)if(n.contract?.chainId===e){for(let r of n.moveEventConfigs)for(let o of r.filters)for(let i of t.events||[])if(u(n.contract.address)+"::"+o.type===E(i.type).qname)return{data:{suiEvent:{transaction:t,timestamp:new Date(t.timestampMs||0),slot:10000n}},handlerIds:[r.handlerId],handlerType:a.SUI_EVENT}}}};import("process").then(s=>s.stdout.write(""));var N=class{server;constructor(t){this.server=t}testOnTransaction(t,e=F.TEST_NET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test transaction: "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e){for(let o of r.fuelCallConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL},c=o.filters[0]?.function;if(c)for(let d of t.status.receipts||[])d.receiptType=="CALL"&&d.param1==c&&n.push(i);else n.push(i)}for(let o of r.fuelLogConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL},c=o.logIds;for(let d of t.status.receipts||[])if((d.receiptType=="LOG"||d.receiptType=="LOG_DATA")&&c.includes(d.rb)){n.push(i);break}}for(let o of r.assetConfigs){let i={data:{fuelCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.FUEL_CALL};n.push(i)}}return n}};import("process").then(s=>s.stdout.write(""));var R=h(m(),1),x={INJECTIVE_MAINNET:R.CosmosChainId.INJECTIVE_MAINNET,INJECTIVE_TESTNET:R.CosmosChainId.INJECTIVE_TESTNET};import("process").then(s=>s.stdout.write(""));var P=class{server;constructor(t){this.server=t}testOnTransaction(t,e=x.INJECTIVE_TESTNET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test transaction: "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e)for(let o of r.cosmosLogConfigs){let i={data:{cosmosCall:{transaction:t,timestamp:new Date}},handlerIds:[o.handlerId],handlerType:a.COSMOS_CALL},c=o.logFilters;for(let d of t.logs||[])if(d.events.find(l=>c.includes(l.type))){n.push(i);break}}return n}};import("process").then(s=>s.stdout.write(""));var O=h(m(),1),y=class{server;constructor(t){this.server=t}testOnEvents(t,e=O.StarknetChainId.STARKNET_SEPOLIA){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test : "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[],r=Array.isArray(t)?t:[t];for(let o of r)for(let i of this.server.contractConfigs)if(i.contract?.chainId===e)for(let c of i.starknetEventConfigs){let d={data:{starknetEvents:{result:o,timestamp:new Date}},handlerIds:[c.handlerId],handlerType:a.STARKNET_EVENT},l=c.filters,p=o.keys;for(let w of p)for(let J of l)if(J.keys.includes(w))return n.push(d),n}return n}};import("process").then(s=>s.stdout.write(""));var H=h(m(),1);var b=class{server;constructor(t){this.server=t}testOnTransactions(t,e=H.BTCChainId.BTC_TESTNET){let n=this.buildBinding(t,e);if(!n)throw Error("Invalid test : "+JSON.stringify(t));return this.server.processBindings({bindings:n})}buildBinding(t,e){let n=[];for(let r of this.server.contractConfigs)if(r.contract?.chainId===e)for(let o of r.btcTransactionConfigs){let i={data:{btcTransaction:t},handlerIds:[o.handlerId],handlerType:a.BTC_TRANSACTION};n.push(i)}return n}};import("process").then(s=>s.stdout.write(""));var C={};function K(){j.reset()}var k=class{service;contractConfigs;accountConfigs;aptos;eth;solana;sui;fuel;cosmos;starknet;btc;constructor(t,e={}){K(),this.service=new G(t),this.aptos=new I(this),this.solana=new v(this),this.eth=new B(this),this.sui=new S(this),this.fuel=new N(this),this.cosmos=new P(this),this.starknet=new y(this),this.btc=new b(this);for(let n in U.CHAIN_MAP){let r=e[n]||"";q.INSTANCE.chainServer.set(n,r)}}async start(t={templateInstances:[]},e=C){let n=await this.service.start(t,e),r=await this.getConfig({});return this.contractConfigs=r.contractConfigs,this.accountConfigs=r.accountConfigs,n}stop(t,e=C){return this.service.stop(t,e)}getConfig(t,e=C){return this.service.getConfig(t,e)}processBindings(t,e=C){return this.service.processBindings(t,e)}processBinding(t,e=C){return this.service.processBindings({bindings:[t]},e)}processBindingsStream(t,e){throw new Error("Method not implemented.")}preprocessBindingsStream(t,e){throw new Error("Method not implemented.")}};import("process").then(s=>s.stdout.write(""));function A(s){if(s!==void 0){if(s.doubleValue!==void 0)return s.doubleValue;if(s.bigInteger!==void 0){let t=M(s.bigInteger.data);return s.bigInteger.negative&&(t=-t),t}if(s.bigDecimal!==void 0)return new L(s.bigDecimal)}}function X(s,t){if(s){for(let e of s.counters)if(e.metadata?.name===t)return A(e.metricValue)}}function z(s,t){if(s){for(let e of s.gauges)if(e.metadata?.name===t)return A(e.metricValue)}}import("process").then(s=>s.stdout.write(""));var V=h(m(),1);import{Endpoints as Q}from"@sentio/runtime";function W(s){let t=[];Array.isArray(s)||(s=[s]);for(let e of Object.keys(V.CHAIN_MAP)){let n="TEST_ENDPOINT_"+e,r=process.env[n];r&&(t.push(e),Q.INSTANCE.chainServer.set(e,r))}for(let e of s)if(!t.includes(e))return!1;return!0}import("process").then(s=>s.stdout.write(""));import("process").then(s=>s.stdout.write(""));export{A as MetricValueToNumber,k as TestProcessorServer,X as firstCounterValue,z as firstGaugeValue,W as loadTestProvidersFromEnv};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk-bundle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"!{lib,src}/*/tests"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@sentio/runtime": "^2.
|
|
51
|
+
"@sentio/runtime": "^2.45.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {},
|
|
54
54
|
"devDependencies": {},
|
|
@@ -19,7 +19,7 @@ import { ServerError, Status } from 'nice-grpc'
|
|
|
19
19
|
|
|
20
20
|
import { AptosProcessorState, AptosResourceProcessorState } from './aptos-processor.js'
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import { initTokenList } from './ext/token.js'
|
|
23
23
|
import { AptosChainId } from '@sentio/chain'
|
|
24
24
|
import { AptosResourcesContext } from './context.js'
|
|
25
25
|
import {
|
|
@@ -42,7 +42,7 @@ export class AptosPlugin extends Plugin {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async start(request: StartRequest) {
|
|
45
|
-
await
|
|
45
|
+
await initTokenList()
|
|
46
46
|
|
|
47
47
|
const allowedChainIds = new Set<string>(Object.values(AptosChainId))
|
|
48
48
|
for (const instance of request.templateInstances) {
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { BigDecimal } from '@sentio/bigdecimal'
|
|
2
|
-
import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'
|
|
3
2
|
import { AptosResourcesContext, AptosContext, AptosNetwork } from '../index.js'
|
|
4
|
-
import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor
|
|
3
|
+
import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor } from '../../move/ext/index.js'
|
|
5
4
|
import { MoveResource, Event, MoveModuleBytecode } from '@aptos-labs/ts-sdk'
|
|
5
|
+
import { getTokenInfoWithFallback, TokenInfo, tokenTokenValueInUsd, whitelistTokens } from './token.js'
|
|
6
6
|
|
|
7
7
|
export type PoolAdaptor<T> = MovePoolAdaptor<MoveResource, T>
|
|
8
8
|
|
|
9
|
-
export class CoinList implements MoveCoinList<AptosNetwork> {
|
|
9
|
+
export class CoinList implements MoveCoinList<TokenInfo, AptosNetwork> {
|
|
10
10
|
calculateValueInUsd(
|
|
11
11
|
amount: bigint,
|
|
12
|
-
coinInfo:
|
|
12
|
+
coinInfo: TokenInfo,
|
|
13
13
|
timestamp: number,
|
|
14
14
|
network: AptosNetwork = AptosNetwork.MAIN_NET
|
|
15
15
|
): Promise<BigDecimal> {
|
|
16
|
-
return
|
|
16
|
+
return tokenTokenValueInUsd(amount, coinInfo, timestamp, network)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getCoinInfo(type: string)
|
|
20
|
-
return
|
|
19
|
+
async getCoinInfo(type: string) {
|
|
20
|
+
return getTokenInfoWithFallback(type)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
whiteListed(type: string): boolean {
|
|
24
|
-
return
|
|
24
|
+
return whitelistTokens().has(type)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
whitelistCoins()
|
|
28
|
-
return
|
|
27
|
+
whitelistCoins() {
|
|
28
|
+
return whitelistTokens()
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const AptosCoinList = new CoinList()
|
|
33
33
|
|
|
34
34
|
export class AptosDex<T> extends MoveDex<
|
|
35
|
+
TokenInfo,
|
|
35
36
|
AptosNetwork,
|
|
36
37
|
MoveModuleBytecode,
|
|
37
38
|
MoveResource,
|
package/src/aptos/ext/index.ts
CHANGED
package/src/aptos/ext/token.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { coin } from '../builtin/0x1.js'
|
|
|
6
6
|
import { MoveStructId } from '@aptos-labs/ts-sdk'
|
|
7
7
|
import { AptosChainId } from '@sentio/chain'
|
|
8
8
|
import DEFAULT_TOKEN_LIST from './token-list.json' assert { type: 'json' }
|
|
9
|
+
import { BaseCoinInfo } from '../../move/ext/index.js'
|
|
9
10
|
|
|
10
|
-
type
|
|
11
|
+
type InternalTokenInfo = {
|
|
11
12
|
chainId: number
|
|
12
13
|
tokenAddress: `0x${string}` | null
|
|
13
14
|
faAddress: `0x${string}` | null
|
|
@@ -26,7 +27,8 @@ type TokenInfo = {
|
|
|
26
27
|
coinMarketCapId: number | null
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export
|
|
30
|
+
export interface TokenInfo extends BaseCoinInfo {
|
|
31
|
+
type: `0x${string}` // either tokenAddress or faAddress
|
|
30
32
|
tokenAddress?: `0x${string}`
|
|
31
33
|
faAddress?: `0x${string}`
|
|
32
34
|
name: string
|
|
@@ -40,15 +42,15 @@ export type SimpleTokenInfo = {
|
|
|
40
42
|
coinMarketCapId?: number
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
const TOKEN_MAP = new Map<string,
|
|
45
|
+
const TOKEN_MAP = new Map<string, TokenInfo>()
|
|
44
46
|
|
|
45
47
|
export async function initTokenList() {
|
|
46
|
-
let list = DEFAULT_TOKEN_LIST as
|
|
48
|
+
let list = DEFAULT_TOKEN_LIST as InternalTokenInfo[]
|
|
47
49
|
try {
|
|
48
50
|
const resp = await fetch(
|
|
49
51
|
'https://raw.githubusercontent.com/PanoraExchange/Aptos-Tokens/refs/heads/main/token-list.json'
|
|
50
52
|
)
|
|
51
|
-
list = (await resp.json()) as
|
|
53
|
+
list = (await resp.json()) as InternalTokenInfo[]
|
|
52
54
|
} catch (e) {
|
|
53
55
|
console.warn("Can't not fetch newest token list, use default list")
|
|
54
56
|
}
|
|
@@ -56,8 +58,13 @@ export async function initTokenList() {
|
|
|
56
58
|
setTokenList(list)
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
function tokenInfoToSimple(info:
|
|
61
|
+
function tokenInfoToSimple(info: InternalTokenInfo): TokenInfo {
|
|
62
|
+
const type = info.tokenAddress || info.faAddress
|
|
63
|
+
if (!type) {
|
|
64
|
+
throw Error('Token info must have tokenAddress or faAddress')
|
|
65
|
+
}
|
|
60
66
|
return {
|
|
67
|
+
type,
|
|
61
68
|
tokenAddress: info.tokenAddress || undefined,
|
|
62
69
|
faAddress: info.faAddress || undefined,
|
|
63
70
|
name: info.name,
|
|
@@ -72,7 +79,7 @@ function tokenInfoToSimple(info: TokenInfo): SimpleTokenInfo {
|
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
function setTokenList(list:
|
|
82
|
+
function setTokenList(list: InternalTokenInfo[]) {
|
|
76
83
|
for (const info of list) {
|
|
77
84
|
const simpleInfo = tokenInfoToSimple(info)
|
|
78
85
|
if (
|
|
@@ -107,7 +114,7 @@ export function isWhiteListToken(token: string): boolean {
|
|
|
107
114
|
const TOKEN_METADATA_CACHE = new Map<string, Promise<any | null>>()
|
|
108
115
|
|
|
109
116
|
// token: address of the fungible asset, e.g. "0xa", or the coin type, e.g. "0x1::aptos::AptosCoin"
|
|
110
|
-
export async function getTokenInfoWithFallback(token: string, network?: AptosNetwork): Promise<
|
|
117
|
+
export async function getTokenInfoWithFallback(token: string, network?: AptosNetwork): Promise<TokenInfo> {
|
|
111
118
|
const r = TOKEN_MAP.get(token)
|
|
112
119
|
if (!r) {
|
|
113
120
|
network = network || AptosNetwork.MAIN_NET
|
|
@@ -134,6 +141,7 @@ export async function getTokenInfoWithFallback(token: string, network?: AptosNet
|
|
|
134
141
|
|
|
135
142
|
// const parts = type.split(SPLITTER)
|
|
136
143
|
return {
|
|
144
|
+
type: token as `0x${string}`,
|
|
137
145
|
category: 'Native',
|
|
138
146
|
tokenAddress: token as `0x${string}`,
|
|
139
147
|
name: meta.name,
|
|
@@ -166,7 +174,7 @@ export async function getPriceForToken(
|
|
|
166
174
|
|
|
167
175
|
export async function tokenTokenValueInUsd(
|
|
168
176
|
n: bigint,
|
|
169
|
-
coinInfo:
|
|
177
|
+
coinInfo: TokenInfo,
|
|
170
178
|
timestamp: number,
|
|
171
179
|
network = AptosChainId.APTOS_MAINNET
|
|
172
180
|
) {
|
|
@@ -179,4 +187,4 @@ export async function tokenTokenValueInUsd(
|
|
|
179
187
|
throw Error('Token not found' + JSON.stringify(coinInfo))
|
|
180
188
|
}
|
|
181
189
|
|
|
182
|
-
setTokenList(DEFAULT_TOKEN_LIST as
|
|
190
|
+
setTokenList(DEFAULT_TOKEN_LIST as InternalTokenInfo[])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BigDecimal } from '@sentio/bigdecimal'
|
|
2
|
+
|
|
3
|
+
export interface BaseCoinInfo {
|
|
4
|
+
// token_type: { type: string; account_address: string }
|
|
5
|
+
type: string
|
|
6
|
+
symbol: string
|
|
7
|
+
hippo_symbol?: string
|
|
8
|
+
decimals: number
|
|
9
|
+
bridge: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MoveCoinList<TokenType extends BaseCoinInfo, Network> {
|
|
13
|
+
whiteListed(type: string): boolean
|
|
14
|
+
whitelistCoins(): Map<string, TokenType>
|
|
15
|
+
getCoinInfo(type: string): Promise<TokenType>
|
|
16
|
+
calculateValueInUsd(amount: bigint, coinInfo: TokenType, timestamp: number, network: Network): Promise<BigDecimal>
|
|
17
|
+
}
|
package/src/move/ext/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './coin
|
|
1
|
+
export * from './coin.js'
|
|
2
2
|
export * from './move-dex.js'
|