@affluent-org/sdk 0.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/.prettierrc +11 -0
- package/Refactoring.md +548 -0
- package/dist/_compiled/Account.compiled.json +1 -0
- package/dist/_compiled/Receipt.compiled.json +1 -0
- package/dist/_compiled/WTONWallet.compiled.json +1 -0
- package/dist/_compiled/index.d.ts +4 -0
- package/dist/_compiled/index.js +12 -0
- package/dist/affluent.d.ts +14 -0
- package/dist/affluent.js +20 -0
- package/dist/constants/constants.d.ts +2 -0
- package/dist/constants/constants.js +5 -0
- package/dist/constants/contracts.d.ts +9 -0
- package/dist/constants/contracts.js +18 -0
- package/dist/context.d.ts +43 -0
- package/dist/context.js +90 -0
- package/dist/contracts/common/type.d.ts +16 -0
- package/dist/contracts/common/type.js +2 -0
- package/dist/contracts/common/utils.d.ts +3 -0
- package/dist/contracts/common/utils.js +16 -0
- package/dist/contracts/core/account/index.d.ts +38 -0
- package/dist/contracts/core/account/index.js +128 -0
- package/dist/contracts/core/account/type.d.ts +18 -0
- package/dist/contracts/core/account/type.js +2 -0
- package/dist/contracts/core/pool/index.d.ts +149 -0
- package/dist/contracts/core/pool/index.js +379 -0
- package/dist/contracts/core/pool/serializer.d.ts +15 -0
- package/dist/contracts/core/pool/serializer.js +307 -0
- package/dist/contracts/core/pool/type.d.ts +136 -0
- package/dist/contracts/core/pool/type.js +2 -0
- package/dist/contracts/dedust-farm/MockDedustFarm.d.ts +41 -0
- package/dist/contracts/dedust-farm/MockDedustFarm.js +79 -0
- package/dist/contracts/external/tonstaker.d.ts +18 -0
- package/dist/contracts/external/tonstaker.js +26 -0
- package/dist/contracts/factory/factory.d.ts +24 -0
- package/dist/contracts/factory/factory.js +58 -0
- package/dist/contracts/factory/type.d.ts +11 -0
- package/dist/contracts/factory/type.js +2 -0
- package/dist/contracts/farm/distributor.d.ts +43 -0
- package/dist/contracts/farm/distributor.js +83 -0
- package/dist/contracts/farm/receipt.d.ts +40 -0
- package/dist/contracts/farm/receipt.js +68 -0
- package/dist/contracts/irm/jump-irm/serializer.d.ts +4 -0
- package/dist/contracts/irm/jump-irm/serializer.js +26 -0
- package/dist/contracts/irm/jump-irm/type.d.ts +8 -0
- package/dist/contracts/irm/jump-irm/type.js +2 -0
- package/dist/contracts/jetton/jetton-minter.d.ts +23 -0
- package/dist/contracts/jetton/jetton-minter.js +46 -0
- package/dist/contracts/jetton/jetton-wallet.d.ts +67 -0
- package/dist/contracts/jetton/jetton-wallet.js +119 -0
- package/dist/contracts/jetton/type.d.ts +7 -0
- package/dist/contracts/jetton/type.js +2 -0
- package/dist/contracts/liquid_token/dedust/minter.d.ts +56 -0
- package/dist/contracts/liquid_token/dedust/minter.js +112 -0
- package/dist/contracts/liquid_token/dedust/wallet.d.ts +127 -0
- package/dist/contracts/liquid_token/dedust/wallet.js +213 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonMinter.d.ts +53 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonMinter.js +110 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonWallet.d.ts +169 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonWallet.js +288 -0
- package/dist/contracts/oracle/composite-onchain-oracle/index.d.ts +108 -0
- package/dist/contracts/oracle/composite-onchain-oracle/index.js +185 -0
- package/dist/contracts/oracle/parser.d.ts +7 -0
- package/dist/contracts/oracle/parser.js +77 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/index.d.ts +56 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/index.js +159 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/serializer.d.ts +4 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/serializer.js +137 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/type.d.ts +57 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/type.js +18 -0
- package/dist/contracts/oracle/redstone-oracle/serializer.d.ts +3 -0
- package/dist/contracts/oracle/redstone-oracle/serializer.js +30 -0
- package/dist/contracts/oracle/redstone-oracle/type.d.ts +9 -0
- package/dist/contracts/oracle/redstone-oracle/type.js +2 -0
- package/dist/contracts/oracle/redstone-parser.d.ts +9 -0
- package/dist/contracts/oracle/redstone-parser.js +58 -0
- package/dist/contracts/rfq/rfq_auction/index.d.ts +216 -0
- package/dist/contracts/rfq/rfq_auction/index.js +334 -0
- package/dist/contracts/rfq/rfq_batch/index.d.ts +346 -0
- package/dist/contracts/rfq/rfq_batch/index.js +448 -0
- package/dist/contracts/rfq/rfq_event_emitter/index.d.ts +132 -0
- package/dist/contracts/rfq/rfq_event_emitter/index.js +143 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmItem.d.ts +41 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmItem.js +83 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmMinter.d.ts +45 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmMinter.js +92 -0
- package/dist/contracts/unknown-contract/index.d.ts +14 -0
- package/dist/contracts/unknown-contract/index.js +18 -0
- package/dist/contracts/vault/share-vault/index.d.ts +206 -0
- package/dist/contracts/vault/share-vault/index.js +373 -0
- package/dist/contracts/vault/strategy-vault/codec.d.ts +710 -0
- package/dist/contracts/vault/strategy-vault/codec.js +1256 -0
- package/dist/contracts/vault/strategy-vault/computation.d.ts +11 -0
- package/dist/contracts/vault/strategy-vault/computation.js +56 -0
- package/dist/contracts/vault/strategy-vault/constants.d.ts +163 -0
- package/dist/contracts/vault/strategy-vault/constants.js +170 -0
- package/dist/contracts/vault/strategy-vault/index.d.ts +587 -0
- package/dist/contracts/vault/strategy-vault/index.js +406 -0
- package/dist/contracts/vault/strategy-vault/type.d.ts +115 -0
- package/dist/contracts/vault/strategy-vault/type.js +2 -0
- package/dist/contracts/wton/jetton-minter.d.ts +35 -0
- package/dist/contracts/wton/jetton-minter.js +71 -0
- package/dist/contracts/wton/jetton-wallet.d.ts +90 -0
- package/dist/contracts/wton/jetton-wallet.js +153 -0
- package/dist/contracts/wton/type.d.ts +7 -0
- package/dist/contracts/wton/type.js +2 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +65 -0
- package/dist/lib/assert.d.ts +1 -0
- package/dist/lib/assert.js +9 -0
- package/dist/lib/query-cache.d.ts +5 -0
- package/dist/lib/query-cache.js +57 -0
- package/dist/lib/send-msg.d.ts +11 -0
- package/dist/lib/send-msg.js +9 -0
- package/dist/services/composite-oracle/computation.d.ts +55 -0
- package/dist/services/composite-oracle/computation.js +295 -0
- package/dist/services/composite-oracle/index.d.ts +45 -0
- package/dist/services/composite-oracle/index.js +110 -0
- package/dist/services/composite-oracle/query.d.ts +36 -0
- package/dist/services/composite-oracle/query.js +251 -0
- package/dist/services/composite-oracle/types.d.ts +82 -0
- package/dist/services/composite-oracle/types.js +11 -0
- package/dist/services/pool/computation.d.ts +75 -0
- package/dist/services/pool/computation.js +219 -0
- package/dist/services/pool/index.d.ts +94 -0
- package/dist/services/pool/index.js +139 -0
- package/dist/services/pool/oracle.d.ts +20 -0
- package/dist/services/pool/oracle.js +61 -0
- package/dist/services/pool/owner/index.d.ts +37 -0
- package/dist/services/pool/owner/index.js +76 -0
- package/dist/services/pool/owner/types.d.ts +18 -0
- package/dist/services/pool/owner/types.js +2 -0
- package/dist/services/pool/query.d.ts +64 -0
- package/dist/services/pool/query.js +282 -0
- package/dist/services/pool/user/index.d.ts +86 -0
- package/dist/services/pool/user/index.js +285 -0
- package/dist/services/pool/user/types.d.ts +44 -0
- package/dist/services/pool/user/types.js +2 -0
- package/dist/services/rfq-auction/index.d.ts +81 -0
- package/dist/services/rfq-auction/index.js +93 -0
- package/dist/services/rfq-auction/oracle.d.ts +19 -0
- package/dist/services/rfq-auction/oracle.js +60 -0
- package/dist/services/rfq-auction/query.d.ts +50 -0
- package/dist/services/rfq-auction/query.js +19 -0
- package/dist/services/rfq-auction/user/index.d.ts +63 -0
- package/dist/services/rfq-auction/user/index.js +218 -0
- package/dist/services/rfq-auction/user/types.d.ts +29 -0
- package/dist/services/rfq-auction/user/types.js +2 -0
- package/dist/services/rfq-batch/index.d.ts +78 -0
- package/dist/services/rfq-batch/index.js +132 -0
- package/dist/services/rfq-batch/oracle.d.ts +22 -0
- package/dist/services/rfq-batch/oracle.js +54 -0
- package/dist/services/rfq-batch/query.d.ts +46 -0
- package/dist/services/rfq-batch/query.js +34 -0
- package/dist/services/rfq-batch/user/index.d.ts +79 -0
- package/dist/services/rfq-batch/user/index.js +171 -0
- package/dist/services/rfq-batch/user/types.d.ts +37 -0
- package/dist/services/rfq-batch/user/types.js +2 -0
- package/dist/services/share-vault/computation.d.ts +24 -0
- package/dist/services/share-vault/computation.js +42 -0
- package/dist/services/share-vault/index.d.ts +90 -0
- package/dist/services/share-vault/index.js +128 -0
- package/dist/services/share-vault/manager/index.d.ts +40 -0
- package/dist/services/share-vault/manager/index.js +111 -0
- package/dist/services/share-vault/manager/types.d.ts +23 -0
- package/dist/services/share-vault/manager/types.js +2 -0
- package/dist/services/share-vault/owner/index.d.ts +64 -0
- package/dist/services/share-vault/owner/index.js +122 -0
- package/dist/services/share-vault/owner/types.d.ts +33 -0
- package/dist/services/share-vault/owner/types.js +2 -0
- package/dist/services/share-vault/query.d.ts +34 -0
- package/dist/services/share-vault/query.js +138 -0
- package/dist/services/share-vault/user/index.d.ts +33 -0
- package/dist/services/share-vault/user/index.js +106 -0
- package/dist/services/share-vault/user/types.d.ts +13 -0
- package/dist/services/share-vault/user/types.js +2 -0
- package/dist/services/strategy-vault/index.d.ts +2124 -0
- package/dist/services/strategy-vault/index.js +268 -0
- package/dist/services/strategy-vault/manager/index.d.ts +1968 -0
- package/dist/services/strategy-vault/manager/index.js +475 -0
- package/dist/services/strategy-vault/manager/types.d.ts +144 -0
- package/dist/services/strategy-vault/manager/types.js +2 -0
- package/dist/services/strategy-vault/oracle.d.ts +66 -0
- package/dist/services/strategy-vault/oracle.js +162 -0
- package/dist/services/strategy-vault/owner/index.d.ts +277 -0
- package/dist/services/strategy-vault/owner/index.js +333 -0
- package/dist/services/strategy-vault/owner/types.d.ts +146 -0
- package/dist/services/strategy-vault/owner/types.js +2 -0
- package/dist/services/strategy-vault/query.d.ts +138 -0
- package/dist/services/strategy-vault/query.js +59 -0
- package/dist/services/strategy-vault/user/index.d.ts +89 -0
- package/dist/services/strategy-vault/user/index.js +219 -0
- package/dist/services/strategy-vault/user/types.d.ts +46 -0
- package/dist/services/strategy-vault/user/types.js +2 -0
- package/dist/types/sender.d.ts +7 -0
- package/dist/types/sender.js +2 -0
- package/dist/utils/action-parser.d.ts +7 -0
- package/dist/utils/action-parser.js +20 -0
- package/dist/utils/external-message-hash.d.ts +45 -0
- package/dist/utils/external-message-hash.js +65 -0
- package/dist/utils/oracle/redstone/readonlyCachedRedstone.d.ts +3 -0
- package/dist/utils/oracle/redstone/readonlyCachedRedstone.js +25 -0
- package/dist/utils/oracle/redstone/redstoneHelper.d.ts +21 -0
- package/dist/utils/oracle/redstone/redstoneHelper.js +228 -0
- package/dist/utils/parser.d.ts +40 -0
- package/dist/utils/parser.js +580 -0
- package/dist/utils/pending-tracker/index.d.ts +14 -0
- package/dist/utils/pending-tracker/index.js +34 -0
- package/dist/utils/pending-tracker/trackable-sender.d.ts +16 -0
- package/dist/utils/pending-tracker/trackable-sender.js +87 -0
- package/dist/utils/pending-tracker/type.d.ts +78 -0
- package/dist/utils/pending-tracker/type.js +2 -0
- package/dist/utils/pending-tracker/v3-client.d.ts +31 -0
- package/dist/utils/pending-tracker/v3-client.js +104 -0
- package/dist/utils/risk_calculator/risk_calculator.d.ts +45 -0
- package/dist/utils/risk_calculator/risk_calculator.js +332 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +12 -0
- package/package.json +46 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { StrategyVaultState } from "../../contracts/vault/strategy-vault";
|
|
5
|
+
import { PoolState } from "../../contracts/core/pool/type";
|
|
6
|
+
import { OracleExposures } from "../composite-oracle/computation";
|
|
7
|
+
import { VaultPositions } from "../composite-oracle/types";
|
|
8
|
+
export { OracleExposures, createOracleExposures } from "../composite-oracle/computation";
|
|
9
|
+
/**
|
|
10
|
+
* Build oracle params Cell from pre-fetched data
|
|
11
|
+
* Pure computation - no network calls
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildOracleParamsCellFromData(assets: string[], oracleConfig: any, vaultPositions: VaultPositions, extraPools?: string[]): Promise<Cell>;
|
|
14
|
+
/**
|
|
15
|
+
* Build oracle params with bucket from pre-fetched data
|
|
16
|
+
* Pure computation - no network calls
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildOracleParamsWithBucketFromData(assets: string[], oracleConfig: any, vaultPositions: VaultPositions, initialBucket?: OracleExposures, extraPools?: string[]): {
|
|
19
|
+
oracleParamsPromise: Promise<Cell>;
|
|
20
|
+
bucket: OracleExposures;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get oracle params for a strategy vault
|
|
24
|
+
*/
|
|
25
|
+
export declare function getOracleParams(ctx: AffluentContext, vaultAddress: AddressLike, vaultData?: StrategyVaultState, extraAssets?: {
|
|
26
|
+
assets: string[];
|
|
27
|
+
vaultAssets: string[];
|
|
28
|
+
}): Promise<Cell>;
|
|
29
|
+
/**
|
|
30
|
+
* Get oracle params with bucket information (for gas calculation)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getOracleParamsWithBucket(ctx: AffluentContext, vaultAddress: AddressLike, vaultData?: StrategyVaultState, bucket?: OracleExposures, extraAssets?: string[]): Promise<{
|
|
33
|
+
oracleParams: Cell;
|
|
34
|
+
bucket: OracleExposures;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Get oracle params for pool (used in factorial pool operations)
|
|
38
|
+
*/
|
|
39
|
+
export declare function getOracleParamsForPool(ctx: AffluentContext, poolAddress: AddressInput, anyAssets?: string[]): Promise<Cell>;
|
|
40
|
+
/**
|
|
41
|
+
* Oracle helper class for strategy vault operations
|
|
42
|
+
*/
|
|
43
|
+
export declare class OracleHelper {
|
|
44
|
+
private ctx;
|
|
45
|
+
private fetcher;
|
|
46
|
+
constructor(ctx?: AffluentContext);
|
|
47
|
+
/**
|
|
48
|
+
* Get oracle params for strategy vault with bucket
|
|
49
|
+
*/
|
|
50
|
+
getOracleParamsForStrategyVaultV2(vaultData: StrategyVaultState, additionalAssets?: string[]): Promise<{
|
|
51
|
+
oracleParams: Cell;
|
|
52
|
+
bucket: OracleExposures;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Get oracle params for pool
|
|
56
|
+
*/
|
|
57
|
+
getOracleParamsForPool(poolData: PoolState, anyAssets?: string[]): Promise<Cell>;
|
|
58
|
+
/**
|
|
59
|
+
* Get oracle params for strategy vault by address with bucket
|
|
60
|
+
*/
|
|
61
|
+
getOracleParamsForStrategyVault(vaultAddressOrData: AddressLike | StrategyVaultState, vaultDataOrBucket?: StrategyVaultState | OracleExposures, bucket?: OracleExposures): Promise<{
|
|
62
|
+
oracleParams: Cell;
|
|
63
|
+
bucket: OracleExposures;
|
|
64
|
+
}>;
|
|
65
|
+
private getOracleParamsForStrategyVaultWithAddress;
|
|
66
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OracleHelper = exports.createOracleExposures = void 0;
|
|
4
|
+
exports.buildOracleParamsCellFromData = buildOracleParamsCellFromData;
|
|
5
|
+
exports.buildOracleParamsWithBucketFromData = buildOracleParamsWithBucketFromData;
|
|
6
|
+
exports.getOracleParams = getOracleParams;
|
|
7
|
+
exports.getOracleParamsWithBucket = getOracleParamsWithBucket;
|
|
8
|
+
exports.getOracleParamsForPool = getOracleParamsForPool;
|
|
9
|
+
const core_1 = require("@ton/core");
|
|
10
|
+
const context_1 = require("../../context");
|
|
11
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
12
|
+
const strategy_vault_1 = require("../../contracts/vault/strategy-vault");
|
|
13
|
+
const pool_1 = require("../../contracts/core/pool");
|
|
14
|
+
const query_1 = require("../composite-oracle/query");
|
|
15
|
+
const computation_1 = require("../composite-oracle/computation");
|
|
16
|
+
const computation_2 = require("../composite-oracle/computation");
|
|
17
|
+
// Re-export for backward compatibility
|
|
18
|
+
var computation_3 = require("../composite-oracle/computation");
|
|
19
|
+
Object.defineProperty(exports, "createOracleExposures", { enumerable: true, get: function () { return computation_3.createOracleExposures; } });
|
|
20
|
+
// ============================================================
|
|
21
|
+
// Pure Computation (no I/O)
|
|
22
|
+
// ============================================================
|
|
23
|
+
/**
|
|
24
|
+
* Build oracle params Cell from pre-fetched data
|
|
25
|
+
* Pure computation - no network calls
|
|
26
|
+
*/
|
|
27
|
+
function buildOracleParamsCellFromData(assets, oracleConfig, vaultPositions, extraPools) {
|
|
28
|
+
const { assets: pureAssets, vaultAssets } = (0, computation_1.separateAssets)(assets, oracleConfig);
|
|
29
|
+
const exposures = (0, computation_1.getExposures)(vaultPositions);
|
|
30
|
+
const allAssets = [...new Set([...pureAssets, ...exposures.assets])];
|
|
31
|
+
const allPools = [...new Set([...exposures.pools, ...(extraPools ?? [])])];
|
|
32
|
+
return (0, computation_2.buildOracleParamsCell)(allAssets, oracleConfig, allPools, vaultAssets);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build oracle params with bucket from pre-fetched data
|
|
36
|
+
* Pure computation - no network calls
|
|
37
|
+
*/
|
|
38
|
+
function buildOracleParamsWithBucketFromData(assets, oracleConfig, vaultPositions, initialBucket, extraPools) {
|
|
39
|
+
const bucket = initialBucket ?? (0, computation_2.createOracleExposures)();
|
|
40
|
+
const { assets: pureAssets, vaultAssets } = (0, computation_1.separateAssets)(assets, oracleConfig);
|
|
41
|
+
const exposures = (0, computation_1.getExposures)(vaultPositions);
|
|
42
|
+
// Populate bucket
|
|
43
|
+
[...new Set([...pureAssets, ...exposures.assets])].forEach((a) => bucket.assets.add(a));
|
|
44
|
+
exposures.pools.forEach((p) => bucket.pools.add(p));
|
|
45
|
+
(extraPools ?? []).forEach((p) => bucket.pools.add(p));
|
|
46
|
+
vaultAssets.forEach((v) => bucket.vaults.add(v));
|
|
47
|
+
const oracleParamsPromise = (0, computation_2.buildOracleParamsCell)([...bucket.assets], oracleConfig, [...bucket.pools], [...bucket.vaults]);
|
|
48
|
+
return { oracleParamsPromise, bucket };
|
|
49
|
+
}
|
|
50
|
+
// ============================================================
|
|
51
|
+
// Orchestration (fetch + compute)
|
|
52
|
+
// ============================================================
|
|
53
|
+
/**
|
|
54
|
+
* Get oracle params for a strategy vault
|
|
55
|
+
*/
|
|
56
|
+
async function getOracleParams(ctx, vaultAddress, vaultData, extraAssets) {
|
|
57
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
58
|
+
const oracleCtx = await fetcher.getOracleContext(vaultAddress, vaultData, extraAssets);
|
|
59
|
+
return (0, computation_2.buildOracleParamsCell)(oracleCtx.allRequiredAssets, oracleCtx.oracleConfig, oracleCtx.exposures.pools, oracleCtx.vaultAssets);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get oracle params with bucket information (for gas calculation)
|
|
63
|
+
*/
|
|
64
|
+
async function getOracleParamsWithBucket(ctx, vaultAddress, vaultData, bucket, extraAssets) {
|
|
65
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
66
|
+
const vault = ctx.getByContract(strategy_vault_1.StrategyVault, (0, utils_1.toAddress)(vaultAddress));
|
|
67
|
+
vaultData = vaultData ?? (await vault.getVaultData());
|
|
68
|
+
const oracleConfig = vaultData.oracleConfig;
|
|
69
|
+
let { assets, vaultAssets } = (0, computation_1.separateAssets)(Object.keys(vaultData.assets), oracleConfig);
|
|
70
|
+
if (extraAssets) {
|
|
71
|
+
const separated = (0, computation_1.separateAssets)(extraAssets, oracleConfig);
|
|
72
|
+
assets = [...new Set([...assets, ...separated.assets])];
|
|
73
|
+
vaultAssets = [...new Set([...vaultAssets, ...separated.vaultAssets])];
|
|
74
|
+
}
|
|
75
|
+
// Fetch
|
|
76
|
+
const vaultPositions = await fetcher.fetchVaultPositions([...vaultAssets, vault.address]);
|
|
77
|
+
// Compute
|
|
78
|
+
const allAssets = [...new Set([...Object.keys(vaultData.assets), ...(extraAssets ?? [])])];
|
|
79
|
+
const result = buildOracleParamsWithBucketFromData(allAssets, oracleConfig, vaultPositions, bucket);
|
|
80
|
+
return { oracleParams: await result.oracleParamsPromise, bucket: result.bucket };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get oracle params for pool (used in factorial pool operations)
|
|
84
|
+
*/
|
|
85
|
+
async function getOracleParamsForPool(ctx, poolAddress, anyAssets = []) {
|
|
86
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
87
|
+
const pool = ctx.getByContract(pool_1.Pool, (0, utils_1.toAddress)(poolAddress));
|
|
88
|
+
const poolData = await pool.getPoolData();
|
|
89
|
+
const oracleConfig = poolData.oracleConfig;
|
|
90
|
+
const allAssets = [...new Set([...Object.keys(poolData.assets), ...anyAssets])];
|
|
91
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(allAssets, oracleConfig);
|
|
92
|
+
// Fetch
|
|
93
|
+
const vaultPositions = await fetcher.fetchVaultPositions(vaultAssets.map((v) => core_1.Address.parse(v)));
|
|
94
|
+
// Compute
|
|
95
|
+
return buildOracleParamsCellFromData(allAssets, oracleConfig, vaultPositions);
|
|
96
|
+
}
|
|
97
|
+
// ============================================================
|
|
98
|
+
// OracleHelper Class
|
|
99
|
+
// ============================================================
|
|
100
|
+
/**
|
|
101
|
+
* Oracle helper class for strategy vault operations
|
|
102
|
+
*/
|
|
103
|
+
class OracleHelper {
|
|
104
|
+
ctx;
|
|
105
|
+
fetcher;
|
|
106
|
+
constructor(ctx = context_1.AffluentContext.getInstance()) {
|
|
107
|
+
this.ctx = ctx;
|
|
108
|
+
this.fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get oracle params for strategy vault with bucket
|
|
112
|
+
*/
|
|
113
|
+
async getOracleParamsForStrategyVaultV2(vaultData, additionalAssets = []) {
|
|
114
|
+
const oracleConfig = vaultData.oracleConfig;
|
|
115
|
+
const allAssets = [...Object.keys(vaultData.assets), ...additionalAssets];
|
|
116
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(allAssets, oracleConfig);
|
|
117
|
+
// Fetch
|
|
118
|
+
const vaultPositions = await this.fetcher.fetchVaultPositions(vaultAssets);
|
|
119
|
+
// Compute
|
|
120
|
+
const result = buildOracleParamsWithBucketFromData(allAssets, oracleConfig, vaultPositions);
|
|
121
|
+
return { oracleParams: await result.oracleParamsPromise, bucket: result.bucket };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get oracle params for pool
|
|
125
|
+
*/
|
|
126
|
+
async getOracleParamsForPool(poolData, anyAssets = []) {
|
|
127
|
+
const oracleConfig = poolData.oracleConfig;
|
|
128
|
+
const allAssets = [...new Set([...Object.keys(poolData.assets), ...anyAssets])];
|
|
129
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(allAssets, oracleConfig);
|
|
130
|
+
// Fetch
|
|
131
|
+
const vaultPositions = await this.fetcher.fetchVaultPositions(vaultAssets.map((v) => core_1.Address.parse(v)));
|
|
132
|
+
// Compute
|
|
133
|
+
return buildOracleParamsCellFromData(allAssets, oracleConfig, vaultPositions);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get oracle params for strategy vault by address with bucket
|
|
137
|
+
*/
|
|
138
|
+
async getOracleParamsForStrategyVault(vaultAddressOrData, vaultDataOrBucket, bucket) {
|
|
139
|
+
if (typeof vaultAddressOrData === "object" && "oracleConfig" in vaultAddressOrData) {
|
|
140
|
+
const vaultData = vaultAddressOrData;
|
|
141
|
+
const additionalAssets = Array.isArray(vaultDataOrBucket) ? vaultDataOrBucket : [];
|
|
142
|
+
return this.getOracleParamsForStrategyVaultV2(vaultData, additionalAssets);
|
|
143
|
+
}
|
|
144
|
+
const vaultAddress = vaultAddressOrData;
|
|
145
|
+
const vaultData = vaultDataOrBucket;
|
|
146
|
+
return this.getOracleParamsForStrategyVaultWithAddress(vaultAddress, vaultData, bucket);
|
|
147
|
+
}
|
|
148
|
+
async getOracleParamsForStrategyVaultWithAddress(vaultAddress, vaultData, bucket) {
|
|
149
|
+
const vault = this.ctx.getByContract(strategy_vault_1.StrategyVault, (0, utils_1.toAddress)(vaultAddress));
|
|
150
|
+
vaultData = vaultData ?? (await vault.getVaultData());
|
|
151
|
+
const oracleConfig = vaultData.oracleConfig;
|
|
152
|
+
const allAssets = Object.keys(vaultData.assets);
|
|
153
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(allAssets, oracleConfig);
|
|
154
|
+
const extraPools = Object.keys(vaultData.factorialPools);
|
|
155
|
+
// Fetch
|
|
156
|
+
const vaultPositions = await this.fetcher.fetchVaultPositions(vaultAssets);
|
|
157
|
+
// Compute
|
|
158
|
+
const result = buildOracleParamsWithBucketFromData(allAssets, oracleConfig, vaultPositions, bucket, extraPools);
|
|
159
|
+
return { oracleParams: await result.oracleParamsPromise, bucket: result.bucket };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.OracleHelper = OracleHelper;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Dictionary } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../../context";
|
|
3
|
+
import { StrategyVault } from "../../../contracts/vault/strategy-vault";
|
|
4
|
+
import { SetOwnerParams, SetGuardianAddressParams, SetManagerParams, SetPrivateVaultParams, SetWhitelistedMintersParams, SetMaxLeverageRatioParams, ExecuteOwnerActionParams, RevertOwnerActionParams, SetTimelockParams, SetManagementFeeRecipientAddressParams, SetProtocolFeeRatePerYearParams, SetProtocolFeeManagerAddressParams, SetFactorialPoolConfigParams, SetAssetConfigParams, SetRFQConfigParams, SetManagementFeeRatePerYearParams, SetDepositCloseTimestampParams, SetWithdrawOpenTimestampParams, SetGasConfigParams, SetOracleConfigParams, SetWalletCodeParams, SetDataAggregatorCodeParams, SetRFQCodeParams, SetContentParams, UpgradeCodeParams, CollectProtocolFeeParams, ClaimManagementFeeParams } from "./types";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export declare function createSetOwnerMsg(ctx: AffluentContext, params: SetOwnerParams): Promise<{
|
|
7
|
+
opts: {
|
|
8
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
9
|
+
};
|
|
10
|
+
input: {
|
|
11
|
+
to: import("@ton/core").Address;
|
|
12
|
+
value: bigint;
|
|
13
|
+
body: import("@ton/core").Cell;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
export declare function createSetGuardianAddressMsg(ctx: AffluentContext, params: SetGuardianAddressParams, value?: bigint): Promise<{
|
|
17
|
+
opts: {
|
|
18
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
19
|
+
};
|
|
20
|
+
input: {
|
|
21
|
+
to: import("@ton/core").Address;
|
|
22
|
+
value: bigint;
|
|
23
|
+
body: import("@ton/core").Cell;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export declare function createSetManagerMsg(ctx: AffluentContext, params: SetManagerParams): Promise<{
|
|
27
|
+
opts: {
|
|
28
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
29
|
+
};
|
|
30
|
+
input: {
|
|
31
|
+
to: import("@ton/core").Address;
|
|
32
|
+
value: bigint;
|
|
33
|
+
body: import("@ton/core").Cell;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
export declare function createSetPrivateVaultMsg(ctx: AffluentContext, params: SetPrivateVaultParams, value?: bigint): Promise<{
|
|
37
|
+
opts: {
|
|
38
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
39
|
+
};
|
|
40
|
+
input: {
|
|
41
|
+
to: import("@ton/core").Address;
|
|
42
|
+
value: bigint;
|
|
43
|
+
body: import("@ton/core").Cell;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
export declare function createSetWhitelistedMintersMsg(ctx: AffluentContext, params: SetWhitelistedMintersParams, value?: bigint): Promise<{
|
|
47
|
+
opts: {
|
|
48
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
49
|
+
mintersDict: Dictionary<import("@ton/core").Address, any>;
|
|
50
|
+
};
|
|
51
|
+
input: {
|
|
52
|
+
to: import("@ton/core").Address;
|
|
53
|
+
value: bigint;
|
|
54
|
+
body: import("@ton/core").Cell;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export declare function createSetMaxLeverageRatioMsg(ctx: AffluentContext, params: SetMaxLeverageRatioParams, value?: bigint): Promise<{
|
|
58
|
+
opts: {
|
|
59
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
60
|
+
};
|
|
61
|
+
input: {
|
|
62
|
+
to: import("@ton/core").Address;
|
|
63
|
+
value: bigint;
|
|
64
|
+
body: import("@ton/core").Cell;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
export declare function createExecuteOwnerActionMsg(ctx: AffluentContext, params: ExecuteOwnerActionParams, value?: bigint): Promise<{
|
|
68
|
+
opts: {
|
|
69
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
70
|
+
};
|
|
71
|
+
input: {
|
|
72
|
+
to: import("@ton/core").Address;
|
|
73
|
+
value: bigint;
|
|
74
|
+
body: import("@ton/core").Cell;
|
|
75
|
+
};
|
|
76
|
+
}>;
|
|
77
|
+
export declare function createRevertOwnerActionMsg(ctx: AffluentContext, params: RevertOwnerActionParams, value?: bigint): Promise<{
|
|
78
|
+
opts: {
|
|
79
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
80
|
+
};
|
|
81
|
+
input: {
|
|
82
|
+
to: import("@ton/core").Address;
|
|
83
|
+
value: bigint;
|
|
84
|
+
body: import("@ton/core").Cell;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
export declare function createSetTimelockMsg(ctx: AffluentContext, params: SetTimelockParams, value?: bigint): Promise<{
|
|
88
|
+
opts: {
|
|
89
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
90
|
+
};
|
|
91
|
+
input: {
|
|
92
|
+
to: import("@ton/core").Address;
|
|
93
|
+
value: bigint;
|
|
94
|
+
body: import("@ton/core").Cell;
|
|
95
|
+
};
|
|
96
|
+
}>;
|
|
97
|
+
export declare function createSetManagementFeeRecipientAddressMsg(ctx: AffluentContext, params: SetManagementFeeRecipientAddressParams, value?: bigint): Promise<{
|
|
98
|
+
opts: {
|
|
99
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
100
|
+
};
|
|
101
|
+
input: {
|
|
102
|
+
to: import("@ton/core").Address;
|
|
103
|
+
value: bigint;
|
|
104
|
+
body: import("@ton/core").Cell;
|
|
105
|
+
};
|
|
106
|
+
}>;
|
|
107
|
+
export declare function createSetProtocolFeeRatePerYearMsg(ctx: AffluentContext, params: SetProtocolFeeRatePerYearParams, value?: bigint): Promise<{
|
|
108
|
+
opts: {
|
|
109
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
110
|
+
};
|
|
111
|
+
input: {
|
|
112
|
+
to: import("@ton/core").Address;
|
|
113
|
+
value: bigint;
|
|
114
|
+
body: import("@ton/core").Cell;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
export declare function createSetProtocolFeeManagerAddressMsg(ctx: AffluentContext, params: SetProtocolFeeManagerAddressParams, value?: bigint): Promise<{
|
|
118
|
+
opts: {
|
|
119
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
120
|
+
};
|
|
121
|
+
input: {
|
|
122
|
+
to: import("@ton/core").Address;
|
|
123
|
+
value: bigint;
|
|
124
|
+
body: import("@ton/core").Cell;
|
|
125
|
+
};
|
|
126
|
+
}>;
|
|
127
|
+
export declare function createSetFactorialPoolConfigMsg(ctx: AffluentContext, params: SetFactorialPoolConfigParams): Promise<{
|
|
128
|
+
opts: {
|
|
129
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
130
|
+
factorialPoolConfig: import("@ton/core").Cell;
|
|
131
|
+
};
|
|
132
|
+
input: {
|
|
133
|
+
to: import("@ton/core").Address;
|
|
134
|
+
value: bigint;
|
|
135
|
+
body: import("@ton/core").Cell;
|
|
136
|
+
};
|
|
137
|
+
}>;
|
|
138
|
+
export declare function createSetAssetConfigMsg(ctx: AffluentContext, params: SetAssetConfigParams, value?: bigint): Promise<{
|
|
139
|
+
opts: {
|
|
140
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
141
|
+
};
|
|
142
|
+
input: {
|
|
143
|
+
to: import("@ton/core").Address;
|
|
144
|
+
value: bigint;
|
|
145
|
+
body: import("@ton/core").Cell;
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
export declare function createSetRFQConfigMsg(ctx: AffluentContext, params: SetRFQConfigParams, value?: bigint): Promise<{
|
|
149
|
+
opts: {
|
|
150
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
151
|
+
};
|
|
152
|
+
input: {
|
|
153
|
+
to: import("@ton/core").Address;
|
|
154
|
+
value: bigint;
|
|
155
|
+
body: import("@ton/core").Cell;
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
export declare function createSetManagementFeeRatePerYearMsg(ctx: AffluentContext, params: SetManagementFeeRatePerYearParams, value?: bigint): Promise<{
|
|
159
|
+
opts: {
|
|
160
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
161
|
+
};
|
|
162
|
+
input: {
|
|
163
|
+
to: import("@ton/core").Address;
|
|
164
|
+
value: bigint;
|
|
165
|
+
body: import("@ton/core").Cell;
|
|
166
|
+
};
|
|
167
|
+
}>;
|
|
168
|
+
export declare function createSetDepositCloseTimestampMsg(ctx: AffluentContext, params: SetDepositCloseTimestampParams, value?: bigint): Promise<{
|
|
169
|
+
opts: {
|
|
170
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
171
|
+
};
|
|
172
|
+
input: {
|
|
173
|
+
to: import("@ton/core").Address;
|
|
174
|
+
value: bigint;
|
|
175
|
+
body: import("@ton/core").Cell;
|
|
176
|
+
};
|
|
177
|
+
}>;
|
|
178
|
+
export declare function createSetWithdrawOpenTimestampMsg(ctx: AffluentContext, params: SetWithdrawOpenTimestampParams, value?: bigint): Promise<{
|
|
179
|
+
opts: {
|
|
180
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
181
|
+
};
|
|
182
|
+
input: {
|
|
183
|
+
to: import("@ton/core").Address;
|
|
184
|
+
value: bigint;
|
|
185
|
+
body: import("@ton/core").Cell;
|
|
186
|
+
};
|
|
187
|
+
}>;
|
|
188
|
+
export declare function createSetGasConfigMsg(ctx: AffluentContext, params: SetGasConfigParams, value?: bigint): Promise<{
|
|
189
|
+
opts: {
|
|
190
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
191
|
+
};
|
|
192
|
+
input: {
|
|
193
|
+
to: import("@ton/core").Address;
|
|
194
|
+
value: bigint;
|
|
195
|
+
body: import("@ton/core").Cell;
|
|
196
|
+
};
|
|
197
|
+
}>;
|
|
198
|
+
export declare function createSetOracleConfigMsg(ctx: AffluentContext, params: SetOracleConfigParams, value?: bigint): Promise<{
|
|
199
|
+
opts: {
|
|
200
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
201
|
+
};
|
|
202
|
+
input: {
|
|
203
|
+
to: import("@ton/core").Address;
|
|
204
|
+
value: bigint;
|
|
205
|
+
body: import("@ton/core").Cell;
|
|
206
|
+
};
|
|
207
|
+
}>;
|
|
208
|
+
export declare function createSetWalletCodeMsg(ctx: AffluentContext, params: SetWalletCodeParams, value?: bigint): Promise<{
|
|
209
|
+
opts: {
|
|
210
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
211
|
+
};
|
|
212
|
+
input: {
|
|
213
|
+
to: import("@ton/core").Address;
|
|
214
|
+
value: bigint;
|
|
215
|
+
body: import("@ton/core").Cell;
|
|
216
|
+
};
|
|
217
|
+
}>;
|
|
218
|
+
export declare function createSetDataAggregatorCodeMsg(ctx: AffluentContext, params: SetDataAggregatorCodeParams, value?: bigint): Promise<{
|
|
219
|
+
opts: {
|
|
220
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
221
|
+
};
|
|
222
|
+
input: {
|
|
223
|
+
to: import("@ton/core").Address;
|
|
224
|
+
value: bigint;
|
|
225
|
+
body: import("@ton/core").Cell;
|
|
226
|
+
};
|
|
227
|
+
}>;
|
|
228
|
+
export declare function createSetRFQCodeMsg(ctx: AffluentContext, params: SetRFQCodeParams, value?: bigint): Promise<{
|
|
229
|
+
opts: {
|
|
230
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
231
|
+
};
|
|
232
|
+
input: {
|
|
233
|
+
to: import("@ton/core").Address;
|
|
234
|
+
value: bigint;
|
|
235
|
+
body: import("@ton/core").Cell;
|
|
236
|
+
};
|
|
237
|
+
}>;
|
|
238
|
+
export declare function createSetContentMsg(ctx: AffluentContext, params: SetContentParams, value?: bigint): Promise<{
|
|
239
|
+
opts: {
|
|
240
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
241
|
+
};
|
|
242
|
+
input: {
|
|
243
|
+
to: import("@ton/core").Address;
|
|
244
|
+
value: bigint;
|
|
245
|
+
body: import("@ton/core").Cell;
|
|
246
|
+
};
|
|
247
|
+
}>;
|
|
248
|
+
export declare function createUpgradeCodeMsg(ctx: AffluentContext, params: UpgradeCodeParams, value?: bigint): Promise<{
|
|
249
|
+
opts: {
|
|
250
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
251
|
+
};
|
|
252
|
+
input: {
|
|
253
|
+
to: import("@ton/core").Address;
|
|
254
|
+
value: bigint;
|
|
255
|
+
body: import("@ton/core").Cell;
|
|
256
|
+
};
|
|
257
|
+
}>;
|
|
258
|
+
export declare function createCollectProtocolFeeMsg(ctx: AffluentContext, params: CollectProtocolFeeParams, value?: bigint): Promise<{
|
|
259
|
+
opts: {
|
|
260
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
261
|
+
};
|
|
262
|
+
input: {
|
|
263
|
+
to: import("@ton/core").Address;
|
|
264
|
+
value: bigint;
|
|
265
|
+
body: import("@ton/core").Cell;
|
|
266
|
+
};
|
|
267
|
+
}>;
|
|
268
|
+
export declare function createClaimManagementFeeMsg(ctx: AffluentContext, params: ClaimManagementFeeParams, value?: bigint): Promise<{
|
|
269
|
+
opts: {
|
|
270
|
+
vault: import("@ton/core").OpenedContract<StrategyVault>;
|
|
271
|
+
};
|
|
272
|
+
input: {
|
|
273
|
+
to: import("@ton/core").Address;
|
|
274
|
+
value: bigint;
|
|
275
|
+
body: import("@ton/core").Cell;
|
|
276
|
+
};
|
|
277
|
+
}>;
|