Browse Source

Staking, foundation

master
Lev 2 years ago
parent
commit
7e4ffe0ac5
  1. 49
      sources/foundation.tact
  2. 1
      sources/jetton.tact
  3. 4
      sources/jetton_trait.tact
  4. 12
      sources/messages.tact
  5. 2
      sources/output/jetton_Linker.abi
  6. 2
      sources/output/jetton_Linker.code.fc
  7. 2
      sources/output/jetton_Linker.code.fif
  8. 14
      sources/output/jetton_Linker.md
  9. 2
      sources/output/jetton_Linker.pkg
  10. 124
      sources/output/jetton_Linker.ts
  11. 2
      sources/output/jetton_PseudoStaking.abi
  12. BIN
      sources/output/jetton_PseudoStaking.code.boc
  13. 12
      sources/output/jetton_PseudoStaking.code.fc
  14. 44
      sources/output/jetton_PseudoStaking.code.fif
  15. 90
      sources/output/jetton_PseudoStaking.code.rev.fif
  16. 16
      sources/output/jetton_PseudoStaking.md
  17. 2
      sources/output/jetton_PseudoStaking.pkg
  18. 128
      sources/output/jetton_PseudoStaking.ts
  19. 2
      sources/output/jetton_TONB.abi
  20. BIN
      sources/output/jetton_TONB.code.boc
  21. 50
      sources/output/jetton_TONB.code.fc
  22. 92
      sources/output/jetton_TONB.code.fif
  23. 868
      sources/output/jetton_TONB.code.rev.fif
  24. 16
      sources/output/jetton_TONB.md
  25. 2
      sources/output/jetton_TONB.pkg
  26. 133
      sources/output/jetton_TONB.ts
  27. 2
      sources/output/jetton_TONBWallet.abi
  28. 2
      sources/output/jetton_TONBWallet.code.fc
  29. 2
      sources/output/jetton_TONBWallet.code.fif
  30. 14
      sources/output/jetton_TONBWallet.md
  31. 2
      sources/output/jetton_TONBWallet.pkg
  32. 124
      sources/output/jetton_TONBWallet.ts
  33. 4218
      sources/output/types.json
  34. 10
      sources/pseudostaking.tact
  35. 22
      sources/staking.tact
  36. 36
      sources/tests/__snapshots__/jetton.spec.ts.snap
  37. 11
      sources/tests/jetton.spec.ts
  38. 11
      sources/utils/compile_types.py

49
sources/foundation.tact

@ -33,6 +33,7 @@ contract Foundation {
admins: Distribution/* Distribution is defined in messages.tact */;
tonb: Address;
votes: map[Int]Vote;
profits: map[Address]Int;
n_votes: Int;
init(admins: Distribution, founders: AddressList, tonb: Address) {
@ -177,4 +178,52 @@ contract Foundation {
self.votes.set(self.n_votes, vote);
self.n_votes = self.n_votes + 1;
}
receive(msg: Unstake /* staking profits */) {
// If this is sent by TONB, it means that this is receiving stake profits
let ctx: Context = context();
if (ctx.sender == self.tonb) {
let value: Int = ctx.value;
let i: Int = 0;
while (i < self.admins.addresses.length) {
let addr: Address = self.admins.addresses.addresses.get(i)!!;
let percent: Int = self.admins.percents.percents.get(i)!!;
let amount: Int = value * percent / 100;
// todo: record the profit
let current_profit: Int = 0;
let profit_record: Int? = self.profits.get(addr);
if (profit_record != null) {
current_profit = profit_record!!;
}
self.profits.set(addr, current_profit + amount);
i = i + 1;
}
}
}
receive(msg: RequestUnstake) {
// If this is sent by one of the founders, it means that the user wants to unstake
let ctx: Context = context();
require(self.founders.get(msg.founderIndex) == ctx.sender, "Only a founder can request unstake");
send(SendParameters{
to: self.tonb,
value: msg.amount,
mode: SendRemainingValue,
body: Unstake { amount: 0 }.toCell()
});
}
receive(msg: CollectProfit) {
let ctx: Context = context();
require(self.admins.addresses.addresses.get(msg.adminIndex) == ctx.sender, "Only an admin can collect profit");
let profit: Int? = self.profits.get(ctx.sender);
require(profit != null, "No profit to collect");
let amount: Int = profit!!;
self.profits.set(ctx.sender, 0);
send(SendParameters{
to: ctx.sender,
value: amount - withdraw_gas_consumption,
mode: SendRemainingValue
});
}
}

1
sources/jetton.tact

@ -29,7 +29,6 @@ contract TONB with TONBTrait {
staking_pool: Address?;
in_the_pool: Int = 0;
withdrawal_requests: WithdrawalRequests;
requested_withdrawal: Int = 0;
init(owner: Address, content: Cell?, staking_pool: Address?) {
self.totalSupply = 0;

4
sources/jetton_trait.tact

@ -23,8 +23,6 @@ trait TONBTrait with Ownable, StakingTrait {
staking_pool: Address?;
in_the_pool: Int = 0;
withdrawal_requests: WithdrawalRequests;
requested_withdrawal: Int = 0;
//
// Receivers
@ -52,7 +50,7 @@ trait TONBTrait with Ownable, StakingTrait {
let diff: Int = msg.amount - available;
send(SendParameters{
to: msg.owner,
value: myBalance() - tonb_floor,
value: myBalance() - tonb_floor - withdraw_gas_consumption,
bounce: false
});
let body: Cell = TokenTransferInternal{

12
sources/messages.tact

@ -134,3 +134,15 @@ message SetStakingPool {
message RequestLinker {
client: Address;
}
message Unstake {
amount: Int;
}
message RequestUnstake {
founderIndex: Int;
}
message CollectProfit {
adminIndex: Int;
}

2
sources/output/jetton_Linker.abi

File diff suppressed because one or more lines are too long

2
sources/output/jetton_Linker.code.fc

@ -229,5 +229,5 @@ _ supported_interfaces() method_id {
}
_ get_abi_ipfs() {
return "ipfs://QmUSvHrma2CS7pvfxCP2ZnYPCvVGM3Z1FstSNW6u8M2T4h";
return "ipfs://QmeGA7QUi3FCDzQtd9VhqDi1VpHx2sbycwoWaDsMsQNDS3";
}

2
sources/output/jetton_Linker.code.fif

@ -354,6 +354,6 @@ PROGRAM{
209801025412363888721030803524359905849 PUSHINT
}>
get_abi_ipfs PROC:<{
x{697066733a2f2f516d55537648726d6132435337707666784350325a6e5950437656474d335a31467374534e573675384d32543468} PUSHSLICE
x{697066733a2f2f516d65474137515569334643447a51746439566871446931567048783273627963776f576144734d73514e445333} PUSHSLICE
}>
}END>c

14
sources/output/jetton_Linker.md

@ -3,7 +3,7 @@ Contract: Linker
BOC Size: 645 bytes
# Types
Total Types: 30
Total Types: 33
## StateInit
TLB: `_ code:^cell data:^cell = StateInit`
@ -109,6 +109,18 @@ Signature: `SetStakingPool{staking_pool:Maybe address}`
TLB: `request_linker#5a29431e client:address = RequestLinker`
Signature: `RequestLinker{client:address}`
## Unstake
TLB: `unstake#ba522821 amount:int257 = Unstake`
Signature: `Unstake{amount:int257}`
## RequestUnstake
TLB: `request_unstake#e9cedf7f founderIndex:int257 = RequestUnstake`
Signature: `RequestUnstake{founderIndex:int257}`
## CollectProfit
TLB: `collect_profit#51912735 adminIndex:int257 = CollectProfit`
Signature: `CollectProfit{adminIndex:int257}`
## WithdrawalRequests
TLB: `_ addresses:dict<int, address> amounts:dict<int, int> n_requests:int257 = WithdrawalRequests`
Signature: `WithdrawalRequests{addresses:dict<int, address>,amounts:dict<int, int>,n_requests:int257}`

2
sources/output/jetton_Linker.pkg

File diff suppressed because one or more lines are too long

124
sources/output/jetton_Linker.ts

@ -1345,6 +1345,129 @@ function dictValueParserRequestLinker(): DictionaryValue<RequestLinker> {
}
}
}
export type Unstake = {
$$type: 'Unstake';
amount: bigint;
}
export function storeUnstake(src: Unstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3125946401, 32);
b_0.storeInt(src.amount, 257);
};
}
export function loadUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3125946401) { throw Error('Invalid prefix'); }
let _amount = sc_0.loadIntBig(257);
return { $$type: 'Unstake' as const, amount: _amount };
}
function loadTupleUnstake(source: TupleReader) {
let _amount = source.readBigNumber();
return { $$type: 'Unstake' as const, amount: _amount };
}
function storeTupleUnstake(source: Unstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.amount);
return builder.build();
}
function dictValueParserUnstake(): DictionaryValue<Unstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeUnstake(src)).endCell());
},
parse: (src) => {
return loadUnstake(src.loadRef().beginParse());
}
}
}
export type RequestUnstake = {
$$type: 'RequestUnstake';
founderIndex: bigint;
}
export function storeRequestUnstake(src: RequestUnstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3922648959, 32);
b_0.storeInt(src.founderIndex, 257);
};
}
export function loadRequestUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3922648959) { throw Error('Invalid prefix'); }
let _founderIndex = sc_0.loadIntBig(257);
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function loadTupleRequestUnstake(source: TupleReader) {
let _founderIndex = source.readBigNumber();
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function storeTupleRequestUnstake(source: RequestUnstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.founderIndex);
return builder.build();
}
function dictValueParserRequestUnstake(): DictionaryValue<RequestUnstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeRequestUnstake(src)).endCell());
},
parse: (src) => {
return loadRequestUnstake(src.loadRef().beginParse());
}
}
}
export type CollectProfit = {
$$type: 'CollectProfit';
adminIndex: bigint;
}
export function storeCollectProfit(src: CollectProfit) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(1368467253, 32);
b_0.storeInt(src.adminIndex, 257);
};
}
export function loadCollectProfit(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 1368467253) { throw Error('Invalid prefix'); }
let _adminIndex = sc_0.loadIntBig(257);
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function loadTupleCollectProfit(source: TupleReader) {
let _adminIndex = source.readBigNumber();
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function storeTupleCollectProfit(source: CollectProfit) {
let builder = new TupleBuilder();
builder.writeNumber(source.adminIndex);
return builder.build();
}
function dictValueParserCollectProfit(): DictionaryValue<CollectProfit> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeCollectProfit(src)).endCell());
},
parse: (src) => {
return loadCollectProfit(src.loadRef().beginParse());
}
}
}
export type WithdrawalRequests = {
$$type: 'WithdrawalRequests';
addresses: Dictionary<bigint, Address>;
@ -1577,6 +1700,7 @@ const Linker_errors: { [key: number]: { message: string } } = {
32366: { message: `not enough money for deposit` },
41207: { message: `invalid sender` },
44816: { message: `Wallet is blacklisted` },
61265: { message: `Only the owner can trigger un-staking` },
62972: { message: `Invalid balance` },
}

2
sources/output/jetton_PseudoStaking.abi

File diff suppressed because one or more lines are too long

BIN
sources/output/jetton_PseudoStaking.code.boc

Binary file not shown.

12
sources/output/jetton_PseudoStaking.code.fc

@ -202,7 +202,15 @@ cell $__gen_String_asComment(slice $self) impure inline_ref {
var ($self'stakes) = $self;
var ($msg'value) = $msg;
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
$send((true, $ctx'sender, $msg'value, 0, $__gen_String_asComment(__gen_str_2874951020()), null(), null()));
int $value = $msg'value;
if (($value == 0)) {
$value = ((__tact_not_null(__tact_dict_get_slice_int($self'stakes, 267, $ctx'sender, 257)) * 110) / 100);
}
$self'stakes~__tact_dict_set_slice_int(267, $ctx'sender, (__tact_not_null(__tact_dict_get_slice_int($self'stakes, 267, $ctx'sender, 257)) - $value), 257);
if ((__tact_not_null(__tact_dict_get_slice_int($self'stakes, 267, $ctx'sender, 257)) < 0)) {
$self'stakes~__tact_dict_set_slice_int(267, $ctx'sender, 0, 257);
}
$send((true, $ctx'sender, $value, 0, $__gen_String_asComment(__gen_str_2874951020()), null(), null()));
return (($self'stakes), ());
}
@ -276,5 +284,5 @@ _ supported_interfaces() method_id {
}
_ get_abi_ipfs() {
return "ipfs://QmPwuNr3oQ5NQcD4Xd7t7WX9wnsfuhfVhNMNuVNSKXHm5R";
return "ipfs://QmTpVYvpJy7wvLrPak1F6KJSC44yccvcdix7pmrnjZmAHa";
}

44
sources/output/jetton_PseudoStaking.code.fif

@ -340,11 +340,53 @@ PROGRAM{
__tact_context_get INLINECALLDICT
s2 s3 XCHG
3 BLKDROP
OVER
0 EQINT
IF:<{
NIP
OVER
267 PUSHINT
s2 PUSH
257 PUSHINT
__tact_dict_get_slice_int INLINECALLDICT
__tact_not_null INLINECALLDICT
110 MULCONST
100 PUSHINT
DIV
SWAP
}>
267 PUSHINT
s3 s0 s1 PUSH3
257 PUSHINT
__tact_dict_get_slice_int INLINECALLDICT
__tact_not_null INLINECALLDICT
s3 PUSH
SUB
s2 PUSH
s3 s5 XCHG
SWAP
257 PUSHINT
__tact_dict_set_slice_int CALLDICT
DUP
267 PUSHINT
s4 PUSH
257 PUSHINT
__tact_dict_get_slice_int INLINECALLDICT
__tact_not_null INLINECALLDICT
0 LESSINT
IF:<{
267 PUSHINT
s3 PUSH
0 PUSHINT
257 PUSHINT
__tact_dict_set_slice_int CALLDICT
}>
TRUE
0 PUSHINT
B{b5ee9c72410101010014000024576974686472617720636f6d706c65746564f7612edd} B>boc <s PUSHSLICE
$__gen_String_asComment INLINECALLDICT
s2 s4 XCHG
s3 s5 XCHG
PUSHNULL
PUSHNULL
$send INLINECALLDICT
@ -448,6 +490,6 @@ PROGRAM{
209801025412363888721030803524359905849 PUSHINT
}>
get_abi_ipfs PROC:<{
x{697066733a2f2f516d5077754e72336f51354e516344345864377437575839776e736675686656684e4d4e75564e534b58486d3552} PUSHSLICE
x{697066733a2f2f516d5470565976704a793777764c7250616b3146364b4a53433434796363766364697837706d726e6a5a6d414861} PUSHSLICE
}>
}END>c

90
sources/output/jetton_PseudoStaking.code.rev.fif

@ -60,10 +60,95 @@ SETCP0
LDGRAMS
s0 s1 XCHG
s1 POP
<{
1 GETGLOBVAR
4 UNTUPLE
s2 s3 XCHG
3 BLKDROP
s1 PUSH
0 EQINT
<{
s1 POP
s1 PUSH
267 PUSHINT
s2 PUSH
257 PUSHINT
s1 s3 s3 XCHG3
DICTGET
NULLSWAPIFNOT
<{
s0 s1 XCHG
LDI
s0 POP
}> PUSHCONT
<{
2DROP
PUSHNULL
}> PUSHCONT
IFELSE
s0 PUSH
ISNULL
128 THROWIF
110 MULCONST
100 PUSHINT
DIV QOUT
s0 s1 XCHG
}> PUSHCONT
IF
267 PUSHINT
3 0 1 PUSH3
257 PUSHINT
s1 s3 s3 XCHG3
DICTGET
NULLSWAPIFNOT
<{
s0 s1 XCHG
LDI
s0 POP
}> PUSHCONT
<{
2DROP
PUSHNULL
}> PUSHCONT
IFELSE
s0 PUSH
ISNULL
128 THROWIF
s3 PUSH
SUB
s2 PUSH
s3 s5 XCHG
s0 s1 XCHG
257 PUSHINT
6 CALLDICT
s0 PUSH
267 PUSHINT
s4 PUSH
257 PUSHINT
s1 s3 s3 XCHG3
DICTGET
NULLSWAPIFNOT
<{
s0 s1 XCHG
LDI
s0 POP
}> PUSHCONT
<{
2DROP
PUSHNULL
}> PUSHCONT
IFELSE
s0 PUSH
ISNULL
128 THROWIF
0 LESSINT
<{
267 PUSHINT
s3 PUSH
0 PUSHINT
257 PUSHINT
6 CALLDICT
}> IFREF
-1 PUSHINT
0 PUSHINT
PUSHSLICE
@ -170,6 +255,7 @@ SETCP0
s1 POP
}> CALLREF
s2 s4 XCHG
s3 s5 XCHG
PUSHNULL
PUSHNULL
<{
@ -298,6 +384,7 @@ SETCP0
s0 s1 XCHG
SENDRAWMSG
}> CALLREF
}> CALLREF
NEWC
2 GETGLOBVAR
s0 s1 XCHG
@ -307,7 +394,8 @@ SETCP0
STDICT
ENDC
c4 POP
}> IFJMPREF
}> PUSHCONT
IFJMP
0 EQINT
<{
s0 PUSH

16
sources/output/jetton_PseudoStaking.md

@ -1,9 +1,9 @@
# TACT Compilation Report
Contract: PseudoStaking
BOC Size: 741 bytes
BOC Size: 876 bytes
# Types
Total Types: 30
Total Types: 33
## StateInit
TLB: `_ code:^cell data:^cell = StateInit`
@ -109,6 +109,18 @@ Signature: `SetStakingPool{staking_pool:Maybe address}`
TLB: `request_linker#5a29431e client:address = RequestLinker`
Signature: `RequestLinker{client:address}`
## Unstake
TLB: `unstake#ba522821 amount:int257 = Unstake`
Signature: `Unstake{amount:int257}`
## RequestUnstake
TLB: `request_unstake#e9cedf7f founderIndex:int257 = RequestUnstake`
Signature: `RequestUnstake{founderIndex:int257}`
## CollectProfit
TLB: `collect_profit#51912735 adminIndex:int257 = CollectProfit`
Signature: `CollectProfit{adminIndex:int257}`
## WithdrawalRequests
TLB: `_ addresses:dict<int, address> amounts:dict<int, int> n_requests:int257 = WithdrawalRequests`
Signature: `WithdrawalRequests{addresses:dict<int, address>,amounts:dict<int, int>,n_requests:int257}`

2
sources/output/jetton_PseudoStaking.pkg

File diff suppressed because one or more lines are too long

128
sources/output/jetton_PseudoStaking.ts

@ -1345,6 +1345,129 @@ function dictValueParserRequestLinker(): DictionaryValue<RequestLinker> {
}
}
}
export type Unstake = {
$$type: 'Unstake';
amount: bigint;
}
export function storeUnstake(src: Unstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3125946401, 32);
b_0.storeInt(src.amount, 257);
};
}
export function loadUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3125946401) { throw Error('Invalid prefix'); }
let _amount = sc_0.loadIntBig(257);
return { $$type: 'Unstake' as const, amount: _amount };
}
function loadTupleUnstake(source: TupleReader) {
let _amount = source.readBigNumber();
return { $$type: 'Unstake' as const, amount: _amount };
}
function storeTupleUnstake(source: Unstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.amount);
return builder.build();
}
function dictValueParserUnstake(): DictionaryValue<Unstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeUnstake(src)).endCell());
},
parse: (src) => {
return loadUnstake(src.loadRef().beginParse());
}
}
}
export type RequestUnstake = {
$$type: 'RequestUnstake';
founderIndex: bigint;
}
export function storeRequestUnstake(src: RequestUnstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3922648959, 32);
b_0.storeInt(src.founderIndex, 257);
};
}
export function loadRequestUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3922648959) { throw Error('Invalid prefix'); }
let _founderIndex = sc_0.loadIntBig(257);
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function loadTupleRequestUnstake(source: TupleReader) {
let _founderIndex = source.readBigNumber();
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function storeTupleRequestUnstake(source: RequestUnstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.founderIndex);
return builder.build();
}
function dictValueParserRequestUnstake(): DictionaryValue<RequestUnstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeRequestUnstake(src)).endCell());
},
parse: (src) => {
return loadRequestUnstake(src.loadRef().beginParse());
}
}
}
export type CollectProfit = {
$$type: 'CollectProfit';
adminIndex: bigint;
}
export function storeCollectProfit(src: CollectProfit) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(1368467253, 32);
b_0.storeInt(src.adminIndex, 257);
};
}
export function loadCollectProfit(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 1368467253) { throw Error('Invalid prefix'); }
let _adminIndex = sc_0.loadIntBig(257);
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function loadTupleCollectProfit(source: TupleReader) {
let _adminIndex = source.readBigNumber();
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function storeTupleCollectProfit(source: CollectProfit) {
let builder = new TupleBuilder();
builder.writeNumber(source.adminIndex);
return builder.build();
}
function dictValueParserCollectProfit(): DictionaryValue<CollectProfit> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeCollectProfit(src)).endCell());
},
parse: (src) => {
return loadCollectProfit(src.loadRef().beginParse());
}
}
}
export type WithdrawalRequests = {
$$type: 'WithdrawalRequests';
addresses: Dictionary<bigint, Address>;
@ -1519,8 +1642,8 @@ function dictValueParserWithdraw(): DictionaryValue<Withdraw> {
}
async function PseudoStaking_init() {
const __init = 'te6ccgEBBgEALQABFP8A9KQT9LzyyAsBAgFiAgMCAs4EBQAJoUrd4AUAAUgAE0bQHIzAEB9ADJg=';
const __code = 'te6ccgECDQEAAtkAART/APSkE/S88sgLAQIBYgIDAgLNBAUATaF3owTgudh6ullc9j0J2HOslQo2zQThO6xqWlbI+WZFp15b++LEcwOP120Xb9uBDrpOEPypgQa4WP7wFoaYGAuNhgAMi/yLhxAP0gESgzN4J8MIFIrfAQQQhtQB9+3XGBYABxgHaiaGoA/DF6AgCYgMBgcIACNohbpVbWfRZMODIAc8AQTP0QYCojDtRNDUAfhi9AQBMQHTHwGCENqAPv268uCB+gABMfhBbyQQI18Df3CNBJXaXRoZHJhdyBjb21wbGV0ZWSDbPBAkbW3b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LQgFADoIEBAfAG3sj4QgHMAQH0AMntVADuIPkBgvAtyxmluJ250zd/xlHG+ba5Lbm+YkBgxipQVyzcl5aGOLqOTjDtRNDUAfhi9AQBMfhBbyQwMiKBAQsigQEBQTP0Cm+hlAHXADCSW23iIG6SMHDegQELASBu8tCAUAOggQEB8AbI+EIBzAEB9ADJ7VTbMeAC9vhBbyQQI18DIcAAjiQxIYEBCyKBAQFBM/QKb6GUAdcAMJJbbeIgbvLQgKdugGSpBAHegQELVHMBgQEBQTP0Cm+hlAHXADCSW23iIG7y0IAjoSIQNQGBAQHwBiCBAQskgQEBQTP0Cm+hlAHXADCSW23iIG7y0IDBAOMAfxALAkBwjQSV2l0aGRyYXcgY29tcGxldGVkg2zwQJBA1bW3bPA4MAfbIcQHKAVAHAcoAcAHKAlAFzxZQA/oCcAHKaCNusyVus7GOTH8BygDIcAHKAHABygAkbrOdfwHKAAQgbvLQgFAEzJY0A3ABygDiJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4nABygACfwHKAALJWMyXMzMBcAHKAOIhbrMNADCcfwHKAAEgbvLQgAHMlTFwAcoA4skB+wABQshwAcsfbwABb4xtb4wB2zxvIgHJkyFus5YBbyJZzMnoMQ8AuiDXSiHXSZcgwgAiwgCxjkoDbyKAfyLPMasCoQWrAlFVtgggwgCcIKoCFdcYUDPPFkAU3llvAlNBocIAmcgBbwJQRKGqAo4SMTPCAJnUMNAg10oh10mScCDi4uhfAwAUgQELI3CBAQHwBpIeRwU=';
let systemCell = Cell.fromBase64(__system);
let builder = new TupleBuilder();
builder.writeCell(systemCell);
@ -1574,6 +1697,7 @@ const PseudoStaking_errors: { [key: number]: { message: string } } = {
32366: { message: `not enough money for deposit` },
41207: { message: `invalid sender` },
44816: { message: `Wallet is blacklisted` },
61265: { message: `Only the owner can trigger un-staking` },
62972: { message: `Invalid balance` },
}

2
sources/output/jetton_TONB.abi

File diff suppressed because one or more lines are too long

BIN
sources/output/jetton_TONB.code.boc

Binary file not shown.

50
sources/output/jetton_TONB.code.fc

@ -212,6 +212,23 @@ cell __gen_writecell_BlacklistWallet((slice) v) inline_ref {
return (sc_0, (v'client));
}
builder __gen_write_Unstake(builder build_0, (int) v) inline {
var (v'amount) = v;
build_0 = store_uint(build_0, 3125946401, 32);
build_0 = build_0.store_int(v'amount, 257);
return build_0;
}
cell __gen_writecell_Unstake((int) v) inline_ref {
return __gen_write_Unstake(begin_cell(), v).end_cell();
}
(slice, ((int))) __gen_read_Unstake(slice sc_0) inline {
throw_unless(129, sc_0~load_uint(32) == 3125946401);
var v'amount = sc_0~load_int(257);
return (sc_0, (v'amount));
}
builder __gen_write_WithdrawalRequests(builder build_0, (cell, cell, int) v) inline {
var (v'addresses, v'amounts, v'n_requests) = v;
build_0 = build_0.store_dict(v'addresses);
@ -589,7 +606,7 @@ _ $__gen_get_owner() method_id(83229) {
int $available = ((__tact_my_balance() - 500000000) - 150000000);
if (($available < $msg'amount)) {
int $diff = ($msg'amount - $available);
$send((false, $msg'owner, (__tact_my_balance() - 500000000), 0, null(), null(), null()));
$send((false, $msg'owner, ((__tact_my_balance() - 500000000) - 150000000), 0, null(), null(), null()));
cell $body = __gen_writecell_TokenTransferInternal((0, $diff, my_address(), my_address(), 0, $emptySlice(), null(), null()));
slice $walletAddress = $__gen_TONB_get_wallet_address(($self'totalSupply, $self'owner, $self'content, $self'mintable, $self'first_linker, $self'last_linker, $self'n_linkers, $self'staking_pool, $self'in_the_pool, ($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests)), $msg'owner);
$send((false, $walletAddress, 0, 64, $body, null(), null()));
@ -636,10 +653,30 @@ _ $__gen_get_owner() method_id(83229) {
$send((false, $addr, 80000000, 0, __gen_writecell_TokenBurn((0, __tact_not_null(__tact_dict_get_int_int($self'withdrawal_requests'amounts, 257, $i, 257)), $addr, my_address())), null(), null()));
$i = ($i + 1);
}
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
int $val = $ctx'value;
$self'in_the_pool = ($self'in_the_pool - $val);
if (($self'in_the_pool < 0)) {
int $value = (- $self'in_the_pool);
$send((true, $self'owner, $value, 0, __gen_writecell_Unstake(($value)), null(), null()));
$self'in_the_pool = 0;
}
($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests) = (null(), null(), 0);
return (($self'totalSupply, $self'owner, $self'content, $self'mintable, $self'first_linker, $self'last_linker, $self'n_linkers, $self'staking_pool, $self'in_the_pool, ($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests)), ());
}
(((int, slice, cell, int, slice, slice, int, slice, int, (cell, cell, int))), ()) $__gen_TONB_receive_Unstake((int, slice, cell, int, slice, slice, int, slice, int, (cell, cell, int)) $self, (int) $msg) impure inline {
var ($self'totalSupply, $self'owner, $self'content, $self'mintable, $self'first_linker, $self'last_linker, $self'n_linkers, $self'staking_pool, $self'in_the_pool, ($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests)) = $self;
var ($msg'amount) = $msg;
if (null?($self'staking_pool)) {
return (($self'totalSupply, $self'owner, $self'content, $self'mintable, $self'first_linker, $self'last_linker, $self'n_linkers, $self'staking_pool, $self'in_the_pool, ($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests)), ());
}
var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get();
throw_unless(61265, __tact_address_eq($ctx'sender, $self'owner));
$send($stakingWithdrawMessage($msg'amount, __tact_not_null($self'staking_pool)));
return (($self'totalSupply, $self'owner, $self'content, $self'mintable, $self'first_linker, $self'last_linker, $self'n_linkers, $self'staking_pool, $self'in_the_pool, ($self'withdrawal_requests'addresses, $self'withdrawal_requests'amounts, $self'withdrawal_requests'n_requests)), ());
}
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {
@ -730,6 +767,15 @@ _ $__gen_get_owner() method_id(83229) {
return ();
}
;; Receive Unstake message
if (op == 3125946401) {
var self = __gen_load_TONB();
var msg = in_msg~__gen_read_Unstake();
self~$__gen_TONB_receive_Unstake(msg);
__gen_store_TONB(self);
return ();
}
;; Text Receivers
if (op == 0) {
var text_op = slice_hash(in_msg);
@ -756,5 +802,5 @@ _ supported_interfaces() method_id {
}
_ get_abi_ipfs() {
return "ipfs://QmbvAFjnCM5XTJgrgt7t9fPJakhgnHe6UgD1XQ2bUmTLTR";
return "ipfs://QmZei32YRHJRnTCv7qY3WpT16zADJCXJ6BC996CpHaiRqG";
}

92
sources/output/jetton_TONB.code.fif

@ -30,6 +30,9 @@ PROGRAM{
DECLPROC __gen_read_BlacklistWallet
DECLPROC __gen_read_SetStakingPool
DECLPROC __gen_read_RequestLinker
DECLPROC __gen_write_Unstake
DECLPROC __gen_writecell_Unstake
DECLPROC __gen_read_Unstake
DECLPROC __gen_write_WithdrawalRequests
DECLPROC __gen_read_WithdrawalRequests
DECLPROC __gen_read_Deposit
@ -76,6 +79,7 @@ PROGRAM{
DECLPROC $__gen_TONB_receive_BlacklistWallet
DECLPROC $__gen_TONB_receive_RequestLinker
DECLPROC $__gen_TONB_receive_comment_f7b1ab6077945b37370a1550574675180cf87df4cb047c869746812a83667d4c
DECLPROC $__gen_TONB_receive_Unstake
DECLPROC recv_internal
113617 DECLMETHOD supported_interfaces
DECLPROC get_abi_ipfs
@ -378,6 +382,29 @@ PROGRAM{
129 THROWIFNOT
__tact_load_address INLINECALLDICT
}>
__gen_write_Unstake PROCINLINE:<{
3125946401 PUSHINT
ROT
32 STU
257 PUSHINT
STIX
}>
__gen_writecell_Unstake PROCREF:<{
NEWC
SWAP
__gen_write_Unstake INLINECALLDICT
ENDC
}>
__gen_read_Unstake PROCINLINE:<{
32 LDU
SWAP
3125946401 PUSHINT
EQUAL
129 THROWIFNOT
257 PUSHINT
LDIX
SWAP
}>
__gen_write_WithdrawalRequests PROCINLINE:<{
s2 s3 XCHG2
STDICT
@ -1026,6 +1053,8 @@ PROGRAM{
__tact_my_balance INLINECALLDICT
500000000 PUSHINT
SUB
150000000 PUSHINT
SUB
s15 s(-1) PUXC
0 PUSHINT
PUSHNULL
@ -1204,10 +1233,49 @@ PROGRAM{
INC
}>
4 BLKDROP
__tact_context_get INLINECALLDICT
s1 s3 XCHG
3 BLKDROP
SUB
DUP
0 LESSINT
IF:<{
NEGATE
TRUE
0 PUSHINT
s2 PUSH
__gen_writecell_Unstake INLINECALLDICT
s10 PUSH
s0 s3 XCHG
s4 s4 s4 XCHG3
PUSHNULL
PUSHNULL
$send INLINECALLDICT
0 PUSHINT
}>
PUSHNULL
PUSHNULL
0 PUSHINT
}>
$__gen_TONB_receive_Unstake PROCINLINE:<{
s5 PUSH
ISNULL
IF:<{
DROP
}>ELSE<{
__tact_context_get INLINECALLDICT
2DROP
61265 PUSHINT
s2 POP
s13 PUSH
__tact_address_eq INLINECALLDICT
THROWANYIFNOT
s5 PUSH
__tact_not_null INLINECALLDICT
$stakingWithdrawMessage INLINECALLDICT
$send INLINECALLDICT
}>
}>
recv_internal PROC:<{
c2 SAVE
SAMEALTSAVE
@ -1410,6 +1478,28 @@ PROGRAM{
$__gen_TONB_receive_RequestLinker INLINECALLDICT
__gen_store_TONB INLINECALLDICT
}>
DUP
3125946401 PUSHINT
EQUAL
IFJMP:<{
DROP
__gen_load_TONB INLINECALLDICT
s0 s12 XCHG
__gen_read_Unstake INLINECALLDICT
NIP
s11 s12 XCHG
s10 s11 XCHG
s9 s10 XCHG
s8 s9 XCHG
s7 s8 XCHG
s6 s7 XCHG
s5 s6 XCHG
s4 s5 XCHG
s3 s4 XCHG
s1 s3 s0 XCHG3
$__gen_TONB_receive_Unstake INLINECALLDICT
__gen_store_TONB INLINECALLDICT
}>
0 EQINT
IF:<{
HASHSU
@ -1433,6 +1523,6 @@ PROGRAM{
86142586315491086060343270784266291122 PUSHINT
}>
get_abi_ipfs PROC:<{
x{697066733a2f2f516d627641466a6e434d3558544a6772677437743966504a616b68676e4865365567443158513262556d544c5452} PUSHSLICE
x{697066733a2f2f516d5a656933325952484a526e5443763771593357705431367a41444a43584a3642433939364370486169527147} PUSHSLICE
}>
}END>c

868
sources/output/jetton_TONB.code.rev.fif

File diff suppressed because it is too large Load Diff

16
sources/output/jetton_TONB.md

@ -1,9 +1,9 @@
# TACT Compilation Report
Contract: TONB
BOC Size: 3825 bytes
BOC Size: 4090 bytes
# Types
Total Types: 30
Total Types: 33
## StateInit
TLB: `_ code:^cell data:^cell = StateInit`
@ -109,6 +109,18 @@ Signature: `SetStakingPool{staking_pool:Maybe address}`
TLB: `request_linker#5a29431e client:address = RequestLinker`
Signature: `RequestLinker{client:address}`
## Unstake
TLB: `unstake#ba522821 amount:int257 = Unstake`
Signature: `Unstake{amount:int257}`
## RequestUnstake
TLB: `request_unstake#e9cedf7f founderIndex:int257 = RequestUnstake`
Signature: `RequestUnstake{founderIndex:int257}`
## CollectProfit
TLB: `collect_profit#51912735 adminIndex:int257 = CollectProfit`
Signature: `CollectProfit{adminIndex:int257}`
## WithdrawalRequests
TLB: `_ addresses:dict<int, address> amounts:dict<int, int> n_requests:int257 = WithdrawalRequests`
Signature: `WithdrawalRequests{addresses:dict<int, address>,amounts:dict<int, int>,n_requests:int257}`

2
sources/output/jetton_TONB.pkg

File diff suppressed because one or more lines are too long

133
sources/output/jetton_TONB.ts

File diff suppressed because one or more lines are too long

2
sources/output/jetton_TONBWallet.abi

File diff suppressed because one or more lines are too long

2
sources/output/jetton_TONBWallet.code.fc

@ -514,5 +514,5 @@ _ supported_interfaces() method_id {
}
_ get_abi_ipfs() {
return "ipfs://QmcS4CYiu6xUPu6QvPConc7ut86RgukmohTexGBWmm3HM6";
return "ipfs://QmZ8U23MsSzC5NvLwmc6Wh8LzCefCn61CpNQ81T9a6A8dZ";
}

2
sources/output/jetton_TONBWallet.code.fif

@ -1008,6 +1008,6 @@ PROGRAM{
209778528950190195973528115415557644819 PUSHINT
}>
get_abi_ipfs PROC:<{
x{697066733a2f2f516d63533443596975367855507536517650436f6e6337757438365267756b6d6f685465784742576d6d33484d36} PUSHSLICE
x{697066733a2f2f516d5a385532334d73537a43354e764c776d63365768384c7a436566436e363143704e513831543961364138645a} PUSHSLICE
}>
}END>c

14
sources/output/jetton_TONBWallet.md

@ -3,7 +3,7 @@ Contract: TONBWallet
BOC Size: 2111 bytes
# Types
Total Types: 30
Total Types: 33
## StateInit
TLB: `_ code:^cell data:^cell = StateInit`
@ -109,6 +109,18 @@ Signature: `SetStakingPool{staking_pool:Maybe address}`
TLB: `request_linker#5a29431e client:address = RequestLinker`
Signature: `RequestLinker{client:address}`
## Unstake
TLB: `unstake#ba522821 amount:int257 = Unstake`
Signature: `Unstake{amount:int257}`
## RequestUnstake
TLB: `request_unstake#e9cedf7f founderIndex:int257 = RequestUnstake`
Signature: `RequestUnstake{founderIndex:int257}`
## CollectProfit
TLB: `collect_profit#51912735 adminIndex:int257 = CollectProfit`
Signature: `CollectProfit{adminIndex:int257}`
## WithdrawalRequests
TLB: `_ addresses:dict<int, address> amounts:dict<int, int> n_requests:int257 = WithdrawalRequests`
Signature: `WithdrawalRequests{addresses:dict<int, address>,amounts:dict<int, int>,n_requests:int257}`

2
sources/output/jetton_TONBWallet.pkg

File diff suppressed because one or more lines are too long

124
sources/output/jetton_TONBWallet.ts

@ -1345,6 +1345,129 @@ function dictValueParserRequestLinker(): DictionaryValue<RequestLinker> {
}
}
}
export type Unstake = {
$$type: 'Unstake';
amount: bigint;
}
export function storeUnstake(src: Unstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3125946401, 32);
b_0.storeInt(src.amount, 257);
};
}
export function loadUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3125946401) { throw Error('Invalid prefix'); }
let _amount = sc_0.loadIntBig(257);
return { $$type: 'Unstake' as const, amount: _amount };
}
function loadTupleUnstake(source: TupleReader) {
let _amount = source.readBigNumber();
return { $$type: 'Unstake' as const, amount: _amount };
}
function storeTupleUnstake(source: Unstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.amount);
return builder.build();
}
function dictValueParserUnstake(): DictionaryValue<Unstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeUnstake(src)).endCell());
},
parse: (src) => {
return loadUnstake(src.loadRef().beginParse());
}
}
}
export type RequestUnstake = {
$$type: 'RequestUnstake';
founderIndex: bigint;
}
export function storeRequestUnstake(src: RequestUnstake) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(3922648959, 32);
b_0.storeInt(src.founderIndex, 257);
};
}
export function loadRequestUnstake(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 3922648959) { throw Error('Invalid prefix'); }
let _founderIndex = sc_0.loadIntBig(257);
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function loadTupleRequestUnstake(source: TupleReader) {
let _founderIndex = source.readBigNumber();
return { $$type: 'RequestUnstake' as const, founderIndex: _founderIndex };
}
function storeTupleRequestUnstake(source: RequestUnstake) {
let builder = new TupleBuilder();
builder.writeNumber(source.founderIndex);
return builder.build();
}
function dictValueParserRequestUnstake(): DictionaryValue<RequestUnstake> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeRequestUnstake(src)).endCell());
},
parse: (src) => {
return loadRequestUnstake(src.loadRef().beginParse());
}
}
}
export type CollectProfit = {
$$type: 'CollectProfit';
adminIndex: bigint;
}
export function storeCollectProfit(src: CollectProfit) {
return (builder: Builder) => {
let b_0 = builder;
b_0.storeUint(1368467253, 32);
b_0.storeInt(src.adminIndex, 257);
};
}
export function loadCollectProfit(slice: Slice) {
let sc_0 = slice;
if (sc_0.loadUint(32) !== 1368467253) { throw Error('Invalid prefix'); }
let _adminIndex = sc_0.loadIntBig(257);
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function loadTupleCollectProfit(source: TupleReader) {
let _adminIndex = source.readBigNumber();
return { $$type: 'CollectProfit' as const, adminIndex: _adminIndex };
}
function storeTupleCollectProfit(source: CollectProfit) {
let builder = new TupleBuilder();
builder.writeNumber(source.adminIndex);
return builder.build();
}
function dictValueParserCollectProfit(): DictionaryValue<CollectProfit> {
return {
serialize: (src, buidler) => {
buidler.storeRef(beginCell().store(storeCollectProfit(src)).endCell());
},
parse: (src) => {
return loadCollectProfit(src.loadRef().beginParse());
}
}
}
export type WithdrawalRequests = {
$$type: 'WithdrawalRequests';
addresses: Dictionary<bigint, Address>;
@ -1576,6 +1699,7 @@ const TONBWallet_errors: { [key: number]: { message: string } } = {
32366: { message: `not enough money for deposit` },
41207: { message: `invalid sender` },
44816: { message: `Wallet is blacklisted` },
61265: { message: `Only the owner can trigger un-staking` },
62972: { message: `Invalid balance` },
}

4218
sources/output/types.json

File diff suppressed because it is too large Load Diff

10
sources/pseudostaking.tact

@ -17,8 +17,16 @@ contract PseudoStaking {
receive(msg: StakingWithdraw) {
let ctx: Context = context();
let value: Int = msg.value;
if (value == 0) {
value = (self.stakes.get(ctx.sender)!! * 110) / 100;
}
self.stakes.set(ctx.sender, self.stakes.get(ctx.sender)!! - value);
if (self.stakes.get(ctx.sender)!! < 0) {
self.stakes.set(ctx.sender, 0);
}
send(SendParameters {
value: msg.value,
value: value,
to: ctx.sender,
body: "Withdraw completed".asComment()
});

22
sources/staking.tact

@ -38,7 +38,6 @@ trait StakingTrait {
withdrawal_requests: WithdrawalRequests;
owner: Address;
in_the_pool: Int = 0;
requested_withdrawal: Int = 0;
fun sendStake() {
if(self.staking_pool == null) {
@ -80,15 +79,30 @@ trait StakingTrait {
let ctx: Context = context();
let val: Int = ctx.value;
self.in_the_pool = self.in_the_pool - val;
self.requested_withdrawal = self.requested_withdrawal - val;
let profit: Int = self.in_the_pool - self.requested_withdrawal;
// todo: send profit to the foundation (owner)
if (self.in_the_pool < 0) {
let value: Int = -self.in_the_pool;
send(SendParameters{
to: self.owner,
value: value,
body: Unstake{amount: value}.toCell()
});
self.in_the_pool = 0;
}
self.withdrawal_requests = WithdrawalRequests{
addresses: emptyMap(),
amounts: emptyMap()
};
}
receive(msg: Unstake) {
if(self.staking_pool == null) {
return;
}
let ctx: Context = context();
require(ctx.sender == self.owner, "Only the owner can trigger un-staking");
send(stakingWithdrawMessage(msg.amount /* 0 to unstake all */, self.staking_pool!!));
}
fun requestWithdrawal(address: Address, value: Int) {
self.withdrawal_requests.addresses.set(self.withdrawal_requests.n_requests, address);
self.withdrawal_requests.amounts.set(self.withdrawal_requests.n_requests, value);

36
sources/tests/__snapshots__/jetton.spec.ts.snap

@ -13,14 +13,14 @@ exports[`jetton should deploy and deposit the wallet with the correct sum of mon
},
"bounce": true,
"from": "kQAI-3FJVc_ywSuY4vq0bYrzR7S4Och4y7bTU_i5yLOB3A6P",
"to": "kQDqdXWdE6QCwdIav5vKbWisgRNKQ1foZIJEUAP4WR9CNPfy",
"to": "kQABEUn8yLZqJKZAi4TZjnxqafjqNKCwpuE_-kOXim3gA5il",
"type": "internal",
"value": 100200000000n,
},
"type": "received",
},
{
"gasUsed": 32790n,
"gasUsed": 32815n,
"type": "processed",
},
{
@ -31,8 +31,8 @@ exports[`jetton should deploy and deposit the wallet with the correct sum of mon
"type": "cell",
},
"bounce": false,
"from": "kQDqdXWdE6QCwdIav5vKbWisgRNKQ1foZIJEUAP4WR9CNPfy",
"to": "kQCFWdZkHt68RZzf5yLYgur4jRtW4Ns8l6N2S1t8g0MDPRv7",
"from": "kQABEUn8yLZqJKZAi4TZjnxqafjqNKCwpuE_-kOXim3gA5il",
"to": "kQCMEn5NnRirD8pMXczMDKEXDjBM8tPVXYdj6X3b9ySJdCgP",
"type": "internal",
"value": 11365000n,
},
@ -43,13 +43,13 @@ exports[`jetton should deploy and deposit the wallet with the correct sum of mon
"messages": [
{
"body": {
"cell": "x{178D451900000000000000005174876E800801D4EAEB3A27480583A4357F3794DAD15902269486AFD0C90488A007F0B23E846900023EDC525573FCB04AE638BEAD1B62BCD1ED2E0E721E32EDB4D4FE2E722CE07702_}
x{800000000000000000000000000000000000000000000000000000000000000020042ACEB320F6F5E22CE6FF3916C41757C468DAB706D9E4BD1BB25ADBE41A1819EC_}",
"cell": "x{178D451900000000000000005174876E800800022293F9916CD4494C811709B31CF8D4D3F1D46941614DC27FF4872F14DBC00700023EDC525573FCB04AE638BEAD1B62BCD1ED2E0E721E32EDB4D4FE2E722CE07702_}
x{800000000000000000000000000000000000000000000000000000000000000020046093F26CE8C5587E5262EE66606508B8718267969EAAEC3B1F4BEEDFB9244BA4_}",
"type": "cell",
},
"bounce": false,
"from": "kQDqdXWdE6QCwdIav5vKbWisgRNKQ1foZIJEUAP4WR9CNPfy",
"to": "kQDx8Kg9QTHxou3cHUjl5yisUuHcdW3SO_r2k2KOX9WImtuB",
"from": "kQABEUn8yLZqJKZAi4TZjnxqafjqNKCwpuE_-kOXim3gA5il",
"to": "kQBPWbXsnNaT4jX5J-TIyCfqT9ieWU1c-OxPUejeUisQd5cf",
"type": "internal",
"value": 41715000n,
},
@ -69,14 +69,14 @@ exports[`jetton should work correctly with the staking 1`] = `
},
"bounce": true,
"from": "kQAI-3FJVc_ywSuY4vq0bYrzR7S4Och4y7bTU_i5yLOB3A6P",
"to": "kQC4vZPVA2qqBA7kJfq6yPGv9VBb7MJOvNfJlDxWkagnBO9K",
"to": "kQCWdkwB2iVEz4eqkgyEp_trwnITQd4LiGEcLGENymBCqgFX",
"type": "internal",
"value": 100200000000n,
},
"type": "received",
},
{
"gasUsed": 36073n,
"gasUsed": 36098n,
"type": "processed",
},
{
@ -87,8 +87,8 @@ exports[`jetton should work correctly with the staking 1`] = `
"type": "cell",
},
"bounce": false,
"from": "kQC4vZPVA2qqBA7kJfq6yPGv9VBb7MJOvNfJlDxWkagnBO9K",
"to": "kQDTmzk2GN2cZRr-uIAU5a489Ziwu2Y4dAhQJQizU27oGL-G",
"from": "kQCWdkwB2iVEz4eqkgyEp_trwnITQd4LiGEcLGENymBCqgFX",
"to": "kQACkI90BJ8sTu1IlFoOtzChElnpXsotC8lrmFMGJknQ_Flx",
"type": "internal",
"value": 11365000n,
},
@ -99,13 +99,13 @@ exports[`jetton should work correctly with the staking 1`] = `
"messages": [
{
"body": {
"cell": "x{178D451900000000000000005174876E800801717B27AA06D554081DC84BF57591E35FEAA0B7D9849D79AF932878AD23504E0900023EDC525573FCB04AE638BEAD1B62BCD1ED2E0E721E32EDB4D4FE2E722CE07702_}
x{800000000000000000000000000000000000000000000000000000000000000020069CD9C9B0C6ECE328D7F5C400A72D71E7ACC585DB31C3A0428128459A9B7740C4_}",
"cell": "x{178D451900000000000000005174876E8008012CEC9803B44A899F0F552419094FF6D784E42683BC1710C23858C21B94C0855500023EDC525573FCB04AE638BEAD1B62BCD1ED2E0E721E32EDB4D4FE2E722CE07702_}
x{8000000000000000000000000000000000000000000000000000000000000000200014847BA024F962776A44A2D075B9850892CF4AF651685E4B5CC29831324E87E4_}",
"type": "cell",
},
"bounce": false,
"from": "kQC4vZPVA2qqBA7kJfq6yPGv9VBb7MJOvNfJlDxWkagnBO9K",
"to": "kQC1V2Z4YfN7Y2o-d8DsuDYH2YKYJ2fJpLzmN_yMFf-Efy9L",
"from": "kQCWdkwB2iVEz4eqkgyEp_trwnITQd4LiGEcLGENymBCqgFX",
"to": "kQCO4TveQnMW97esrpa9c9juf5h1ry8gHsxGmUzPjVmBd9Sf",
"type": "internal",
"value": 41715000n,
},
@ -120,8 +120,8 @@ exports[`jetton should work correctly with the staking 1`] = `
"type": "cell",
},
"bounce": true,
"from": "kQC4vZPVA2qqBA7kJfq6yPGv9VBb7MJOvNfJlDxWkagnBO9K",
"to": "kQB6IAwD4Haze61PlYJmyim_0AB0bs-PNhn8XOUwnkMnEcnp",
"from": "kQCWdkwB2iVEz4eqkgyEp_trwnITQd4LiGEcLGENymBCqgFX",
"to": "kQC5Y865mUcSTsSpJYbli0KmSiriJUBFHlKmvNqkS7T5VyUx",
"type": "internal",
"value": 99491421000n,
},

11
sources/tests/jetton.spec.ts

@ -63,7 +63,7 @@ describe('jetton', () => {
expect((events[4] as any).messages[0].value).toBeGreaterThan(99000000000n);
// Try to withdraw
await contract.send(owner, { value: toNano('0.15') }, { $$type: 'Withdraw', amount: toNano('50') });
await contract.send(owner, { value: toNano('0.5') }, { $$type: 'Withdraw', amount: toNano('50') });
let log = await system.run();
events = tracker.events();
// console.log(log)
@ -86,10 +86,15 @@ describe('jetton', () => {
}
}
expect(found_transaction).toBeTruthy();
await contract.send(owner, { value: toNano('0.5') }, { $$type: 'Unstake', amount: toNano('0') });
log = await system.run();
events = tracker.events();
logEvents(events, addressBook);
expect((events[events.length-1] as any).messages[0].value).toBeGreaterThan(toNano('4.9'));
expect((events[events.length-1] as any).messages[0].to).toEqual(addressBook_rev['owner']);
});
// expect((events[events.length - 1] as any).messages[0].value).toBeGreaterThan(49000000000n);
});
it('should correctly work with transfers', async () => {
let system = await ContractSystem.create();
let owner = system.treasure('owner');

11
sources/utils/compile_types.py

@ -0,0 +1,11 @@
from glob import glob
import json
res = []
for f in glob('sources/output/*.abi'):
with open(f) as fp:
res += json.load(fp)['types']
with open('sources/output/types.json', 'w') as fp:
json.dump({'types': res}, fp, indent=4)
Loading…
Cancel
Save