@affluent-org/sdk 0.0.7 → 0.0.8
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/common/transform.js +2 -2
- package/dist/contracts/core/pool/index.d.ts +1 -0
- package/dist/contracts/core/pool/index.js +7 -3
- package/dist/lib/send-msg.d.ts +2 -5
- package/dist/lib/send-msg.js +4 -3
- package/dist/services/strategy-vault/index.d.ts +1 -1
- package/dist/services/strategy-vault/query.d.ts +1 -1
- package/dist/services/strategy-vault/query.js +2 -2
- package/dist/types/sender.d.ts +0 -1
- package/package.json +1 -1
package/dist/common/transform.js
CHANGED
|
@@ -77,8 +77,8 @@ class PoolContext {
|
|
|
77
77
|
}
|
|
78
78
|
static fromPoolState(poolState) {
|
|
79
79
|
const assets = {};
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const accrueInterestAssets = pool_1.Pool.applyAccrueInterest(poolState.assets, poolState.protocolFeeRate);
|
|
81
|
+
Object.entries(accrueInterestAssets).forEach(([asset, assetState]) => {
|
|
82
82
|
assets[asset] = {
|
|
83
83
|
amount: new AmountPosition(assetState.totalSupplyAmount, assetState.totalBorrowAmount),
|
|
84
84
|
share: new SharePosition(assetState.totalSupplyShare, assetState.totalBorrowShare),
|
|
@@ -118,6 +118,7 @@ export declare class Pool implements Contract {
|
|
|
118
118
|
}) => Cell;
|
|
119
119
|
static calculateGasFee(actionOp: number, baseFee: bigint, forwardFee: bigint, forwardTonAmount: bigint, useInternalOracle: boolean, useOracle: boolean, gas: PoolGasFee): bigint;
|
|
120
120
|
getState(provider: ContractProvider): Promise<import("@ton/core").ContractState>;
|
|
121
|
+
static applyAccrueInterest(assets: Record<string, AssetState>, protocolFeeRate: bigint, time?: number): Record<string, AssetState>;
|
|
121
122
|
static simulateAccrueInterest(poolState: PoolState, time?: number): PoolState;
|
|
122
123
|
getPoolData(provider: ContractProvider): Promise<PoolState>;
|
|
123
124
|
static parsePoolData(data: Slice): {
|
|
@@ -245,17 +245,17 @@ class Pool {
|
|
|
245
245
|
async getState(provider) {
|
|
246
246
|
return await provider.getState();
|
|
247
247
|
}
|
|
248
|
-
static
|
|
248
|
+
static applyAccrueInterest(assets, protocolFeeRate, time) {
|
|
249
249
|
const currentTime = BigInt(time ?? BigInt(Math.floor(Date.now() / 1000)));
|
|
250
250
|
const newAssets = {};
|
|
251
|
-
Object.entries(
|
|
251
|
+
Object.entries(assets).forEach(([assetAddress, assetInfo]) => {
|
|
252
252
|
if (assetInfo.totalBorrowShare === 0n) {
|
|
253
253
|
newAssets[assetAddress] = assetInfo;
|
|
254
254
|
}
|
|
255
255
|
else {
|
|
256
256
|
const timeDelta = currentTime - assetInfo.lastUpdatedTime;
|
|
257
257
|
const interest = (timeDelta * assetInfo.totalBorrowAmount * assetInfo.storedInterestRate) / 10n ** 36n;
|
|
258
|
-
const protocolFee = (interest *
|
|
258
|
+
const protocolFee = (interest * protocolFeeRate) / 10000n;
|
|
259
259
|
newAssets[assetAddress] = {
|
|
260
260
|
...assetInfo,
|
|
261
261
|
totalBorrowAmount: assetInfo.totalBorrowAmount + interest,
|
|
@@ -265,6 +265,10 @@ class Pool {
|
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
});
|
|
268
|
+
return newAssets;
|
|
269
|
+
}
|
|
270
|
+
static simulateAccrueInterest(poolState, time) {
|
|
271
|
+
const newAssets = Pool.applyAccrueInterest(poolState.assets, poolState.protocolFeeRate, time);
|
|
268
272
|
return {
|
|
269
273
|
...poolState,
|
|
270
274
|
assets: newAssets,
|
package/dist/lib/send-msg.d.ts
CHANGED
|
@@ -10,15 +10,12 @@ export type InternalMessageInput = {
|
|
|
10
10
|
export declare function sendMsg<T>(sender: AddressSender, msg: {
|
|
11
11
|
opts: T;
|
|
12
12
|
input: InternalMessageInput;
|
|
13
|
-
}): Promise<T
|
|
14
|
-
seqno: number;
|
|
15
|
-
}>;
|
|
13
|
+
}): Promise<T>;
|
|
16
14
|
export declare function sendMsgAndWaitTx<T>(ctx: AffluentContext, sender: AddressSender, msg: {
|
|
17
15
|
opts: T;
|
|
18
16
|
input: InternalMessageInput;
|
|
19
|
-
}): Promise<T & {
|
|
17
|
+
}): Promise<Awaited<T> & {
|
|
20
18
|
getExternalHash: () => Promise<import("../utils/external-message-hash").MessageHash>;
|
|
21
|
-
seqno: number;
|
|
22
19
|
}>;
|
|
23
20
|
export declare function sendMsgAndWaitTxSimple(ctx: AffluentContext, sender: AddressSender, msg: {
|
|
24
21
|
input: InternalMessageInput;
|
package/dist/lib/send-msg.js
CHANGED
|
@@ -7,14 +7,15 @@ const core_1 = require("@ton/core");
|
|
|
7
7
|
const trackable_sender_1 = require("../utils/pending-tracker/trackable-sender");
|
|
8
8
|
const trace_action_1 = require("../common/trace-action");
|
|
9
9
|
async function sendMsg(sender, msg) {
|
|
10
|
-
const seqno = await sender.getSeqno();
|
|
11
10
|
const { opts, input } = msg;
|
|
12
11
|
await sender.send({ ...input, sendMode: core_1.SendMode.PAY_GAS_SEPARATELY });
|
|
13
|
-
return { ...opts
|
|
12
|
+
return { ...opts };
|
|
14
13
|
}
|
|
15
14
|
async function sendMsgAndWaitTx(ctx, sender, msg) {
|
|
15
|
+
const seqnoRes = await ctx.client.provider(sender.address).get("seqno", []);
|
|
16
|
+
const seqno = seqnoRes.stack.readNumber();
|
|
16
17
|
const result = await sendMsg(sender, msg);
|
|
17
|
-
const getExternalHash = () => (0, trackable_sender_1.pollExternalTransfer)(ctx.client, sender.address,
|
|
18
|
+
const getExternalHash = () => (0, trackable_sender_1.pollExternalTransfer)(ctx.client, sender.address, seqno);
|
|
18
19
|
return { ...result, getExternalHash };
|
|
19
20
|
}
|
|
20
21
|
async function sendMsgAndWaitTxSimple(ctx, sender, msg) {
|
|
@@ -212,8 +212,8 @@ export declare class StrategyVaultServiceV1 {
|
|
|
212
212
|
vaultStateContext: import("../../common/transform").VaultStateContext;
|
|
213
213
|
amountContext: import("../../common/transform").VaultAmountContext;
|
|
214
214
|
valueContext: import("../../common/transform").VaultValueContext;
|
|
215
|
-
nativeValueDecomposedContext: import("../../common/transform").VaultNativeValueDecomposedContext;
|
|
216
215
|
nativeAmountDecomposedContext: import("../../common/transform").VaultNativeAmountDecomposedContext;
|
|
216
|
+
nativeValueDecomposedContext: import("../../common/transform").VaultNativeValueDecomposedContext;
|
|
217
217
|
priceInfo: import("../composite-oracle").CompositeOracleResult & {
|
|
218
218
|
targetVaultAddress: string;
|
|
219
219
|
price: bigint;
|
|
@@ -144,8 +144,8 @@ export declare function getValuationContext(ctx: AffluentContext, vaultAddress:
|
|
|
144
144
|
vaultStateContext: VaultStateContext;
|
|
145
145
|
amountContext: import("../../common/transform").VaultAmountContext;
|
|
146
146
|
valueContext: import("../../common/transform").VaultValueContext;
|
|
147
|
-
nativeValueDecomposedContext: VaultNativeValueDecomposedContext;
|
|
148
147
|
nativeAmountDecomposedContext: VaultNativeAmountDecomposedContext;
|
|
148
|
+
nativeValueDecomposedContext: VaultNativeValueDecomposedContext;
|
|
149
149
|
priceInfo: import("../composite-oracle").CompositeOracleResult & {
|
|
150
150
|
targetVaultAddress: string;
|
|
151
151
|
price: bigint;
|
|
@@ -87,14 +87,14 @@ async function getValuationContext(ctx, vaultAddress) {
|
|
|
87
87
|
const vaultStateContext = transform_1.VaultStateContext.fromStrategyVaultState(vaultData);
|
|
88
88
|
const amountContext = vaultStateContext.toAmountContext(poolContexts);
|
|
89
89
|
const valueContext = amountContext.toValueContext(priceInfo.allPrices);
|
|
90
|
-
const nativeValueDecomposedContext = transform_1.VaultNativeValueDecomposedContext.fromValueContext(valueContext, priceInfo.allPrices);
|
|
91
90
|
const nativeAmountDecomposedContext = transform_1.VaultNativeAmountDecomposedContext.fromAmountContext(amountContext, priceInfo.allPrices);
|
|
91
|
+
const nativeValueDecomposedContext = transform_1.VaultNativeValueDecomposedContext.fromValueContext(valueContext, priceInfo.allPrices);
|
|
92
92
|
return {
|
|
93
93
|
vaultStateContext,
|
|
94
94
|
amountContext,
|
|
95
95
|
valueContext,
|
|
96
|
-
nativeValueDecomposedContext,
|
|
97
96
|
nativeAmountDecomposedContext,
|
|
97
|
+
nativeValueDecomposedContext,
|
|
98
98
|
priceInfo,
|
|
99
99
|
};
|
|
100
100
|
}
|
package/dist/types/sender.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Address, Sender, SenderArguments } from "@ton/core";
|
|
2
2
|
export interface AddressSender extends Sender {
|
|
3
3
|
readonly address: Address;
|
|
4
|
-
getSeqno(): Promise<number>;
|
|
5
4
|
}
|
|
6
5
|
export interface MultiSender extends AddressSender {
|
|
7
6
|
multiSend(args: SenderArguments[]): Promise<void>;
|