@augustdigital/sdk 5.1.0 → 6.0.1
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/adapters/solana/getters.js +9 -2
- package/lib/adapters/solana/idl/vault-idl.js +14 -0
- package/lib/adapters/solana/index.d.ts +11 -0
- package/lib/adapters/solana/index.js +8 -0
- package/lib/adapters/solana/types.d.ts +4 -1
- package/lib/adapters/solana/utils.d.ts +8 -0
- package/lib/adapters/solana/utils.js +24 -0
- package/lib/core/analytics/version.d.ts +1 -0
- package/lib/core/analytics/version.js +5 -0
- package/lib/core/constants/web3.js +1 -1
- package/lib/main.js +20 -4
- package/lib/modules/vaults/getters.js +12 -6
- package/lib/modules/vaults/main.js +2 -0
- package/lib/modules/vaults/types.d.ts +4 -0
- package/package.json +3 -2
|
@@ -102,8 +102,15 @@ const getSolanaVault = async (tokenizedVault, options) => {
|
|
|
102
102
|
}
|
|
103
103
|
let totalAssets;
|
|
104
104
|
if (onChainAvailable) {
|
|
105
|
-
const
|
|
106
|
-
|
|
105
|
+
const localAumRaw = vaultState?.vaultState?.localAum;
|
|
106
|
+
const deployedAumRaw = vaultState?.vaultState?.deployedAum;
|
|
107
|
+
const localAum = localAumRaw !== null && localAumRaw !== undefined
|
|
108
|
+
? BigInt(localAumRaw.toString())
|
|
109
|
+
: BigInt(0);
|
|
110
|
+
const deployedAum = deployedAumRaw !== null && deployedAumRaw !== undefined
|
|
111
|
+
? BigInt(deployedAumRaw.toString())
|
|
112
|
+
: BigInt(0);
|
|
113
|
+
totalAssets = (0, core_1.toNormalizedBn)(localAum + deployedAum, decimals);
|
|
107
114
|
}
|
|
108
115
|
else {
|
|
109
116
|
totalAssets = (0, utils_2.backendTvlToNormalizedBn)(tokenizedVault.latest_reported_tvl, decimals);
|
|
@@ -1023,12 +1023,26 @@ exports.vaultIdl = {
|
|
|
1023
1023
|
name: 'deployed_aum',
|
|
1024
1024
|
type: 'u64',
|
|
1025
1025
|
},
|
|
1026
|
+
{
|
|
1027
|
+
name: 'aum_increase_limit',
|
|
1028
|
+
type: 'u32',
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
name: 'aum_decrease_limit',
|
|
1032
|
+
type: 'u32',
|
|
1033
|
+
},
|
|
1026
1034
|
{
|
|
1027
1035
|
name: 'pda_bump',
|
|
1028
1036
|
type: {
|
|
1029
1037
|
array: ['u8', 1],
|
|
1030
1038
|
},
|
|
1031
1039
|
},
|
|
1040
|
+
{
|
|
1041
|
+
name: 'vault_version',
|
|
1042
|
+
type: {
|
|
1043
|
+
array: ['u8', 1],
|
|
1044
|
+
},
|
|
1045
|
+
},
|
|
1032
1046
|
{
|
|
1033
1047
|
name: 'paused',
|
|
1034
1048
|
type: 'bool',
|
|
@@ -61,6 +61,13 @@ export declare const Solana: {
|
|
|
61
61
|
publicKey: PublicKey | string;
|
|
62
62
|
shareMint?: PublicKey | string;
|
|
63
63
|
} & import("./types").ISolanaConnectionOptions) => Promise<any>;
|
|
64
|
+
fetchUserShareBalanceRaw: ({ connection, publicKey, shareMint, }: {
|
|
65
|
+
publicKey: PublicKey | string;
|
|
66
|
+
shareMint?: PublicKey | string;
|
|
67
|
+
} & import("./types").ISolanaConnectionOptions) => Promise<{
|
|
68
|
+
amount: string;
|
|
69
|
+
decimals: number | null;
|
|
70
|
+
}>;
|
|
64
71
|
getBestRpcEndpoint: ({ endpoint, network, connection, }: import("./types").ISolanaConnectionOptions) => Promise<`https://${string}` | "http://127.0.0.1:8899">;
|
|
65
72
|
fallbackDecimals: number;
|
|
66
73
|
fallbackNetwork: import("../..").ISolanaNetwork;
|
|
@@ -125,6 +132,10 @@ declare class SolanaAdapter {
|
|
|
125
132
|
getTokenSymbol(mintAddress: string | PublicKey): Promise<string>;
|
|
126
133
|
fetchUserTokenBalance(publicKey: PublicKey | string, depositMint: PublicKey | string): Promise<any>;
|
|
127
134
|
fetchUserShareBalance(publicKey: PublicKey | string, shareMint: PublicKey | string): Promise<any>;
|
|
135
|
+
fetchUserShareBalanceRaw(publicKey: PublicKey | string, shareMint: PublicKey | string): Promise<{
|
|
136
|
+
amount: string;
|
|
137
|
+
decimals: number | null;
|
|
138
|
+
}>;
|
|
128
139
|
vaultDeposit(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, depositAmount: number, sendTransaction: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
|
|
129
140
|
vaultRedeem(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, redeemShares: number, sendTransaction: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
|
|
130
141
|
getProgramId(type: 'vault'): string;
|
|
@@ -143,6 +143,14 @@ class SolanaAdapter {
|
|
|
143
143
|
shareMint,
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
+
async fetchUserShareBalanceRaw(publicKey, shareMint) {
|
|
147
|
+
return await utils_1.SolanaUtils.fetchUserShareBalanceRaw({
|
|
148
|
+
network: this._network,
|
|
149
|
+
connection: this._connection,
|
|
150
|
+
publicKey,
|
|
151
|
+
shareMint,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
146
154
|
async vaultDeposit(vaultProgramId, idl, publicKey, depositAmount, sendTransaction, vaultAddress) {
|
|
147
155
|
return await (0, vault_actions_1.handleSolanaDeposit)({
|
|
148
156
|
network: this._network,
|
|
@@ -15,10 +15,13 @@ export interface ISolanaVaultState {
|
|
|
15
15
|
depositMint: PublicKey | null;
|
|
16
16
|
feeRecipient: PublicKey | null;
|
|
17
17
|
withdrawalFee: number | null;
|
|
18
|
+
localAum: number | null;
|
|
18
19
|
deployedAum: number | null;
|
|
20
|
+
aumIncreaseLimit: number | null;
|
|
21
|
+
aumDecreaseLimit: number | null;
|
|
19
22
|
pdaBump: number[] | null;
|
|
20
|
-
paused: boolean | null;
|
|
21
23
|
vaultVersion: number[] | null;
|
|
24
|
+
paused: boolean | null;
|
|
22
25
|
}
|
|
23
26
|
export interface ISolanaToken {
|
|
24
27
|
address: string;
|
|
@@ -65,6 +65,13 @@ declare function fetchUserShareBalance({ connection, publicKey, shareMint, }: {
|
|
|
65
65
|
publicKey: PublicKey | string;
|
|
66
66
|
shareMint?: PublicKey | string;
|
|
67
67
|
} & ISolanaConnectionOptions): Promise<any>;
|
|
68
|
+
declare function fetchUserShareBalanceRaw({ connection, publicKey, shareMint, }: {
|
|
69
|
+
publicKey: PublicKey | string;
|
|
70
|
+
shareMint?: PublicKey | string;
|
|
71
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
72
|
+
amount: string;
|
|
73
|
+
decimals: number | null;
|
|
74
|
+
}>;
|
|
68
75
|
declare function resolveProgramId(vaultAddress: string, solanaMetadata?: {
|
|
69
76
|
program_id?: string;
|
|
70
77
|
} | null): string;
|
|
@@ -84,6 +91,7 @@ export declare const SolanaUtils: {
|
|
|
84
91
|
getTokenSymbol: typeof getTokenSymbol;
|
|
85
92
|
fetchUserTokenBalance: typeof fetchUserTokenBalance;
|
|
86
93
|
fetchUserShareBalance: typeof fetchUserShareBalance;
|
|
94
|
+
fetchUserShareBalanceRaw: typeof fetchUserShareBalanceRaw;
|
|
87
95
|
getBestRpcEndpoint: typeof getBestRpcEndpoint;
|
|
88
96
|
fallbackDecimals: number;
|
|
89
97
|
fallbackNetwork: import("../..").ISolanaNetwork;
|
|
@@ -416,6 +416,29 @@ async function fetchUserShareBalance({ connection, publicKey, shareMint, }) {
|
|
|
416
416
|
return 0;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
+
async function fetchUserShareBalanceRaw({ connection, publicKey, shareMint, }) {
|
|
420
|
+
if (!publicKey || !shareMint)
|
|
421
|
+
return { amount: '0', decimals: null };
|
|
422
|
+
try {
|
|
423
|
+
const _publicKey = new web3_js_1.PublicKey(publicKey);
|
|
424
|
+
const _shareMint = new web3_js_1.PublicKey(shareMint);
|
|
425
|
+
const shareAccounts = await connection.getParsedTokenAccountsByOwner(_publicKey, {
|
|
426
|
+
mint: _shareMint,
|
|
427
|
+
});
|
|
428
|
+
const tokenAmount = shareAccounts?.value?.[0]?.account?.data?.parsed?.info?.tokenAmount;
|
|
429
|
+
if (!tokenAmount)
|
|
430
|
+
return { amount: '0', decimals: null };
|
|
431
|
+
return {
|
|
432
|
+
amount: String(tokenAmount.amount ?? '0'),
|
|
433
|
+
decimals: typeof tokenAmount.decimals === 'number' ? tokenAmount.decimals : null,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
catch (e) {
|
|
437
|
+
const error = e;
|
|
438
|
+
console.error('Error fetching raw user share balance:', error);
|
|
439
|
+
return { amount: '0', decimals: null };
|
|
440
|
+
}
|
|
441
|
+
}
|
|
419
442
|
function resolveProgramId(vaultAddress, solanaMetadata) {
|
|
420
443
|
return solanaMetadata?.program_id || vaultAddress;
|
|
421
444
|
}
|
|
@@ -435,6 +458,7 @@ exports.SolanaUtils = {
|
|
|
435
458
|
getTokenSymbol,
|
|
436
459
|
fetchUserTokenBalance,
|
|
437
460
|
fetchUserShareBalance,
|
|
461
|
+
fetchUserShareBalanceRaw,
|
|
438
462
|
getBestRpcEndpoint,
|
|
439
463
|
fallbackDecimals: constants_1.fallbackDecimals,
|
|
440
464
|
fallbackNetwork: constants_1.fallbackNetwork,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "6.0.1";
|
package/lib/main.js
CHANGED
|
@@ -50,10 +50,26 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
50
50
|
super(baseConfig);
|
|
51
51
|
this.authorized = true;
|
|
52
52
|
this.evm = new evm_1.default();
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const solanaConfig = (() => {
|
|
54
|
+
if (baseConfig.solana?.rpcUrl) {
|
|
55
|
+
return {
|
|
56
|
+
rpcUrl: baseConfig.solana.rpcUrl,
|
|
57
|
+
network: baseConfig.solana.network,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const legacyRpcUrl = baseConfig.providers?.[core_1.SPECIAL_CHAINS.solana.chainId];
|
|
61
|
+
if (legacyRpcUrl) {
|
|
62
|
+
return {
|
|
63
|
+
rpcUrl: legacyRpcUrl,
|
|
64
|
+
network: legacyRpcUrl.includes('devnet')
|
|
65
|
+
? 'devnet'
|
|
66
|
+
: 'mainnet-beta',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
})();
|
|
71
|
+
if (solanaConfig) {
|
|
72
|
+
this.solana = new solana_1.default(solanaConfig.rpcUrl, solanaConfig.network);
|
|
57
73
|
(0, analytics_1.instrumentClass)(this.solana, () => core_1.SPECIAL_CHAINS.solana.chainId);
|
|
58
74
|
}
|
|
59
75
|
this.sui = new sui_1.default();
|
|
@@ -880,17 +880,23 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
|
|
|
880
880
|
const promises = await Promise.all(tokenizedVaults.map(async (v) => {
|
|
881
881
|
try {
|
|
882
882
|
if (utils_2.SolanaUtils.isSolanaAddress(v.address)) {
|
|
883
|
-
|
|
884
|
-
|
|
883
|
+
const fallbackShareDecimals = v.solana_vault_metadata?.deposit_token_decimals ??
|
|
884
|
+
SolanaConstants.fallbackDecimals;
|
|
885
|
+
let balance = (0, core_1.toNormalizedBn)(0, fallbackShareDecimals);
|
|
886
|
+
if (utils_2.SolanaUtils.isSolanaAddress(solanaWallet) &&
|
|
887
|
+
options.solanaService) {
|
|
885
888
|
const vaultProgramId = utils_2.SolanaUtils.resolveProgramId(String(v.address), v.solana_vault_metadata);
|
|
886
889
|
const vaultStateRes = await options.solanaService.getVaultState(vaultProgramId, SolanaConstants.vaultIdl, v.solana_vault_metadata?.vault_state_pda ?? undefined);
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
+
const vaultState = vaultStateRes?.vaultState;
|
|
891
|
+
const { shareMint } = vaultState ?? { shareMint: null };
|
|
892
|
+
if (shareMint) {
|
|
893
|
+
const raw = await options.solanaService.fetchUserShareBalanceRaw(solanaWallet, shareMint);
|
|
894
|
+
const decimals = raw.decimals ?? fallbackShareDecimals;
|
|
895
|
+
balance = (0, core_1.toNormalizedBn)(BigInt(raw.amount), decimals);
|
|
890
896
|
}
|
|
891
897
|
}
|
|
892
898
|
return {
|
|
893
|
-
vault,
|
|
899
|
+
vault: v.address,
|
|
894
900
|
status: renderStatus([], balance),
|
|
895
901
|
availableRedemptions: [],
|
|
896
902
|
pendingRedemptions: [],
|
|
@@ -75,6 +75,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
75
75
|
async getVaults(options) {
|
|
76
76
|
const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, options?.loadSubaccounts, options?.loadSnapshots);
|
|
77
77
|
const vaultsPerAvailableProviders = allVaults.filter((v) => v?.chain_type === 'stellar' ||
|
|
78
|
+
(v?.chain_type === 'solana' && !!this.solanaService) ||
|
|
78
79
|
(this.providers?.[v?.chain] ? true : false));
|
|
79
80
|
const vaultsPerChainId = options?.chainIds
|
|
80
81
|
? vaultsPerAvailableProviders.filter((v) => options.chainIds.includes(v.chain))
|
|
@@ -478,6 +479,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
478
479
|
return final;
|
|
479
480
|
}
|
|
480
481
|
const vaultsPerAvailableProviders = allVaults.filter((v) => v?.chain_type === 'stellar' ||
|
|
482
|
+
(v?.chain_type === 'solana' && !!this.solanaService) ||
|
|
481
483
|
(this.providers?.[v?.chain] ? true : false));
|
|
482
484
|
const vaultResponses = await Promise.all(vaultsPerAvailableProviders.map((v) => (0, getters_1.getVaultPositions)({
|
|
483
485
|
vault: v.address,
|
|
@@ -4,6 +4,10 @@ export interface ISolanaService {
|
|
|
4
4
|
connection: Connection;
|
|
5
5
|
getVaultState: (vaultProgramId: any, idl: any, vaultAddress?: any) => Promise<any>;
|
|
6
6
|
fetchUserShareBalance: (publicKey: any, shareMint: any) => Promise<any>;
|
|
7
|
+
fetchUserShareBalanceRaw: (publicKey: any, shareMint: any) => Promise<{
|
|
8
|
+
amount: string;
|
|
9
|
+
decimals: number | null;
|
|
10
|
+
}>;
|
|
7
11
|
}
|
|
8
12
|
export interface IVaultBaseOptions {
|
|
9
13
|
rpcUrl: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augustdigital/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"augustdigital",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"format": "eslint . --fix",
|
|
75
75
|
"lint-sdk": "lint-staged",
|
|
76
76
|
"benchmark": "node benchmarks/run.js",
|
|
77
|
-
"benchmark:ci": "node benchmarks/run.js --json benchmarks/results.json --md benchmarks/summary.md"
|
|
77
|
+
"benchmark:ci": "node benchmarks/run.js --json benchmarks/results.json --md benchmarks/summary.md",
|
|
78
|
+
"gen:version": "node scripts/update-version.js"
|
|
78
79
|
}
|
|
79
80
|
}
|