@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,94 @@
|
|
|
1
|
+
import { Address } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { AddressSender } from "../../types/sender";
|
|
5
|
+
import { PoolState } from "../../contracts/core/pool/type";
|
|
6
|
+
import { AccountState } from "../../contracts/core/account/type";
|
|
7
|
+
import * as computation from "./computation";
|
|
8
|
+
import * as query from "./query";
|
|
9
|
+
import * as oracle from "./oracle";
|
|
10
|
+
import * as owner from "./owner";
|
|
11
|
+
import * as user from "./user";
|
|
12
|
+
export { sendMsg } from "../../lib/send-msg";
|
|
13
|
+
export * from "./owner/types";
|
|
14
|
+
export * from "./user/types";
|
|
15
|
+
export * from "./computation";
|
|
16
|
+
export { computation, query, oracle, owner, user };
|
|
17
|
+
export declare class PoolServiceV1 {
|
|
18
|
+
private ctx;
|
|
19
|
+
constructor(ctx?: AffluentContext);
|
|
20
|
+
getPool(poolAddress: AddressInput): import("@ton/core").OpenedContract<import("../..").Pool>;
|
|
21
|
+
getPoolData(poolAddress: AddressInput): Promise<PoolState>;
|
|
22
|
+
getAccountAddress(poolAddress: AddressInput, userAddress: AddressLike): Promise<Address>;
|
|
23
|
+
getAccount(poolAddress: AddressInput, userAddress: AddressLike): Promise<import("@ton/core").OpenedContract<import("../..").Account>>;
|
|
24
|
+
getAccountData(poolAddress: AddressInput, userAddress: AddressLike): Promise<AccountState>;
|
|
25
|
+
getPricesAndCompositions(poolAddress: AddressInput): Promise<{
|
|
26
|
+
prices: import("../composite-oracle").Prices;
|
|
27
|
+
vaultCompositions: import("../composite-oracle").VaultCompositions;
|
|
28
|
+
}>;
|
|
29
|
+
isHealthy(poolAddress: AddressInput, ownerAddress: AddressLike): Promise<computation.HealthResult>;
|
|
30
|
+
getOracleParams(poolAddress: AddressInput, actorAddress: AddressLike, executeAssetAddress: AddressLike): Promise<import("@ton/core").Cell | null>;
|
|
31
|
+
static simulateAccrueInterest(poolData: PoolState, time?: number): PoolState;
|
|
32
|
+
static convertShareToAmount(accountData: AccountState, poolData: PoolState): AccountState;
|
|
33
|
+
static haveBorrow(accountData: AccountState): boolean;
|
|
34
|
+
static haveAssets(accountData: AccountState): string[];
|
|
35
|
+
sendSetOwner(sender: AddressSender, params: owner.SetOwnerParams, value?: bigint): Promise<{
|
|
36
|
+
newOwner: Address;
|
|
37
|
+
queryID: number | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
sendSetIrmConfig(sender: AddressSender, params: owner.SetIrmConfigParams, value?: bigint): Promise<{
|
|
40
|
+
asset: Address;
|
|
41
|
+
irmConfig: import("@ton/core").Cell;
|
|
42
|
+
queryId: number | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
sendSetFeeConfigurer(sender: AddressSender, params: owner.SetFeeConfigurerParams, value?: bigint): Promise<{
|
|
45
|
+
feeConfigurer: Address;
|
|
46
|
+
queryId: number | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
sendSupply(sender: AddressSender, params: user.SupplyParams, value?: bigint): Promise<{
|
|
49
|
+
recipient: Address;
|
|
50
|
+
amount: bigint;
|
|
51
|
+
response: Address;
|
|
52
|
+
forwardTonAmount: bigint;
|
|
53
|
+
forwardPayload: import("@ton/core").Cell;
|
|
54
|
+
queryId: bigint | undefined;
|
|
55
|
+
}>;
|
|
56
|
+
sendWithdraw(sender: AddressSender, params: user.WithdrawParams, value?: bigint): Promise<{
|
|
57
|
+
asset: Address;
|
|
58
|
+
isShare: boolean;
|
|
59
|
+
amount: bigint;
|
|
60
|
+
recipient: Address;
|
|
61
|
+
response: Address;
|
|
62
|
+
jettonForwardTonAmount: bigint;
|
|
63
|
+
jettonForwardPayload: import("@ton/core").Cell | null;
|
|
64
|
+
oracleParams: import("@ton/core").Cell | null;
|
|
65
|
+
queryId: bigint | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
sendBorrow(sender: AddressSender, params: user.BorrowParams, value?: bigint): Promise<{
|
|
68
|
+
asset: Address;
|
|
69
|
+
isShare: boolean;
|
|
70
|
+
amount: bigint;
|
|
71
|
+
recipient: Address;
|
|
72
|
+
response: Address;
|
|
73
|
+
jettonForwardTonAmount: bigint;
|
|
74
|
+
jettonForwardPayload: import("@ton/core").Cell | null;
|
|
75
|
+
oracleParams: import("@ton/core").Cell | null;
|
|
76
|
+
queryId: bigint | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
sendRepay(sender: AddressSender, params: user.RepayParams, value?: bigint): Promise<{
|
|
79
|
+
recipient: Address;
|
|
80
|
+
amount: bigint;
|
|
81
|
+
response: Address;
|
|
82
|
+
forwardTonAmount: bigint;
|
|
83
|
+
forwardPayload: import("@ton/core").Cell;
|
|
84
|
+
queryId: bigint | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
sendLiquidate(sender: AddressSender, params: user.LiquidateParams, value?: bigint): Promise<{
|
|
87
|
+
recipient: Address;
|
|
88
|
+
amount: bigint;
|
|
89
|
+
response: Address;
|
|
90
|
+
forwardTonAmount: bigint;
|
|
91
|
+
forwardPayload: import("@ton/core").Cell;
|
|
92
|
+
queryId: bigint | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PoolServiceV1 = exports.user = exports.owner = exports.oracle = exports.query = exports.computation = exports.sendMsg = void 0;
|
|
40
|
+
const context_1 = require("../../context");
|
|
41
|
+
const send_msg_1 = require("../../lib/send-msg");
|
|
42
|
+
const computation = __importStar(require("./computation"));
|
|
43
|
+
exports.computation = computation;
|
|
44
|
+
const query = __importStar(require("./query"));
|
|
45
|
+
exports.query = query;
|
|
46
|
+
const oracle = __importStar(require("./oracle"));
|
|
47
|
+
exports.oracle = oracle;
|
|
48
|
+
const owner = __importStar(require("./owner"));
|
|
49
|
+
exports.owner = owner;
|
|
50
|
+
const user = __importStar(require("./user"));
|
|
51
|
+
exports.user = user;
|
|
52
|
+
// Re-exports
|
|
53
|
+
var send_msg_2 = require("../../lib/send-msg");
|
|
54
|
+
Object.defineProperty(exports, "sendMsg", { enumerable: true, get: function () { return send_msg_2.sendMsg; } });
|
|
55
|
+
__exportStar(require("./owner/types"), exports);
|
|
56
|
+
__exportStar(require("./user/types"), exports);
|
|
57
|
+
__exportStar(require("./computation"), exports); // Types and pure computation functions
|
|
58
|
+
class PoolServiceV1 {
|
|
59
|
+
ctx;
|
|
60
|
+
constructor(ctx = context_1.AffluentContext.getInstance()) {
|
|
61
|
+
this.ctx = ctx;
|
|
62
|
+
}
|
|
63
|
+
// ============================================================
|
|
64
|
+
// Query (Data Fetching)
|
|
65
|
+
// ============================================================
|
|
66
|
+
getPool(poolAddress) {
|
|
67
|
+
return query.getPool(this.ctx, poolAddress);
|
|
68
|
+
}
|
|
69
|
+
async getPoolData(poolAddress) {
|
|
70
|
+
return query.getPoolData(this.ctx, poolAddress);
|
|
71
|
+
}
|
|
72
|
+
async getAccountAddress(poolAddress, userAddress) {
|
|
73
|
+
return query.getAccountAddress(this.ctx, poolAddress, userAddress);
|
|
74
|
+
}
|
|
75
|
+
async getAccount(poolAddress, userAddress) {
|
|
76
|
+
return query.getAccount(this.ctx, poolAddress, userAddress);
|
|
77
|
+
}
|
|
78
|
+
async getAccountData(poolAddress, userAddress) {
|
|
79
|
+
return query.getAccountData(this.ctx, poolAddress, userAddress);
|
|
80
|
+
}
|
|
81
|
+
async getPricesAndCompositions(poolAddress) {
|
|
82
|
+
return query.getPricesAndCompositions(this.ctx, poolAddress);
|
|
83
|
+
}
|
|
84
|
+
async isHealthy(poolAddress, ownerAddress) {
|
|
85
|
+
return query.isHealthy(this.ctx, poolAddress, ownerAddress);
|
|
86
|
+
}
|
|
87
|
+
// ============================================================
|
|
88
|
+
// Oracle
|
|
89
|
+
// ============================================================
|
|
90
|
+
async getOracleParams(poolAddress, actorAddress, executeAssetAddress) {
|
|
91
|
+
return oracle.getOracleParams(this.ctx, poolAddress, actorAddress, executeAssetAddress);
|
|
92
|
+
}
|
|
93
|
+
// ============================================================
|
|
94
|
+
// Static Computation (no context needed)
|
|
95
|
+
// ============================================================
|
|
96
|
+
static simulateAccrueInterest(poolData, time) {
|
|
97
|
+
return computation.simulateAccrueInterest(poolData, time);
|
|
98
|
+
}
|
|
99
|
+
static convertShareToAmount(accountData, poolData) {
|
|
100
|
+
return computation.convertShareToAmount(accountData, poolData);
|
|
101
|
+
}
|
|
102
|
+
static haveBorrow(accountData) {
|
|
103
|
+
return computation.haveBorrow(accountData);
|
|
104
|
+
}
|
|
105
|
+
static haveAssets(accountData) {
|
|
106
|
+
return computation.haveAssets(accountData);
|
|
107
|
+
}
|
|
108
|
+
// ============================================================
|
|
109
|
+
// Owner
|
|
110
|
+
// ============================================================
|
|
111
|
+
async sendSetOwner(sender, params, value) {
|
|
112
|
+
return (0, send_msg_1.sendMsg)(sender, owner.createSetOwnerMsg(this.ctx, params, value));
|
|
113
|
+
}
|
|
114
|
+
async sendSetIrmConfig(sender, params, value) {
|
|
115
|
+
return (0, send_msg_1.sendMsg)(sender, owner.createSetIrmConfigMsg(this.ctx, params, value));
|
|
116
|
+
}
|
|
117
|
+
async sendSetFeeConfigurer(sender, params, value) {
|
|
118
|
+
return (0, send_msg_1.sendMsg)(sender, owner.createSetFeeConfigurerMsg(this.ctx, params, value));
|
|
119
|
+
}
|
|
120
|
+
// ============================================================
|
|
121
|
+
// User
|
|
122
|
+
// ============================================================
|
|
123
|
+
async sendSupply(sender, params, value) {
|
|
124
|
+
return (0, send_msg_1.sendMsg)(sender, user.createSupplyMsg(this.ctx, sender, params, value));
|
|
125
|
+
}
|
|
126
|
+
async sendWithdraw(sender, params, value) {
|
|
127
|
+
return (0, send_msg_1.sendMsg)(sender, user.createWithdrawMsg(this.ctx, sender, params, value));
|
|
128
|
+
}
|
|
129
|
+
async sendBorrow(sender, params, value) {
|
|
130
|
+
return (0, send_msg_1.sendMsg)(sender, user.createBorrowMsg(this.ctx, sender, params, value));
|
|
131
|
+
}
|
|
132
|
+
async sendRepay(sender, params, value) {
|
|
133
|
+
return (0, send_msg_1.sendMsg)(sender, user.createRepayMsg(this.ctx, sender, params, value));
|
|
134
|
+
}
|
|
135
|
+
async sendLiquidate(sender, params, value) {
|
|
136
|
+
return (0, send_msg_1.sendMsg)(sender, user.createLiquidateMsg(this.ctx, sender, params, value));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.PoolServiceV1 = PoolServiceV1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { PoolState } from "../../contracts/core/pool/type";
|
|
5
|
+
import { VaultPositions } from "../composite-oracle/types";
|
|
6
|
+
/**
|
|
7
|
+
* Build oracle params Cell from pre-fetched vault positions
|
|
8
|
+
* Pure computation - no network calls
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildOracleParamsCellFromData(assets: string[], oracleConfig: any, vaultPositions: VaultPositions): Promise<Cell>;
|
|
11
|
+
/**
|
|
12
|
+
* Get oracle params for a pool operation
|
|
13
|
+
* Fetches account data and builds oracle params
|
|
14
|
+
*/
|
|
15
|
+
export declare function getOracleParams(ctx: AffluentContext, poolAddress: AddressInput, actorAddress: AddressLike, executeAssetAddress: AddressLike): Promise<Cell | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Build oracle params Cell for pool operations
|
|
18
|
+
* Fetches vault positions and builds params
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildOracleParams(ctx: AffluentContext, assets: string[], poolData: PoolState): Promise<Cell>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildOracleParamsCellFromData = buildOracleParamsCellFromData;
|
|
4
|
+
exports.getOracleParams = getOracleParams;
|
|
5
|
+
exports.buildOracleParams = buildOracleParams;
|
|
6
|
+
const core_1 = require("@ton/core");
|
|
7
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
8
|
+
const pool_1 = require("../../contracts/core/pool");
|
|
9
|
+
const account_1 = require("../../contracts/core/account");
|
|
10
|
+
const query_1 = require("../composite-oracle/query");
|
|
11
|
+
const computation_1 = require("../composite-oracle/computation");
|
|
12
|
+
const computation_2 = require("../composite-oracle/computation");
|
|
13
|
+
const query_2 = require("./query");
|
|
14
|
+
// ============================================================
|
|
15
|
+
// Pure Computation (no I/O)
|
|
16
|
+
// ============================================================
|
|
17
|
+
/**
|
|
18
|
+
* Build oracle params Cell from pre-fetched vault positions
|
|
19
|
+
* Pure computation - no network calls
|
|
20
|
+
*/
|
|
21
|
+
function buildOracleParamsCellFromData(assets, oracleConfig, vaultPositions) {
|
|
22
|
+
const { assets: pureAssets, vaultAssets } = (0, computation_1.separateAssets)(assets, oracleConfig);
|
|
23
|
+
const exposures = (0, computation_1.getExposures)(vaultPositions);
|
|
24
|
+
const allAssets = [...new Set([...pureAssets, ...exposures.assets])];
|
|
25
|
+
return (0, computation_2.buildOracleParamsCell)(allAssets, oracleConfig, exposures.pools, vaultAssets);
|
|
26
|
+
}
|
|
27
|
+
// ============================================================
|
|
28
|
+
// Orchestration (fetch + compute)
|
|
29
|
+
// ============================================================
|
|
30
|
+
/**
|
|
31
|
+
* Get oracle params for a pool operation
|
|
32
|
+
* Fetches account data and builds oracle params
|
|
33
|
+
*/
|
|
34
|
+
async function getOracleParams(ctx, poolAddress, actorAddress, executeAssetAddress) {
|
|
35
|
+
const pool = ctx.getByContract(pool_1.Pool, (0, utils_1.toAddress)(poolAddress));
|
|
36
|
+
const poolData = await pool.getPoolData();
|
|
37
|
+
const accountAddress = await (0, query_2.getAccountAddress)(ctx, poolAddress, actorAddress);
|
|
38
|
+
const account = ctx.getByContract(account_1.Account, accountAddress);
|
|
39
|
+
let accountData;
|
|
40
|
+
try {
|
|
41
|
+
accountData = await account.getAccountData();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const userAssets = [...new Set([...account_1.Account.haveAssets(accountData), (0, utils_1.toAddress)(executeAssetAddress).toString()])];
|
|
47
|
+
return buildOracleParams(ctx, userAssets, poolData);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build oracle params Cell for pool operations
|
|
51
|
+
* Fetches vault positions and builds params
|
|
52
|
+
*/
|
|
53
|
+
async function buildOracleParams(ctx, assets, poolData) {
|
|
54
|
+
const oracleConfig = poolData.oracleConfig;
|
|
55
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(assets, oracleConfig);
|
|
56
|
+
// Fetch
|
|
57
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
58
|
+
const vaultPositions = await fetcher.fetchVaultPositions(vaultAssets.map((v) => core_1.Address.parse(v)));
|
|
59
|
+
// Compute
|
|
60
|
+
return buildOracleParamsCellFromData(assets, oracleConfig, vaultPositions);
|
|
61
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AffluentContext } from "../../../context";
|
|
2
|
+
import { SetOwnerParams, SetIrmConfigParams, SetFeeConfigurerParams } from "./types";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export declare function createSetOwnerMsg(ctx: AffluentContext, params: SetOwnerParams, value?: bigint): Promise<{
|
|
5
|
+
opts: {
|
|
6
|
+
newOwner: import("@ton/core").Address;
|
|
7
|
+
queryID: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
input: {
|
|
10
|
+
to: import("@ton/core").Address;
|
|
11
|
+
value: bigint;
|
|
12
|
+
body: import("@ton/core").Cell;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
export declare function createSetIrmConfigMsg(ctx: AffluentContext, params: SetIrmConfigParams, value?: bigint): Promise<{
|
|
16
|
+
opts: {
|
|
17
|
+
asset: import("@ton/core").Address;
|
|
18
|
+
irmConfig: import("@ton/core").Cell;
|
|
19
|
+
queryId: number | undefined;
|
|
20
|
+
};
|
|
21
|
+
input: {
|
|
22
|
+
to: import("@ton/core").Address;
|
|
23
|
+
value: bigint;
|
|
24
|
+
body: import("@ton/core").Cell;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
export declare function createSetFeeConfigurerMsg(ctx: AffluentContext, params: SetFeeConfigurerParams, value?: bigint): Promise<{
|
|
28
|
+
opts: {
|
|
29
|
+
feeConfigurer: import("@ton/core").Address;
|
|
30
|
+
queryId: number | undefined;
|
|
31
|
+
};
|
|
32
|
+
input: {
|
|
33
|
+
to: import("@ton/core").Address;
|
|
34
|
+
value: bigint;
|
|
35
|
+
body: import("@ton/core").Cell;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createSetOwnerMsg = createSetOwnerMsg;
|
|
18
|
+
exports.createSetIrmConfigMsg = createSetIrmConfigMsg;
|
|
19
|
+
exports.createSetFeeConfigurerMsg = createSetFeeConfigurerMsg;
|
|
20
|
+
const core_1 = require("@ton/core");
|
|
21
|
+
const utils_1 = require("../../../contracts/common/utils");
|
|
22
|
+
const pool_1 = require("../../../contracts/core/pool");
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
const DEFAULT_VALUE = (0, core_1.toNano)(0.1);
|
|
25
|
+
// ============================================================
|
|
26
|
+
// Owner Operations
|
|
27
|
+
// ============================================================
|
|
28
|
+
async function createSetOwnerMsg(ctx, params, value) {
|
|
29
|
+
const poolAddress = (0, utils_1.toAddress)(params.poolAddress);
|
|
30
|
+
const pool = ctx.getByContract(pool_1.Pool, poolAddress);
|
|
31
|
+
const opts = {
|
|
32
|
+
newOwner: (0, utils_1.toAddress)(params.newOwner),
|
|
33
|
+
queryID: params.queryId ? Number(params.queryId) : undefined,
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
opts,
|
|
37
|
+
input: {
|
|
38
|
+
to: pool.address,
|
|
39
|
+
value: value ?? DEFAULT_VALUE,
|
|
40
|
+
body: pool_1.Pool.createSetOwnerMsgBody(opts),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function createSetIrmConfigMsg(ctx, params, value) {
|
|
45
|
+
const poolAddress = (0, utils_1.toAddress)(params.poolAddress);
|
|
46
|
+
const pool = ctx.getByContract(pool_1.Pool, poolAddress);
|
|
47
|
+
const opts = {
|
|
48
|
+
asset: (0, utils_1.toAddress)(params.assetAddress),
|
|
49
|
+
irmConfig: params.irmConfig,
|
|
50
|
+
queryId: params.queryId ? Number(params.queryId) : undefined,
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
opts,
|
|
54
|
+
input: {
|
|
55
|
+
to: pool.address,
|
|
56
|
+
value: value ?? DEFAULT_VALUE,
|
|
57
|
+
body: pool_1.Pool.createSetIrmConfigMsgBody(opts),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function createSetFeeConfigurerMsg(ctx, params, value) {
|
|
62
|
+
const poolAddress = (0, utils_1.toAddress)(params.poolAddress);
|
|
63
|
+
const pool = ctx.getByContract(pool_1.Pool, poolAddress);
|
|
64
|
+
const opts = {
|
|
65
|
+
feeConfigurer: (0, utils_1.toAddress)(params.feeConfigurer),
|
|
66
|
+
queryId: params.queryId ? Number(params.queryId) : undefined,
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
opts,
|
|
70
|
+
input: {
|
|
71
|
+
to: pool.address,
|
|
72
|
+
value: value ?? DEFAULT_VALUE,
|
|
73
|
+
body: pool_1.Pool.createSetFeeConfigurerMsgBody(opts),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AddressInput, AddressLike } from "../../../contracts/common/type";
|
|
3
|
+
export type SetOwnerParams = {
|
|
4
|
+
poolAddress: AddressInput;
|
|
5
|
+
newOwner: AddressLike;
|
|
6
|
+
queryId?: bigint;
|
|
7
|
+
};
|
|
8
|
+
export type SetIrmConfigParams = {
|
|
9
|
+
poolAddress: AddressInput;
|
|
10
|
+
assetAddress: AddressLike;
|
|
11
|
+
irmConfig: Cell;
|
|
12
|
+
queryId?: bigint;
|
|
13
|
+
};
|
|
14
|
+
export type SetFeeConfigurerParams = {
|
|
15
|
+
poolAddress: AddressInput;
|
|
16
|
+
feeConfigurer: AddressLike;
|
|
17
|
+
queryId?: bigint;
|
|
18
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Address } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { Pool } from "../../contracts/core/pool";
|
|
5
|
+
import { PoolState } from "../../contracts/core/pool/type";
|
|
6
|
+
import { Account } from "../../contracts/core/account";
|
|
7
|
+
import { AccountState, AccountAssetState } from "../../contracts/core/account/type";
|
|
8
|
+
import { VaultCompositions, Prices } from "../composite-oracle/types";
|
|
9
|
+
import { HealthResult, MaxBorrowableResult, MaxWithdrawableResult } from "./computation";
|
|
10
|
+
/**
|
|
11
|
+
* Get Pool contract instance
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPool(ctx: AffluentContext, poolAddress: AddressInput): import("@ton/core").OpenedContract<Pool>;
|
|
14
|
+
/**
|
|
15
|
+
* Get Pool data
|
|
16
|
+
*/
|
|
17
|
+
export declare function getPoolData(ctx: AffluentContext, poolAddress: AddressInput): Promise<PoolState>;
|
|
18
|
+
/**
|
|
19
|
+
* Get Account address for a user in a pool
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAccountAddress(ctx: AffluentContext, poolAddress: AddressInput, userAddress: AddressLike): Promise<Address>;
|
|
22
|
+
/**
|
|
23
|
+
* Get Account contract instance
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAccount(ctx: AffluentContext, poolAddress: AddressInput, userAddress: AddressLike): Promise<import("@ton/core").OpenedContract<Account>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get Account data for a user in a pool
|
|
28
|
+
*/
|
|
29
|
+
export declare function getAccountData(ctx: AffluentContext, poolAddress: AddressInput, userAddress: AddressLike): Promise<AccountState>;
|
|
30
|
+
/**
|
|
31
|
+
* Get prices and vault compositions for all assets in a pool
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPricesAndCompositions(ctx: AffluentContext, poolAddress: AddressInput): Promise<{
|
|
34
|
+
prices: Prices;
|
|
35
|
+
vaultCompositions: VaultCompositions;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Get prices for all assets in a pool
|
|
39
|
+
* @deprecated Use getPricesAndCompositions instead
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPrices(ctx: AffluentContext, poolAddress: AddressInput): Promise<Prices>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if account is healthy
|
|
44
|
+
* Fetches pool data, account data, and prices, then calculates health
|
|
45
|
+
*/
|
|
46
|
+
export declare function isHealthy(ctx: AffluentContext, poolAddress: AddressInput, ownerAddress: AddressLike, delta?: Record<string, AccountAssetState>): Promise<HealthResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Calculate maximum borrowable amount for an asset
|
|
49
|
+
*/
|
|
50
|
+
export declare function calculateMaxBorrowableAmount(ctx: AffluentContext, params: {
|
|
51
|
+
borrowerAddress: Address;
|
|
52
|
+
poolAddress: Address;
|
|
53
|
+
tokenAddress: string;
|
|
54
|
+
BUFFER?: bigint;
|
|
55
|
+
}): Promise<MaxBorrowableResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate maximum withdrawable amount for an asset
|
|
58
|
+
*/
|
|
59
|
+
export declare function calculateMaxWithdrawableAmount(ctx: AffluentContext, params: {
|
|
60
|
+
withdrawerAddress: Address;
|
|
61
|
+
poolAddress: Address;
|
|
62
|
+
tokenAddress: string;
|
|
63
|
+
BUFFER?: bigint;
|
|
64
|
+
}): Promise<MaxWithdrawableResult>;
|