@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.
Files changed (104) hide show
  1. package/dist/build/Account.compiled.json +1 -0
  2. package/dist/build/Receipt.compiled.json +1 -0
  3. package/dist/build/WTONWallet.compiled.json +1 -0
  4. package/dist/common/cache.d.ts +16 -0
  5. package/dist/common/cache.js +96 -0
  6. package/dist/common/service.d.ts +20 -0
  7. package/dist/common/service.js +69 -0
  8. package/dist/common/type.d.ts +14 -0
  9. package/dist/common/type.js +2 -0
  10. package/dist/common/unknown-contract.d.ts +14 -0
  11. package/dist/common/unknown-contract.js +18 -0
  12. package/dist/common/versions.d.ts +14 -0
  13. package/dist/common/versions.js +22 -0
  14. package/dist/constants/pool.d.ts +1 -0
  15. package/dist/constants/pool.js +2 -0
  16. package/dist/contracts/_mock/simple-oracle.d.ts +34 -0
  17. package/dist/contracts/_mock/simple-oracle.js +73 -0
  18. package/dist/contracts/vault/share-vault/type.d.ts +30 -0
  19. package/dist/contracts/vault/share-vault/type.js +2 -0
  20. package/dist/contracts/vault/strategy-vault/utils.d.ts +6 -0
  21. package/dist/contracts/vault/strategy-vault/utils.js +32 -0
  22. package/dist/factorial.d.ts +14 -0
  23. package/dist/factorial.js +20 -0
  24. package/dist/farm.d.ts +92 -0
  25. package/dist/farm.js +209 -0
  26. package/dist/monitor.d.ts +57 -0
  27. package/dist/monitor.js +527 -0
  28. package/dist/monitorCacheV1.d.ts +52 -0
  29. package/dist/monitorCacheV1.js +504 -0
  30. package/dist/oracle/oracle-v2.d.ts +39 -0
  31. package/dist/oracle/oracle-v2.js +151 -0
  32. package/dist/oracle/oracle.d.ts +107 -0
  33. package/dist/oracle/oracle.js +392 -0
  34. package/dist/periphery.d.ts +259 -0
  35. package/dist/periphery.js +1087 -0
  36. package/dist/pool.d.ts +216 -0
  37. package/dist/pool.js +2298 -0
  38. package/dist/poolCacheV1.d.ts +139 -0
  39. package/dist/poolCacheV1.js +1841 -0
  40. package/dist/rfq-auction.d.ts +75 -0
  41. package/dist/rfq-auction.js +220 -0
  42. package/dist/rfq-batch.d.ts +112 -0
  43. package/dist/rfq-batch.js +284 -0
  44. package/dist/services/share-vault/computation.d.ts +14 -17
  45. package/dist/services/share-vault/computation.js +39 -0
  46. package/dist/services/share-vault/index.js +6 -3
  47. package/dist/services/share-vault/query.d.ts +38 -8
  48. package/dist/services/share-vault/query.js +20 -27
  49. package/dist/services/share-vault/type.d.ts +19 -0
  50. package/dist/services/share-vault/type.js +2 -0
  51. package/dist/services/share-vault/user/index.js +3 -1
  52. package/dist/services/strategy-vault/computation.d.ts +1 -0
  53. package/dist/services/strategy-vault/computation.js +15 -0
  54. package/dist/services/strategy-vault/query.d.ts +147 -0
  55. package/dist/services/strategy-vault/query.js +67 -0
  56. package/dist/services/strategy-vault/type.d.ts +2 -0
  57. package/dist/services/strategy-vault/type.js +2 -0
  58. package/dist/share-vault.d.ts +91 -0
  59. package/dist/share-vault.js +747 -0
  60. package/dist/stonfi.d.ts +18 -0
  61. package/dist/stonfi.js +76 -0
  62. package/dist/strategy_vault/base.d.ts +399 -0
  63. package/dist/strategy_vault/base.js +1199 -0
  64. package/dist/strategy_vault/index.d.ts +3 -0
  65. package/dist/strategy_vault/index.js +7 -0
  66. package/dist/strategy_vault/steps.d.ts +49 -0
  67. package/dist/strategy_vault/steps.js +170 -0
  68. package/dist/types/action.d.ts +55 -0
  69. package/dist/types/action.js +2 -0
  70. package/dist/types/messages.d.ts +7 -0
  71. package/dist/types/messages.js +2 -0
  72. package/dist/types/params.d.ts +19 -0
  73. package/dist/types/params.js +2 -0
  74. package/dist/types/pool.d.ts +83 -0
  75. package/dist/types/pool.js +2 -0
  76. package/dist/types/transaction.d.ts +40 -0
  77. package/dist/types/transaction.js +2 -0
  78. package/dist/utils/_parse_temp/JumpIRM.d.ts +37 -0
  79. package/dist/utils/_parse_temp/JumpIRM.js +71 -0
  80. package/dist/utils/_parse_temp/Pool.d.ts +559 -0
  81. package/dist/utils/_parse_temp/Pool.js +1023 -0
  82. package/dist/utils/_parse_temp/ShareVault.d.ts +264 -0
  83. package/dist/utils/_parse_temp/ShareVault.js +479 -0
  84. package/dist/utils/_parse_temp/StrategyVault.d.ts +729 -0
  85. package/dist/utils/_parse_temp/StrategyVault.js +1865 -0
  86. package/dist/utils/_parse_temp/parseMsgBody.d.ts +13 -0
  87. package/dist/utils/_parse_temp/parseMsgBody.js +313 -0
  88. package/dist/utils/assert.d.ts +1 -0
  89. package/dist/utils/assert.js +9 -0
  90. package/dist/utils/client-for-parameter.d.ts +12 -0
  91. package/dist/utils/client-for-parameter.js +97 -0
  92. package/dist/utils/oracle/index.d.ts +4 -0
  93. package/dist/utils/oracle/index.js +19 -0
  94. package/dist/utils/oracle/redstone/helper.d.ts +22 -0
  95. package/dist/utils/oracle/redstone/helper.js +186 -0
  96. package/dist/utils/tracer.d.ts +13 -0
  97. package/dist/utils/tracer.js +137 -0
  98. package/dist/utils/tracker/index.d.ts +5 -0
  99. package/dist/utils/tracker/index.js +118 -0
  100. package/dist/utils/tracker/query-id-generactor.d.ts +2 -0
  101. package/dist/utils/tracker/query-id-generactor.js +12 -0
  102. package/dist/utils/tracker/type.d.ts +34 -0
  103. package/dist/utils/tracker/type.js +2 -0
  104. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ import { StrategyVaultSteps } from "./steps";
2
+ export declare class StrategyVaultV1 extends StrategyVaultSteps {
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StrategyVaultV1 = void 0;
4
+ const steps_1 = require("./steps");
5
+ class StrategyVaultV1 extends steps_1.StrategyVaultSteps {
6
+ }
7
+ exports.StrategyVaultV1 = StrategyVaultV1;
@@ -0,0 +1,49 @@
1
+ import { Address, Sender } from "@ton/core";
2
+ import { AddressLike } from "../contracts/common/type";
3
+ import { StrategyVaultBase } from "./base";
4
+ import { TxCallBackFn, TxStep } from "../utils/tracker/type";
5
+ export declare class StrategyVaultSteps extends StrategyVaultBase {
6
+ sendDepositAssetAndWait(sender: Sender, params: {
7
+ strategyVaultAddress: AddressLike;
8
+ assetAddress: AddressLike;
9
+ amount: bigint;
10
+ queryID?: bigint;
11
+ }, callbackFn?: TxCallBackFn, value?: bigint): Promise<{
12
+ action: {
13
+ type: string;
14
+ params: {
15
+ strategyVaultAddress: AddressLike;
16
+ assetAddress: AddressLike;
17
+ amount: bigint;
18
+ queryID?: bigint;
19
+ };
20
+ queryId: bigint;
21
+ };
22
+ steps: TxStep[];
23
+ }>;
24
+ sendBurnVaultAssetAndWait(sender: Sender, params: {
25
+ strategyVaultAddress: AddressLike;
26
+ withdrawAssetAddress: AddressLike;
27
+ vaultShareAmountForBurn: bigint;
28
+ queryID?: bigint;
29
+ }, callbackFn?: TxCallBackFn, value?: bigint): Promise<{
30
+ action: {
31
+ type: string;
32
+ params: {
33
+ strategyVaultAddress: AddressLike;
34
+ withdrawAssetAddress: AddressLike;
35
+ vaultShareAmountForBurn: bigint;
36
+ queryID?: bigint;
37
+ };
38
+ queryId: bigint;
39
+ };
40
+ steps: TxStep[];
41
+ }>;
42
+ findAndCallback(target: Address, step: TxStep, createdLt: string | bigint, callbackFn?: TxCallBackFn): Promise<import("../utils/tracker/type").MatchedTxResult>;
43
+ buildFullSteps(startAddress: Address, queryId: bigint, steps: TxStep[]): TxStep[];
44
+ processingSteps(startAddress: Address, queryId: bigint, steps: ({
45
+ description: string;
46
+ opcode: number;
47
+ to: Address;
48
+ } | TxStep)[], callbackFn?: TxCallBackFn): Promise<void>;
49
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StrategyVaultSteps = void 0;
4
+ const utils_1 = require("../contracts/common/utils");
5
+ const jetton_minter_1 = require("../contracts/jetton/jetton-minter");
6
+ const base_1 = require("./base");
7
+ const jetton_wallet_1 = require("../contracts/jetton/jetton-wallet");
8
+ const parser_1 = require("../utils/parser");
9
+ const tracker_1 = require("../utils/tracker");
10
+ const jetton_minter_2 = require("../contracts/wton/jetton-minter");
11
+ const jetton_wallet_2 = require("../contracts/wton/jetton-wallet");
12
+ class StrategyVaultSteps extends base_1.StrategyVaultBase {
13
+ async sendDepositAssetAndWait(sender, params, callbackFn, value) {
14
+ const requesterAddress = sender.address;
15
+ const vault = this.getVault(params.strategyVaultAddress);
16
+ const assetAddress = (0, utils_1.toAddress)(params.assetAddress);
17
+ const isWTONDeposit = assetAddress.toString() === (0, utils_1.toAddress)(this.contracts.WTON).toString();
18
+ ////////////////////////// tx //////////////////////////
19
+ const opts = await this.sendDepositAsset(sender, params, value);
20
+ const stepInfo = [];
21
+ if (isWTONDeposit) {
22
+ const wtonMaster = this.getByContract(jetton_minter_2.WTONMinter, assetAddress);
23
+ stepInfo.push({
24
+ description: "Supplying Ton to the StrategyVault",
25
+ to: await wtonMaster.getWalletAddress(vault.address),
26
+ opcode: jetton_wallet_2.WTONWallet.Op.ExternalTransfer,
27
+ });
28
+ }
29
+ else {
30
+ const asset = this.getByContract(jetton_minter_1.JettonMinter, assetAddress);
31
+ stepInfo.push({
32
+ description: "Sending the tx",
33
+ to: await asset.getWalletAddress(sender.address),
34
+ opcode: jetton_wallet_1.JettonWallet.Op.Transfer,
35
+ }, {
36
+ description: "Supplying jetton to the StrategyVault",
37
+ to: await asset.getWalletAddress(vault.address),
38
+ opcode: jetton_wallet_1.JettonWallet.Op.InternalTransfer,
39
+ });
40
+ }
41
+ ////////////////////////// steps //////////////////////////
42
+ stepInfo.push({
43
+ description: "StrategyVault action notification",
44
+ to: vault.address,
45
+ opcode: jetton_wallet_1.JettonWallet.Op.TransferNotification,
46
+ }, {
47
+ description: "Mint StrategyVault jetton",
48
+ to: await vault.getWalletAddress(sender.address),
49
+ opcode: jetton_wallet_1.JettonWallet.Op.InternalTransfer,
50
+ }, {
51
+ description: "Excesses StrategyVault jetton mint",
52
+ to: opts.response,
53
+ opcode: jetton_wallet_1.JettonWallet.Op.Excesses,
54
+ });
55
+ const fullSteps = this.buildFullSteps(requesterAddress, opts.queryId, stepInfo);
56
+ this.processingSteps(requesterAddress, opts.queryId, fullSteps, callbackFn);
57
+ return {
58
+ action: {
59
+ type: "strategy_vault-supply",
60
+ params,
61
+ queryId: opts.queryId,
62
+ },
63
+ steps: fullSteps,
64
+ };
65
+ }
66
+ async sendBurnVaultAssetAndWait(sender, params, callbackFn, value) {
67
+ const opts = await this.sendBurnVaultAsset(sender, params, value);
68
+ const requesterAddress = sender.address;
69
+ const vault = this.getVault(params.strategyVaultAddress);
70
+ const isWTON = params.withdrawAssetAddress.toString() === this.contracts.WTON
71
+ ? true
72
+ : false;
73
+ const stepInfo = [];
74
+ stepInfo.push({
75
+ description: "Sending the Burn tx",
76
+ to: await vault.getWalletAddress(sender.address),
77
+ opcode: jetton_wallet_1.JettonWallet.Op.Burn,
78
+ }, {
79
+ description: "Notify StrategyVault Token Burn",
80
+ to: vault.address,
81
+ opcode: jetton_wallet_1.JettonWallet.Op.BurnNotification,
82
+ });
83
+ if (isWTON) {
84
+ const wton = this.getByContract(jetton_minter_2.WTONMinter, params.withdrawAssetAddress);
85
+ stepInfo.push({
86
+ description: "Withdraw WTON",
87
+ to: await wton.getWalletAddress(vault.address),
88
+ opcode: jetton_wallet_2.WTONWallet.Op.Transfer,
89
+ }, {
90
+ description: "Transfer WTON Asset",
91
+ to: await wton.getWalletAddress(sender.address),
92
+ opcode: jetton_wallet_2.WTONWallet.Op.InternalTransfer,
93
+ }, {
94
+ description: "Unwrap WTON",
95
+ to: sender.address,
96
+ opcode: jetton_wallet_2.WTONWallet.Op.UnwrapNotification,
97
+ });
98
+ }
99
+ else {
100
+ const asset = this.getByContract(jetton_minter_1.JettonMinter, params.withdrawAssetAddress);
101
+ stepInfo.push({
102
+ description: "Withdraw Asset",
103
+ to: await asset.getWalletAddress(vault.address),
104
+ opcode: jetton_wallet_1.JettonWallet.Op.Transfer,
105
+ }, {
106
+ description: "Transfer Withdraw Asset",
107
+ to: await asset.getWalletAddress(sender.address),
108
+ opcode: jetton_wallet_1.JettonWallet.Op.InternalTransfer,
109
+ }, {
110
+ description: "Excesses StrategyVault withdraw",
111
+ to: opts.response,
112
+ opcode: jetton_wallet_1.JettonWallet.Op.Excesses,
113
+ });
114
+ }
115
+ const fullSteps = this.buildFullSteps(requesterAddress, opts.queryId, stepInfo);
116
+ this.processingSteps(requesterAddress, opts.queryId, fullSteps, callbackFn);
117
+ return {
118
+ action: {
119
+ type: "strategy_vault-withdraw",
120
+ params,
121
+ queryId: opts.queryId,
122
+ },
123
+ steps: fullSteps,
124
+ };
125
+ }
126
+ async findAndCallback(target, step, createdLt, callbackFn) {
127
+ const matchedTx = await (0, tracker_1.findTx)(this.client, (0, utils_1.toAddress)(target), createdLt.toString(), step);
128
+ step.matchedTx = matchedTx;
129
+ if (matchedTx.inMessage?.body) {
130
+ const parsed = (0, parser_1.parseActionNotification)(matchedTx.inMessage.body);
131
+ if (parsed) {
132
+ step.actionNotificationResult = parsed;
133
+ }
134
+ }
135
+ if (callbackFn)
136
+ callbackFn(step);
137
+ return matchedTx;
138
+ }
139
+ buildFullSteps(startAddress, queryId, steps) {
140
+ const result = [];
141
+ let currentFrom = startAddress;
142
+ for (const step of steps) {
143
+ const fullStep = {
144
+ queryId,
145
+ description: step.description,
146
+ opcode: step.opcode,
147
+ from: currentFrom,
148
+ to: step.to,
149
+ };
150
+ result.push(fullStep);
151
+ currentFrom = step.to;
152
+ }
153
+ return result;
154
+ }
155
+ async processingSteps(startAddress, queryId, steps, callbackFn) {
156
+ let prevLt = "0";
157
+ let currentAddress = startAddress;
158
+ for (const step of steps) {
159
+ const enrichedStep = {
160
+ ...step,
161
+ queryId,
162
+ from: currentAddress,
163
+ };
164
+ const matchedTx = await this.findAndCallback(currentAddress, enrichedStep, prevLt, callbackFn);
165
+ currentAddress = step.to;
166
+ prevLt = matchedTx.lt.toString();
167
+ }
168
+ }
169
+ }
170
+ exports.StrategyVaultSteps = StrategyVaultSteps;
@@ -0,0 +1,55 @@
1
+ import { Address } from "@ton/ton";
2
+ export type TransferInActionParams = {
3
+ sender: Address | string;
4
+ pool: Address | string;
5
+ asset: Address | string;
6
+ amount: bigint;
7
+ recipient: Address | string;
8
+ response: Address | string;
9
+ };
10
+ export type TansferOutActionParams = {
11
+ sender: Address | string;
12
+ pool: Address | string;
13
+ asset: Address | string;
14
+ isShare: boolean;
15
+ amount: bigint;
16
+ recipient: Address | string;
17
+ response: Address | string;
18
+ };
19
+ export type LiquidateActionParams = {
20
+ sender: Address | string;
21
+ pool: Address | string;
22
+ repayAsset: Address | string;
23
+ seizeAsset: Address | string;
24
+ borrower: Address | string;
25
+ amount: bigint;
26
+ response: Address | string;
27
+ };
28
+ export type HealthCheckParams = {
29
+ pool: Address | string;
30
+ borrower: Address | string;
31
+ };
32
+ export type ShareVaultUserActionParams = {
33
+ sender: Address | string;
34
+ vault: Address | string;
35
+ amount: bigint;
36
+ response: Address | string;
37
+ };
38
+ export type ShareVaultManagerSupplyAction = {
39
+ sender: Address | string;
40
+ vault: Address | string;
41
+ pool: Address | string;
42
+ amount: bigint;
43
+ };
44
+ export type ShareVaultManagerWithdrawAction = {
45
+ sender: Address | string;
46
+ vault: Address | string;
47
+ pool: Address | string;
48
+ amount: bigint;
49
+ isShare: boolean;
50
+ };
51
+ export type ShareVaultManagerSetTargetWeightAction = {
52
+ vault: Address | string;
53
+ pool: Address | string;
54
+ targetWeight: number;
55
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { Address, Cell, internal } from "@ton/core";
2
+ export type InternalInput = Promise<Parameters<typeof internal>[0]>;
3
+ export type InternalMessageInput = {
4
+ to: Address;
5
+ value: bigint;
6
+ body: Cell;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { Address } from "@ton/core";
2
+ export type Hex = `0x${string}`;
3
+ export type UnderlyingAssetOracleConfig = {
4
+ type: "underlying";
5
+ assetAddress: Address;
6
+ decimal: bigint;
7
+ };
8
+ export type SynthAssetOracleConfig = {
9
+ type: "synth";
10
+ assetAddress: Address;
11
+ underlyingAddress: Address;
12
+ decimal: bigint;
13
+ };
14
+ export type AssetOracleConfigParams = Record<string, UnderlyingAssetOracleConfig | SynthAssetOracleConfig>;
15
+ export type OracleConfigParams = {
16
+ assetConfig: AssetOracleConfigParams;
17
+ signerThreshold: bigint;
18
+ signers: Hex[];
19
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,83 @@
1
+ import { Address, BitString, Cell, Dictionary } from "@ton/ton";
2
+ export type Maybe<T> = T | null | undefined;
3
+ export type PoolConfig = {
4
+ feeConfigurer: Address;
5
+ owner: Address;
6
+ router: Address;
7
+ oracle: Address;
8
+ plugins: Dictionary<Address, Boolean>;
9
+ assets: Dictionary<Address, BitString>;
10
+ accountCode: Cell;
11
+ };
12
+ export type AssetConfig = {
13
+ wallet?: Address;
14
+ irm?: Address;
15
+ irmData: Cell;
16
+ ltv: number;
17
+ lltv: number;
18
+ lir: number;
19
+ isBorrowable: number;
20
+ };
21
+ export type ActionGasFee = {
22
+ supply: bigint;
23
+ withdraw: bigint;
24
+ borrow: bigint;
25
+ repay: bigint;
26
+ liquidate: bigint;
27
+ };
28
+ export type ActionParams = {
29
+ pool: Address;
30
+ queryId?: number;
31
+ deadline?: number;
32
+ };
33
+ export type SupplyParams = ActionParams & {
34
+ asset: Address;
35
+ amount: bigint;
36
+ recipient?: Address;
37
+ };
38
+ export type WithdrawParams = ActionParams & {
39
+ asset: Address;
40
+ amount: bigint;
41
+ isShare: boolean;
42
+ useOracle: boolean;
43
+ recipient?: Address;
44
+ };
45
+ export type BorrowParams = ActionParams & {
46
+ asset: Address;
47
+ amount: bigint;
48
+ isShare: boolean;
49
+ recipient?: Address;
50
+ };
51
+ export type RepayParams = ActionParams & {
52
+ asset: Address;
53
+ amount: bigint;
54
+ recipient?: Address;
55
+ };
56
+ export type LiquidateParams = ActionParams & {
57
+ repayAsset: Address;
58
+ seizeAsset: Address;
59
+ borrower: Address;
60
+ oracleParams: Cell;
61
+ };
62
+ export type RiskResult = {
63
+ result: boolean;
64
+ healthy: boolean;
65
+ unhealthy: boolean;
66
+ collateral: bigint;
67
+ debt: bigint;
68
+ risk: bigint;
69
+ riskRatio: bigint;
70
+ leverageRatio: bigint;
71
+ };
72
+ export type MaxBorrowableResult = {
73
+ amount: bigint;
74
+ reason: "RISK_RATIO_CONSTRAINT" | "LEVERAGE_CONSTRAINT" | "POOL_CASH_CONSTRAINT";
75
+ beforeAccountHealth: RiskResult;
76
+ afterAccountHealth: RiskResult;
77
+ };
78
+ export type MaxWithdrawableResult = {
79
+ amount: bigint;
80
+ reason: "RISK_RATIO_CONSTRAINT" | "LEVERAGE_CONSTRAINT" | "POOL_CASH_CONSTRAINT" | "USER_SUPPLY_CONSTRAINT";
81
+ beforeAccountHealth?: RiskResult;
82
+ afterAccountHealth?: RiskResult;
83
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ import { Address } from "@ton/ton";
2
+ export type ActionSuccessTransaciton = {
3
+ op: number;
4
+ queryId: number;
5
+ sender: Address;
6
+ opType: "supply" | "withdraw" | "borrow" | "repay" | "liquidate";
7
+ };
8
+ export type SupplySuccessTransaction = ActionSuccessTransaciton & {
9
+ opType: "supply";
10
+ asset: Address;
11
+ supplyAmount: bigint;
12
+ supplyShare: bigint;
13
+ };
14
+ export type WithdrawSuccessTransaction = ActionSuccessTransaciton & {
15
+ opType: "withdraw";
16
+ asset: Address;
17
+ withdrawAmount: bigint;
18
+ withdrawShare: bigint;
19
+ };
20
+ export type BorrowSuccessTransaction = ActionSuccessTransaciton & {
21
+ opType: "borrow";
22
+ asset: Address;
23
+ borrowAmount: bigint;
24
+ borrowShare: bigint;
25
+ };
26
+ export type RepaySuccessTransaction = ActionSuccessTransaciton & {
27
+ opType: "repay";
28
+ asset: Address;
29
+ repayAmount: bigint;
30
+ repayShare: bigint;
31
+ overRepaidAmount: bigint;
32
+ };
33
+ export type LiquidateSuccessTransaction = ActionSuccessTransaciton & {
34
+ opType: "liquidate";
35
+ repayAsset: Address;
36
+ seizeAsset: Address;
37
+ repayAmount: bigint;
38
+ repayShare: bigint;
39
+ seizeShare: bigint;
40
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import { Address, Cell, Contract, ContractProvider, Sender } from '@ton/core';
2
+ export type JumpIRMConfig = {
3
+ owner: Address;
4
+ };
5
+ export type JumpIRMParams = {
6
+ baseRate: bigint;
7
+ kinkLow: number;
8
+ kinkHigh: number;
9
+ slopeLow: bigint;
10
+ slopeMedium: bigint;
11
+ slopeHigh: bigint;
12
+ };
13
+ export declare function jumpIRMConfigToCell(config: JumpIRMConfig): Cell;
14
+ export declare class JumpIRM implements Contract {
15
+ readonly address: Address;
16
+ readonly init?: {
17
+ code: Cell;
18
+ data: Cell;
19
+ } | undefined;
20
+ constructor(address: Address, init?: {
21
+ code: Cell;
22
+ data: Cell;
23
+ } | undefined);
24
+ static createFromAddress(address: Address): JumpIRM;
25
+ static createFromConfig(config: JumpIRMConfig, code: Cell, workchain?: number): JumpIRM;
26
+ static createJumpIRMConfig(params: JumpIRMParams): Cell;
27
+ static parseJumpIRMConfig(cell: Cell): {
28
+ baseRate: bigint;
29
+ kinkLow: number;
30
+ kinkHigh: number;
31
+ slopeLow: bigint;
32
+ slopeMedium: bigint;
33
+ slopeHigh: bigint;
34
+ };
35
+ sendDeploy(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
36
+ getInterestRate(provider: ContractProvider, supply: bigint, borrow: bigint, cell: Cell): Promise<bigint>;
37
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JumpIRM = void 0;
4
+ exports.jumpIRMConfigToCell = jumpIRMConfigToCell;
5
+ const core_1 = require("@ton/core");
6
+ function jumpIRMConfigToCell(config) {
7
+ return (0, core_1.beginCell)()
8
+ .storeAddress(config.owner)
9
+ .endCell();
10
+ }
11
+ class JumpIRM {
12
+ address;
13
+ init;
14
+ constructor(address, init) {
15
+ this.address = address;
16
+ this.init = init;
17
+ }
18
+ static createFromAddress(address) {
19
+ return new JumpIRM(address);
20
+ }
21
+ static createFromConfig(config, code, workchain = 0) {
22
+ const data = jumpIRMConfigToCell(config);
23
+ const init = { code, data };
24
+ return new JumpIRM((0, core_1.contractAddress)(workchain, init), init);
25
+ }
26
+ static createJumpIRMConfig(params) {
27
+ return (0, core_1.beginCell)()
28
+ .storeCoins(params.baseRate)
29
+ .storeUint(params.kinkLow, 14)
30
+ .storeUint(params.kinkHigh, 14)
31
+ .storeCoins(params.slopeLow)
32
+ .storeCoins(params.slopeMedium)
33
+ .storeCoins(params.slopeHigh)
34
+ .endCell();
35
+ }
36
+ static parseJumpIRMConfig(cell) {
37
+ const result = cell.beginParse();
38
+ const baseRate = result.loadCoins();
39
+ const kinkLow = result.loadUint(14);
40
+ const kinkHigh = result.loadUint(14);
41
+ const slopeLow = result.loadCoins();
42
+ const slopeMedium = result.loadCoins();
43
+ const slopeHigh = result.loadCoins();
44
+ return {
45
+ baseRate,
46
+ kinkLow,
47
+ kinkHigh,
48
+ slopeLow,
49
+ slopeMedium,
50
+ slopeHigh,
51
+ };
52
+ }
53
+ async sendDeploy(provider, via, value) {
54
+ await provider.internal(via, {
55
+ value,
56
+ sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
57
+ body: (0, core_1.beginCell)().endCell(),
58
+ });
59
+ }
60
+ async getInterestRate(provider, supply, borrow, cell) {
61
+ const _supply = { type: 'int', value: supply };
62
+ const _borrow = { type: 'int', value: borrow };
63
+ const tic = {
64
+ type: 'cell',
65
+ cell: cell,
66
+ };
67
+ const result = await provider.get('get_interest_rate', [_supply, _borrow, tic]);
68
+ return result.stack.readBigNumber();
69
+ }
70
+ }
71
+ exports.JumpIRM = JumpIRM;