@affluent-org/sdk 0.0.5 → 0.0.6
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/affluent.d.ts +3 -3
- package/dist/affluent.js +3 -3
- package/dist/common/computation.d.ts +6 -0
- package/dist/common/computation.js +54 -0
- package/dist/common/helper.d.ts +5 -0
- package/dist/common/helper.js +29 -0
- package/dist/common/service.d.ts +10 -2
- package/dist/common/service.js +56 -3
- package/dist/common/trace-action.d.ts +92 -0
- package/dist/common/trace-action.js +187 -0
- package/dist/common/transform.d.ts +15 -21
- package/dist/common/transform.js +63 -150
- package/dist/common/types.d.ts +9 -13
- package/dist/common/types.js +2 -2
- package/dist/context.d.ts +3 -0
- package/dist/context.js +9 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/index.js +2 -0
- package/dist/contracts/vault/strategy-vault/index.d.ts +2 -1
- package/dist/contracts/vault/strategy-vault/index.js +1 -0
- package/dist/factorial.d.ts +18 -8
- package/dist/factorial.js +26 -14
- package/dist/index.d.ts +4 -2
- package/dist/index.js +18 -2
- package/dist/lib/send-msg.d.ts +16 -2
- package/dist/lib/send-msg.js +23 -2
- package/dist/monitor.js +2 -0
- package/dist/monitorCacheV1.js +3 -2
- package/dist/oracle/oracle.d.ts +3 -2
- package/dist/oracle/oracle.js +25 -2
- package/dist/pool.d.ts +41 -0
- package/dist/pool.js +146 -178
- package/dist/poolCacheV1.js +1 -0
- package/dist/rfq-auction.d.ts +2 -2
- package/dist/rfq-auction.js +6 -6
- package/dist/rfq-batch.d.ts +21 -11
- package/dist/rfq-batch.js +81 -9
- package/dist/services/composite-oracle/computation.d.ts +3 -8
- package/dist/services/composite-oracle/computation.js +91 -56
- package/dist/services/composite-oracle/index.js +4 -5
- package/dist/services/composite-oracle/query.js +1 -3
- package/dist/services/pool/computation.js +9 -61
- package/dist/services/pool/index.d.ts +10 -59
- package/dist/services/pool/index.js +55 -8
- package/dist/services/pool/query.js +1 -1
- package/dist/services/pool/user/trace.d.ts +90 -0
- package/dist/services/pool/user/trace.js +168 -0
- package/dist/services/rfq-auction/index.d.ts +7 -23
- package/dist/services/rfq-auction/index.js +45 -6
- package/dist/services/rfq-auction/user/index.js +1 -1
- package/dist/services/rfq-auction/user/trace.d.ts +53 -0
- package/dist/services/rfq-auction/user/trace.js +68 -0
- package/dist/services/rfq-batch/index.d.ts +16 -13
- package/dist/services/rfq-batch/index.js +34 -10
- package/dist/services/rfq-batch/user/trace.d.ts +49 -0
- package/dist/services/rfq-batch/user/trace.js +67 -0
- package/dist/services/share-vault/index.d.ts +12 -56
- package/dist/services/share-vault/index.js +37 -10
- package/dist/services/share-vault/query.js +1 -1
- package/dist/services/share-vault/user/trace.d.ts +54 -0
- package/dist/services/share-vault/user/trace.js +84 -0
- package/dist/services/strategy-vault/index.d.ts +68 -1981
- package/dist/services/strategy-vault/index.js +114 -53
- package/dist/services/strategy-vault/oracle.js +1 -0
- package/dist/services/strategy-vault/owner/index.d.ts +2 -2
- package/dist/services/strategy-vault/owner/index.js +1 -1
- package/dist/services/strategy-vault/owner/types.d.ts +4 -0
- package/dist/services/strategy-vault/query.js +1 -1
- package/dist/services/strategy-vault/user/trace.d.ts +156 -0
- package/dist/services/strategy-vault/user/trace.js +264 -0
- package/dist/share-vault.d.ts +164 -8
- package/dist/share-vault.js +222 -67
- package/dist/strategy_vault/base.d.ts +521 -105
- package/dist/strategy_vault/base.js +493 -41
- package/dist/strategy_vault/steps.d.ts +120 -3
- package/dist/strategy_vault/steps.js +161 -0
- package/dist/types/sender.d.ts +1 -0
- package/dist/utils/_parse_temp/StrategyVault.d.ts +9 -9
- package/dist/utils/_parse_temp/StrategyVault.js +48 -40
- package/dist/utils/_parse_temp/parseMsgBody.d.ts +2 -2
- package/dist/utils/_parse_temp/parseMsgBody.js +84 -84
- package/dist/utils/external-message-hash.d.ts +7 -3
- package/dist/utils/external-message-hash.js +20 -7
- package/dist/utils/oracle/redstone/helper.js +2 -0
- package/dist/utils/oracle/redstone/redstoneHelper.d.ts +7 -0
- package/dist/utils/oracle/redstone/redstoneHelper.js +103 -1
- package/dist/utils/pending-tracker/trackable-sender.d.ts +37 -4
- package/dist/utils/pending-tracker/trackable-sender.js +47 -8
- package/dist/utils/pending-tracker/v3-client.d.ts +16 -0
- package/dist/utils/pending-tracker/v3-client.js +80 -2
- package/dist/utils/toncenter/index.d.ts +1 -0
- package/dist/utils/toncenter/index.js +17 -0
- package/dist/utils/toncenter/transform.d.ts +11 -0
- package/dist/utils/toncenter/transform.js +40 -0
- package/dist/utils/toncenter/type.d.ts +227 -0
- package/dist/utils/toncenter/type.js +2 -0
- package/package.json +3 -3
package/dist/lib/send-msg.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { Address, Cell } from "@ton/core";
|
|
2
2
|
import { AddressSender } from "../types/sender";
|
|
3
|
+
import { AffluentContext } from "../context";
|
|
4
|
+
import { SimpleTracer } from "../common/trace-action";
|
|
3
5
|
export type InternalMessageInput = {
|
|
4
6
|
to: Address;
|
|
5
7
|
value: bigint;
|
|
6
8
|
body: Cell;
|
|
7
9
|
};
|
|
8
|
-
export declare function sendMsg<T>(sender: AddressSender, msg:
|
|
10
|
+
export declare function sendMsg<T>(sender: AddressSender, msg: {
|
|
9
11
|
opts: T;
|
|
10
12
|
input: InternalMessageInput;
|
|
11
|
-
}
|
|
13
|
+
}): Promise<T & {
|
|
14
|
+
seqno: number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function sendMsgAndWaitTx<T>(ctx: AffluentContext, sender: AddressSender, msg: {
|
|
17
|
+
opts: T;
|
|
18
|
+
input: InternalMessageInput;
|
|
19
|
+
}): Promise<T & {
|
|
20
|
+
getExternalHash: () => Promise<import("../utils/external-message-hash").MessageHash>;
|
|
21
|
+
seqno: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function sendMsgAndWaitTxSimple(ctx: AffluentContext, sender: AddressSender, msg: {
|
|
24
|
+
input: InternalMessageInput;
|
|
25
|
+
}): Promise<SimpleTracer>;
|
package/dist/lib/send-msg.js
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendMsg = sendMsg;
|
|
4
|
+
exports.sendMsgAndWaitTx = sendMsgAndWaitTx;
|
|
5
|
+
exports.sendMsgAndWaitTxSimple = sendMsgAndWaitTxSimple;
|
|
4
6
|
const core_1 = require("@ton/core");
|
|
7
|
+
const trackable_sender_1 = require("../utils/pending-tracker/trackable-sender");
|
|
8
|
+
const trace_action_1 = require("../common/trace-action");
|
|
5
9
|
async function sendMsg(sender, msg) {
|
|
6
|
-
const
|
|
10
|
+
const seqno = await sender.getSeqno();
|
|
11
|
+
const { opts, input } = msg;
|
|
7
12
|
await sender.send({ ...input, sendMode: core_1.SendMode.PAY_GAS_SEPARATELY });
|
|
8
|
-
return opts;
|
|
13
|
+
return { ...opts, seqno };
|
|
14
|
+
}
|
|
15
|
+
async function sendMsgAndWaitTx(ctx, sender, msg) {
|
|
16
|
+
const result = await sendMsg(sender, msg);
|
|
17
|
+
const getExternalHash = () => (0, trackable_sender_1.pollExternalTransfer)(ctx.client, sender.address, result.seqno);
|
|
18
|
+
return { ...result, getExternalHash };
|
|
19
|
+
}
|
|
20
|
+
async function sendMsgAndWaitTxSimple(ctx, sender, msg) {
|
|
21
|
+
const result = await sendMsgAndWaitTx(ctx, sender, msg);
|
|
22
|
+
const { op, queryId } = (0, trace_action_1.getOpAndQueryId)(msg.input.body);
|
|
23
|
+
return new trace_action_1.SimpleTracer(ctx.toncenterClient, {
|
|
24
|
+
extHash: await result.getExternalHash(),
|
|
25
|
+
queryId,
|
|
26
|
+
actor: sender.address,
|
|
27
|
+
target: msg.input.to,
|
|
28
|
+
op,
|
|
29
|
+
});
|
|
9
30
|
}
|
package/dist/monitor.js
CHANGED
|
@@ -428,6 +428,7 @@ class MonitorV1 {
|
|
|
428
428
|
const { redstonePrices, onchainData: od } = await this.getRedstonePrices(assets, poolData);
|
|
429
429
|
const onchainData2 = await this.updateOnchainData(poolData.oracleConfig.assetOnchainDataInfo);
|
|
430
430
|
const onchainData = { ...od, ...onchainData2 };
|
|
431
|
+
// this.updateOnchainInternalData(redstonePrices, onchainData);
|
|
431
432
|
Object.keys(onchainData).forEach((key) => {
|
|
432
433
|
if (!result.requestAssets.map((item) => item.toString()).includes(key) &&
|
|
433
434
|
!result.redstoneAssets.map((item) => item.toString()).includes(key)) {
|
|
@@ -442,6 +443,7 @@ class MonitorV1 {
|
|
|
442
443
|
const { redstonePrices, onchainData: od } = await this.getRedstonePricesNew(assets, oracleConfig);
|
|
443
444
|
const _onchainData = await this.updateOnchainData(oracleConfig.assetOnchainDataInfo);
|
|
444
445
|
const onchainData = { ...od, ..._onchainData };
|
|
446
|
+
// this.updateOnchainInternalData(redstonePrices, onchainData);
|
|
445
447
|
const prices = this.calculatePrices(redstonePrices, onchainData);
|
|
446
448
|
return prices;
|
|
447
449
|
}
|
package/dist/monitorCacheV1.js
CHANGED
|
@@ -170,8 +170,7 @@ class MonitorCacheV1 extends service_1.ServiceBaseV1 {
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
catch (e) {
|
|
174
|
-
}
|
|
173
|
+
catch (e) { }
|
|
175
174
|
});
|
|
176
175
|
return { redstonePrices: prices, onchainData };
|
|
177
176
|
}
|
|
@@ -405,6 +404,7 @@ class MonitorCacheV1 extends service_1.ServiceBaseV1 {
|
|
|
405
404
|
const { redstonePrices, onchainData: od } = await this.getRedstonePrices(assets, poolData);
|
|
406
405
|
const onchainData2 = await this.updateOnchainData(poolData.oracleConfig.assetOnchainDataInfo);
|
|
407
406
|
const onchainData = { ...od, ...onchainData2 };
|
|
407
|
+
this.updateOnchainInternalData(redstonePrices, onchainData);
|
|
408
408
|
Object.keys(onchainData).forEach((key) => {
|
|
409
409
|
if (!result.requestAssets.map((item) => item.toString()).includes(key) &&
|
|
410
410
|
!result.redstoneAssets.map((item) => item.toString()).includes(key)) {
|
|
@@ -419,6 +419,7 @@ class MonitorCacheV1 extends service_1.ServiceBaseV1 {
|
|
|
419
419
|
const { redstonePrices, onchainData: od } = await this.getRedstonePricesNew(assets, oracleConfig);
|
|
420
420
|
const _onchainData = await this.updateOnchainData(oracleConfig.assetOnchainDataInfo);
|
|
421
421
|
const onchainData = { ...od, ..._onchainData };
|
|
422
|
+
this.updateOnchainInternalData(redstonePrices, onchainData);
|
|
422
423
|
const prices = this.calculatePrices(redstonePrices, onchainData);
|
|
423
424
|
return prices;
|
|
424
425
|
}
|
package/dist/oracle/oracle.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Address, Cell, OpenedContract } from "@ton/core";
|
|
|
2
2
|
import { ServiceBaseV1 } from "../common/service";
|
|
3
3
|
import { ShareVault } from "../contracts/vault/share-vault";
|
|
4
4
|
import { StrategyVault } from "../contracts/vault/strategy-vault";
|
|
5
|
-
import { ShareVaultState } from "../contracts/vault/share-vault
|
|
5
|
+
import { ShareVaultState } from "../contracts/vault/share-vault";
|
|
6
6
|
import { RFQAuction } from "../contracts/rfq/rfq_auction";
|
|
7
7
|
import { Pool } from "../contracts/core/pool";
|
|
8
8
|
import { PoolState } from "../contracts/core/pool/type";
|
|
@@ -88,7 +88,7 @@ export declare class OracleLibs extends ServiceBaseV1 {
|
|
|
88
88
|
oracleParams: Cell;
|
|
89
89
|
bucket: AddressBucket;
|
|
90
90
|
}>;
|
|
91
|
-
getOracleParamsForStrategyVaultRFQAuction(rfqAuctionData: ReturnType<typeof RFQAuction.
|
|
91
|
+
getOracleParamsForStrategyVaultRFQAuction(rfqAuctionData: ReturnType<typeof RFQAuction.parseRFQStorage>, bucket?: AddressBucket): Promise<Cell>;
|
|
92
92
|
getOracleParamsForRFQBatch(rfqBatchData: ReturnType<typeof RFQBatch.parseRFQBatchStorage>, bucket?: AddressBucket): Promise<{
|
|
93
93
|
oracleParams: Cell;
|
|
94
94
|
bucket: AddressBucket;
|
|
@@ -103,5 +103,6 @@ export declare class OracleLibs extends ServiceBaseV1 {
|
|
|
103
103
|
strategyVaults: Record<string, StrategyVaultValueStatus>;
|
|
104
104
|
shareVaults: Record<string, ShareVaultValueStatus>;
|
|
105
105
|
}>;
|
|
106
|
+
makeAddressBucket(asset: Address, bucket?: AddressBucket): Promise<AddressBucket>;
|
|
106
107
|
}
|
|
107
108
|
export {};
|
package/dist/oracle/oracle.js
CHANGED
|
@@ -202,10 +202,10 @@ class AddressBucket {
|
|
|
202
202
|
}
|
|
203
203
|
updateVaultPoolPositions(vaultPoolPositions) {
|
|
204
204
|
for (const [poolAddress, poolPosition] of Object.entries(vaultPoolPositions)) {
|
|
205
|
-
for (const [
|
|
205
|
+
for (const [assetAddress, position] of Object.entries(poolPosition)) {
|
|
206
206
|
if (position.supply > 0 || position.borrow > 0) {
|
|
207
|
+
this.assets.add(assetAddress);
|
|
207
208
|
this.pools.add(poolAddress);
|
|
208
|
-
break;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -388,5 +388,28 @@ class OracleLibs extends service_1.ServiceBaseV1 {
|
|
|
388
388
|
}));
|
|
389
389
|
return { strategyVaults, shareVaults };
|
|
390
390
|
}
|
|
391
|
+
async makeAddressBucket(asset, bucket = new AddressBucket()) {
|
|
392
|
+
const assetAddress = asset.toString();
|
|
393
|
+
const assetType = await this.getAssetType(assetAddress);
|
|
394
|
+
if (assetType.type === "underlying-asset") {
|
|
395
|
+
bucket.assets.add(assetAddress.toString());
|
|
396
|
+
}
|
|
397
|
+
else if (assetType.type === "share-vault") {
|
|
398
|
+
bucket.vaults.add(assetAddress.toString());
|
|
399
|
+
Object.keys(assetType.data.whitelistedPools).forEach((poolAddress) => {
|
|
400
|
+
bucket.pools.add(poolAddress);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else if (assetType.type === "strategy-vault") {
|
|
404
|
+
bucket.vaults.add(assetAddress.toString());
|
|
405
|
+
Object.keys(assetType.data.factorialPools).forEach((poolAddress) => {
|
|
406
|
+
bucket.pools.add(poolAddress);
|
|
407
|
+
});
|
|
408
|
+
await Promise.all(Object.keys(assetType.data.assets).map(async (assetAddress) => {
|
|
409
|
+
this.makeAddressBucket(core_1.Address.parse(assetAddress), bucket);
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
return bucket;
|
|
413
|
+
}
|
|
391
414
|
}
|
|
392
415
|
exports.OracleLibs = OracleLibs;
|
package/dist/pool.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Address, Cell, Sender } from "@ton/ton";
|
|
2
2
|
import { PoolState } from "./contracts/core/pool/type";
|
|
3
|
+
import { Pool } from "./contracts/core/pool";
|
|
3
4
|
import { OnchainDataInfo } from "./contracts/oracle/redstone-onchain-oracle/type";
|
|
4
5
|
import { LiquidateActionParams, TransferInActionParams, TansferOutActionParams } from "./types/action";
|
|
5
6
|
import { TxCallBackFn, TxStep } from "./utils/tracker/type";
|
|
@@ -47,6 +48,26 @@ export declare class PoolV1 extends ServiceBaseV1 {
|
|
|
47
48
|
};
|
|
48
49
|
steps: TxStep[];
|
|
49
50
|
}>;
|
|
51
|
+
_withdrawMessage(params: TansferOutActionParams): Promise<{
|
|
52
|
+
pool: import("@ton/ton").OpenedContract<Pool>;
|
|
53
|
+
poolData: any;
|
|
54
|
+
oracleParams: Cell | null;
|
|
55
|
+
gas: bigint;
|
|
56
|
+
opts: {
|
|
57
|
+
queryId: bigint;
|
|
58
|
+
asset: Address;
|
|
59
|
+
isShare: boolean;
|
|
60
|
+
amount: bigint;
|
|
61
|
+
recipient: Address;
|
|
62
|
+
response: Address;
|
|
63
|
+
jettonForwardTonAmount: bigint;
|
|
64
|
+
jettonForwardPayload: Cell | null;
|
|
65
|
+
oracleParams: Cell | null;
|
|
66
|
+
};
|
|
67
|
+
senderAccountAddress: Address;
|
|
68
|
+
poolJettonWalletAddress: Address;
|
|
69
|
+
recipeintJettonWalletAddress: Address;
|
|
70
|
+
}>;
|
|
50
71
|
findWithdrawTx(queryId: bigint, params: TansferOutActionParams, callbackFn?: TxCallBackFn): Promise<{
|
|
51
72
|
action: {
|
|
52
73
|
type: string;
|
|
@@ -64,6 +85,26 @@ export declare class PoolV1 extends ServiceBaseV1 {
|
|
|
64
85
|
};
|
|
65
86
|
steps: TxStep[];
|
|
66
87
|
}>;
|
|
88
|
+
_borrowMessage(params: TansferOutActionParams): Promise<{
|
|
89
|
+
pool: import("@ton/ton").OpenedContract<Pool>;
|
|
90
|
+
poolData: any;
|
|
91
|
+
oracleParams: Cell;
|
|
92
|
+
gas: bigint;
|
|
93
|
+
opts: {
|
|
94
|
+
queryId: bigint;
|
|
95
|
+
asset: Address;
|
|
96
|
+
isShare: boolean;
|
|
97
|
+
amount: bigint;
|
|
98
|
+
recipient: Address;
|
|
99
|
+
response: Address;
|
|
100
|
+
jettonForwardTonAmount: bigint;
|
|
101
|
+
jettonForwardPayload: Cell | null;
|
|
102
|
+
oracleParams: Cell;
|
|
103
|
+
};
|
|
104
|
+
senderAccountAddress: Address;
|
|
105
|
+
poolJettonWalletAddress: Address;
|
|
106
|
+
recipeintJettonWalletAddress: Address;
|
|
107
|
+
}>;
|
|
67
108
|
findBorrowTx(queryId: bigint, params: TansferOutActionParams, callbackFn?: TxCallBackFn): Promise<{
|
|
68
109
|
action: {
|
|
69
110
|
type: string;
|