@affluent-org/sdk 0.0.5 → 0.0.7
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 +71 -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 +55 -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 +9 -26
- package/dist/services/rfq-batch/index.js +48 -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 +57 -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 +214 -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
|
@@ -38,6 +38,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.PoolServiceV1 = exports.user = exports.owner = exports.oracle = exports.query = exports.computation = exports.sendMsg = void 0;
|
|
40
40
|
const context_1 = require("../../context");
|
|
41
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
41
42
|
const send_msg_1 = require("../../lib/send-msg");
|
|
42
43
|
const computation = __importStar(require("./computation"));
|
|
43
44
|
exports.computation = computation;
|
|
@@ -49,11 +50,13 @@ const owner = __importStar(require("./owner"));
|
|
|
49
50
|
exports.owner = owner;
|
|
50
51
|
const user = __importStar(require("./user"));
|
|
51
52
|
exports.user = user;
|
|
53
|
+
const trace_1 = require("./user/trace");
|
|
52
54
|
// Re-exports
|
|
53
55
|
var send_msg_2 = require("../../lib/send-msg");
|
|
54
56
|
Object.defineProperty(exports, "sendMsg", { enumerable: true, get: function () { return send_msg_2.sendMsg; } });
|
|
55
57
|
__exportStar(require("./owner/types"), exports);
|
|
56
58
|
__exportStar(require("./user/types"), exports);
|
|
59
|
+
__exportStar(require("./user/trace"), exports);
|
|
57
60
|
__exportStar(require("./computation"), exports); // Types and pure computation functions
|
|
58
61
|
class PoolServiceV1 {
|
|
59
62
|
ctx;
|
|
@@ -109,31 +112,91 @@ class PoolServiceV1 {
|
|
|
109
112
|
// Owner
|
|
110
113
|
// ============================================================
|
|
111
114
|
async sendSetOwner(sender, params, value) {
|
|
112
|
-
|
|
115
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await owner.createSetOwnerMsg(this.ctx, params, value));
|
|
116
|
+
await trace.wait();
|
|
117
|
+
return trace;
|
|
113
118
|
}
|
|
114
119
|
async sendSetIrmConfig(sender, params, value) {
|
|
115
|
-
|
|
120
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await owner.createSetIrmConfigMsg(this.ctx, params, value));
|
|
121
|
+
await trace.wait();
|
|
122
|
+
return trace;
|
|
116
123
|
}
|
|
117
124
|
async sendSetFeeConfigurer(sender, params, value) {
|
|
118
|
-
|
|
125
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await owner.createSetFeeConfigurerMsg(this.ctx, params, value));
|
|
126
|
+
await trace.wait();
|
|
127
|
+
return trace;
|
|
119
128
|
}
|
|
120
129
|
// ============================================================
|
|
121
130
|
// User
|
|
122
131
|
// ============================================================
|
|
123
132
|
async sendSupply(sender, params, value) {
|
|
124
|
-
|
|
133
|
+
const msg = await user.createSupplyMsg(this.ctx, sender, params, value);
|
|
134
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
135
|
+
const asset = (0, utils_1.toAddress)(params.assetAddress);
|
|
136
|
+
const trace = await trace_1.PoolSupplyTracer.create({
|
|
137
|
+
ctx: this.ctx,
|
|
138
|
+
msgBody: msg.input.body,
|
|
139
|
+
extHash: await result.getExternalHash(),
|
|
140
|
+
actor: sender.address,
|
|
141
|
+
asset,
|
|
142
|
+
pool: (0, utils_1.toAddress)(params.poolAddress),
|
|
143
|
+
isWTON: this.ctx.isWTON(asset),
|
|
144
|
+
});
|
|
145
|
+
await trace.wait();
|
|
146
|
+
return trace;
|
|
125
147
|
}
|
|
126
148
|
async sendWithdraw(sender, params, value) {
|
|
127
|
-
|
|
149
|
+
const msg = await user.createWithdrawMsg(this.ctx, sender, params, value);
|
|
150
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
151
|
+
const asset = (0, utils_1.toAddress)(params.assetAddress);
|
|
152
|
+
const trace = await trace_1.PoolWithdrawTracer.create({
|
|
153
|
+
ctx: this.ctx,
|
|
154
|
+
msgBody: msg.input.body,
|
|
155
|
+
extHash: await result.getExternalHash(),
|
|
156
|
+
actor: sender.address,
|
|
157
|
+
asset,
|
|
158
|
+
pool: (0, utils_1.toAddress)(params.poolAddress),
|
|
159
|
+
isWTON: this.ctx.isWTON(asset),
|
|
160
|
+
});
|
|
161
|
+
await trace.wait();
|
|
162
|
+
return trace;
|
|
128
163
|
}
|
|
129
164
|
async sendBorrow(sender, params, value) {
|
|
130
|
-
|
|
165
|
+
const msg = await user.createBorrowMsg(this.ctx, sender, params, value);
|
|
166
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
167
|
+
const asset = (0, utils_1.toAddress)(params.assetAddress);
|
|
168
|
+
const trace = await trace_1.PoolBorrowTracer.create({
|
|
169
|
+
ctx: this.ctx,
|
|
170
|
+
msgBody: msg.input.body,
|
|
171
|
+
extHash: await result.getExternalHash(),
|
|
172
|
+
actor: sender.address,
|
|
173
|
+
asset,
|
|
174
|
+
pool: (0, utils_1.toAddress)(params.poolAddress),
|
|
175
|
+
isWTON: this.ctx.isWTON(asset),
|
|
176
|
+
});
|
|
177
|
+
await trace.wait();
|
|
178
|
+
return trace;
|
|
131
179
|
}
|
|
132
180
|
async sendRepay(sender, params, value) {
|
|
133
|
-
|
|
181
|
+
const msg = await user.createRepayMsg(this.ctx, sender, params, value);
|
|
182
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
183
|
+
const asset = (0, utils_1.toAddress)(params.assetAddress);
|
|
184
|
+
const trace = await trace_1.PoolRepayTracer.create({
|
|
185
|
+
ctx: this.ctx,
|
|
186
|
+
msgBody: msg.input.body,
|
|
187
|
+
extHash: await result.getExternalHash(),
|
|
188
|
+
actor: sender.address,
|
|
189
|
+
asset,
|
|
190
|
+
pool: (0, utils_1.toAddress)(params.poolAddress),
|
|
191
|
+
isWTON: this.ctx.isWTON(asset),
|
|
192
|
+
});
|
|
193
|
+
await trace.wait();
|
|
194
|
+
return trace;
|
|
134
195
|
}
|
|
135
196
|
async sendLiquidate(sender, params, value) {
|
|
136
|
-
|
|
197
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await user.createLiquidateMsg(this.ctx, sender, params, value));
|
|
198
|
+
await trace.wait();
|
|
199
|
+
return trace;
|
|
137
200
|
}
|
|
138
201
|
}
|
|
139
202
|
exports.PoolServiceV1 = PoolServiceV1;
|
|
@@ -107,7 +107,7 @@ async function getPricesAndCompositions(ctx, poolAddress) {
|
|
|
107
107
|
vaultPositions,
|
|
108
108
|
poolInfos,
|
|
109
109
|
});
|
|
110
|
-
const vaultCompositions = Object.fromEntries(Object.entries(result.vaultPrices).map(([
|
|
110
|
+
const vaultCompositions = Object.fromEntries(Object.entries(result.vaultPrices).map(([asset, priceData]) => [asset, priceData.additionalData]));
|
|
111
111
|
return { prices: result.allPrices, vaultCompositions };
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Address, Cell } from "@ton/core";
|
|
2
|
+
import { TracerBase } from "../../../common/trace-action";
|
|
3
|
+
import { MessageHash } from "../../../utils/external-message-hash";
|
|
4
|
+
import { TonClient } from "@ton/ton";
|
|
5
|
+
import { AffluentContext } from "../../../context";
|
|
6
|
+
import { ToncenterV3Client } from "../../../utils/pending-tracker/v3-client";
|
|
7
|
+
export type PoolAddresses = {
|
|
8
|
+
actor: Address;
|
|
9
|
+
actorAssetWallet: Address;
|
|
10
|
+
account: Address;
|
|
11
|
+
pool: Address;
|
|
12
|
+
poolAssetWallet: Address;
|
|
13
|
+
};
|
|
14
|
+
export declare function getPoolAddresses(client: TonClient, params: {
|
|
15
|
+
actor: Address;
|
|
16
|
+
asset: Address;
|
|
17
|
+
pool: Address;
|
|
18
|
+
}): Promise<PoolAddresses>;
|
|
19
|
+
export type PoolSupplyTracerParams = {
|
|
20
|
+
ctx: AffluentContext;
|
|
21
|
+
msgBody: Cell;
|
|
22
|
+
extHash: MessageHash;
|
|
23
|
+
actor: Address;
|
|
24
|
+
asset: Address;
|
|
25
|
+
pool: Address;
|
|
26
|
+
isWTON: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare class PoolSupplyTracer extends TracerBase<"jetton" | "wton"> {
|
|
29
|
+
static create(params: PoolSupplyTracerParams): Promise<PoolSupplyTracer>;
|
|
30
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
31
|
+
isWTON: boolean;
|
|
32
|
+
queryId: bigint;
|
|
33
|
+
extHash: MessageHash;
|
|
34
|
+
addresses: PoolAddresses;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export type PoolWithdrawTracerParams = {
|
|
38
|
+
ctx: AffluentContext;
|
|
39
|
+
msgBody: Cell;
|
|
40
|
+
extHash: MessageHash;
|
|
41
|
+
actor: Address;
|
|
42
|
+
asset: Address;
|
|
43
|
+
pool: Address;
|
|
44
|
+
isWTON: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare class PoolWithdrawTracer extends TracerBase<"jetton" | "wton"> {
|
|
47
|
+
static create(params: PoolWithdrawTracerParams): Promise<PoolWithdrawTracer>;
|
|
48
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
49
|
+
isWTON: boolean;
|
|
50
|
+
queryId: bigint;
|
|
51
|
+
extHash: MessageHash;
|
|
52
|
+
addresses: PoolAddresses;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export type PoolBorrowTracerParams = {
|
|
56
|
+
ctx: AffluentContext;
|
|
57
|
+
msgBody: Cell;
|
|
58
|
+
extHash: MessageHash;
|
|
59
|
+
actor: Address;
|
|
60
|
+
asset: Address;
|
|
61
|
+
pool: Address;
|
|
62
|
+
isWTON: boolean;
|
|
63
|
+
};
|
|
64
|
+
export declare class PoolBorrowTracer extends TracerBase<"jetton" | "wton"> {
|
|
65
|
+
static create(params: PoolBorrowTracerParams): Promise<PoolBorrowTracer>;
|
|
66
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
67
|
+
isWTON: boolean;
|
|
68
|
+
queryId: bigint;
|
|
69
|
+
extHash: MessageHash;
|
|
70
|
+
addresses: PoolAddresses;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export type PoolRepayTracerParams = {
|
|
74
|
+
ctx: AffluentContext;
|
|
75
|
+
msgBody: Cell;
|
|
76
|
+
extHash: MessageHash;
|
|
77
|
+
actor: Address;
|
|
78
|
+
asset: Address;
|
|
79
|
+
pool: Address;
|
|
80
|
+
isWTON: boolean;
|
|
81
|
+
};
|
|
82
|
+
export declare class PoolRepayTracer extends TracerBase<"jetton" | "wton"> {
|
|
83
|
+
static create(params: PoolRepayTracerParams): Promise<PoolRepayTracer>;
|
|
84
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
85
|
+
isWTON: boolean;
|
|
86
|
+
queryId: bigint;
|
|
87
|
+
extHash: MessageHash;
|
|
88
|
+
addresses: PoolAddresses;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PoolRepayTracer = exports.PoolBorrowTracer = exports.PoolWithdrawTracer = exports.PoolSupplyTracer = void 0;
|
|
4
|
+
exports.getPoolAddresses = getPoolAddresses;
|
|
5
|
+
const trace_action_1 = require("../../../common/trace-action");
|
|
6
|
+
const jetton_wallet_1 = require("../../../contracts/jetton/jetton-wallet");
|
|
7
|
+
const pool_1 = require("../../../contracts/core/pool");
|
|
8
|
+
const jetton_minter_1 = require("../../../contracts/jetton/jetton-minter");
|
|
9
|
+
async function getPoolAddresses(client, params) {
|
|
10
|
+
const { actor, asset, pool } = params;
|
|
11
|
+
const _asset = client.open(jetton_minter_1.JettonMinter.createFromAddress(asset));
|
|
12
|
+
const _pool = client.open(pool_1.Pool.createFromAddress(pool));
|
|
13
|
+
return {
|
|
14
|
+
actor,
|
|
15
|
+
actorAssetWallet: await _asset.getWalletAddress(actor),
|
|
16
|
+
account: await _pool.getAccountAddress(actor),
|
|
17
|
+
pool,
|
|
18
|
+
poolAssetWallet: await _asset.getWalletAddress(pool),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
class PoolSupplyTracer extends trace_action_1.TracerBase {
|
|
22
|
+
static async create(params) {
|
|
23
|
+
const { ctx, msgBody, extHash, actor, asset, pool, isWTON } = params;
|
|
24
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
25
|
+
const addresses = await getPoolAddresses(ctx.client, { actor, asset, pool });
|
|
26
|
+
return new PoolSupplyTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
27
|
+
}
|
|
28
|
+
constructor(toncenterClient, params) {
|
|
29
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
30
|
+
const type = isWTON ? "wton" : "jetton";
|
|
31
|
+
const steps = [
|
|
32
|
+
...(0, trace_action_1.createJettonSendSteps)({
|
|
33
|
+
isWTON,
|
|
34
|
+
actor: addresses.actor,
|
|
35
|
+
actorWallet: addresses.actorAssetWallet,
|
|
36
|
+
targetWallet: addresses.poolAssetWallet,
|
|
37
|
+
target: addresses.pool,
|
|
38
|
+
description: "Supplying Tokens",
|
|
39
|
+
}),
|
|
40
|
+
{
|
|
41
|
+
op: pool_1.Pool.Op.UpdateAccountStatus,
|
|
42
|
+
from: addresses.pool,
|
|
43
|
+
to: addresses.account,
|
|
44
|
+
description: "Updating Account Status",
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
const failStep = {
|
|
48
|
+
op: jetton_wallet_1.JettonWallet.Op.Transfer,
|
|
49
|
+
from: addresses.pool,
|
|
50
|
+
to: addresses.poolAssetWallet,
|
|
51
|
+
description: "Refunding Tokens",
|
|
52
|
+
};
|
|
53
|
+
super(toncenterClient, extHash, type, queryId, steps, failStep);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.PoolSupplyTracer = PoolSupplyTracer;
|
|
57
|
+
class PoolWithdrawTracer extends trace_action_1.TracerBase {
|
|
58
|
+
static async create(params) {
|
|
59
|
+
const { ctx, msgBody, extHash, actor, asset, pool, isWTON } = params;
|
|
60
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
61
|
+
const addresses = await getPoolAddresses(ctx.client, { actor, asset, pool });
|
|
62
|
+
return new PoolWithdrawTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
63
|
+
}
|
|
64
|
+
constructor(toncenterClient, params) {
|
|
65
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
66
|
+
const type = isWTON ? "wton" : "jetton";
|
|
67
|
+
const steps = [
|
|
68
|
+
{
|
|
69
|
+
op: pool_1.Pool.Op.Withdraw,
|
|
70
|
+
from: addresses.actor,
|
|
71
|
+
to: addresses.pool,
|
|
72
|
+
description: "Requesting Withdrawal",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
op: pool_1.Pool.Op.ExecuteAction,
|
|
76
|
+
from: addresses.pool,
|
|
77
|
+
to: addresses.account,
|
|
78
|
+
description: "Checking Account Health",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
op: pool_1.Pool.Op.ExecuteAction,
|
|
82
|
+
from: addresses.account,
|
|
83
|
+
to: addresses.pool,
|
|
84
|
+
description: "Checking Account Health",
|
|
85
|
+
},
|
|
86
|
+
...(0, trace_action_1.createJettonReceiveSteps)({
|
|
87
|
+
isWTON,
|
|
88
|
+
sourceWallet: addresses.poolAssetWallet,
|
|
89
|
+
actorWallet: addresses.actorAssetWallet,
|
|
90
|
+
actor: addresses.actor,
|
|
91
|
+
description: "Receiving Asset",
|
|
92
|
+
}),
|
|
93
|
+
];
|
|
94
|
+
super(toncenterClient, extHash, type, queryId, steps);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.PoolWithdrawTracer = PoolWithdrawTracer;
|
|
98
|
+
class PoolBorrowTracer extends trace_action_1.TracerBase {
|
|
99
|
+
static async create(params) {
|
|
100
|
+
const { ctx, msgBody, extHash, actor, asset, pool, isWTON } = params;
|
|
101
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
102
|
+
const addresses = await getPoolAddresses(ctx.client, { actor, asset, pool });
|
|
103
|
+
return new PoolBorrowTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
104
|
+
}
|
|
105
|
+
constructor(toncenterClient, params) {
|
|
106
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
107
|
+
const type = isWTON ? "wton" : "jetton";
|
|
108
|
+
const steps = [
|
|
109
|
+
{
|
|
110
|
+
op: pool_1.Pool.Op.Borrow,
|
|
111
|
+
from: addresses.actor,
|
|
112
|
+
to: addresses.pool,
|
|
113
|
+
description: "Requesting Borrow",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
op: pool_1.Pool.Op.ExecuteAction,
|
|
117
|
+
from: addresses.pool,
|
|
118
|
+
to: addresses.account,
|
|
119
|
+
description: "Checking Account Health",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
op: pool_1.Pool.Op.ExecuteAction,
|
|
123
|
+
from: addresses.account,
|
|
124
|
+
to: addresses.pool,
|
|
125
|
+
description: "Checking Account Health",
|
|
126
|
+
},
|
|
127
|
+
...(0, trace_action_1.createJettonReceiveSteps)({
|
|
128
|
+
isWTON,
|
|
129
|
+
sourceWallet: addresses.poolAssetWallet,
|
|
130
|
+
actorWallet: addresses.actorAssetWallet,
|
|
131
|
+
actor: addresses.actor,
|
|
132
|
+
description: "Receiving Borrowed Asset",
|
|
133
|
+
}),
|
|
134
|
+
];
|
|
135
|
+
super(toncenterClient, extHash, type, queryId, steps);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.PoolBorrowTracer = PoolBorrowTracer;
|
|
139
|
+
class PoolRepayTracer extends trace_action_1.TracerBase {
|
|
140
|
+
static async create(params) {
|
|
141
|
+
const { ctx, msgBody, extHash, actor, asset, pool, isWTON } = params;
|
|
142
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
143
|
+
const addresses = await getPoolAddresses(ctx.client, { actor, asset, pool });
|
|
144
|
+
return new PoolRepayTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
145
|
+
}
|
|
146
|
+
constructor(toncenterClient, params) {
|
|
147
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
148
|
+
const type = isWTON ? "wton" : "jetton";
|
|
149
|
+
const steps = [
|
|
150
|
+
...(0, trace_action_1.createJettonSendSteps)({
|
|
151
|
+
isWTON,
|
|
152
|
+
actor: addresses.actor,
|
|
153
|
+
actorWallet: addresses.actorAssetWallet,
|
|
154
|
+
targetWallet: addresses.poolAssetWallet,
|
|
155
|
+
target: addresses.pool,
|
|
156
|
+
description: "Repaying Tokens",
|
|
157
|
+
}),
|
|
158
|
+
{
|
|
159
|
+
op: pool_1.Pool.Op.ExecuteAction,
|
|
160
|
+
from: addresses.pool,
|
|
161
|
+
to: addresses.account,
|
|
162
|
+
description: "Updating Account Health",
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
super(toncenterClient, extHash, type, queryId, steps);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.PoolRepayTracer = PoolRepayTracer;
|
|
@@ -3,11 +3,13 @@ import { AffluentContext } from "../../context";
|
|
|
3
3
|
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
4
|
import { StrategyVaultState } from "../../contracts/vault/strategy-vault";
|
|
5
5
|
import { AddressSender } from "../../types/sender";
|
|
6
|
+
import { RFQAuctionBidTracer, RFQAuctionCancelBidTracer } from "./user/trace";
|
|
6
7
|
import * as query from "./query";
|
|
7
8
|
import * as oracle from "./oracle";
|
|
8
9
|
import * as user from "./user";
|
|
9
10
|
export { sendMsg } from "../../lib/send-msg";
|
|
10
11
|
export * from "./user/types";
|
|
12
|
+
export * from "./user/trace";
|
|
11
13
|
export { query, oracle, user };
|
|
12
14
|
export declare class RFQAuctionServiceV1 {
|
|
13
15
|
private ctx;
|
|
@@ -55,27 +57,9 @@ export declare class RFQAuctionServiceV1 {
|
|
|
55
57
|
}>;
|
|
56
58
|
getOracleParams(rfqAuctionAddress: AddressInput): Promise<Cell>;
|
|
57
59
|
getOracleParamsForVault(vaultAddress: AddressLike, additionalAssets?: AddressLike[], vaultData?: StrategyVaultState): Promise<Cell>;
|
|
58
|
-
sendAmountBid(sender: AddressSender, params: user.AmountBidParams, value?: bigint): Promise<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
forwardPayload: Cell;
|
|
64
|
-
queryId: bigint | undefined;
|
|
65
|
-
}>;
|
|
66
|
-
sendSlippageBid(sender: AddressSender, params: user.SlippageBidParams, value?: bigint): Promise<{
|
|
67
|
-
recipient: import("@ton/core").Address;
|
|
68
|
-
response: import("@ton/core").Address;
|
|
69
|
-
amount: bigint;
|
|
70
|
-
forwardTonAmount: bigint;
|
|
71
|
-
forwardPayload: Cell;
|
|
72
|
-
queryId: bigint | undefined;
|
|
73
|
-
}>;
|
|
74
|
-
sendCancelBid(sender: AddressSender, params: user.CancelBidParams, value?: bigint): Promise<{}>;
|
|
75
|
-
sendSettle(sender: AddressSender, params: user.SettleParams, value?: bigint): Promise<{
|
|
76
|
-
oracleParams: Cell;
|
|
77
|
-
}>;
|
|
78
|
-
sendClearBids(sender: AddressSender, params: user.ClearBidsParams, value?: bigint): Promise<{
|
|
79
|
-
clearCount: number;
|
|
80
|
-
}>;
|
|
60
|
+
sendAmountBid(sender: AddressSender, params: user.AmountBidParams, value?: bigint): Promise<RFQAuctionBidTracer>;
|
|
61
|
+
sendSlippageBid(sender: AddressSender, params: user.SlippageBidParams, value?: bigint): Promise<RFQAuctionBidTracer>;
|
|
62
|
+
sendCancelBid(sender: AddressSender, params: user.CancelBidParams, value?: bigint): Promise<RFQAuctionCancelBidTracer>;
|
|
63
|
+
sendSettle(sender: AddressSender, params: user.SettleParams, value?: bigint): Promise<import("../..").SimpleTracer>;
|
|
64
|
+
sendClearBids(sender: AddressSender, params: user.ClearBidsParams, value?: bigint): Promise<import("../..").SimpleTracer>;
|
|
81
65
|
}
|
|
@@ -39,6 +39,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.RFQAuctionServiceV1 = exports.user = exports.oracle = exports.query = exports.sendMsg = void 0;
|
|
40
40
|
const context_1 = require("../../context");
|
|
41
41
|
const send_msg_1 = require("../../lib/send-msg");
|
|
42
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
43
|
+
const trace_1 = require("./user/trace");
|
|
42
44
|
const query = __importStar(require("./query"));
|
|
43
45
|
exports.query = query;
|
|
44
46
|
const oracle = __importStar(require("./oracle"));
|
|
@@ -48,6 +50,7 @@ exports.user = user;
|
|
|
48
50
|
var send_msg_2 = require("../../lib/send-msg");
|
|
49
51
|
Object.defineProperty(exports, "sendMsg", { enumerable: true, get: function () { return send_msg_2.sendMsg; } });
|
|
50
52
|
__exportStar(require("./user/types"), exports);
|
|
53
|
+
__exportStar(require("./user/trace"), exports);
|
|
51
54
|
class RFQAuctionServiceV1 {
|
|
52
55
|
ctx;
|
|
53
56
|
constructor(ctx = context_1.AffluentContext.getInstance()) {
|
|
@@ -72,22 +75,68 @@ class RFQAuctionServiceV1 {
|
|
|
72
75
|
return oracle.getOracleParamsForVault(this.ctx, vaultAddress, additionalAssets, vaultData);
|
|
73
76
|
}
|
|
74
77
|
// ============================================================
|
|
75
|
-
// User
|
|
78
|
+
// User
|
|
76
79
|
// ============================================================
|
|
77
80
|
async sendAmountBid(sender, params, value) {
|
|
78
|
-
|
|
81
|
+
const msg = await user.createAmountBidMsg(this.ctx, sender, params, value);
|
|
82
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
83
|
+
const bidAsset = (0, utils_1.toAddress)(params.bidAsset);
|
|
84
|
+
const trace = await trace_1.RFQAuctionBidTracer.create({
|
|
85
|
+
ctx: this.ctx,
|
|
86
|
+
msgBody: msg.input.body,
|
|
87
|
+
extHash: await result.getExternalHash(),
|
|
88
|
+
actor: sender.address,
|
|
89
|
+
bidAsset,
|
|
90
|
+
rfqAuction: (0, utils_1.toAddress)(params.rfqAuctionAddress),
|
|
91
|
+
isWTON: this.ctx.isWTON(bidAsset),
|
|
92
|
+
});
|
|
93
|
+
await trace.wait();
|
|
94
|
+
return trace;
|
|
79
95
|
}
|
|
80
96
|
async sendSlippageBid(sender, params, value) {
|
|
81
|
-
|
|
97
|
+
const msg = await user.createSlippageBidMsg(this.ctx, sender, params, value);
|
|
98
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
99
|
+
const bidAsset = (0, utils_1.toAddress)(params.bidAsset);
|
|
100
|
+
const trace = await trace_1.RFQAuctionBidTracer.create({
|
|
101
|
+
ctx: this.ctx,
|
|
102
|
+
msgBody: msg.input.body,
|
|
103
|
+
extHash: await result.getExternalHash(),
|
|
104
|
+
actor: sender.address,
|
|
105
|
+
bidAsset,
|
|
106
|
+
rfqAuction: (0, utils_1.toAddress)(params.rfqAuctionAddress),
|
|
107
|
+
isWTON: this.ctx.isWTON(bidAsset),
|
|
108
|
+
});
|
|
109
|
+
await trace.wait();
|
|
110
|
+
return trace;
|
|
82
111
|
}
|
|
83
112
|
async sendCancelBid(sender, params, value) {
|
|
84
|
-
|
|
113
|
+
const rfqData = await this.getRFQData(params.rfqAuctionAddress);
|
|
114
|
+
const msg = await user.createCancelBidMsg(this.ctx, params, value);
|
|
115
|
+
const result = await (0, send_msg_1.sendMsgAndWaitTx)(this.ctx, sender, msg);
|
|
116
|
+
const trace = await trace_1.RFQAuctionCancelBidTracer.create({
|
|
117
|
+
ctx: this.ctx,
|
|
118
|
+
msgBody: msg.input.body,
|
|
119
|
+
extHash: await result.getExternalHash(),
|
|
120
|
+
actor: sender.address,
|
|
121
|
+
bidAsset: rfqData.buyAssetAddress,
|
|
122
|
+
rfqAuction: (0, utils_1.toAddress)(params.rfqAuctionAddress),
|
|
123
|
+
isWTON: this.ctx.isWTON(rfqData.buyAssetAddress),
|
|
124
|
+
});
|
|
125
|
+
await trace.wait();
|
|
126
|
+
return trace;
|
|
85
127
|
}
|
|
128
|
+
// ============================================================
|
|
129
|
+
// Market Maker
|
|
130
|
+
// ============================================================
|
|
86
131
|
async sendSettle(sender, params, value) {
|
|
87
|
-
|
|
132
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await user.createSettleMsg(this.ctx, params, value));
|
|
133
|
+
await trace.wait();
|
|
134
|
+
return trace;
|
|
88
135
|
}
|
|
89
136
|
async sendClearBids(sender, params, value) {
|
|
90
|
-
|
|
137
|
+
const trace = await (0, send_msg_1.sendMsgAndWaitTxSimple)(this.ctx, sender, await user.createClearBidsMsg(this.ctx, params, value));
|
|
138
|
+
await trace.wait();
|
|
139
|
+
return trace;
|
|
91
140
|
}
|
|
92
141
|
}
|
|
93
142
|
exports.RFQAuctionServiceV1 = RFQAuctionServiceV1;
|
|
@@ -192,7 +192,7 @@ async function createSettleMsg(ctx, params, value) {
|
|
|
192
192
|
body: (0, core_1.beginCell)()
|
|
193
193
|
.storeUint(rfq_auction_1.RFQAuction.Op.Settle, 32)
|
|
194
194
|
.storeUint(params.queryId ?? 0, 64)
|
|
195
|
-
.
|
|
195
|
+
.storeMaybeRef(oracleParams)
|
|
196
196
|
.endCell(),
|
|
197
197
|
},
|
|
198
198
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Address, Cell } from "@ton/core";
|
|
2
|
+
import { TracerBase } from "../../../common/trace-action";
|
|
3
|
+
import { MessageHash } from "../../../utils/external-message-hash";
|
|
4
|
+
import { TonClient } from "@ton/ton";
|
|
5
|
+
import { AffluentContext } from "../../../context";
|
|
6
|
+
import { ToncenterV3Client } from "../../../utils/pending-tracker/v3-client";
|
|
7
|
+
export type RFQAuctionAddresses = {
|
|
8
|
+
actor: Address;
|
|
9
|
+
actorBidAssetWallet: Address;
|
|
10
|
+
rfqAuction: Address;
|
|
11
|
+
rfqAuctionBidAssetWallet: Address;
|
|
12
|
+
};
|
|
13
|
+
export declare function getRFQAuctionAddresses(client: TonClient, params: {
|
|
14
|
+
actor: Address;
|
|
15
|
+
bidAsset: Address;
|
|
16
|
+
rfqAuction: Address;
|
|
17
|
+
}): Promise<RFQAuctionAddresses>;
|
|
18
|
+
export type RFQAuctionBidTracerParams = {
|
|
19
|
+
ctx: AffluentContext;
|
|
20
|
+
msgBody: Cell;
|
|
21
|
+
extHash: MessageHash;
|
|
22
|
+
actor: Address;
|
|
23
|
+
bidAsset: Address;
|
|
24
|
+
rfqAuction: Address;
|
|
25
|
+
isWTON: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare class RFQAuctionBidTracer extends TracerBase<"jetton" | "wton"> {
|
|
28
|
+
static create(params: RFQAuctionBidTracerParams): Promise<RFQAuctionBidTracer>;
|
|
29
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
30
|
+
isWTON: boolean;
|
|
31
|
+
queryId: bigint;
|
|
32
|
+
extHash: MessageHash;
|
|
33
|
+
addresses: RFQAuctionAddresses;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export type RFQAuctionCancelBidTracerParams = {
|
|
37
|
+
ctx: AffluentContext;
|
|
38
|
+
msgBody: Cell;
|
|
39
|
+
extHash: MessageHash;
|
|
40
|
+
actor: Address;
|
|
41
|
+
bidAsset: Address;
|
|
42
|
+
rfqAuction: Address;
|
|
43
|
+
isWTON: boolean;
|
|
44
|
+
};
|
|
45
|
+
export declare class RFQAuctionCancelBidTracer extends TracerBase<"cancel"> {
|
|
46
|
+
static create(params: RFQAuctionCancelBidTracerParams): Promise<RFQAuctionCancelBidTracer>;
|
|
47
|
+
constructor(toncenterClient: ToncenterV3Client, params: {
|
|
48
|
+
isWTON: boolean;
|
|
49
|
+
queryId: bigint;
|
|
50
|
+
extHash: MessageHash;
|
|
51
|
+
addresses: RFQAuctionAddresses;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RFQAuctionCancelBidTracer = exports.RFQAuctionBidTracer = void 0;
|
|
4
|
+
exports.getRFQAuctionAddresses = getRFQAuctionAddresses;
|
|
5
|
+
const trace_action_1 = require("../../../common/trace-action");
|
|
6
|
+
const rfq_auction_1 = require("../../../contracts/rfq/rfq_auction");
|
|
7
|
+
const jetton_minter_1 = require("../../../contracts/jetton/jetton-minter");
|
|
8
|
+
async function getRFQAuctionAddresses(client, params) {
|
|
9
|
+
const { actor, bidAsset, rfqAuction } = params;
|
|
10
|
+
const _bidAsset = client.open(jetton_minter_1.JettonMinter.createFromAddress(bidAsset));
|
|
11
|
+
return {
|
|
12
|
+
actor,
|
|
13
|
+
actorBidAssetWallet: await _bidAsset.getWalletAddress(actor),
|
|
14
|
+
rfqAuction,
|
|
15
|
+
rfqAuctionBidAssetWallet: await _bidAsset.getWalletAddress(rfqAuction),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class RFQAuctionBidTracer extends trace_action_1.TracerBase {
|
|
19
|
+
static async create(params) {
|
|
20
|
+
const { ctx, msgBody, extHash, actor, bidAsset, rfqAuction, isWTON } = params;
|
|
21
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
22
|
+
const addresses = await getRFQAuctionAddresses(ctx.client, { actor, bidAsset, rfqAuction });
|
|
23
|
+
return new RFQAuctionBidTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
24
|
+
}
|
|
25
|
+
constructor(toncenterClient, params) {
|
|
26
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
27
|
+
const type = isWTON ? "wton" : "jetton";
|
|
28
|
+
const steps = [
|
|
29
|
+
...(0, trace_action_1.createJettonSendSteps)({
|
|
30
|
+
isWTON,
|
|
31
|
+
actor: addresses.actor,
|
|
32
|
+
actorWallet: addresses.actorBidAssetWallet,
|
|
33
|
+
targetWallet: addresses.rfqAuctionBidAssetWallet,
|
|
34
|
+
target: addresses.rfqAuction,
|
|
35
|
+
description: "Transferring Bid Asset",
|
|
36
|
+
}),
|
|
37
|
+
];
|
|
38
|
+
super(toncenterClient, extHash, type, queryId, steps);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.RFQAuctionBidTracer = RFQAuctionBidTracer;
|
|
42
|
+
class RFQAuctionCancelBidTracer extends trace_action_1.TracerBase {
|
|
43
|
+
static async create(params) {
|
|
44
|
+
const { ctx, msgBody, extHash, actor, bidAsset, rfqAuction, isWTON } = params;
|
|
45
|
+
const { queryId } = (0, trace_action_1.getOpAndQueryId)(msgBody);
|
|
46
|
+
const addresses = await getRFQAuctionAddresses(ctx.client, { actor, bidAsset, rfqAuction });
|
|
47
|
+
return new RFQAuctionCancelBidTracer(ctx.toncenterClient, { isWTON, queryId, extHash, addresses });
|
|
48
|
+
}
|
|
49
|
+
constructor(toncenterClient, params) {
|
|
50
|
+
const { isWTON, queryId, extHash, addresses } = params;
|
|
51
|
+
const steps = [
|
|
52
|
+
{
|
|
53
|
+
op: rfq_auction_1.RFQAuction.Op.CancelBid,
|
|
54
|
+
from: addresses.actor,
|
|
55
|
+
to: addresses.rfqAuction,
|
|
56
|
+
description: "Cancelling Bid",
|
|
57
|
+
},
|
|
58
|
+
...(0, trace_action_1.createJettonReceiveSteps)({
|
|
59
|
+
isWTON,
|
|
60
|
+
sourceWallet: addresses.rfqAuctionBidAssetWallet,
|
|
61
|
+
actorWallet: addresses.actorBidAssetWallet,
|
|
62
|
+
description: "Refunding Bid Asset",
|
|
63
|
+
}),
|
|
64
|
+
];
|
|
65
|
+
super(toncenterClient, extHash, "cancel", queryId, steps);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.RFQAuctionCancelBidTracer = RFQAuctionCancelBidTracer;
|