-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Foundation | ||
import BigInt | ||
|
||
public struct StakeDepositMessage { | ||
public static func whalesInternalMessage(queryId: BigUInt, | ||
poolAddress: Address, | ||
amount: BigUInt, | ||
forwardAmount: BigUInt, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let body = Builder() | ||
try body.store(uint: OpCodes.WHALES_DEPOSIT, bits: 32) | ||
try body.store(uint: queryId, bits: 64) | ||
try body.store(coins: Coins(forwardAmount.magnitude)) | ||
|
||
return MessageRelaxed.internal( | ||
to: poolAddress, | ||
value: amount, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
|
||
public static func liquidTFInternalMessage(queryId: BigUInt, | ||
poolAddress: Address, | ||
amount: BigUInt, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let body = Builder() | ||
try body.store(uint: OpCodes.LIQUID_TF_DEPOSIT, bits: 32) | ||
try body.store(uint: queryId, bits: 64) | ||
try body.store(uint: 0x000000000005b7ce, bits: 64) | ||
|
||
return MessageRelaxed.internal( | ||
to: poolAddress, | ||
value: amount, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
|
||
public static func tfInternalMessage(queryId: BigUInt, | ||
poolAddress: Address, | ||
amount: BigUInt, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let body = Builder() | ||
try body.store(uint: 0, bits: 32) | ||
try body.writeSnakeData(Data("d".utf8)) | ||
|
||
return MessageRelaxed.internal( | ||
to: poolAddress, | ||
value: amount, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Foundation | ||
import BigInt | ||
|
||
public struct StakeWithdrawMessage { | ||
public static func whalesInternalMessage(queryId: BigUInt, | ||
poolAddress: Address, | ||
amount: BigUInt, | ||
withdrawFee: BigUInt, | ||
forwardAmount: BigUInt, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let body = Builder() | ||
try body.store(uint: OpCodes.WHALES_WITHDRAW, bits: 32) | ||
try body.store(uint: queryId, bits: 64) | ||
try body.store(coins: Coins(forwardAmount.magnitude)) | ||
try body.store(coins: Coins(amount.magnitude)) | ||
|
||
return MessageRelaxed.internal( | ||
to: poolAddress, | ||
value: withdrawFee, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
|
||
public static func liquidTFInternalMessage(queryId: BigUInt, | ||
amount: BigUInt, | ||
withdrawFee: BigUInt, | ||
jettonWalletAddress: Address, | ||
responseAddress: Address, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let customPayload = Builder() | ||
try customPayload.store(uint: 1, bits: 1) | ||
try customPayload.store(uint: 0, bits: 1) | ||
|
||
let body = Builder() | ||
try body.store(uint: OpCodes.LIQUID_TF_BURN, bits: 32) | ||
try body.store(uint: queryId, bits: 64) | ||
try body.store(coins: Coins(amount.magnitude)) | ||
try body.store(AnyAddress(responseAddress)) | ||
try body.storeMaybe(ref: customPayload.endCell()) | ||
|
||
return MessageRelaxed.internal( | ||
to: jettonWalletAddress, | ||
value: withdrawFee, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
|
||
public static func tfInternalMessage(queryId: BigUInt, | ||
poolAddress: Address, | ||
amount: BigUInt, | ||
withdrawFee: BigUInt, | ||
bounce: Bool = true) throws -> MessageRelaxed { | ||
let body = Builder() | ||
try body.store(uint: 0, bits: 32) | ||
try body.writeSnakeData(Data("w".utf8)) | ||
|
||
return MessageRelaxed.internal( | ||
to: poolAddress, | ||
value: withdrawFee, | ||
bounce: bounce, | ||
body: try body.asCell() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters