@affluent-org/sdk 0.0.2 → 0.0.3
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/build/Account.compiled.json +1 -0
- package/dist/build/Receipt.compiled.json +1 -0
- package/dist/build/WTONWallet.compiled.json +1 -0
- package/dist/common/cache.d.ts +16 -0
- package/dist/common/cache.js +96 -0
- package/dist/common/service.d.ts +20 -0
- package/dist/common/service.js +69 -0
- package/dist/common/type.d.ts +14 -0
- package/dist/common/type.js +2 -0
- package/dist/common/unknown-contract.d.ts +14 -0
- package/dist/common/unknown-contract.js +18 -0
- package/dist/common/versions.d.ts +14 -0
- package/dist/common/versions.js +22 -0
- package/dist/constants/pool.d.ts +1 -0
- package/dist/constants/pool.js +2 -0
- package/dist/contracts/_mock/simple-oracle.d.ts +34 -0
- package/dist/contracts/_mock/simple-oracle.js +73 -0
- package/dist/contracts/vault/share-vault/type.d.ts +30 -0
- package/dist/contracts/vault/share-vault/type.js +2 -0
- package/dist/contracts/vault/strategy-vault/utils.d.ts +6 -0
- package/dist/contracts/vault/strategy-vault/utils.js +32 -0
- package/dist/factorial.d.ts +14 -0
- package/dist/factorial.js +20 -0
- package/dist/farm.d.ts +92 -0
- package/dist/farm.js +209 -0
- package/dist/monitor.d.ts +57 -0
- package/dist/monitor.js +527 -0
- package/dist/monitorCacheV1.d.ts +52 -0
- package/dist/monitorCacheV1.js +504 -0
- package/dist/oracle/oracle-v2.d.ts +39 -0
- package/dist/oracle/oracle-v2.js +151 -0
- package/dist/oracle/oracle.d.ts +107 -0
- package/dist/oracle/oracle.js +392 -0
- package/dist/periphery.d.ts +259 -0
- package/dist/periphery.js +1087 -0
- package/dist/pool.d.ts +216 -0
- package/dist/pool.js +2298 -0
- package/dist/poolCacheV1.d.ts +139 -0
- package/dist/poolCacheV1.js +1841 -0
- package/dist/rfq-auction.d.ts +75 -0
- package/dist/rfq-auction.js +220 -0
- package/dist/rfq-batch.d.ts +112 -0
- package/dist/rfq-batch.js +284 -0
- package/dist/services/share-vault/computation.d.ts +14 -17
- package/dist/services/share-vault/computation.js +39 -0
- package/dist/services/share-vault/index.js +6 -3
- package/dist/services/share-vault/query.d.ts +38 -8
- package/dist/services/share-vault/query.js +20 -27
- package/dist/services/share-vault/type.d.ts +19 -0
- package/dist/services/share-vault/type.js +2 -0
- package/dist/services/share-vault/user/index.js +3 -1
- package/dist/services/strategy-vault/computation.d.ts +1 -0
- package/dist/services/strategy-vault/computation.js +15 -0
- package/dist/services/strategy-vault/query.d.ts +147 -0
- package/dist/services/strategy-vault/query.js +67 -0
- package/dist/services/strategy-vault/type.d.ts +2 -0
- package/dist/services/strategy-vault/type.js +2 -0
- package/dist/share-vault.d.ts +91 -0
- package/dist/share-vault.js +747 -0
- package/dist/stonfi.d.ts +18 -0
- package/dist/stonfi.js +76 -0
- package/dist/strategy_vault/base.d.ts +399 -0
- package/dist/strategy_vault/base.js +1199 -0
- package/dist/strategy_vault/index.d.ts +3 -0
- package/dist/strategy_vault/index.js +7 -0
- package/dist/strategy_vault/steps.d.ts +49 -0
- package/dist/strategy_vault/steps.js +170 -0
- package/dist/types/action.d.ts +55 -0
- package/dist/types/action.js +2 -0
- package/dist/types/messages.d.ts +7 -0
- package/dist/types/messages.js +2 -0
- package/dist/types/params.d.ts +19 -0
- package/dist/types/params.js +2 -0
- package/dist/types/pool.d.ts +83 -0
- package/dist/types/pool.js +2 -0
- package/dist/types/transaction.d.ts +40 -0
- package/dist/types/transaction.js +2 -0
- package/dist/utils/_parse_temp/JumpIRM.d.ts +37 -0
- package/dist/utils/_parse_temp/JumpIRM.js +71 -0
- package/dist/utils/_parse_temp/Pool.d.ts +559 -0
- package/dist/utils/_parse_temp/Pool.js +1023 -0
- package/dist/utils/_parse_temp/ShareVault.d.ts +264 -0
- package/dist/utils/_parse_temp/ShareVault.js +479 -0
- package/dist/utils/_parse_temp/StrategyVault.d.ts +729 -0
- package/dist/utils/_parse_temp/StrategyVault.js +1865 -0
- package/dist/utils/_parse_temp/parseMsgBody.d.ts +13 -0
- package/dist/utils/_parse_temp/parseMsgBody.js +313 -0
- package/dist/utils/assert.d.ts +1 -0
- package/dist/utils/assert.js +9 -0
- package/dist/utils/client-for-parameter.d.ts +12 -0
- package/dist/utils/client-for-parameter.js +97 -0
- package/dist/utils/oracle/index.d.ts +4 -0
- package/dist/utils/oracle/index.js +19 -0
- package/dist/utils/oracle/redstone/helper.d.ts +22 -0
- package/dist/utils/oracle/redstone/helper.js +186 -0
- package/dist/utils/tracer.d.ts +13 -0
- package/dist/utils/tracer.js +137 -0
- package/dist/utils/tracker/index.d.ts +5 -0
- package/dist/utils/tracker/index.js +118 -0
- package/dist/utils/tracker/query-id-generactor.d.ts +2 -0
- package/dist/utils/tracker/query-id-generactor.js +12 -0
- package/dist/utils/tracker/type.d.ts +34 -0
- package/dist/utils/tracker/type.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1865 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StrategyVault = void 0;
|
|
4
|
+
exports.strategyVaultConfigToCell = strategyVaultConfigToCell;
|
|
5
|
+
const core_1 = require("@ton/core");
|
|
6
|
+
function strategyVaultConfigToCell(config) {
|
|
7
|
+
return (0, core_1.beginCell)()
|
|
8
|
+
.storeAddress(config.ownerAddress) // 0: owner_address
|
|
9
|
+
.storeMaybeRef(config.assets) // 1: assets
|
|
10
|
+
.storeMaybeRef(config.positions) // 2: factorial_pools
|
|
11
|
+
.storeCoins(config.aggregatorIndex) // 3: data_aggregator_index
|
|
12
|
+
.storeCoins(config.rfqIndex) // 4: rfq_index
|
|
13
|
+
.storeCoins(config.totalSupply) // 5: total_supply
|
|
14
|
+
.storeCoins(config.collectedManagementFee) // 6: collected_management_fee
|
|
15
|
+
.storeCoins(config.collectedProtocolFee) // 7: collected_protocol_fee
|
|
16
|
+
.storeBit(config.isExecutingStrategy) // 8: is_executing_strategy
|
|
17
|
+
.storeRef(// 9: config_cell
|
|
18
|
+
(0, core_1.beginCell)()
|
|
19
|
+
.storeAddress(config.config.protocolFeeManagerAddress) // 11: protocol_fee_manager_address
|
|
20
|
+
.storeAddress(config.config.managerAddress) // 12: manager_address
|
|
21
|
+
.storeBit(config.config.isPrivateVault) // 13: is_private_vault
|
|
22
|
+
.storeUint(config.config.depositCloseTimestamp, 40) // 14: deposit_close_timestamp
|
|
23
|
+
.storeUint(config.config.withdrawOpenTimestamp, 40) // 15: withdraw_open_timestamp
|
|
24
|
+
.storeMaybeRef(config.config.whitelistedMinters) // 16: whitelisted_minters
|
|
25
|
+
.storeUint(config.config.lastCollectTime, 40) // 17: last_collect_time
|
|
26
|
+
.storeUint(config.config.managementFeeRate, 14) // 18: management_fee_rate_per_year
|
|
27
|
+
.storeUint(config.config.protocolFeeRate, 14) // 19: protocol_fee_rate_per_year
|
|
28
|
+
.storeUint(config.config.maxLeverageRatio, 20) // 20: max_leverage_ratio
|
|
29
|
+
.storeMaybeRef(config.config.assetWalletDict) // 21: assets_wallet_dict
|
|
30
|
+
.storeMaybeRef(config.config.walletAssetDict) // 22: wallet_asset_dict
|
|
31
|
+
.storeRef((0, core_1.beginCell)()
|
|
32
|
+
.storeMaybeRef(config.config.rfqConfig) // 23: rfq_config
|
|
33
|
+
.storeMaybeRef(config.config.gasConfig) // 24: gas_config
|
|
34
|
+
.storeMaybeRef(config.config.oracleConfig) // 25: oracle_config
|
|
35
|
+
.storeAddress(config.config.managementFeeRecipientAddress) // 26: management_fee_recipient_address
|
|
36
|
+
.storeAddress(config.config.guardianAddress) // 27: guardian_address
|
|
37
|
+
.storeCoins(config.config.timelock ?? 0n) // 28: timelock
|
|
38
|
+
.storeCoins(0) // 29: owner_action_index
|
|
39
|
+
.storeCoins(0) // 30: pending_owner_action_count
|
|
40
|
+
.storeMaybeRef(null) // 31: pending_owner_action
|
|
41
|
+
.endCell())
|
|
42
|
+
.endCell())
|
|
43
|
+
.storeRef(// 10: code_cell
|
|
44
|
+
(0, core_1.beginCell)()
|
|
45
|
+
.storeRef(config.code.walletCode) // 32: wallet_code
|
|
46
|
+
.storeRef(config.code.poolAggregatorCode) // 33: data_aggregator_code
|
|
47
|
+
.storeRef(config.code.rfqCode) // 34: rfq_code
|
|
48
|
+
.storeRef(config.config.content) // 35: content
|
|
49
|
+
.endCell())
|
|
50
|
+
.endCell();
|
|
51
|
+
}
|
|
52
|
+
class StrategyVault {
|
|
53
|
+
address;
|
|
54
|
+
init;
|
|
55
|
+
constructor(address, init) {
|
|
56
|
+
this.address = address;
|
|
57
|
+
this.init = init;
|
|
58
|
+
}
|
|
59
|
+
static Op = {
|
|
60
|
+
QueueOwnerAction: 0x84d73e58,
|
|
61
|
+
ExecuteOwnerAction: 0xf535d310,
|
|
62
|
+
RevertOwnerAction: 0x3d4f8110,
|
|
63
|
+
SetOwnerAddress: 0x8f8ca467,
|
|
64
|
+
SetAssetConfig: 0x5362ab69,
|
|
65
|
+
SetFactorialPoolConfig: 0x6d4006ad,
|
|
66
|
+
SetManagerAddress: 0xb56ae4b4,
|
|
67
|
+
SetPrivateVault: 0xddcd58e7,
|
|
68
|
+
SetDepositCloseTimestamp: 0x8e450bfe,
|
|
69
|
+
SetWithdrawOpenTimestamp: 0x44163c0a,
|
|
70
|
+
SetWhitelistedMinters: 0x7ebd9169,
|
|
71
|
+
SetManagementFeeRatePerYear: 0x3b11dcb0,
|
|
72
|
+
SetMaxLeverageRatio: 0x4a59e8d2,
|
|
73
|
+
SetRfqConfig: 0xf82a09b0,
|
|
74
|
+
SetGasConfig: 0x1fe929a8,
|
|
75
|
+
SetOracleConfig: 0xd93126de,
|
|
76
|
+
SetWalletCode: 0x6ffb2c4b,
|
|
77
|
+
SetDataAggregatorCode: 0x265fba0d,
|
|
78
|
+
SetRfqCode: 0x13ea2a91,
|
|
79
|
+
SetContent: 0xfadc0412,
|
|
80
|
+
UpgradeCode: 0x61bddf8b,
|
|
81
|
+
SetGuardianAddress: 0xc2aefefb,
|
|
82
|
+
SetTimelock: 0x4cd29aae,
|
|
83
|
+
SetManagementFeeRecipientAddress: 0x75563990,
|
|
84
|
+
IncreaseBalance: 0xb8e2db76,
|
|
85
|
+
ClaimProtocolFee: 0x456fd0c7,
|
|
86
|
+
SetProtocolFeeRatePerYear: 0x6a4a61da,
|
|
87
|
+
SetProtocolFeeManagerAddress: 0x885cbab8,
|
|
88
|
+
ClaimManagementFee: 0x5c4a19b,
|
|
89
|
+
UpgradeVersion: 0xa0970a05,
|
|
90
|
+
ForwardMessage: 0xc04f1320,
|
|
91
|
+
TransferTon: 0xab662c06,
|
|
92
|
+
SetWhitelistedPoolsRaw: 0xae41f912,
|
|
93
|
+
Initialize: 0xbe5a7595,
|
|
94
|
+
SupplyToFactorial: 0x6856d3b7,
|
|
95
|
+
WithdrawFromFactorial: 0xe68e9046,
|
|
96
|
+
BorrowFromFactorial: 0x3d27ede4,
|
|
97
|
+
RepayToFactorial: 0xeedee3a4,
|
|
98
|
+
LiquidateToFactorial: 0xfe4f47ab,
|
|
99
|
+
Deposit: 0xf9471134,
|
|
100
|
+
Withdraw: 0xcb03bfaf,
|
|
101
|
+
CreateRfq: 0xc54dd764,
|
|
102
|
+
ExecuteStrategy: 0x66e7f212,
|
|
103
|
+
TakeAggregatedData: 0x77c65602,
|
|
104
|
+
CancelRfq: 0x5f6f17e0,
|
|
105
|
+
Excesses: 0xd53276db,
|
|
106
|
+
};
|
|
107
|
+
static Error = {
|
|
108
|
+
NotEnoughBalance: 2002,
|
|
109
|
+
NotEnoughCash: 2003,
|
|
110
|
+
NotSuppliableAsset: 2004,
|
|
111
|
+
NotBorrowableAsset: 2005,
|
|
112
|
+
ExceededMaxLeverageRatio: 2006,
|
|
113
|
+
ClosedDeposit: 2007,
|
|
114
|
+
ClosedWithdraw: 2008,
|
|
115
|
+
Unauthorized: 1000,
|
|
116
|
+
AlreadyExecutingStrategy: 1005,
|
|
117
|
+
TypeCheckError: 7,
|
|
118
|
+
CellUnderflow: 9,
|
|
119
|
+
InvalidWalletAddress: 1010,
|
|
120
|
+
NotWhitelistedMinter: 1006,
|
|
121
|
+
NotWhitelistedAsset: 1007,
|
|
122
|
+
NotDepositableAsset: 1008,
|
|
123
|
+
NotWithdrawableAsset: 1009,
|
|
124
|
+
InvalidAsset: 1015,
|
|
125
|
+
VaultPriceNotFound: 2001,
|
|
126
|
+
NotFoundAssetPrice: 9999,
|
|
127
|
+
NotFoundPoolAssetTotals: 9998,
|
|
128
|
+
NotFoundAssetTotals: 9997,
|
|
129
|
+
NotFoundVaultPrice: 9996,
|
|
130
|
+
NotFoundGasConfig: 11111,
|
|
131
|
+
NotEnoughGas: 1999,
|
|
132
|
+
InvalidOp: 2000,
|
|
133
|
+
ExceededExposureCap: 2001,
|
|
134
|
+
InvalidRfqPeriod: 2009,
|
|
135
|
+
InvalidConfig: 2010,
|
|
136
|
+
InvalidPendingOwnerActionIndex: 2011,
|
|
137
|
+
NotYetExecutable: 2012,
|
|
138
|
+
ExceededMaxPendingOwnerActionCount: 2013,
|
|
139
|
+
};
|
|
140
|
+
static GasKey = {
|
|
141
|
+
Deposit: 0,
|
|
142
|
+
Withdraw: 1,
|
|
143
|
+
IncreaseBalance: 2,
|
|
144
|
+
FactorialTransferIn: 3,
|
|
145
|
+
FactorialTransferOut: 4,
|
|
146
|
+
CreateRfq: 5,
|
|
147
|
+
FactorialLiquidate: 6,
|
|
148
|
+
RFQInitialize: 7,
|
|
149
|
+
RFQNotification: 8,
|
|
150
|
+
RFQDeposit: 9,
|
|
151
|
+
JettonTransfer: 10,
|
|
152
|
+
ExecuteStrategy: 11,
|
|
153
|
+
ClaimFee: 12,
|
|
154
|
+
DepositLogic: 13,
|
|
155
|
+
WithdrawLogic: 14,
|
|
156
|
+
};
|
|
157
|
+
static emptyGasDictionary() {
|
|
158
|
+
const GAS_KEY_LENGTH = 8;
|
|
159
|
+
return core_1.Dictionary.empty(core_1.Dictionary.Keys.Uint(GAS_KEY_LENGTH), core_1.Dictionary.Values.BigVarUint(4));
|
|
160
|
+
}
|
|
161
|
+
static createFromAddress(address) {
|
|
162
|
+
return new StrategyVault(address);
|
|
163
|
+
}
|
|
164
|
+
static createFromConfig(config, code, workchain = 0) {
|
|
165
|
+
const data = strategyVaultConfigToCell(config);
|
|
166
|
+
const init = { code, data };
|
|
167
|
+
return new StrategyVault((0, core_1.contractAddress)(workchain, init), init);
|
|
168
|
+
}
|
|
169
|
+
async sendDeploy(provider, via, value) {
|
|
170
|
+
await provider.internal(via, {
|
|
171
|
+
value,
|
|
172
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
173
|
+
body: (0, core_1.beginCell)().endCell(),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
async sendInitialize(provider, via, value, opts) {
|
|
177
|
+
await provider.internal(via, {
|
|
178
|
+
value: value,
|
|
179
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
180
|
+
body: StrategyVault.createInitializeMsgBody(opts.queryID),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
async sendExecuteStrategy(provider, via, value, opts) {
|
|
184
|
+
await provider.internal(via, {
|
|
185
|
+
value: value,
|
|
186
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
187
|
+
body: StrategyVault.createExecuteStrategyMsgBody(opts.body, opts.queryID),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async sendLiquidateToFactorial(provider, via, value, opts) {
|
|
191
|
+
// cell oracle_params = in_msg_body~load_ref();
|
|
192
|
+
// slice pool_address = in_msg_body~load_msg_addr();
|
|
193
|
+
// slice borrower_address = in_msg_body~load_msg_addr();
|
|
194
|
+
// slice repay_asset = in_msg_body~load_msg_addr();
|
|
195
|
+
// slice seize_asset = in_msg_body~load_msg_addr();
|
|
196
|
+
// int repay_amount = in_msg_body~load_coins();
|
|
197
|
+
// slice response = in_msg_body~load_msg_addr();
|
|
198
|
+
await provider.internal(via, {
|
|
199
|
+
value: value,
|
|
200
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
201
|
+
body: (0, core_1.beginCell)()
|
|
202
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
203
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
204
|
+
.storeUint(StrategyVault.Op.LiquidateToFactorial, 32)
|
|
205
|
+
.storeMaybeRef(opts.oracleParams)
|
|
206
|
+
.storeRef(opts.oracleParams)
|
|
207
|
+
.storeAddress(opts.pool)
|
|
208
|
+
.storeAddress(opts.borrower)
|
|
209
|
+
.storeAddress(opts.repayAsset)
|
|
210
|
+
.storeRef((0, core_1.beginCell)()
|
|
211
|
+
.storeAddress(opts.seizeAsset)
|
|
212
|
+
.storeCoins(opts.repayAmount)
|
|
213
|
+
.storeAddress(opts.response)
|
|
214
|
+
.endCell())
|
|
215
|
+
.endCell(),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async sendSupplyToFactorial(provider, via, value, opts) {
|
|
219
|
+
await provider.internal(via, {
|
|
220
|
+
value: value,
|
|
221
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
222
|
+
body: (0, core_1.beginCell)()
|
|
223
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
224
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
225
|
+
.storeUint(StrategyVault.Op.SupplyToFactorial, 32)
|
|
226
|
+
.storeAddress(opts.pool)
|
|
227
|
+
.storeAddress(opts.asset)
|
|
228
|
+
.storeCoins(opts.amount)
|
|
229
|
+
.storeAddress(opts.response)
|
|
230
|
+
.endCell(),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async sendWithdrawFromFactorial(provider, via, value, opts) {
|
|
234
|
+
await provider.internal(via, {
|
|
235
|
+
value: value,
|
|
236
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
237
|
+
body: (0, core_1.beginCell)()
|
|
238
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
239
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
240
|
+
.storeRef(opts.oracleParams)
|
|
241
|
+
.storeUint(StrategyVault.Op.WithdrawFromFactorial, 32)
|
|
242
|
+
.storeAddress(opts.pool)
|
|
243
|
+
.storeAddress(opts.asset)
|
|
244
|
+
.storeCoins(opts.amount)
|
|
245
|
+
.storeBit(opts.isShare)
|
|
246
|
+
.storeAddress(opts.response)
|
|
247
|
+
.endCell(),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
async sendBorrowFromFactorial(provider, via, value, opts) {
|
|
251
|
+
await provider.internal(via, {
|
|
252
|
+
value: value,
|
|
253
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
254
|
+
body: (0, core_1.beginCell)()
|
|
255
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
256
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
257
|
+
.storeUint(StrategyVault.Op.BorrowFromFactorial, 32)
|
|
258
|
+
.storeMaybeRef(opts.oracleParams)
|
|
259
|
+
.storeRef(opts.oracleParams)
|
|
260
|
+
.storeAddress(opts.pool)
|
|
261
|
+
.storeAddress(opts.asset)
|
|
262
|
+
.storeCoins(opts.amount)
|
|
263
|
+
.storeBit(opts.isShare)
|
|
264
|
+
.storeAddress(opts.response)
|
|
265
|
+
.endCell(),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async sendRepayToFactorial(provider, via, value, opts) {
|
|
269
|
+
await provider.internal(via, {
|
|
270
|
+
value: value,
|
|
271
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
272
|
+
body: (0, core_1.beginCell)()
|
|
273
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
274
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
275
|
+
.storeUint(StrategyVault.Op.RepayToFactorial, 32)
|
|
276
|
+
.storeAddress(opts.pool)
|
|
277
|
+
.storeAddress(opts.asset)
|
|
278
|
+
.storeCoins(opts.amount)
|
|
279
|
+
.storeAddress(opts.response)
|
|
280
|
+
.endCell(),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async sendCreateRFQ(provider, via, value, opts) {
|
|
284
|
+
await provider.internal(via, {
|
|
285
|
+
value: value,
|
|
286
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
287
|
+
body: (0, core_1.beginCell)()
|
|
288
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
289
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
290
|
+
.storeUint(StrategyVault.Op.CreateRfq, 32)
|
|
291
|
+
.storeMaybeRef(opts.oracleParams)
|
|
292
|
+
.storeCoins(opts.rfqIndex)
|
|
293
|
+
.storeAddress(opts.sellAsset)
|
|
294
|
+
.storeAddress(opts.buyAsset)
|
|
295
|
+
.storeCoins(opts.sellAssetAmount)
|
|
296
|
+
.storeCoins(opts.minBuyAssetValue)
|
|
297
|
+
.storeCoins(opts.maxBuyAssetValue)
|
|
298
|
+
.storeRef((0, core_1.beginCell)()
|
|
299
|
+
.storeAddress(opts.sellAssetRFQWallet)
|
|
300
|
+
.storeAddress(opts.buyAssetRFQWallet)
|
|
301
|
+
.storeUint(opts.period, 40)
|
|
302
|
+
.storeBit(opts.allowSellerCancel)
|
|
303
|
+
.storeBit(opts.allowBidderCancel)
|
|
304
|
+
.storeBit(opts.isAmountBid)
|
|
305
|
+
.endCell())
|
|
306
|
+
.endCell(),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
async sendCancelRFQ(provider, via, value, opts) {
|
|
310
|
+
await provider.internal(via, {
|
|
311
|
+
value: value,
|
|
312
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
313
|
+
body: (0, core_1.beginCell)()
|
|
314
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
315
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
316
|
+
.storeUint(StrategyVault.Op.CancelRfq, 32)
|
|
317
|
+
.storeCoins(opts.rfqIndex)
|
|
318
|
+
.endCell(),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
async sendSetAssetConfig(provider, via, value, opts) {
|
|
322
|
+
await provider.internal(via, {
|
|
323
|
+
value,
|
|
324
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
325
|
+
body: (0, core_1.beginCell)()
|
|
326
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
327
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
328
|
+
.storeUint(StrategyVault.Op.SetAssetConfig, 32)
|
|
329
|
+
.storeAddress(opts.assetAddress)
|
|
330
|
+
.storeBit(opts.isWhitelisted)
|
|
331
|
+
.storeBit(opts.isDepositable)
|
|
332
|
+
.storeBit(opts.isWithdrawable)
|
|
333
|
+
.storeUint(opts.exposureCap, 20)
|
|
334
|
+
.endCell(),
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
async sendSetFactorialPoolConfig(provider, via, value, opts) {
|
|
338
|
+
await provider.internal(via, {
|
|
339
|
+
value,
|
|
340
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
341
|
+
body: (0, core_1.beginCell)()
|
|
342
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
343
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
344
|
+
.storeUint(StrategyVault.Op.SetFactorialPoolConfig, 32)
|
|
345
|
+
.storeMaybeRef(opts.updateConfig)
|
|
346
|
+
.endCell(),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
async sendClaimManagementFee(provider, via, value, opts) {
|
|
350
|
+
await provider.internal(via, {
|
|
351
|
+
value,
|
|
352
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
353
|
+
body: (0, core_1.beginCell)()
|
|
354
|
+
.storeUint(StrategyVault.Op.ClaimManagementFee, 32)
|
|
355
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
356
|
+
.storeAddress(opts.receiverAddress)
|
|
357
|
+
.endCell(),
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
async sendClaimProtocolFee(provider, via, value, opts) {
|
|
361
|
+
await provider.internal(via, {
|
|
362
|
+
value,
|
|
363
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
364
|
+
body: (0, core_1.beginCell)()
|
|
365
|
+
.storeUint(StrategyVault.Op.ClaimProtocolFee, 32)
|
|
366
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
367
|
+
.storeAddress(opts.receiverAddress)
|
|
368
|
+
.endCell(),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
async getState(provider) {
|
|
372
|
+
return await provider.getState();
|
|
373
|
+
}
|
|
374
|
+
async getWalletAddress(provider, address) {
|
|
375
|
+
const params1 = { type: "slice", cell: (0, core_1.beginCell)().storeAddress(address).endCell() };
|
|
376
|
+
const result = await provider.get('get_wallet_address', [params1]);
|
|
377
|
+
return result.stack.readAddress();
|
|
378
|
+
}
|
|
379
|
+
async getRfqAddress(provider, index) {
|
|
380
|
+
const params1 = { type: "int", value: index };
|
|
381
|
+
const result = await provider.get('get_rfq_address', [params1]);
|
|
382
|
+
return result.stack.readAddress();
|
|
383
|
+
}
|
|
384
|
+
static createFactorialPoolConfig(params) {
|
|
385
|
+
const poolDictionary = core_1.Dictionary.empty(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.FactorialPool());
|
|
386
|
+
for (let param of params) {
|
|
387
|
+
const [poolAddress, assetAddress, isSupplyable, isBorrowable] = param;
|
|
388
|
+
poolDictionary.set(poolAddress, {
|
|
389
|
+
...poolDictionary.get(poolAddress),
|
|
390
|
+
[assetAddress.toString()]: {
|
|
391
|
+
supply: 0n,
|
|
392
|
+
borrow: 0n,
|
|
393
|
+
isSupplyable: isSupplyable,
|
|
394
|
+
isBorrowable: isBorrowable,
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return poolDictionary;
|
|
399
|
+
}
|
|
400
|
+
static createFactorialPoolUpdateConfig(params) {
|
|
401
|
+
const poolDictionary = core_1.Dictionary.empty(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.UpdateFactorialPool());
|
|
402
|
+
for (let param of params) {
|
|
403
|
+
const [poolAddress, assetAddress, isSupplyable, isBorrowable] = param;
|
|
404
|
+
poolDictionary.set(poolAddress, {
|
|
405
|
+
...poolDictionary.get(poolAddress),
|
|
406
|
+
[assetAddress.toString()]: {
|
|
407
|
+
isSupplyable: isSupplyable,
|
|
408
|
+
isBorrowable: isBorrowable,
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return poolDictionary;
|
|
413
|
+
}
|
|
414
|
+
static createAssetConfig(params) {
|
|
415
|
+
const assetDictionary = core_1.Dictionary.empty(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.Asset());
|
|
416
|
+
for (let param of params) {
|
|
417
|
+
const [assetAddress, isWhitelisted, isDepositable, isWithdrawable, exposureCap] = param;
|
|
418
|
+
assetDictionary.set(assetAddress, {
|
|
419
|
+
isWhitelisted: isWhitelisted,
|
|
420
|
+
isDepositable: isDepositable,
|
|
421
|
+
isWithdrawable: isWithdrawable,
|
|
422
|
+
exposureCap: exposureCap,
|
|
423
|
+
cash: 0n,
|
|
424
|
+
balance: 0n,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
return assetDictionary;
|
|
428
|
+
}
|
|
429
|
+
async getVaultData(provider) {
|
|
430
|
+
const state = await provider.getState();
|
|
431
|
+
if (state.state.type !== "active")
|
|
432
|
+
throw "not active";
|
|
433
|
+
if (!state.state.data)
|
|
434
|
+
throw "not active";
|
|
435
|
+
const data = core_1.Cell.fromBoc(state.state.data)[0].beginParse();
|
|
436
|
+
const owner = data.loadAddress();
|
|
437
|
+
const _assets = data.loadDict(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.Asset());
|
|
438
|
+
const assets = {};
|
|
439
|
+
for (const key of _assets.keys()) {
|
|
440
|
+
const asset = _assets.get(key);
|
|
441
|
+
if (asset) {
|
|
442
|
+
assets[key.toString()] = asset;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const _factorialPools = data.loadDict(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.FactorialPool());
|
|
446
|
+
const factorialPools = {};
|
|
447
|
+
for (const key of _factorialPools.keys()) {
|
|
448
|
+
const factorialPool = _factorialPools.get(key);
|
|
449
|
+
if (factorialPool) {
|
|
450
|
+
factorialPools[key.toString()] = factorialPool;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const aggregatorIndex = data.loadCoins();
|
|
454
|
+
const rfqIndex = data.loadCoins();
|
|
455
|
+
const totalSupply = data.loadCoins();
|
|
456
|
+
const collectedManagementFee = data.loadCoins();
|
|
457
|
+
const collectedProtocolFee = data.loadCoins();
|
|
458
|
+
const isExecutingStrategy = data.loadBoolean();
|
|
459
|
+
const configCs = data.loadRef().beginParse();
|
|
460
|
+
const protocolFeeManagerAddress = configCs.loadAddress();
|
|
461
|
+
const manager = configCs.loadAddress();
|
|
462
|
+
const isPrivateVault = configCs.loadBit();
|
|
463
|
+
const depositCloseTimestamp = configCs.loadUint(40);
|
|
464
|
+
const withdrawOpenTimestamp = configCs.loadUint(40);
|
|
465
|
+
const whitelistedMinters = configCs.loadDict(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.Empty());
|
|
466
|
+
const lastCollectTime = configCs.loadUint(40);
|
|
467
|
+
const managementFeeRatePerYear = configCs.loadUint(14);
|
|
468
|
+
const protocolFeeRatePerYear = configCs.loadUint(14);
|
|
469
|
+
const maxLeverageRatio = configCs.loadUint(20);
|
|
470
|
+
const _assetWalletDict = configCs.loadDict(core_1.Dictionary.Keys.Address(), core_1.Dictionary.Values.Address());
|
|
471
|
+
const assetWalletDict = {};
|
|
472
|
+
for (const asset of _assetWalletDict.keys()) {
|
|
473
|
+
const wallet = _assetWalletDict.get(asset);
|
|
474
|
+
if (wallet) {
|
|
475
|
+
assetWalletDict[asset.toString()] = wallet.toString();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const _walletAssetDict = configCs.loadDict(core_1.Dictionary.Keys.Address(), core_1.Dictionary.Values.Address());
|
|
479
|
+
const walletAssetDict = {};
|
|
480
|
+
for (const wallet of _walletAssetDict.keys()) {
|
|
481
|
+
const asset = _walletAssetDict.get(wallet);
|
|
482
|
+
if (asset) {
|
|
483
|
+
walletAssetDict[wallet.toString()] = asset.toString();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const configCs2 = configCs.loadRef().beginParse();
|
|
487
|
+
const _rfqConfig = configCs2.loadMaybeRef()?.beginParse();
|
|
488
|
+
const rfqConfig = _rfqConfig ? {
|
|
489
|
+
priceDeviationTolerance: _rfqConfig.loadUint(14),
|
|
490
|
+
eventEmitter: _rfqConfig.loadMaybeAddress(),
|
|
491
|
+
} : null;
|
|
492
|
+
const gasConfig = configCs2.loadMaybeRef();
|
|
493
|
+
const oracleConfig = configCs2.loadMaybeRef();
|
|
494
|
+
const managementFeeRecipientAddress = configCs2.loadMaybeAddress();
|
|
495
|
+
const guardianAddress = configCs2.loadMaybeAddress();
|
|
496
|
+
const timelock = configCs2.loadCoins();
|
|
497
|
+
const pendingOwnerActionIndex = configCs2.loadCoins();
|
|
498
|
+
const pendingOwnerActionCount = configCs2.loadCoins();
|
|
499
|
+
const _pendingOwnerAction = configCs2.loadMaybeRef();
|
|
500
|
+
const pendingOwnerAction = {};
|
|
501
|
+
if (_pendingOwnerAction) {
|
|
502
|
+
const pendingOwnerActionData = _pendingOwnerAction.beginParse().loadDictDirect(core_1.Dictionary.Keys.Uint(128), StrategyVault.Dictionary.Values.PendingOwnerAction());
|
|
503
|
+
for (const key of pendingOwnerActionData.keys()) {
|
|
504
|
+
const ownerAction = pendingOwnerActionData.get(key);
|
|
505
|
+
if (ownerAction) {
|
|
506
|
+
pendingOwnerAction[key.toString()] = ownerAction;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
const codeCs = data.loadRef().beginParse();
|
|
511
|
+
const walletCode = codeCs.loadRef();
|
|
512
|
+
const dataAggregatorCode = codeCs.loadRef();
|
|
513
|
+
const rfqCode = codeCs.loadRef();
|
|
514
|
+
const content = codeCs.loadRef();
|
|
515
|
+
return {
|
|
516
|
+
address: this.address,
|
|
517
|
+
owner,
|
|
518
|
+
manager,
|
|
519
|
+
assets,
|
|
520
|
+
factorialPools,
|
|
521
|
+
aggregatorIndex,
|
|
522
|
+
content,
|
|
523
|
+
totalSupply,
|
|
524
|
+
oracleConfig: oracleConfig,
|
|
525
|
+
rfqConfig: rfqConfig,
|
|
526
|
+
gasConfig: gasConfig,
|
|
527
|
+
isPrivateVault,
|
|
528
|
+
depositCloseTimestamp,
|
|
529
|
+
withdrawOpenTimestamp,
|
|
530
|
+
whitelistedMinters,
|
|
531
|
+
lastCollectTime,
|
|
532
|
+
managementFeeRatePerYear,
|
|
533
|
+
protocolFeeRatePerYear,
|
|
534
|
+
collectedManagementFee,
|
|
535
|
+
collectedProtocolFee,
|
|
536
|
+
rfqCode: rfqCode,
|
|
537
|
+
walletCode: walletCode,
|
|
538
|
+
dataAggregatorCode: dataAggregatorCode,
|
|
539
|
+
protocolFeeManagerAddress,
|
|
540
|
+
rfqIndex,
|
|
541
|
+
isExecutingStrategy,
|
|
542
|
+
maxLeverageRatio,
|
|
543
|
+
assetWalletDict,
|
|
544
|
+
walletAssetDict,
|
|
545
|
+
managementFeeRecipientAddress,
|
|
546
|
+
guardianAddress,
|
|
547
|
+
timelock,
|
|
548
|
+
pendingOwnerActionIndex,
|
|
549
|
+
pendingOwnerActionCount,
|
|
550
|
+
pendingOwnerAction,
|
|
551
|
+
getFactorialPoolAsset: (poolAddress, assetAddress) => {
|
|
552
|
+
const factorialPool = factorialPools[poolAddress.toString()];
|
|
553
|
+
if (!factorialPool)
|
|
554
|
+
throw "not found factorial pool";
|
|
555
|
+
const factorialPoolAsset = factorialPool[assetAddress.toString()];
|
|
556
|
+
if (!factorialPoolAsset)
|
|
557
|
+
throw "not found factorial pool asset";
|
|
558
|
+
return factorialPoolAsset;
|
|
559
|
+
},
|
|
560
|
+
getAsset: (assetAddress) => {
|
|
561
|
+
return assets[assetAddress.toString()];
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
static Dictionary = {
|
|
566
|
+
Values: {
|
|
567
|
+
Asset: () => ({
|
|
568
|
+
serialize: (src, builder) => {
|
|
569
|
+
return builder
|
|
570
|
+
.storeCoins(src.cash)
|
|
571
|
+
.storeCoins(src.balance)
|
|
572
|
+
.storeUint(src.isWhitelisted ? 1 : 0, 1)
|
|
573
|
+
.storeUint(src.isDepositable ? 1 : 0, 1)
|
|
574
|
+
.storeUint(src.isWithdrawable ? 1 : 0, 1)
|
|
575
|
+
.storeUint(src.exposureCap, 20);
|
|
576
|
+
},
|
|
577
|
+
parse: (src) => {
|
|
578
|
+
const cash = src.loadCoins();
|
|
579
|
+
const balance = src.loadCoins();
|
|
580
|
+
const isWhitelisted = src.loadBoolean();
|
|
581
|
+
const isDepositable = src.loadBoolean();
|
|
582
|
+
const isWithdrawable = src.loadBoolean();
|
|
583
|
+
const exposureCap = src.loadUint(20);
|
|
584
|
+
return {
|
|
585
|
+
isWhitelisted,
|
|
586
|
+
isDepositable,
|
|
587
|
+
isWithdrawable,
|
|
588
|
+
exposureCap,
|
|
589
|
+
cash,
|
|
590
|
+
balance,
|
|
591
|
+
};
|
|
592
|
+
},
|
|
593
|
+
}),
|
|
594
|
+
FactorialPool: () => ({
|
|
595
|
+
serialize: (src, builder) => {
|
|
596
|
+
const _assets = core_1.Dictionary.empty(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.FactorialPoolAsset());
|
|
597
|
+
Object.keys(src).forEach((key) => {
|
|
598
|
+
_assets.set(core_1.Address.parse(key), src[key]);
|
|
599
|
+
});
|
|
600
|
+
return builder.storeDict(_assets);
|
|
601
|
+
},
|
|
602
|
+
parse: (src) => {
|
|
603
|
+
const _assets = src.loadDict(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.FactorialPoolAsset());
|
|
604
|
+
const assets = {};
|
|
605
|
+
for (const key of _assets.keys()) {
|
|
606
|
+
assets[key.toString()] = _assets.get(key);
|
|
607
|
+
}
|
|
608
|
+
return assets;
|
|
609
|
+
},
|
|
610
|
+
}),
|
|
611
|
+
FactorialPoolAsset: () => ({
|
|
612
|
+
serialize: (src, builder) => {
|
|
613
|
+
return builder
|
|
614
|
+
.storeCoins(src.supply)
|
|
615
|
+
.storeCoins(src.borrow)
|
|
616
|
+
.storeBit(src.isSupplyable)
|
|
617
|
+
.storeBit(src.isBorrowable);
|
|
618
|
+
},
|
|
619
|
+
parse: (src) => {
|
|
620
|
+
const supply = src.loadCoins();
|
|
621
|
+
const borrow = src.loadCoins();
|
|
622
|
+
const isSupplyable = src.loadBoolean();
|
|
623
|
+
const isBorrowable = src.loadBoolean();
|
|
624
|
+
return {
|
|
625
|
+
supply,
|
|
626
|
+
borrow,
|
|
627
|
+
isSupplyable,
|
|
628
|
+
isBorrowable,
|
|
629
|
+
};
|
|
630
|
+
},
|
|
631
|
+
}),
|
|
632
|
+
UpdateFactorialPool: () => ({
|
|
633
|
+
serialize: (src, builder) => {
|
|
634
|
+
const _assets = core_1.Dictionary.empty(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.UpdateFactorialPoolAsset());
|
|
635
|
+
Object.keys(src).forEach((key) => {
|
|
636
|
+
_assets.set(core_1.Address.parse(key), src[key]);
|
|
637
|
+
});
|
|
638
|
+
return builder.storeDict(_assets);
|
|
639
|
+
},
|
|
640
|
+
parse: (src) => {
|
|
641
|
+
const _assets = src.loadDict(core_1.Dictionary.Keys.Address(), StrategyVault.Dictionary.Values.UpdateFactorialPoolAsset());
|
|
642
|
+
const assets = {};
|
|
643
|
+
for (const key of _assets.keys()) {
|
|
644
|
+
assets[key.toString()] = _assets.get(key);
|
|
645
|
+
}
|
|
646
|
+
return assets;
|
|
647
|
+
},
|
|
648
|
+
}),
|
|
649
|
+
UpdateFactorialPoolAsset: () => ({
|
|
650
|
+
serialize: (src, builder) => {
|
|
651
|
+
return builder
|
|
652
|
+
.storeBit(src.isSupplyable)
|
|
653
|
+
.storeBit(src.isBorrowable);
|
|
654
|
+
},
|
|
655
|
+
parse: (src) => {
|
|
656
|
+
const isSupplyable = src.loadBoolean();
|
|
657
|
+
const isBorrowable = src.loadBoolean();
|
|
658
|
+
return {
|
|
659
|
+
isSupplyable,
|
|
660
|
+
isBorrowable,
|
|
661
|
+
};
|
|
662
|
+
},
|
|
663
|
+
}),
|
|
664
|
+
Empty: () => ({
|
|
665
|
+
serialize: (src, builder) => {
|
|
666
|
+
return builder;
|
|
667
|
+
},
|
|
668
|
+
parse: (src) => {
|
|
669
|
+
return null;
|
|
670
|
+
},
|
|
671
|
+
}),
|
|
672
|
+
PendingOwnerAction: () => ({
|
|
673
|
+
serialize: (src, builder) => { },
|
|
674
|
+
parse: (src) => {
|
|
675
|
+
const timelock = src.loadCoins();
|
|
676
|
+
const op = src.loadUint(32);
|
|
677
|
+
const payloadHash = src.asCell().hash().toString("hex");
|
|
678
|
+
return {
|
|
679
|
+
timelock,
|
|
680
|
+
op,
|
|
681
|
+
payloadHash,
|
|
682
|
+
};
|
|
683
|
+
},
|
|
684
|
+
}),
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
async sendSetOwnerAddress(provider, via, value, opts) {
|
|
688
|
+
await provider.internal(via, {
|
|
689
|
+
value,
|
|
690
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
691
|
+
body: (0, core_1.beginCell)()
|
|
692
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
693
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
694
|
+
.storeUint(StrategyVault.Op.SetOwnerAddress, 32)
|
|
695
|
+
.storeAddress(opts.newOwner)
|
|
696
|
+
.endCell(),
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
async sendSetManagementFeeRatePerYear(provider, via, value, opts) {
|
|
700
|
+
await provider.internal(via, {
|
|
701
|
+
value,
|
|
702
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
703
|
+
body: (0, core_1.beginCell)()
|
|
704
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
705
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
706
|
+
.storeUint(StrategyVault.Op.SetManagementFeeRatePerYear, 32)
|
|
707
|
+
.storeUint(opts.managementFeeRate, 14)
|
|
708
|
+
.endCell(),
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
async sendSetMaxLeverageRatio(provider, via, value, opts) {
|
|
712
|
+
await provider.internal(via, {
|
|
713
|
+
value,
|
|
714
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
715
|
+
body: (0, core_1.beginCell)()
|
|
716
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
717
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
718
|
+
.storeUint(StrategyVault.Op.SetMaxLeverageRatio, 32)
|
|
719
|
+
.storeUint(opts.maxLeverageRatio, 20)
|
|
720
|
+
.endCell(),
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
async sendSetRFQConfig(provider, via, value, opts) {
|
|
724
|
+
await provider.internal(via, {
|
|
725
|
+
value,
|
|
726
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
727
|
+
body: (0, core_1.beginCell)()
|
|
728
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
729
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
730
|
+
.storeUint(StrategyVault.Op.SetRfqConfig, 32)
|
|
731
|
+
.storeMaybeRef(opts.rfqConfig)
|
|
732
|
+
.endCell(),
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
async sendSetOracleConfig(provider, via, value, opts) {
|
|
736
|
+
await provider.internal(via, {
|
|
737
|
+
value,
|
|
738
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
739
|
+
body: (0, core_1.beginCell)()
|
|
740
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
741
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
742
|
+
.storeUint(StrategyVault.Op.SetOracleConfig, 32)
|
|
743
|
+
.storeMaybeRef(opts.oracleConfig)
|
|
744
|
+
.endCell(),
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
async sendSetWalletCode(provider, via, value, opts) {
|
|
748
|
+
await provider.internal(via, {
|
|
749
|
+
value,
|
|
750
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
751
|
+
body: (0, core_1.beginCell)()
|
|
752
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
753
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
754
|
+
.storeUint(StrategyVault.Op.SetWalletCode, 32)
|
|
755
|
+
.storeRef(opts.walletCode)
|
|
756
|
+
.endCell(),
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
async sendSetDataAggregatorCode(provider, via, value, opts) {
|
|
760
|
+
await provider.internal(via, {
|
|
761
|
+
value,
|
|
762
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
763
|
+
body: (0, core_1.beginCell)()
|
|
764
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
765
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
766
|
+
.storeUint(StrategyVault.Op.SetDataAggregatorCode, 32)
|
|
767
|
+
.storeRef(opts.dataAggregatorCode)
|
|
768
|
+
.endCell(),
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
async sendSetRFQCode(provider, via, value, opts) {
|
|
772
|
+
await provider.internal(via, {
|
|
773
|
+
value,
|
|
774
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
775
|
+
body: (0, core_1.beginCell)()
|
|
776
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
777
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
778
|
+
.storeUint(StrategyVault.Op.SetRfqCode, 32)
|
|
779
|
+
.storeRef(opts.rfqCode)
|
|
780
|
+
.endCell(),
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async sendSetContent(provider, via, value, opts) {
|
|
784
|
+
await provider.internal(via, {
|
|
785
|
+
value,
|
|
786
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
787
|
+
body: (0, core_1.beginCell)()
|
|
788
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
789
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
790
|
+
.storeUint(StrategyVault.Op.SetContent, 32)
|
|
791
|
+
.storeRef(opts.content)
|
|
792
|
+
.endCell(),
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
async sendUpgradeCode(provider, via, value, opts) {
|
|
796
|
+
await provider.internal(via, {
|
|
797
|
+
value,
|
|
798
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
799
|
+
body: (0, core_1.beginCell)()
|
|
800
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
801
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
802
|
+
.storeUint(StrategyVault.Op.UpgradeCode, 32)
|
|
803
|
+
.storeRef(opts.newCode)
|
|
804
|
+
.endCell(),
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
async sendSetManagerAddress(provider, via, value, opts) {
|
|
808
|
+
await provider.internal(via, {
|
|
809
|
+
value,
|
|
810
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
811
|
+
body: (0, core_1.beginCell)()
|
|
812
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
813
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
814
|
+
.storeUint(StrategyVault.Op.SetManagerAddress, 32)
|
|
815
|
+
.storeAddress(opts.managerAddress)
|
|
816
|
+
.endCell(),
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
async sendSetPrivateVault(provider, via, value, opts) {
|
|
820
|
+
await provider.internal(via, {
|
|
821
|
+
value,
|
|
822
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
823
|
+
body: (0, core_1.beginCell)()
|
|
824
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
825
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
826
|
+
.storeUint(StrategyVault.Op.SetPrivateVault, 32)
|
|
827
|
+
.storeBit(opts.isPrivateVault)
|
|
828
|
+
.endCell(),
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
async sendSetDepositCloseTimestamp(provider, via, value, opts) {
|
|
832
|
+
await provider.internal(via, {
|
|
833
|
+
value,
|
|
834
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
835
|
+
body: (0, core_1.beginCell)()
|
|
836
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
837
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
838
|
+
.storeUint(StrategyVault.Op.SetDepositCloseTimestamp, 32)
|
|
839
|
+
.storeUint(opts.depositCloseTimestamp, 40)
|
|
840
|
+
.endCell(),
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
async sendSetWithdrawOpenTimestamp(provider, via, value, opts) {
|
|
844
|
+
await provider.internal(via, {
|
|
845
|
+
value,
|
|
846
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
847
|
+
body: (0, core_1.beginCell)()
|
|
848
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
849
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
850
|
+
.storeUint(StrategyVault.Op.SetWithdrawOpenTimestamp, 32)
|
|
851
|
+
.storeUint(opts.withdrawOpenTimestamp, 40)
|
|
852
|
+
.endCell(),
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
async sendSetWhitelistedMinters(provider, via, value, opts) {
|
|
856
|
+
await provider.internal(via, {
|
|
857
|
+
value,
|
|
858
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
859
|
+
body: (0, core_1.beginCell)()
|
|
860
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
861
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
862
|
+
.storeUint(StrategyVault.Op.SetWhitelistedMinters, 32)
|
|
863
|
+
.storeMaybeRef(opts.whitelistedMinters)
|
|
864
|
+
.endCell(),
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
async sendSetGasConfig(provider, via, value, opts) {
|
|
868
|
+
await provider.internal(via, {
|
|
869
|
+
value,
|
|
870
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
871
|
+
body: (0, core_1.beginCell)()
|
|
872
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
873
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
874
|
+
.storeUint(StrategyVault.Op.SetGasConfig, 32)
|
|
875
|
+
.storeMaybeRef(opts.gasConfig)
|
|
876
|
+
.endCell(),
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
async sendExecuteOwnerAction(provider, via, value, opts) {
|
|
880
|
+
await provider.internal(via, {
|
|
881
|
+
value,
|
|
882
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
883
|
+
body: (0, core_1.beginCell)()
|
|
884
|
+
.storeUint(StrategyVault.Op.ExecuteOwnerAction, 32)
|
|
885
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
886
|
+
.storeCoins(opts.updateIndex)
|
|
887
|
+
.endCell(),
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
async sendRevertOwnerAction(provider, via, value, opts) {
|
|
891
|
+
await provider.internal(via, {
|
|
892
|
+
value,
|
|
893
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
894
|
+
body: (0, core_1.beginCell)()
|
|
895
|
+
.storeUint(StrategyVault.Op.RevertOwnerAction, 32)
|
|
896
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
897
|
+
.storeCoins(opts.updateIndex)
|
|
898
|
+
.endCell(),
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
async sendSetGuardianAddress(provider, via, value, opts) {
|
|
902
|
+
await provider.internal(via, {
|
|
903
|
+
value,
|
|
904
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
905
|
+
body: (0, core_1.beginCell)()
|
|
906
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
907
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
908
|
+
.storeUint(StrategyVault.Op.SetGuardianAddress, 32)
|
|
909
|
+
.storeAddress(opts.guardianAddress)
|
|
910
|
+
.endCell(),
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
async sendSetTimelock(provider, via, value, opts) {
|
|
914
|
+
await provider.internal(via, {
|
|
915
|
+
value,
|
|
916
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
917
|
+
body: (0, core_1.beginCell)()
|
|
918
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
919
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
920
|
+
.storeUint(StrategyVault.Op.SetTimelock, 32)
|
|
921
|
+
.storeCoins(opts.timelock)
|
|
922
|
+
.endCell(),
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
async sendSetManagementFeeRecipientAddress(provider, via, value, opts) {
|
|
926
|
+
await provider.internal(via, {
|
|
927
|
+
value,
|
|
928
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
929
|
+
body: (0, core_1.beginCell)()
|
|
930
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
931
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
932
|
+
.storeUint(StrategyVault.Op.SetManagementFeeRecipientAddress, 32)
|
|
933
|
+
.storeAddress(opts.managementFeeRecipientAddress)
|
|
934
|
+
.endCell(),
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
static createDepositPayload(oracleParams, forwardTonAmount, forwardPayload) {
|
|
938
|
+
return (0, core_1.beginCell)()
|
|
939
|
+
.storeUint(StrategyVault.Op.Deposit, 32)
|
|
940
|
+
.storeMaybeRef(oracleParams)
|
|
941
|
+
.storeCoins(forwardTonAmount ?? 0n)
|
|
942
|
+
.storeMaybeRef(forwardPayload).endCell();
|
|
943
|
+
}
|
|
944
|
+
static createWithdrawPayload(assetAddress, oracleParams, forwardTonAmount, forwardPayload) {
|
|
945
|
+
return (0, core_1.beginCell)()
|
|
946
|
+
.storeUint(StrategyVault.Op.Withdraw, 32)
|
|
947
|
+
.storeAddress(assetAddress)
|
|
948
|
+
.storeMaybeRef(oracleParams)
|
|
949
|
+
.storeCoins(forwardTonAmount ?? 0n)
|
|
950
|
+
.storeMaybeRef(forwardPayload)
|
|
951
|
+
.endCell();
|
|
952
|
+
}
|
|
953
|
+
async sendSetProtocolFeeRatePerYear(provider, via, value, opts) {
|
|
954
|
+
await provider.internal(via, {
|
|
955
|
+
value,
|
|
956
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
957
|
+
body: (0, core_1.beginCell)()
|
|
958
|
+
.storeUint(StrategyVault.Op.SetProtocolFeeRatePerYear, 32)
|
|
959
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
960
|
+
.storeUint(opts.protocolFeeRate, 14)
|
|
961
|
+
.endCell(),
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
async sendSetProtocolFeeManagerAddress(provider, via, value, opts) {
|
|
965
|
+
await provider.internal(via, {
|
|
966
|
+
value,
|
|
967
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
968
|
+
body: (0, core_1.beginCell)()
|
|
969
|
+
.storeUint(StrategyVault.Op.SetProtocolFeeManagerAddress, 32)
|
|
970
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
971
|
+
.storeAddress(opts.protocolFeeManagerAddress)
|
|
972
|
+
.endCell(),
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
static createRFQConfig(params) {
|
|
976
|
+
return (0, core_1.beginCell)()
|
|
977
|
+
.storeUint(params.priceDeviationTolerance, 14)
|
|
978
|
+
.storeAddress(params.eventEmitter)
|
|
979
|
+
.endCell();
|
|
980
|
+
}
|
|
981
|
+
static getOpName(opCode) {
|
|
982
|
+
const opEntries = Object.entries(StrategyVault.Op);
|
|
983
|
+
const opMap = Object.fromEntries(opEntries);
|
|
984
|
+
const opName = Object.keys(opMap).find(key => opMap[key] === opCode);
|
|
985
|
+
return opName || `UnknownOp(${opCode.toString(16)})`;
|
|
986
|
+
}
|
|
987
|
+
static getErrorName(errorCode) {
|
|
988
|
+
const errorEntries = Object.entries(StrategyVault.Error);
|
|
989
|
+
const errorMap = Object.fromEntries(errorEntries);
|
|
990
|
+
const errorName = Object.keys(errorMap).find(key => errorMap[key] === errorCode);
|
|
991
|
+
return errorName || `UnknownError(${errorCode})`;
|
|
992
|
+
}
|
|
993
|
+
static getGasKeyName(gasKey) {
|
|
994
|
+
const gasKeyEntries = Object.entries(StrategyVault.GasKey);
|
|
995
|
+
const gasKeyMap = Object.fromEntries(gasKeyEntries.map(([key, value]) => [value, key]));
|
|
996
|
+
return gasKeyMap[gasKey] || `UnknownGasKey(${gasKey.toString(16)})`;
|
|
997
|
+
}
|
|
998
|
+
// Get available actions for the modal
|
|
999
|
+
static getAvailableActionsOriginal() {
|
|
1000
|
+
return [
|
|
1001
|
+
// Owner Actions
|
|
1002
|
+
"SetOwnerAddress",
|
|
1003
|
+
"SetAssetConfig",
|
|
1004
|
+
"SetFactorialPoolConfig",
|
|
1005
|
+
"SetManagerAddress",
|
|
1006
|
+
"SetPrivateVault",
|
|
1007
|
+
"SetDepositCloseTimestamp",
|
|
1008
|
+
"SetWithdrawOpenTimestamp",
|
|
1009
|
+
"SetWhitelistedMinters",
|
|
1010
|
+
"SetManagementFeeRatePerYear",
|
|
1011
|
+
"SetMaxLeverageRatio",
|
|
1012
|
+
"SetRfqConfig",
|
|
1013
|
+
"SetGasConfig",
|
|
1014
|
+
"SetOracleConfig",
|
|
1015
|
+
"SetWalletCode",
|
|
1016
|
+
"SetDataAggregatorCode",
|
|
1017
|
+
"SetRfqCode",
|
|
1018
|
+
"SetContent",
|
|
1019
|
+
"UpgradeCode",
|
|
1020
|
+
"SetGuardianAddress",
|
|
1021
|
+
"SetTimelock",
|
|
1022
|
+
"SetManagementFeeRecipientAddress",
|
|
1023
|
+
// Direct Actions
|
|
1024
|
+
"ClaimProtocolFee",
|
|
1025
|
+
"SetProtocolFeeRatePerYear",
|
|
1026
|
+
"SetProtocolFeeManagerAddress",
|
|
1027
|
+
"ClaimManagementFee",
|
|
1028
|
+
"ExecuteOwnerAction",
|
|
1029
|
+
"RevertOwnerAction",
|
|
1030
|
+
"Initialize",
|
|
1031
|
+
"SupplyToFactorial",
|
|
1032
|
+
"WithdrawFromFactorial",
|
|
1033
|
+
"BorrowFromFactorial",
|
|
1034
|
+
"RepayToFactorial",
|
|
1035
|
+
"LiquidateToFactorial",
|
|
1036
|
+
"CreateRfq",
|
|
1037
|
+
"CancelRfq",
|
|
1038
|
+
"TakeAggregatedData",
|
|
1039
|
+
"Excesses",
|
|
1040
|
+
];
|
|
1041
|
+
}
|
|
1042
|
+
// Message body creation functions
|
|
1043
|
+
static createInitializeMsgBody(queryID) {
|
|
1044
|
+
return (0, core_1.beginCell)()
|
|
1045
|
+
.storeUint(StrategyVault.Op.Initialize, 32)
|
|
1046
|
+
.storeUint(queryID ?? 0, 64)
|
|
1047
|
+
.endCell();
|
|
1048
|
+
}
|
|
1049
|
+
static createExecuteStrategyMsgBody(body, queryID) {
|
|
1050
|
+
return (0, core_1.beginCell)()
|
|
1051
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1052
|
+
.storeUint(queryID ?? 0, 64)
|
|
1053
|
+
.storeBuilder(body)
|
|
1054
|
+
.endCell();
|
|
1055
|
+
}
|
|
1056
|
+
static createLiquidateToFactorialMsgBody(oracleParams, pool, borrower, repayAsset, seizeAsset, repayAmount, response, queryID) {
|
|
1057
|
+
return (0, core_1.beginCell)()
|
|
1058
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1059
|
+
.storeUint(queryID ?? 0, 64)
|
|
1060
|
+
.storeUint(StrategyVault.Op.LiquidateToFactorial, 32)
|
|
1061
|
+
.storeMaybeRef(oracleParams)
|
|
1062
|
+
.storeRef(oracleParams)
|
|
1063
|
+
.storeAddress(pool)
|
|
1064
|
+
.storeAddress(borrower)
|
|
1065
|
+
.storeAddress(repayAsset)
|
|
1066
|
+
.storeRef((0, core_1.beginCell)()
|
|
1067
|
+
.storeAddress(seizeAsset)
|
|
1068
|
+
.storeCoins(repayAmount)
|
|
1069
|
+
.storeAddress(response)
|
|
1070
|
+
.endCell())
|
|
1071
|
+
.endCell();
|
|
1072
|
+
}
|
|
1073
|
+
static createSupplyToFactorialMsgBody(pool, asset, amount, response, queryID) {
|
|
1074
|
+
return (0, core_1.beginCell)()
|
|
1075
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1076
|
+
.storeUint(queryID ?? 0, 64)
|
|
1077
|
+
.storeUint(StrategyVault.Op.SupplyToFactorial, 32)
|
|
1078
|
+
.storeAddress(pool)
|
|
1079
|
+
.storeAddress(asset)
|
|
1080
|
+
.storeCoins(amount)
|
|
1081
|
+
.storeAddress(response)
|
|
1082
|
+
.endCell();
|
|
1083
|
+
}
|
|
1084
|
+
static createWithdrawFromFactorialMsgBody(oracleParams, pool, asset, amount, isShare, response, queryID) {
|
|
1085
|
+
return (0, core_1.beginCell)()
|
|
1086
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1087
|
+
.storeUint(queryID ?? 0, 64)
|
|
1088
|
+
.storeRef(oracleParams)
|
|
1089
|
+
.storeUint(StrategyVault.Op.WithdrawFromFactorial, 32)
|
|
1090
|
+
.storeAddress(pool)
|
|
1091
|
+
.storeAddress(asset)
|
|
1092
|
+
.storeCoins(amount)
|
|
1093
|
+
.storeBit(isShare)
|
|
1094
|
+
.storeAddress(response)
|
|
1095
|
+
.endCell();
|
|
1096
|
+
}
|
|
1097
|
+
static createBorrowFromFactorialMsgBody(oracleParams, pool, asset, amount, isShare, response, queryID) {
|
|
1098
|
+
return (0, core_1.beginCell)()
|
|
1099
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1100
|
+
.storeUint(queryID ?? 0, 64)
|
|
1101
|
+
.storeUint(StrategyVault.Op.BorrowFromFactorial, 32)
|
|
1102
|
+
.storeMaybeRef(oracleParams)
|
|
1103
|
+
.storeRef(oracleParams)
|
|
1104
|
+
.storeAddress(pool)
|
|
1105
|
+
.storeAddress(asset)
|
|
1106
|
+
.storeCoins(amount)
|
|
1107
|
+
.storeBit(isShare)
|
|
1108
|
+
.storeAddress(response)
|
|
1109
|
+
.endCell();
|
|
1110
|
+
}
|
|
1111
|
+
static createRepayToFactorialMsgBody(pool, asset, amount, response, queryID) {
|
|
1112
|
+
return (0, core_1.beginCell)()
|
|
1113
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1114
|
+
.storeUint(queryID ?? 0, 64)
|
|
1115
|
+
.storeUint(StrategyVault.Op.RepayToFactorial, 32)
|
|
1116
|
+
.storeAddress(pool)
|
|
1117
|
+
.storeAddress(asset)
|
|
1118
|
+
.storeCoins(amount)
|
|
1119
|
+
.storeAddress(response)
|
|
1120
|
+
.endCell();
|
|
1121
|
+
}
|
|
1122
|
+
static createCreateRFQMsgBody(rfqIndex, sellAsset, buyAsset, sellAssetAmount, minBuyAssetValue, maxBuyAssetValue, sellAssetRFQWallet, buyAssetRFQWallet, oracleParams, period, allowSellerCancel, allowBidderCancel, isAmountBid, queryID) {
|
|
1123
|
+
return (0, core_1.beginCell)()
|
|
1124
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1125
|
+
.storeUint(queryID ?? 0, 64)
|
|
1126
|
+
.storeUint(StrategyVault.Op.CreateRfq, 32)
|
|
1127
|
+
.storeCoins(rfqIndex)
|
|
1128
|
+
.storeAddress(sellAsset)
|
|
1129
|
+
.storeAddress(buyAsset)
|
|
1130
|
+
.storeCoins(sellAssetAmount)
|
|
1131
|
+
.storeCoins(minBuyAssetValue)
|
|
1132
|
+
.storeCoins(maxBuyAssetValue)
|
|
1133
|
+
.storeAddress(sellAssetRFQWallet)
|
|
1134
|
+
.storeAddress(buyAssetRFQWallet)
|
|
1135
|
+
.storeRef(oracleParams)
|
|
1136
|
+
.storeUint(period, 32)
|
|
1137
|
+
.storeBit(allowSellerCancel)
|
|
1138
|
+
.storeBit(allowBidderCancel)
|
|
1139
|
+
.storeBit(isAmountBid)
|
|
1140
|
+
.endCell();
|
|
1141
|
+
}
|
|
1142
|
+
static createCancelRFQMsgBody(rfqIndex, queryID) {
|
|
1143
|
+
return (0, core_1.beginCell)()
|
|
1144
|
+
.storeUint(StrategyVault.Op.ExecuteStrategy, 32)
|
|
1145
|
+
.storeUint(queryID ?? 0, 64)
|
|
1146
|
+
.storeUint(StrategyVault.Op.CancelRfq, 32)
|
|
1147
|
+
.storeCoins(rfqIndex)
|
|
1148
|
+
.endCell();
|
|
1149
|
+
}
|
|
1150
|
+
static createSetAssetConfigMsgBody(assetAddress, isWhitelisted, isDepositable, isWithdrawable, exposureCap, queryID) {
|
|
1151
|
+
return (0, core_1.beginCell)()
|
|
1152
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1153
|
+
.storeUint(queryID ?? 0, 64)
|
|
1154
|
+
.storeUint(StrategyVault.Op.SetAssetConfig, 32)
|
|
1155
|
+
.storeAddress(assetAddress)
|
|
1156
|
+
.storeBit(isWhitelisted)
|
|
1157
|
+
.storeBit(isDepositable)
|
|
1158
|
+
.storeBit(isWithdrawable)
|
|
1159
|
+
.storeUint(exposureCap, 20)
|
|
1160
|
+
.endCell();
|
|
1161
|
+
}
|
|
1162
|
+
static createSetFactorialPoolConfigMsgBody(updateConfig, queryID) {
|
|
1163
|
+
return (0, core_1.beginCell)()
|
|
1164
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1165
|
+
.storeUint(queryID ?? 0, 64)
|
|
1166
|
+
.storeUint(StrategyVault.Op.SetFactorialPoolConfig, 32)
|
|
1167
|
+
.storeMaybeRef(updateConfig)
|
|
1168
|
+
.endCell();
|
|
1169
|
+
}
|
|
1170
|
+
static createClaimManagementFeeMsgBody(receiverAddress, queryID) {
|
|
1171
|
+
return (0, core_1.beginCell)()
|
|
1172
|
+
.storeUint(StrategyVault.Op.ClaimManagementFee, 32)
|
|
1173
|
+
.storeUint(queryID ?? 0, 64)
|
|
1174
|
+
.storeAddress(receiverAddress)
|
|
1175
|
+
.endCell();
|
|
1176
|
+
}
|
|
1177
|
+
static createClaimProtocolFeeMsgBody(receiverAddress, queryID) {
|
|
1178
|
+
return (0, core_1.beginCell)()
|
|
1179
|
+
.storeUint(StrategyVault.Op.ClaimProtocolFee, 32)
|
|
1180
|
+
.storeUint(queryID ?? 0, 64)
|
|
1181
|
+
.storeAddress(receiverAddress)
|
|
1182
|
+
.endCell();
|
|
1183
|
+
}
|
|
1184
|
+
static createSetOwnerAddressMsgBody(newOwner, queryID) {
|
|
1185
|
+
return (0, core_1.beginCell)()
|
|
1186
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1187
|
+
.storeUint(queryID ?? 0, 64)
|
|
1188
|
+
.storeUint(StrategyVault.Op.SetOwnerAddress, 32)
|
|
1189
|
+
.storeAddress(newOwner)
|
|
1190
|
+
.endCell();
|
|
1191
|
+
}
|
|
1192
|
+
static createSetManagementFeeRatePerYearMsgBody(managementFeeRate, queryID) {
|
|
1193
|
+
return (0, core_1.beginCell)()
|
|
1194
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1195
|
+
.storeUint(queryID ?? 0, 64)
|
|
1196
|
+
.storeUint(StrategyVault.Op.SetManagementFeeRatePerYear, 32)
|
|
1197
|
+
.storeUint(managementFeeRate, 14)
|
|
1198
|
+
.endCell();
|
|
1199
|
+
}
|
|
1200
|
+
static createSetMaxLeverageRatioMsgBody(maxLeverageRatio, queryID) {
|
|
1201
|
+
return (0, core_1.beginCell)()
|
|
1202
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1203
|
+
.storeUint(queryID ?? 0, 64)
|
|
1204
|
+
.storeUint(StrategyVault.Op.SetMaxLeverageRatio, 32)
|
|
1205
|
+
.storeUint(maxLeverageRatio, 20)
|
|
1206
|
+
.endCell();
|
|
1207
|
+
}
|
|
1208
|
+
static createSetRFQConfigMsgBody(rfqConfig, queryID) {
|
|
1209
|
+
return (0, core_1.beginCell)()
|
|
1210
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1211
|
+
.storeUint(queryID ?? 0, 64)
|
|
1212
|
+
.storeUint(StrategyVault.Op.SetRfqConfig, 32)
|
|
1213
|
+
.storeMaybeRef(rfqConfig)
|
|
1214
|
+
.endCell();
|
|
1215
|
+
}
|
|
1216
|
+
static createSetOracleConfigMsgBody(oracleConfig, queryID) {
|
|
1217
|
+
return (0, core_1.beginCell)()
|
|
1218
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1219
|
+
.storeUint(queryID ?? 0, 64)
|
|
1220
|
+
.storeUint(StrategyVault.Op.SetOracleConfig, 32)
|
|
1221
|
+
.storeMaybeRef(oracleConfig)
|
|
1222
|
+
.endCell();
|
|
1223
|
+
}
|
|
1224
|
+
static createSetWalletCodeMsgBody(walletCode, queryID) {
|
|
1225
|
+
return (0, core_1.beginCell)()
|
|
1226
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1227
|
+
.storeUint(queryID ?? 0, 64)
|
|
1228
|
+
.storeUint(StrategyVault.Op.SetWalletCode, 32)
|
|
1229
|
+
.storeRef(walletCode)
|
|
1230
|
+
.endCell();
|
|
1231
|
+
}
|
|
1232
|
+
static createSetDataAggregatorCodeMsgBody(dataAggregatorCode, queryID) {
|
|
1233
|
+
return (0, core_1.beginCell)()
|
|
1234
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1235
|
+
.storeUint(queryID ?? 0, 64)
|
|
1236
|
+
.storeUint(StrategyVault.Op.SetDataAggregatorCode, 32)
|
|
1237
|
+
.storeRef(dataAggregatorCode)
|
|
1238
|
+
.endCell();
|
|
1239
|
+
}
|
|
1240
|
+
static createSetRFQCodeMsgBody(rfqCode, queryID) {
|
|
1241
|
+
return (0, core_1.beginCell)()
|
|
1242
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1243
|
+
.storeUint(queryID ?? 0, 64)
|
|
1244
|
+
.storeUint(StrategyVault.Op.SetRfqCode, 32)
|
|
1245
|
+
.storeRef(rfqCode)
|
|
1246
|
+
.endCell();
|
|
1247
|
+
}
|
|
1248
|
+
static createSetContentMsgBody(content, queryID) {
|
|
1249
|
+
return (0, core_1.beginCell)()
|
|
1250
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1251
|
+
.storeUint(queryID ?? 0, 64)
|
|
1252
|
+
.storeUint(StrategyVault.Op.SetContent, 32)
|
|
1253
|
+
.storeRef(content)
|
|
1254
|
+
.endCell();
|
|
1255
|
+
}
|
|
1256
|
+
static createUpgradeCodeMsgBody(newCode, queryID) {
|
|
1257
|
+
return (0, core_1.beginCell)()
|
|
1258
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1259
|
+
.storeUint(queryID ?? 0, 64)
|
|
1260
|
+
.storeUint(StrategyVault.Op.UpgradeCode, 32)
|
|
1261
|
+
.storeRef(newCode)
|
|
1262
|
+
.endCell();
|
|
1263
|
+
}
|
|
1264
|
+
static createSetManagerAddressMsgBody(managerAddress, queryID) {
|
|
1265
|
+
return (0, core_1.beginCell)()
|
|
1266
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1267
|
+
.storeUint(queryID ?? 0, 64)
|
|
1268
|
+
.storeUint(StrategyVault.Op.SetManagerAddress, 32)
|
|
1269
|
+
.storeAddress(managerAddress)
|
|
1270
|
+
.endCell();
|
|
1271
|
+
}
|
|
1272
|
+
static createSetPrivateVaultMsgBody(isPrivateVault, queryID) {
|
|
1273
|
+
return (0, core_1.beginCell)()
|
|
1274
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1275
|
+
.storeUint(queryID ?? 0, 64)
|
|
1276
|
+
.storeUint(StrategyVault.Op.SetPrivateVault, 32)
|
|
1277
|
+
.storeBit(isPrivateVault)
|
|
1278
|
+
.endCell();
|
|
1279
|
+
}
|
|
1280
|
+
static createSetDepositCloseTimestampMsgBody(depositCloseTimestamp, queryID) {
|
|
1281
|
+
return (0, core_1.beginCell)()
|
|
1282
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1283
|
+
.storeUint(queryID ?? 0, 64)
|
|
1284
|
+
.storeUint(StrategyVault.Op.SetDepositCloseTimestamp, 32)
|
|
1285
|
+
.storeUint(depositCloseTimestamp, 64)
|
|
1286
|
+
.endCell();
|
|
1287
|
+
}
|
|
1288
|
+
static createSetWithdrawOpenTimestampMsgBody(withdrawOpenTimestamp, queryID) {
|
|
1289
|
+
return (0, core_1.beginCell)()
|
|
1290
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1291
|
+
.storeUint(queryID ?? 0, 64)
|
|
1292
|
+
.storeUint(StrategyVault.Op.SetWithdrawOpenTimestamp, 32)
|
|
1293
|
+
.storeUint(withdrawOpenTimestamp, 64)
|
|
1294
|
+
.endCell();
|
|
1295
|
+
}
|
|
1296
|
+
static createSetWhitelistedMintersMsgBody(whitelistedMinters, queryID) {
|
|
1297
|
+
return (0, core_1.beginCell)()
|
|
1298
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1299
|
+
.storeUint(queryID ?? 0, 64)
|
|
1300
|
+
.storeUint(StrategyVault.Op.SetWhitelistedMinters, 32)
|
|
1301
|
+
.storeMaybeRef(whitelistedMinters)
|
|
1302
|
+
.endCell();
|
|
1303
|
+
}
|
|
1304
|
+
static createSetGasConfigMsgBody(gasConfig, queryID) {
|
|
1305
|
+
return (0, core_1.beginCell)()
|
|
1306
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1307
|
+
.storeUint(queryID ?? 0, 64)
|
|
1308
|
+
.storeUint(StrategyVault.Op.SetGasConfig, 32)
|
|
1309
|
+
.storeMaybeRef(gasConfig)
|
|
1310
|
+
.endCell();
|
|
1311
|
+
}
|
|
1312
|
+
static createExecuteOwnerActionMsgBody(updateIndex, queryID) {
|
|
1313
|
+
return (0, core_1.beginCell)()
|
|
1314
|
+
.storeUint(StrategyVault.Op.ExecuteOwnerAction, 32)
|
|
1315
|
+
.storeUint(queryID ?? 0, 64)
|
|
1316
|
+
.storeCoins(updateIndex)
|
|
1317
|
+
.endCell();
|
|
1318
|
+
}
|
|
1319
|
+
static createRevertOwnerActionMsgBody(updateIndex, queryID) {
|
|
1320
|
+
return (0, core_1.beginCell)()
|
|
1321
|
+
.storeUint(StrategyVault.Op.RevertOwnerAction, 32)
|
|
1322
|
+
.storeUint(queryID ?? 0, 64)
|
|
1323
|
+
.storeCoins(updateIndex)
|
|
1324
|
+
.endCell();
|
|
1325
|
+
}
|
|
1326
|
+
static createSetGuardianAddressMsgBody(guardianAddress, queryID) {
|
|
1327
|
+
return (0, core_1.beginCell)()
|
|
1328
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1329
|
+
.storeUint(queryID ?? 0, 64)
|
|
1330
|
+
.storeUint(StrategyVault.Op.SetGuardianAddress, 32)
|
|
1331
|
+
.storeAddress(guardianAddress)
|
|
1332
|
+
.endCell();
|
|
1333
|
+
}
|
|
1334
|
+
static createSetTimelockMsgBody(timelock, queryID) {
|
|
1335
|
+
return (0, core_1.beginCell)()
|
|
1336
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1337
|
+
.storeUint(queryID ?? 0, 64)
|
|
1338
|
+
.storeUint(StrategyVault.Op.SetTimelock, 32)
|
|
1339
|
+
.storeCoins(timelock)
|
|
1340
|
+
.endCell();
|
|
1341
|
+
}
|
|
1342
|
+
static createSetManagementFeeRecipientAddressMsgBody(managementFeeRecipientAddress, queryID) {
|
|
1343
|
+
return (0, core_1.beginCell)()
|
|
1344
|
+
.storeUint(StrategyVault.Op.QueueOwnerAction, 32)
|
|
1345
|
+
.storeUint(queryID ?? 0, 64)
|
|
1346
|
+
.storeUint(StrategyVault.Op.SetManagementFeeRecipientAddress, 32)
|
|
1347
|
+
.storeAddress(managementFeeRecipientAddress)
|
|
1348
|
+
.endCell();
|
|
1349
|
+
}
|
|
1350
|
+
static createSetProtocolFeeRatePerYearMsgBody(protocolFeeRate, queryID) {
|
|
1351
|
+
return (0, core_1.beginCell)()
|
|
1352
|
+
.storeUint(StrategyVault.Op.SetProtocolFeeRatePerYear, 32)
|
|
1353
|
+
.storeUint(queryID ?? 0, 64)
|
|
1354
|
+
.storeUint(protocolFeeRate, 14)
|
|
1355
|
+
.endCell();
|
|
1356
|
+
}
|
|
1357
|
+
static createSetProtocolFeeManagerAddressMsgBody(protocolFeeManagerAddress, queryID) {
|
|
1358
|
+
return (0, core_1.beginCell)()
|
|
1359
|
+
.storeUint(StrategyVault.Op.SetProtocolFeeManagerAddress, 32)
|
|
1360
|
+
.storeUint(queryID ?? 0, 64)
|
|
1361
|
+
.storeAddress(protocolFeeManagerAddress)
|
|
1362
|
+
.endCell();
|
|
1363
|
+
}
|
|
1364
|
+
// Message body parsing functions
|
|
1365
|
+
static parseInitializeMsgBody(cell) {
|
|
1366
|
+
const slice = cell.beginParse();
|
|
1367
|
+
const op = slice.loadUint(32);
|
|
1368
|
+
const queryID = slice.loadUint(64);
|
|
1369
|
+
return { op, queryID };
|
|
1370
|
+
}
|
|
1371
|
+
static parseExecuteStrategyMsgBody(cell) {
|
|
1372
|
+
const slice = cell.beginParse();
|
|
1373
|
+
const op = slice.loadUint(32);
|
|
1374
|
+
const queryID = slice.loadUint(64);
|
|
1375
|
+
const body = slice.loadRef().beginParse();
|
|
1376
|
+
return { op, queryID, body };
|
|
1377
|
+
}
|
|
1378
|
+
static parseLiquidateToFactorialMsgBody(cell) {
|
|
1379
|
+
const slice = cell.beginParse();
|
|
1380
|
+
const op = slice.loadUint(32);
|
|
1381
|
+
const queryID = slice.loadUint(64);
|
|
1382
|
+
const subOp = slice.loadUint(32);
|
|
1383
|
+
const oracleParams = slice.loadMaybeRef();
|
|
1384
|
+
slice.loadRef(); // Skip ref
|
|
1385
|
+
const pool = slice.loadAddress();
|
|
1386
|
+
const borrower = slice.loadAddress();
|
|
1387
|
+
const repayAsset = slice.loadAddress();
|
|
1388
|
+
const seizeData = slice.loadRef().beginParse();
|
|
1389
|
+
const seizeAsset = seizeData.loadAddress();
|
|
1390
|
+
const repayAmount = seizeData.loadCoins();
|
|
1391
|
+
const response = seizeData.loadAddress();
|
|
1392
|
+
return {
|
|
1393
|
+
op,
|
|
1394
|
+
queryID,
|
|
1395
|
+
subOp,
|
|
1396
|
+
oracleParams,
|
|
1397
|
+
pool,
|
|
1398
|
+
borrower,
|
|
1399
|
+
repayAsset,
|
|
1400
|
+
seizeAsset,
|
|
1401
|
+
repayAmount,
|
|
1402
|
+
response,
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
static parseSupplyToFactorialMsgBody(cell) {
|
|
1406
|
+
const slice = cell.beginParse();
|
|
1407
|
+
const op = slice.loadUint(32);
|
|
1408
|
+
const queryID = slice.loadUint(64);
|
|
1409
|
+
const subOp = slice.loadUint(32);
|
|
1410
|
+
const pool = slice.loadAddress();
|
|
1411
|
+
const asset = slice.loadAddress();
|
|
1412
|
+
const amount = slice.loadCoins();
|
|
1413
|
+
const response = slice.loadAddress();
|
|
1414
|
+
return {
|
|
1415
|
+
op,
|
|
1416
|
+
queryID,
|
|
1417
|
+
subOp,
|
|
1418
|
+
pool,
|
|
1419
|
+
asset,
|
|
1420
|
+
amount,
|
|
1421
|
+
response,
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
static parseWithdrawFromFactorialMsgBody(cell) {
|
|
1425
|
+
const slice = cell.beginParse();
|
|
1426
|
+
const op = slice.loadUint(32);
|
|
1427
|
+
const queryID = slice.loadUint(64);
|
|
1428
|
+
slice.loadRef(); // Skip oracle params ref
|
|
1429
|
+
const subOp = slice.loadUint(32);
|
|
1430
|
+
const pool = slice.loadAddress();
|
|
1431
|
+
const asset = slice.loadAddress();
|
|
1432
|
+
const amount = slice.loadCoins();
|
|
1433
|
+
const isShare = slice.loadBit();
|
|
1434
|
+
const response = slice.loadAddress();
|
|
1435
|
+
const oracleParams = slice.loadRef();
|
|
1436
|
+
return {
|
|
1437
|
+
op,
|
|
1438
|
+
queryID,
|
|
1439
|
+
subOp,
|
|
1440
|
+
oracleParams,
|
|
1441
|
+
pool,
|
|
1442
|
+
asset,
|
|
1443
|
+
amount,
|
|
1444
|
+
isShare,
|
|
1445
|
+
response,
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
static parseBorrowFromFactorialMsgBody(cell) {
|
|
1449
|
+
const slice = cell.beginParse();
|
|
1450
|
+
const op = slice.loadUint(32);
|
|
1451
|
+
const queryID = slice.loadUint(64);
|
|
1452
|
+
const subOp = slice.loadUint(32);
|
|
1453
|
+
const oracleParams = slice.loadMaybeRef();
|
|
1454
|
+
slice.loadRef(); // Skip ref
|
|
1455
|
+
const pool = slice.loadAddress();
|
|
1456
|
+
const asset = slice.loadAddress();
|
|
1457
|
+
const amount = slice.loadCoins();
|
|
1458
|
+
const isShare = slice.loadBit();
|
|
1459
|
+
const response = slice.loadAddress();
|
|
1460
|
+
return {
|
|
1461
|
+
op,
|
|
1462
|
+
queryID,
|
|
1463
|
+
subOp,
|
|
1464
|
+
oracleParams,
|
|
1465
|
+
pool,
|
|
1466
|
+
asset,
|
|
1467
|
+
amount,
|
|
1468
|
+
isShare,
|
|
1469
|
+
response,
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
static parseRepayToFactorialMsgBody(cell) {
|
|
1473
|
+
const slice = cell.beginParse();
|
|
1474
|
+
const op = slice.loadUint(32);
|
|
1475
|
+
const queryID = slice.loadUint(64);
|
|
1476
|
+
const subOp = slice.loadUint(32);
|
|
1477
|
+
const pool = slice.loadAddress();
|
|
1478
|
+
const asset = slice.loadAddress();
|
|
1479
|
+
const amount = slice.loadCoins();
|
|
1480
|
+
const response = slice.loadAddress();
|
|
1481
|
+
return {
|
|
1482
|
+
op,
|
|
1483
|
+
queryID,
|
|
1484
|
+
subOp,
|
|
1485
|
+
pool,
|
|
1486
|
+
asset,
|
|
1487
|
+
amount,
|
|
1488
|
+
response,
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
static parseCreateRFQMsgBody(cell) {
|
|
1492
|
+
const slice = cell.beginParse();
|
|
1493
|
+
const op = slice.loadUint(32);
|
|
1494
|
+
const queryID = slice.loadUint(64);
|
|
1495
|
+
const subOp = slice.loadUint(32);
|
|
1496
|
+
const rfqIndex = slice.loadCoins();
|
|
1497
|
+
const sellAsset = slice.loadAddress();
|
|
1498
|
+
const buyAsset = slice.loadAddress();
|
|
1499
|
+
const sellAssetAmount = slice.loadCoins();
|
|
1500
|
+
const minBuyAssetValue = slice.loadCoins();
|
|
1501
|
+
const maxBuyAssetValue = slice.loadCoins();
|
|
1502
|
+
const sellAssetRFQWallet = slice.loadAddress();
|
|
1503
|
+
const buyAssetRFQWallet = slice.loadAddress();
|
|
1504
|
+
const oracleParams = slice.loadRef();
|
|
1505
|
+
const period = slice.loadUint(32);
|
|
1506
|
+
const allowSellerCancel = slice.loadBit();
|
|
1507
|
+
const allowBidderCancel = slice.loadBit();
|
|
1508
|
+
const isAmountBid = slice.loadBit();
|
|
1509
|
+
return {
|
|
1510
|
+
op,
|
|
1511
|
+
queryID,
|
|
1512
|
+
subOp,
|
|
1513
|
+
rfqIndex,
|
|
1514
|
+
sellAsset,
|
|
1515
|
+
buyAsset,
|
|
1516
|
+
sellAssetAmount,
|
|
1517
|
+
minBuyAssetValue,
|
|
1518
|
+
maxBuyAssetValue,
|
|
1519
|
+
sellAssetRFQWallet,
|
|
1520
|
+
buyAssetRFQWallet,
|
|
1521
|
+
oracleParams,
|
|
1522
|
+
period,
|
|
1523
|
+
allowSellerCancel,
|
|
1524
|
+
allowBidderCancel,
|
|
1525
|
+
isAmountBid,
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
static parseCancelRFQMsgBody(cell) {
|
|
1529
|
+
const slice = cell.beginParse();
|
|
1530
|
+
const op = slice.loadUint(32);
|
|
1531
|
+
const queryID = slice.loadUint(64);
|
|
1532
|
+
const subOp = slice.loadUint(32);
|
|
1533
|
+
const rfqIndex = slice.loadCoins();
|
|
1534
|
+
return {
|
|
1535
|
+
op,
|
|
1536
|
+
queryID,
|
|
1537
|
+
subOp,
|
|
1538
|
+
rfqIndex,
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
static parseSetAssetConfigMsgBody(cell) {
|
|
1542
|
+
const slice = cell.beginParse();
|
|
1543
|
+
const op = slice.loadUint(32);
|
|
1544
|
+
const queryID = slice.loadUint(64);
|
|
1545
|
+
const ownerOp = slice.loadUint(32);
|
|
1546
|
+
const assetAddress = slice.loadAddress();
|
|
1547
|
+
const isWhitelisted = slice.loadBit();
|
|
1548
|
+
const isDepositable = slice.loadBit();
|
|
1549
|
+
const isWithdrawable = slice.loadBit();
|
|
1550
|
+
const exposureCap = slice.loadUint(20);
|
|
1551
|
+
return {
|
|
1552
|
+
op,
|
|
1553
|
+
queryID,
|
|
1554
|
+
ownerOp,
|
|
1555
|
+
assetAddress,
|
|
1556
|
+
isWhitelisted,
|
|
1557
|
+
isDepositable,
|
|
1558
|
+
isWithdrawable,
|
|
1559
|
+
exposureCap,
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
static parseSetFactorialPoolConfigMsgBody(cell) {
|
|
1563
|
+
const slice = cell.beginParse();
|
|
1564
|
+
const op = slice.loadUint(32);
|
|
1565
|
+
const queryID = slice.loadUint(64);
|
|
1566
|
+
const ownerOp = slice.loadUint(32);
|
|
1567
|
+
const updateConfig = slice.loadMaybeRef();
|
|
1568
|
+
return {
|
|
1569
|
+
op,
|
|
1570
|
+
queryID,
|
|
1571
|
+
ownerOp,
|
|
1572
|
+
updateConfig,
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
static parseClaimManagementFeeMsgBody(cell) {
|
|
1576
|
+
const slice = cell.beginParse();
|
|
1577
|
+
const op = slice.loadUint(32);
|
|
1578
|
+
const queryID = slice.loadUint(64);
|
|
1579
|
+
const receiverAddress = slice.loadAddress();
|
|
1580
|
+
return { op, queryID, receiverAddress };
|
|
1581
|
+
}
|
|
1582
|
+
static parseClaimProtocolFeeMsgBody(cell) {
|
|
1583
|
+
const slice = cell.beginParse();
|
|
1584
|
+
const op = slice.loadUint(32);
|
|
1585
|
+
const queryID = slice.loadUint(64);
|
|
1586
|
+
const receiverAddress = slice.loadAddress();
|
|
1587
|
+
return { op, queryID, receiverAddress };
|
|
1588
|
+
}
|
|
1589
|
+
static parseSetOwnerAddressMsgBody(cell) {
|
|
1590
|
+
const slice = cell.beginParse();
|
|
1591
|
+
const op = slice.loadUint(32);
|
|
1592
|
+
const queryID = slice.loadUint(64);
|
|
1593
|
+
const ownerOp = slice.loadUint(32);
|
|
1594
|
+
const newOwner = slice.loadAddress();
|
|
1595
|
+
return {
|
|
1596
|
+
op,
|
|
1597
|
+
queryID,
|
|
1598
|
+
ownerOp,
|
|
1599
|
+
newOwner,
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
static parseSetManagementFeeRatePerYearMsgBody(cell) {
|
|
1603
|
+
const slice = cell.beginParse();
|
|
1604
|
+
const op = slice.loadUint(32);
|
|
1605
|
+
const queryID = slice.loadUint(64);
|
|
1606
|
+
const ownerOp = slice.loadUint(32);
|
|
1607
|
+
const managementFeeRate = slice.loadUint(14);
|
|
1608
|
+
return {
|
|
1609
|
+
op,
|
|
1610
|
+
queryID,
|
|
1611
|
+
ownerOp,
|
|
1612
|
+
managementFeeRate,
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
static parseSetMaxLeverageRatioMsgBody(cell) {
|
|
1616
|
+
const slice = cell.beginParse();
|
|
1617
|
+
const op = slice.loadUint(32);
|
|
1618
|
+
const queryID = slice.loadUint(64);
|
|
1619
|
+
const ownerOp = slice.loadUint(32);
|
|
1620
|
+
const maxLeverageRatio = slice.loadUint(20);
|
|
1621
|
+
return {
|
|
1622
|
+
op,
|
|
1623
|
+
queryID,
|
|
1624
|
+
ownerOp,
|
|
1625
|
+
maxLeverageRatio,
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
static parseSetRFQConfigMsgBody(cell) {
|
|
1629
|
+
const slice = cell.beginParse();
|
|
1630
|
+
const op = slice.loadUint(32);
|
|
1631
|
+
const queryID = slice.loadUint(64);
|
|
1632
|
+
const ownerOp = slice.loadUint(32);
|
|
1633
|
+
const rfqConfig = slice.loadMaybeRef();
|
|
1634
|
+
return {
|
|
1635
|
+
op,
|
|
1636
|
+
queryID,
|
|
1637
|
+
ownerOp,
|
|
1638
|
+
rfqConfig,
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
static parseSetOracleConfigMsgBody(cell) {
|
|
1642
|
+
const slice = cell.beginParse();
|
|
1643
|
+
const op = slice.loadUint(32);
|
|
1644
|
+
const queryID = slice.loadUint(64);
|
|
1645
|
+
const ownerOp = slice.loadUint(32);
|
|
1646
|
+
const oracleConfig = slice.loadMaybeRef();
|
|
1647
|
+
return {
|
|
1648
|
+
op,
|
|
1649
|
+
queryID,
|
|
1650
|
+
ownerOp,
|
|
1651
|
+
oracleConfig,
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
static parseSetWalletCodeMsgBody(cell) {
|
|
1655
|
+
const slice = cell.beginParse();
|
|
1656
|
+
const op = slice.loadUint(32);
|
|
1657
|
+
const queryID = slice.loadUint(64);
|
|
1658
|
+
const ownerOp = slice.loadUint(32);
|
|
1659
|
+
const walletCode = slice.loadRef();
|
|
1660
|
+
return {
|
|
1661
|
+
op,
|
|
1662
|
+
queryID,
|
|
1663
|
+
ownerOp,
|
|
1664
|
+
walletCode,
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
static parseSetDataAggregatorCodeMsgBody(cell) {
|
|
1668
|
+
const slice = cell.beginParse();
|
|
1669
|
+
const op = slice.loadUint(32);
|
|
1670
|
+
const queryID = slice.loadUint(64);
|
|
1671
|
+
const ownerOp = slice.loadUint(32);
|
|
1672
|
+
const dataAggregatorCode = slice.loadRef();
|
|
1673
|
+
return {
|
|
1674
|
+
op,
|
|
1675
|
+
queryID,
|
|
1676
|
+
ownerOp,
|
|
1677
|
+
dataAggregatorCode,
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
static parseSetRFQCodeMsgBody(cell) {
|
|
1681
|
+
const slice = cell.beginParse();
|
|
1682
|
+
const op = slice.loadUint(32);
|
|
1683
|
+
const queryID = slice.loadUint(64);
|
|
1684
|
+
const ownerOp = slice.loadUint(32);
|
|
1685
|
+
const rfqCode = slice.loadRef();
|
|
1686
|
+
return {
|
|
1687
|
+
op,
|
|
1688
|
+
queryID,
|
|
1689
|
+
ownerOp,
|
|
1690
|
+
rfqCode,
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
static parseSetContentMsgBody(cell) {
|
|
1694
|
+
const slice = cell.beginParse();
|
|
1695
|
+
const op = slice.loadUint(32);
|
|
1696
|
+
const queryID = slice.loadUint(64);
|
|
1697
|
+
const ownerOp = slice.loadUint(32);
|
|
1698
|
+
const content = slice.loadRef();
|
|
1699
|
+
return {
|
|
1700
|
+
op,
|
|
1701
|
+
queryID,
|
|
1702
|
+
ownerOp,
|
|
1703
|
+
content,
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
static parseUpgradeCodeMsgBody(cell) {
|
|
1707
|
+
const slice = cell.beginParse();
|
|
1708
|
+
const op = slice.loadUint(32);
|
|
1709
|
+
const queryID = slice.loadUint(64);
|
|
1710
|
+
const ownerOp = slice.loadUint(32);
|
|
1711
|
+
const newCode = slice.loadRef();
|
|
1712
|
+
return {
|
|
1713
|
+
op,
|
|
1714
|
+
queryID,
|
|
1715
|
+
ownerOp,
|
|
1716
|
+
newCode,
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
static parseSetManagerAddressMsgBody(cell) {
|
|
1720
|
+
const slice = cell.beginParse();
|
|
1721
|
+
const op = slice.loadUint(32);
|
|
1722
|
+
const queryID = slice.loadUint(64);
|
|
1723
|
+
const ownerOp = slice.loadUint(32);
|
|
1724
|
+
const managerAddress = slice.loadAddress();
|
|
1725
|
+
return {
|
|
1726
|
+
op,
|
|
1727
|
+
queryID,
|
|
1728
|
+
ownerOp,
|
|
1729
|
+
managerAddress,
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
static parseSetPrivateVaultMsgBody(cell) {
|
|
1733
|
+
const slice = cell.beginParse();
|
|
1734
|
+
const op = slice.loadUint(32);
|
|
1735
|
+
const queryID = slice.loadUint(64);
|
|
1736
|
+
const ownerOp = slice.loadUint(32);
|
|
1737
|
+
const isPrivateVault = slice.loadBit();
|
|
1738
|
+
return {
|
|
1739
|
+
op,
|
|
1740
|
+
queryID,
|
|
1741
|
+
ownerOp,
|
|
1742
|
+
isPrivateVault,
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
static parseSetDepositCloseTimestampMsgBody(cell) {
|
|
1746
|
+
const slice = cell.beginParse();
|
|
1747
|
+
const op = slice.loadUint(32);
|
|
1748
|
+
const queryID = slice.loadUint(64);
|
|
1749
|
+
const ownerOp = slice.loadUint(32);
|
|
1750
|
+
const depositCloseTimestamp = slice.loadCoins();
|
|
1751
|
+
return {
|
|
1752
|
+
op,
|
|
1753
|
+
queryID,
|
|
1754
|
+
ownerOp,
|
|
1755
|
+
depositCloseTimestamp,
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
static parseSetWithdrawOpenTimestampMsgBody(cell) {
|
|
1759
|
+
const slice = cell.beginParse();
|
|
1760
|
+
const op = slice.loadUint(32);
|
|
1761
|
+
const queryID = slice.loadUint(64);
|
|
1762
|
+
const ownerOp = slice.loadUint(32);
|
|
1763
|
+
const withdrawOpenTimestamp = slice.loadCoins();
|
|
1764
|
+
return {
|
|
1765
|
+
op,
|
|
1766
|
+
queryID,
|
|
1767
|
+
ownerOp,
|
|
1768
|
+
withdrawOpenTimestamp,
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
static parseSetWhitelistedMintersMsgBody(cell) {
|
|
1772
|
+
const slice = cell.beginParse();
|
|
1773
|
+
const op = slice.loadUint(32);
|
|
1774
|
+
const queryID = slice.loadUint(64);
|
|
1775
|
+
const ownerOp = slice.loadUint(32);
|
|
1776
|
+
const whitelistedMinters = slice.loadMaybeRef();
|
|
1777
|
+
return {
|
|
1778
|
+
op,
|
|
1779
|
+
queryID,
|
|
1780
|
+
ownerOp,
|
|
1781
|
+
whitelistedMinters,
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
static parseSetGasConfigMsgBody(cell) {
|
|
1785
|
+
const slice = cell.beginParse();
|
|
1786
|
+
const op = slice.loadUint(32);
|
|
1787
|
+
const queryID = slice.loadUint(64);
|
|
1788
|
+
const ownerOp = slice.loadUint(32);
|
|
1789
|
+
const gasConfig = slice.loadMaybeRef();
|
|
1790
|
+
return {
|
|
1791
|
+
op,
|
|
1792
|
+
queryID,
|
|
1793
|
+
ownerOp,
|
|
1794
|
+
gasConfig,
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
static parseExecuteOwnerActionMsgBody(cell) {
|
|
1798
|
+
const slice = cell.beginParse();
|
|
1799
|
+
const op = slice.loadUint(32);
|
|
1800
|
+
const queryID = slice.loadUint(64);
|
|
1801
|
+
const updateIndex = slice.loadCoins();
|
|
1802
|
+
return { op, queryID, updateIndex };
|
|
1803
|
+
}
|
|
1804
|
+
static parseRevertOwnerActionMsgBody(cell) {
|
|
1805
|
+
const slice = cell.beginParse();
|
|
1806
|
+
const op = slice.loadUint(32);
|
|
1807
|
+
const queryID = slice.loadUint(64);
|
|
1808
|
+
const updateIndex = slice.loadCoins();
|
|
1809
|
+
return { op, queryID, updateIndex };
|
|
1810
|
+
}
|
|
1811
|
+
static parseSetGuardianAddressMsgBody(cell) {
|
|
1812
|
+
const slice = cell.beginParse();
|
|
1813
|
+
const op = slice.loadUint(32);
|
|
1814
|
+
const queryID = slice.loadUint(64);
|
|
1815
|
+
const ownerOp = slice.loadUint(32);
|
|
1816
|
+
const guardianAddress = slice.loadAddress();
|
|
1817
|
+
return {
|
|
1818
|
+
op,
|
|
1819
|
+
queryID,
|
|
1820
|
+
ownerOp,
|
|
1821
|
+
guardianAddress,
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
static parseSetTimelockMsgBody(cell) {
|
|
1825
|
+
const slice = cell.beginParse();
|
|
1826
|
+
const op = slice.loadUint(32);
|
|
1827
|
+
const queryID = slice.loadUint(64);
|
|
1828
|
+
const ownerOp = slice.loadUint(32);
|
|
1829
|
+
const timelock = slice.loadCoins();
|
|
1830
|
+
return {
|
|
1831
|
+
op,
|
|
1832
|
+
queryID,
|
|
1833
|
+
ownerOp,
|
|
1834
|
+
timelock,
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
static parseSetManagementFeeRecipientAddressMsgBody(cell) {
|
|
1838
|
+
const slice = cell.beginParse();
|
|
1839
|
+
const op = slice.loadUint(32);
|
|
1840
|
+
const queryID = slice.loadUint(64);
|
|
1841
|
+
const ownerOp = slice.loadUint(32);
|
|
1842
|
+
const managementFeeRecipientAddress = slice.loadAddress();
|
|
1843
|
+
return {
|
|
1844
|
+
op,
|
|
1845
|
+
queryID,
|
|
1846
|
+
ownerOp,
|
|
1847
|
+
managementFeeRecipientAddress,
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
static parseSetProtocolFeeRatePerYearMsgBody(cell) {
|
|
1851
|
+
const slice = cell.beginParse();
|
|
1852
|
+
const op = slice.loadUint(32);
|
|
1853
|
+
const queryID = slice.loadUint(64);
|
|
1854
|
+
const protocolFeeRate = slice.loadUint(14);
|
|
1855
|
+
return { op, queryID, protocolFeeRate };
|
|
1856
|
+
}
|
|
1857
|
+
static parseSetProtocolFeeManagerAddressMsgBody(cell) {
|
|
1858
|
+
const slice = cell.beginParse();
|
|
1859
|
+
const op = slice.loadUint(32);
|
|
1860
|
+
const queryID = slice.loadUint(64);
|
|
1861
|
+
const protocolFeeManagerAddress = slice.loadAddress();
|
|
1862
|
+
return { op, queryID, protocolFeeManagerAddress };
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
exports.StrategyVault = StrategyVault;
|