@alphafi/alphafi-sdk 0.0.2 → 0.0.3
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/README.md +47 -1
- package/dist/getAllVaults.d.ts +3 -0
- package/dist/getAllVaults.d.ts.map +1 -0
- package/package.json +5 -2
- package/.babelrc +0 -6
- package/.eslintrc.json +0 -30
- package/jest.config.js +0 -14
- package/src/common/cetus_mainnet_config.ts +0 -72
- package/src/common/coins.ts +0 -126
- package/src/common/constants.ts +0 -820
- package/src/common/maps.ts +0 -200
- package/src/common/pyth.ts +0 -23
- package/src/common/types.ts +0 -446
- package/src/functions.ts +0 -299
- package/src/getVaultBalances.ts +0 -128
- package/src/getVaults.ts +0 -63
- package/src/index.ts +0 -13
- package/src/portfolioAmount.ts +0 -365
- package/src/price.ts +0 -397
- package/tsconfig.json +0 -21
- package/webpack.config.js +0 -59
package/README.md
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ALPHAFI TypeScript SDK
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i @alphafi/alphafi-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## `getVaults`
|
|
10
|
+
|
|
11
|
+
Call this to get all Vaults that a particular user has deposited in.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { getVaults, AlphaFiVault } from "alphafi-sdk";
|
|
15
|
+
|
|
16
|
+
const vaults: AlphaFiVault = await getVaults(address);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## `getAlphaVaultBalance`
|
|
20
|
+
|
|
21
|
+
Call this to get user balance in Alpha Vault.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { getAlphaVaultBalance, AlphaVaultBalance } from "alphafi-sdk";
|
|
25
|
+
|
|
26
|
+
const balance: AlphaVaultBalance = await getAlphaVaultBalance(address);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## `getSingleAssetVaultBalance`
|
|
30
|
+
|
|
31
|
+
Call this to get user balance in Single Asset Vaults.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { getSingleAssetVaultBalance, SingleAssetVaultBalance } from "alphafi-sdk";
|
|
35
|
+
|
|
36
|
+
const balance: SingleAssetVaultBalance = await getSingleAssetVaultBalance(address, poolName);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## `getDoubleAssetVaultBalance`
|
|
40
|
+
|
|
41
|
+
Call this to get user balance in Double Asset Vaults.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { getDoubleAssetVaultBalance, DoubleAssetVaultBalance } from "alphafi-sdk";
|
|
45
|
+
|
|
46
|
+
const balance: DoubleAssetVaultBalance = await getDoubleAssetVaultBalance(address, poolName);
|
|
47
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllVaults.d.ts","sourceRoot":"","sources":["../src/getAllVaults.ts"],"names":[],"mappings":"AAEA,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAQjE;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAQjE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphafi/alphafi-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "AlphaFi SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
"bn.js": "^5.2.1",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
49
|
"tsx": "^4.16.3"
|
|
50
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
]
|
|
51
54
|
}
|
package/.babelrc
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"extends": [
|
|
4
|
-
"eslint:recommended",
|
|
5
|
-
"plugin:@typescript-eslint/recommended",
|
|
6
|
-
"plugin:import/errors",
|
|
7
|
-
"plugin:import/warnings",
|
|
8
|
-
"plugin:import/typescript",
|
|
9
|
-
"plugin:prettier/recommended" // Adds Prettier plugin recommendations at the end
|
|
10
|
-
],
|
|
11
|
-
"parserOptions": {
|
|
12
|
-
"ecmaVersion": 2020,
|
|
13
|
-
"sourceType": "module",
|
|
14
|
-
"project": "./tsconfig.json"
|
|
15
|
-
},
|
|
16
|
-
"rules": {
|
|
17
|
-
"prettier/prettier": "error", // Ensures that Prettier mismatches are shown as errors
|
|
18
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
19
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
20
|
-
"@typescript-eslint/no-unused-vars": [
|
|
21
|
-
"error",
|
|
22
|
-
{ "argsIgnorePattern": "^_" }
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
"plugins": [
|
|
26
|
-
"@typescript-eslint",
|
|
27
|
-
"import",
|
|
28
|
-
"prettier" // Ensure this plugin is installed and included
|
|
29
|
-
]
|
|
30
|
-
}
|
package/jest.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: "ts-jest",
|
|
3
|
-
testEnvironment: "node",
|
|
4
|
-
transform: {
|
|
5
|
-
"^.+\\.tsx?$": "babel-jest",
|
|
6
|
-
"^.+\\.jsx?$": "babel-jest",
|
|
7
|
-
},
|
|
8
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
9
|
-
globals: {
|
|
10
|
-
"ts-jest": {
|
|
11
|
-
tsconfig: "tsconfig.json",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { SdkOptions } from "@cetusprotocol/cetus-sui-clmm-sdk";
|
|
2
|
-
import { getFullnodeUrl } from "@mysten/sui/client";
|
|
3
|
-
|
|
4
|
-
export const cetusMainnetSDKOptions: SdkOptions = {
|
|
5
|
-
fullRpcUrl: getFullnodeUrl("mainnet"),
|
|
6
|
-
swapCountUrl: "https://api-sui.cetus.zone/v2/sui/swap/count",
|
|
7
|
-
simulationAccount: {
|
|
8
|
-
address:
|
|
9
|
-
"0x4260738f0f7341adc79a8edaa62f8a4681ebd27c595aecab1f322f47bfc52c5e",
|
|
10
|
-
},
|
|
11
|
-
cetus_config: {
|
|
12
|
-
package_id:
|
|
13
|
-
"0x95b8d278b876cae22206131fb9724f701c9444515813042f54f0a426c9a3bc2f",
|
|
14
|
-
published_at:
|
|
15
|
-
"0x95b8d278b876cae22206131fb9724f701c9444515813042f54f0a426c9a3bc2f",
|
|
16
|
-
config: {
|
|
17
|
-
coin_list_id:
|
|
18
|
-
"0x8cbc11d9e10140db3d230f50b4d30e9b721201c0083615441707ffec1ef77b23",
|
|
19
|
-
launchpad_pools_id:
|
|
20
|
-
"0x1098fac992eab3a0ab7acf15bb654fc1cf29b5a6142c4ef1058e6c408dd15115",
|
|
21
|
-
clmm_pools_id:
|
|
22
|
-
"0x15b6a27dd9ae03eb455aba03b39e29aad74abd3757b8e18c0755651b2ae5b71e",
|
|
23
|
-
admin_cap_id:
|
|
24
|
-
"0x39d78781750e193ce35c45ff32c6c0c3f2941fa3ddaf8595c90c555589ddb113",
|
|
25
|
-
global_config_id:
|
|
26
|
-
"0x0408fa4e4a4c03cc0de8f23d0c2bbfe8913d178713c9a271ed4080973fe42d8f",
|
|
27
|
-
coin_list_handle:
|
|
28
|
-
"0x49136005e90e28c4695419ed4194cc240603f1ea8eb84e62275eaff088a71063",
|
|
29
|
-
launchpad_pools_handle:
|
|
30
|
-
"0x5e194a8efcf653830daf85a85b52e3ae8f65dc39481d54b2382acda25068375c",
|
|
31
|
-
clmm_pools_handle:
|
|
32
|
-
"0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
clmm_pool: {
|
|
36
|
-
package_id:
|
|
37
|
-
"0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb",
|
|
38
|
-
published_at:
|
|
39
|
-
"0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a",
|
|
40
|
-
config: {
|
|
41
|
-
pools_id:
|
|
42
|
-
"0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",
|
|
43
|
-
global_config_id:
|
|
44
|
-
"0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",
|
|
45
|
-
global_vault_id:
|
|
46
|
-
"0xce7bceef26d3ad1f6d9b6f13a953f053e6ed3ca77907516481ce99ae8e588f2b",
|
|
47
|
-
admin_cap_id:
|
|
48
|
-
"0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75",
|
|
49
|
-
partners_id:
|
|
50
|
-
"0xac30897fa61ab442f6bff518c5923faa1123c94b36bd4558910e9c783adfa204",
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
integrate: {
|
|
54
|
-
package_id:
|
|
55
|
-
"0x996c4d9480708fb8b92aa7acf819fb0497b5ec8e65ba06601cae2fb6db3312c3",
|
|
56
|
-
published_at:
|
|
57
|
-
"0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b",
|
|
58
|
-
},
|
|
59
|
-
deepbook: {
|
|
60
|
-
package_id:
|
|
61
|
-
"0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
62
|
-
published_at:
|
|
63
|
-
"0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
64
|
-
},
|
|
65
|
-
deepbook_endpoint_v2: {
|
|
66
|
-
package_id:
|
|
67
|
-
"0x0dd416959739e1db3a4c6f9cac7f9e7202678f3b067d6d419e569a124fc35e0e",
|
|
68
|
-
published_at:
|
|
69
|
-
"0x0dd416959739e1db3a4c6f9cac7f9e7202678f3b067d6d419e569a124fc35e0e",
|
|
70
|
-
},
|
|
71
|
-
aggregatorUrl: "https://api-sui.cetus.zone/router",
|
|
72
|
-
};
|
package/src/common/coins.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// import { CONF_ENV, conf } from "../constants";
|
|
2
|
-
// import { Coin, CoinName, CoinType } from "./types";
|
|
3
|
-
|
|
4
|
-
import { conf, CONF_ENV } from "./constants";
|
|
5
|
-
import { Coin, CoinName, CoinType } from "./types";
|
|
6
|
-
|
|
7
|
-
export const coins: { [key in CoinName]: Coin } = {
|
|
8
|
-
ALPHA: {
|
|
9
|
-
name: "ALPHA",
|
|
10
|
-
type: conf[CONF_ENV].ALPHA_COIN_TYPE as CoinType,
|
|
11
|
-
icon: "https://7taj6jfau6n3dri7agspzfnva7qbj5sizz5xc3lb56nmxpsyoiba.arweave.net/_MCfJKCnm7HFHwGk_JW1B-AU9kjOe3FtYe-ay75YcgI",
|
|
12
|
-
expo: 9,
|
|
13
|
-
},
|
|
14
|
-
SUI: {
|
|
15
|
-
name: "SUI",
|
|
16
|
-
type: "0x2::sui::SUI",
|
|
17
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x0000000000000000000000000000000000000000000000000000000000000002-sui-SUI.svg",
|
|
18
|
-
expo: 9,
|
|
19
|
-
},
|
|
20
|
-
USDC: {
|
|
21
|
-
name: "USDC",
|
|
22
|
-
type: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
|
|
23
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf-coin-COIN.webp",
|
|
24
|
-
expo: 6,
|
|
25
|
-
},
|
|
26
|
-
USDT: {
|
|
27
|
-
name: "USDT",
|
|
28
|
-
type: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",
|
|
29
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c-coin-COIN.webp",
|
|
30
|
-
expo: 6,
|
|
31
|
-
},
|
|
32
|
-
VSUI: {
|
|
33
|
-
name: "VSUI",
|
|
34
|
-
type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT",
|
|
35
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55-cert-CERT.webp",
|
|
36
|
-
expo: 9,
|
|
37
|
-
},
|
|
38
|
-
NAVX: {
|
|
39
|
-
name: "NAVX",
|
|
40
|
-
type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
|
|
41
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5-navx-NAVX.webp",
|
|
42
|
-
expo: 9,
|
|
43
|
-
},
|
|
44
|
-
SCA: {
|
|
45
|
-
name: "SCA",
|
|
46
|
-
type: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA",
|
|
47
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6-sca-SCA.webp",
|
|
48
|
-
expo: 9,
|
|
49
|
-
},
|
|
50
|
-
CETUS: {
|
|
51
|
-
name: "CETUS",
|
|
52
|
-
type: "0x6864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS",
|
|
53
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b-cetus-CETUS.webp",
|
|
54
|
-
expo: 9,
|
|
55
|
-
},
|
|
56
|
-
TURBOS: {
|
|
57
|
-
name: "TURBOS",
|
|
58
|
-
type: "0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a::turbos::TURBOS",
|
|
59
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a-turbos-TURBOS.svg",
|
|
60
|
-
expo: 9,
|
|
61
|
-
},
|
|
62
|
-
AFSUI: {
|
|
63
|
-
name: "AFSUI",
|
|
64
|
-
type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI",
|
|
65
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc-afsui-AFSUI.webp",
|
|
66
|
-
expo: 9,
|
|
67
|
-
},
|
|
68
|
-
WETH: {
|
|
69
|
-
name: "WETH",
|
|
70
|
-
type: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",
|
|
71
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5-coin-COIN.webp",
|
|
72
|
-
expo: 8,
|
|
73
|
-
},
|
|
74
|
-
APT: {
|
|
75
|
-
name: "APT",
|
|
76
|
-
type: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37::coin::COIN",
|
|
77
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37-coin-COIN.webp",
|
|
78
|
-
expo: 8,
|
|
79
|
-
},
|
|
80
|
-
SOL: {
|
|
81
|
-
name: "SOL",
|
|
82
|
-
type: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN",
|
|
83
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8-coin-COIN.webp",
|
|
84
|
-
expo: 8,
|
|
85
|
-
},
|
|
86
|
-
SLP: {
|
|
87
|
-
name: "SLP",
|
|
88
|
-
type: "0xc44d97a4bc4e5a33ca847b72b123172c88a6328196b71414f32c3070233604b2::slp::SLP",
|
|
89
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xc44d97a4bc4e5a33ca847b72b123172c88a6328196b71414f32c3070233604b2-slp-SLP.webp",
|
|
90
|
-
expo: 6,
|
|
91
|
-
},
|
|
92
|
-
WBTC: {
|
|
93
|
-
name: "WBTC",
|
|
94
|
-
type: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN",
|
|
95
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881-coin-COIN.webp",
|
|
96
|
-
expo: 8,
|
|
97
|
-
},
|
|
98
|
-
CELO: {
|
|
99
|
-
name: "CELO",
|
|
100
|
-
type: "0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN",
|
|
101
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f-coin-COIN.webp",
|
|
102
|
-
expo: 8,
|
|
103
|
-
},
|
|
104
|
-
HASUI: {
|
|
105
|
-
name: "HASUI",
|
|
106
|
-
type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI",
|
|
107
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d-hasui-HASUI.svg",
|
|
108
|
-
expo: 9,
|
|
109
|
-
},
|
|
110
|
-
USDY: {
|
|
111
|
-
name: "USDY",
|
|
112
|
-
type: "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY",
|
|
113
|
-
icon: "https://coinmeta.polymedia.app/img/coins/0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb-usdy-USDY.svg",
|
|
114
|
-
expo: 6,
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const poolTokenMap: {
|
|
119
|
-
[key in string]: { coinName: CoinName; coinType: CoinType };
|
|
120
|
-
} = {
|
|
121
|
-
"NAVI-SUI": { coinName: "SUI", coinType: coins["SUI"].type },
|
|
122
|
-
"NAVI-VSUI": { coinName: "VSUI", coinType: coins["VSUI"].type },
|
|
123
|
-
"NAVI-WETH": { coinName: "WETH", coinType: coins["WETH"].type },
|
|
124
|
-
"NAVI-USDT": { coinName: "USDT", coinType: coins["USDT"].type },
|
|
125
|
-
"NAVI-USDC": { coinName: "USDC", coinType: coins["USDC"].type },
|
|
126
|
-
};
|