@affluent-org/sdk 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/share-vault/index.d.ts +37 -0
- package/dist/services/share-vault/index.js +6 -0
- package/dist/services/strategy-vault/index.d.ts +139 -0
- package/dist/services/strategy-vault/index.js +9 -0
- package/dist/services/strategy-vault/query.d.ts +1 -1
- package/dist/services/strategy-vault/query.js +17 -12
- package/dist/types/address.d.ts +7 -0
- package/dist/types/address.js +2 -0
- package/package.json +1 -1
|
@@ -87,4 +87,41 @@ export declare class ShareVaultServiceV1 {
|
|
|
87
87
|
forwardPayload: import("@ton/core").Cell;
|
|
88
88
|
queryId: bigint | undefined;
|
|
89
89
|
}>;
|
|
90
|
+
getValuationContext(vaultAddress: AddressInput): Promise<{
|
|
91
|
+
storage: {
|
|
92
|
+
totalSupply: bigint;
|
|
93
|
+
owner: Address | null;
|
|
94
|
+
manager: Address | null;
|
|
95
|
+
asset: Address;
|
|
96
|
+
balance: bigint;
|
|
97
|
+
cash: bigint;
|
|
98
|
+
totalTargetWeight: bigint;
|
|
99
|
+
nextAggregatorIndex: bigint;
|
|
100
|
+
isWtonVault: boolean;
|
|
101
|
+
assetWallet: Address | null;
|
|
102
|
+
whitelistedPools: Record<string, {
|
|
103
|
+
isWhitelisted: boolean;
|
|
104
|
+
targetWeight: bigint;
|
|
105
|
+
supply: bigint;
|
|
106
|
+
} & {
|
|
107
|
+
address: Address;
|
|
108
|
+
}>;
|
|
109
|
+
minimumGasFee: {
|
|
110
|
+
supply: bigint;
|
|
111
|
+
withdraw: bigint;
|
|
112
|
+
factorialSupply: bigint;
|
|
113
|
+
factorialWithdraw: bigint;
|
|
114
|
+
mintVaultShareTokens: bigint;
|
|
115
|
+
};
|
|
116
|
+
code: import("@ton/core").Cell;
|
|
117
|
+
address: Address;
|
|
118
|
+
};
|
|
119
|
+
totalSupply: bigint;
|
|
120
|
+
asset: Address;
|
|
121
|
+
reserve: bigint;
|
|
122
|
+
poolPositions: Record<string, query.PoolInfoForShareVault>;
|
|
123
|
+
netAmount: bigint;
|
|
124
|
+
exr: number;
|
|
125
|
+
}>;
|
|
126
|
+
getEXR(vaultAddress: AddressInput): Promise<number>;
|
|
90
127
|
}
|
|
@@ -127,5 +127,11 @@ class ShareVaultServiceV1 {
|
|
|
127
127
|
async sendWithdraw(sender, params, value) {
|
|
128
128
|
return (0, send_msg_1.sendMsg)(sender, user.createWithdrawMsg(this.ctx, sender, params, value));
|
|
129
129
|
}
|
|
130
|
+
async getValuationContext(vaultAddress) {
|
|
131
|
+
return query.getValuationContext(this.ctx, vaultAddress);
|
|
132
|
+
}
|
|
133
|
+
async getEXR(vaultAddress) {
|
|
134
|
+
return query.getEXR(this.ctx, vaultAddress);
|
|
135
|
+
}
|
|
130
136
|
}
|
|
131
137
|
exports.ShareVaultServiceV1 = ShareVaultServiceV1;
|
|
@@ -2121,4 +2121,143 @@ export declare class StrategyVaultV1 {
|
|
|
2121
2121
|
userAddress: import("@ton/core").Address;
|
|
2122
2122
|
queryId: bigint;
|
|
2123
2123
|
}>;
|
|
2124
|
+
getValuationContext(vaultAddress: AddressLike): Promise<{
|
|
2125
|
+
storage: {
|
|
2126
|
+
globalDepositValueCap: bigint;
|
|
2127
|
+
withdrawFeeRate: number;
|
|
2128
|
+
queueWithdrawFeeRate: number;
|
|
2129
|
+
depositQueueManager: import("../../contracts/vault/strategy-vault").QueueManager;
|
|
2130
|
+
withdrawQueueManager: import("../../contracts/vault/strategy-vault").QueueManager;
|
|
2131
|
+
interactiveVaultDict: Record<string, import("../../contracts/vault/strategy-vault").InteractiveVaultConfigItem>;
|
|
2132
|
+
xchainConnectorAddress: import("@ton/core").Address | null;
|
|
2133
|
+
xchainConfig: Record<string, {
|
|
2134
|
+
connected: boolean;
|
|
2135
|
+
xchainAccountAddress: bigint;
|
|
2136
|
+
oftConfig: Map<string, {
|
|
2137
|
+
destinationAddress: import("@ton/core").Address;
|
|
2138
|
+
forwardGas: bigint;
|
|
2139
|
+
forwardPayload?: import("@ton/core").Cell | null;
|
|
2140
|
+
lzTransferFeeRate?: bigint;
|
|
2141
|
+
}> | null;
|
|
2142
|
+
strategyConfig: Map<bigint, {
|
|
2143
|
+
isExecutable: boolean;
|
|
2144
|
+
}> | null;
|
|
2145
|
+
afterStrategyConfig: Map<bigint, {
|
|
2146
|
+
isExecutable: boolean;
|
|
2147
|
+
}> | null;
|
|
2148
|
+
lzGasFee: bigint;
|
|
2149
|
+
}>;
|
|
2150
|
+
xchainUpdateHash: bigint;
|
|
2151
|
+
owner: import("@ton/core").Address;
|
|
2152
|
+
manager: import("@ton/core").Address;
|
|
2153
|
+
assets: Record<string, import("../../contracts/vault/strategy-vault").AssetV2>;
|
|
2154
|
+
factorialPools: Record<string, import("../../contracts/vault/strategy-vault").FactorialPool>;
|
|
2155
|
+
aggregatorIndex: bigint;
|
|
2156
|
+
content: import("@ton/core").Cell;
|
|
2157
|
+
totalSupply: bigint;
|
|
2158
|
+
oracleConfig: import("@ton/core").Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig;
|
|
2159
|
+
rfqConfig: {
|
|
2160
|
+
priceDeviationTolerance: number;
|
|
2161
|
+
rfqEventEmitterAddress: string | null;
|
|
2162
|
+
} | null;
|
|
2163
|
+
gasConfig: Record<string, bigint> | null;
|
|
2164
|
+
isPrivateVault: boolean;
|
|
2165
|
+
depositCloseTimestamp: number;
|
|
2166
|
+
withdrawOpenTimestamp: number;
|
|
2167
|
+
whitelistedMinters: import("@ton/core").Dictionary<import("@ton/core").Address, Boolean>;
|
|
2168
|
+
lastCollectTime: number;
|
|
2169
|
+
managementFeeRatePerYear: number;
|
|
2170
|
+
protocolFeeRatePerYear: number;
|
|
2171
|
+
collectedManagementFee: bigint;
|
|
2172
|
+
collectedProtocolFee: bigint;
|
|
2173
|
+
rfqCode: import("@ton/core").Cell;
|
|
2174
|
+
walletCode: import("@ton/core").Cell;
|
|
2175
|
+
dataAggregatorCode: import("@ton/core").Cell;
|
|
2176
|
+
protocolFeeManagerAddress: import("@ton/core").Address;
|
|
2177
|
+
rfqIndex: bigint;
|
|
2178
|
+
isExecutingStrategy: boolean;
|
|
2179
|
+
maxLeverageRatio: number;
|
|
2180
|
+
assetWalletDict: Record<string, string>;
|
|
2181
|
+
walletAssetDict: Record<string, string>;
|
|
2182
|
+
managementFeeRecipientAddress: import("@ton/core").Address | null;
|
|
2183
|
+
guardianAddress: import("@ton/core").Address | null;
|
|
2184
|
+
timelock: bigint;
|
|
2185
|
+
pendingOwnerActionIndex: bigint;
|
|
2186
|
+
pendingOwnerActionCount: bigint;
|
|
2187
|
+
pendingOwnerAction: any;
|
|
2188
|
+
getFactorialPoolAsset: (poolAddress: import("@ton/core").Address, assetAddress: import("@ton/core").Address) => import("../../contracts/vault/strategy-vault").FactorialPoolShare;
|
|
2189
|
+
getAsset: (assetAddress: import("@ton/core").Address) => import("../../contracts/vault/strategy-vault").AssetV2;
|
|
2190
|
+
version: string;
|
|
2191
|
+
address: import("@ton/core").Address;
|
|
2192
|
+
balance: bigint;
|
|
2193
|
+
code: import("@ton/core").Cell;
|
|
2194
|
+
} | {
|
|
2195
|
+
globalDepositValueCap: bigint;
|
|
2196
|
+
withdrawFeeRate: number;
|
|
2197
|
+
queueWithdrawFeeRate: number;
|
|
2198
|
+
depositQueueManager: import("../../contracts/vault/strategy-vault").QueueManager;
|
|
2199
|
+
withdrawQueueManager: import("../../contracts/vault/strategy-vault").QueueManager;
|
|
2200
|
+
interactiveVaultDict: Record<string, import("../../contracts/vault/strategy-vault").InteractiveVaultConfigItem>;
|
|
2201
|
+
xchainConnectorAddress: null;
|
|
2202
|
+
xchainConfig: null;
|
|
2203
|
+
xchainUpdateHash: bigint;
|
|
2204
|
+
owner: import("@ton/core").Address;
|
|
2205
|
+
manager: import("@ton/core").Address;
|
|
2206
|
+
assets: Record<string, import("../../contracts/vault/strategy-vault").AssetV2>;
|
|
2207
|
+
factorialPools: Record<string, import("../../contracts/vault/strategy-vault").FactorialPool>;
|
|
2208
|
+
aggregatorIndex: bigint;
|
|
2209
|
+
content: import("@ton/core").Cell;
|
|
2210
|
+
totalSupply: bigint;
|
|
2211
|
+
oracleConfig: import("@ton/core").Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig;
|
|
2212
|
+
rfqConfig: {
|
|
2213
|
+
priceDeviationTolerance: number;
|
|
2214
|
+
rfqEventEmitterAddress: string | null;
|
|
2215
|
+
} | null;
|
|
2216
|
+
gasConfig: Record<string, bigint> | null;
|
|
2217
|
+
isPrivateVault: boolean;
|
|
2218
|
+
depositCloseTimestamp: number;
|
|
2219
|
+
withdrawOpenTimestamp: number;
|
|
2220
|
+
whitelistedMinters: import("@ton/core").Dictionary<import("@ton/core").Address, Boolean>;
|
|
2221
|
+
lastCollectTime: number;
|
|
2222
|
+
managementFeeRatePerYear: number;
|
|
2223
|
+
protocolFeeRatePerYear: number;
|
|
2224
|
+
collectedManagementFee: bigint;
|
|
2225
|
+
collectedProtocolFee: bigint;
|
|
2226
|
+
rfqCode: import("@ton/core").Cell;
|
|
2227
|
+
walletCode: import("@ton/core").Cell;
|
|
2228
|
+
dataAggregatorCode: import("@ton/core").Cell;
|
|
2229
|
+
protocolFeeManagerAddress: import("@ton/core").Address;
|
|
2230
|
+
rfqIndex: bigint;
|
|
2231
|
+
isExecutingStrategy: boolean;
|
|
2232
|
+
maxLeverageRatio: number;
|
|
2233
|
+
assetWalletDict: Record<string, string>;
|
|
2234
|
+
walletAssetDict: Record<string, string>;
|
|
2235
|
+
managementFeeRecipientAddress: import("@ton/core").Address | null;
|
|
2236
|
+
guardianAddress: import("@ton/core").Address | null;
|
|
2237
|
+
timelock: bigint;
|
|
2238
|
+
pendingOwnerActionIndex: bigint;
|
|
2239
|
+
pendingOwnerActionCount: bigint;
|
|
2240
|
+
pendingOwnerAction: any;
|
|
2241
|
+
getFactorialPoolAsset: (poolAddress: import("@ton/core").Address, assetAddress: import("@ton/core").Address) => import("../../contracts/vault/strategy-vault").FactorialPoolShare;
|
|
2242
|
+
getAsset: (assetAddress: import("@ton/core").Address) => import("../../contracts/vault/strategy-vault").AssetV2;
|
|
2243
|
+
version: string;
|
|
2244
|
+
address: import("@ton/core").Address;
|
|
2245
|
+
balance: bigint;
|
|
2246
|
+
code: import("@ton/core").Cell;
|
|
2247
|
+
};
|
|
2248
|
+
totalSupply: bigint;
|
|
2249
|
+
reserves: {
|
|
2250
|
+
[k: string]: bigint;
|
|
2251
|
+
};
|
|
2252
|
+
poolPositions: Record<string, Record<string, {
|
|
2253
|
+
supplyShare: bigint;
|
|
2254
|
+
supplyAmount: bigint;
|
|
2255
|
+
borrowShare: bigint;
|
|
2256
|
+
borrowAmount: bigint;
|
|
2257
|
+
}>>;
|
|
2258
|
+
price: bigint;
|
|
2259
|
+
priceInfo: import("../composite-oracle").Prices;
|
|
2260
|
+
}>;
|
|
2261
|
+
getPrice(vaultAddress: AddressLike): Promise<bigint>;
|
|
2262
|
+
getUnderlyingPrices(vaultAddress: AddressLike): Promise<any>;
|
|
2124
2263
|
}
|
|
@@ -264,5 +264,14 @@ class StrategyVaultV1 {
|
|
|
264
264
|
async sendCancelWithdrawQueue(sender, params) {
|
|
265
265
|
return (0, send_msg_1.sendMsg)(sender, user.createCancelWithdrawQueueMsg(this.ctx, params));
|
|
266
266
|
}
|
|
267
|
+
async getValuationContext(vaultAddress) {
|
|
268
|
+
return query.getValuationContext(this.ctx, vaultAddress);
|
|
269
|
+
}
|
|
270
|
+
async getPrice(vaultAddress) {
|
|
271
|
+
return query.getPrice(this.ctx, vaultAddress);
|
|
272
|
+
}
|
|
273
|
+
async getUnderlyingPrices(vaultAddress) {
|
|
274
|
+
return query.getUnderlyingPrices(this.ctx, vaultAddress);
|
|
275
|
+
}
|
|
267
276
|
}
|
|
268
277
|
exports.StrategyVaultV1 = StrategyVaultV1;
|
|
@@ -137,7 +137,7 @@ export declare function splitPureAndVaultAsset(ctx: AffluentContext, addresses:
|
|
|
137
137
|
vaultAssetAddresses: string[];
|
|
138
138
|
pureAssetAddresses: string[];
|
|
139
139
|
}>;
|
|
140
|
-
export declare function
|
|
140
|
+
export declare function getPoolDataForStrategyVault(ctx: AffluentContext, strategyVaultAddress: AddressInput): Promise<Record<string, PoolState>>;
|
|
141
141
|
export declare function getPoolPositionsForStrategyVault(ctx: AffluentContext, strategyVaultAddress: AddressInput): Promise<Record<string, Record<string, {
|
|
142
142
|
supplyShare: bigint;
|
|
143
143
|
supplyAmount: bigint;
|
|
@@ -7,7 +7,7 @@ exports.getRFQAuctionAddress = getRFQAuctionAddress;
|
|
|
7
7
|
exports.getRFQAuction = getRFQAuction;
|
|
8
8
|
exports.isVaultAsset = isVaultAsset;
|
|
9
9
|
exports.splitPureAndVaultAsset = splitPureAndVaultAsset;
|
|
10
|
-
exports.
|
|
10
|
+
exports.getPoolDataForStrategyVault = getPoolDataForStrategyVault;
|
|
11
11
|
exports.getPoolPositionsForStrategyVault = getPoolPositionsForStrategyVault;
|
|
12
12
|
exports.getValuationContext = getValuationContext;
|
|
13
13
|
exports.getPrice = getPrice;
|
|
@@ -65,19 +65,21 @@ async function splitPureAndVaultAsset(ctx, addresses) {
|
|
|
65
65
|
pureAssetAddresses,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
async function
|
|
68
|
+
async function getPoolDataForStrategyVault(ctx, strategyVaultAddress) {
|
|
69
69
|
const vaultData = await getVault(ctx, strategyVaultAddress).getVaultData();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
return [poolAddress,
|
|
74
|
-
})
|
|
70
|
+
const poolAddresses = Object.keys(vaultData.factorialPools);
|
|
71
|
+
const poolDataEntriesPromises = poolAddresses.map(async (poolAddress) => {
|
|
72
|
+
const pool = ctx.getByContract(pool_1.Pool, core_1.Address.parse(poolAddress));
|
|
73
|
+
return [poolAddress, await pool.getPoolData()];
|
|
74
|
+
});
|
|
75
|
+
const poolDataEntries = await Promise.all(poolDataEntriesPromises);
|
|
76
|
+
return Object.fromEntries(poolDataEntries);
|
|
75
77
|
}
|
|
76
78
|
async function getPoolPositionsForStrategyVault(ctx, strategyVaultAddress) {
|
|
77
79
|
const strategyVault = getVault(ctx, strategyVaultAddress);
|
|
78
80
|
const vaultData = await strategyVault.getVaultData();
|
|
79
81
|
const poolInfo = {};
|
|
80
|
-
const poolDatas = await
|
|
82
|
+
const poolDatas = await getPoolDataForStrategyVault(ctx, strategyVaultAddress);
|
|
81
83
|
for (const [poolAddress, poolPosition] of Object.entries(vaultData.factorialPools)) {
|
|
82
84
|
const poolData = poolDatas[poolAddress];
|
|
83
85
|
const position = {};
|
|
@@ -118,9 +120,12 @@ async function getPrice(ctx, strategyVaultAddress) {
|
|
|
118
120
|
}
|
|
119
121
|
async function getUnderlyingPrices(ctx, strategyVaultAddress) {
|
|
120
122
|
const valuationCtx = await getValuationContext(ctx, strategyVaultAddress);
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const underlyingPriceEntries = Object.keys(valuationCtx.storage.assets)
|
|
124
|
+
.map(assetAddress => {
|
|
125
|
+
const priceData = valuationCtx.priceInfo[assetAddress];
|
|
126
|
+
if (!priceData)
|
|
127
|
+
throw new Error(`Price data not found for asset ${assetAddress}`);
|
|
128
|
+
return [assetAddress, priceData.price];
|
|
129
|
+
});
|
|
125
130
|
return Object.fromEntries(underlyingPriceEntries);
|
|
126
131
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Brand<T, B> = T & {
|
|
2
|
+
readonly __brand: B;
|
|
3
|
+
};
|
|
4
|
+
export type AssetAddress = Brand<string, 'AssetAddress'>;
|
|
5
|
+
export type PoolAddress = Brand<string, 'PoolAddress'>;
|
|
6
|
+
export type PoolAccountAddress = Brand<string, 'PoolAccountAddress'>;
|
|
7
|
+
export type VaultAddress = Brand<string, 'VaultAddress'>;
|