Skip to content

Commit 72ef471

Browse files
authored
Token Swap Program patch - Merge pull request #504 from Xor-el/token-swap-fixes
Token Swap related fixes
2 parents e6856f0 + 3218ab5 commit 72ef471

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Solnet.Examples/TokenSwapExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public void Run()
213213
.AddInstruction(SystemProgram.CreateAccount(
214214
wallet.Account,
215215
swap,
216-
RpcClient.GetMinimumBalanceForRentExemption((long)TokenSwapProgram.TokenSwapAccountDataSize).Result,
217-
TokenSwapProgram.TokenSwapAccountDataSize,
216+
RpcClient.GetMinimumBalanceForRentExemption((long)TokenSwapProgram.TokenSwapDataLength).Result,
217+
TokenSwapProgram.TokenSwapDataLength,
218218
program.ProgramIdKey
219219
))
220220
.AddInstruction(program.Initialize(

src/Solnet.Programs/TokenSwap/TokenSwapProgram.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public class TokenSwapProgram : BaseProgram
4141
/// Token Swap account layout size.
4242
/// </summary>
4343
public static readonly ulong TokenSwapAccountDataSize = 323;
44-
44+
45+
/// <summary>
46+
/// Token Swap data length. // 1 (for the SwapVersion enum) + 323 (TokenSwapAccountDataSize)
47+
/// </summary>
48+
public static readonly ulong TokenSwapDataLength = 1 + TokenSwapAccountDataSize;
49+
4550
/// <summary>
4651
/// Create a token swap program instance with the standard programid and program name
4752
/// </summary>

src/Solnet.Programs/TokenSwap/TokenSwapProgramData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ internal static void DecodeInitializeData(DecodedInstruction decodedInstruction,
148148
decodedInstruction.Values.Add("Owner Withraw Fee Denominator", data.GetU64(42));
149149
decodedInstruction.Values.Add("Host Fee Numerator", data.GetU64(50));
150150
decodedInstruction.Values.Add("Host Fee Denominator", data.GetU64(58));
151-
decodedInstruction.Values.Add("Curve Type", data.GetU64(59));
151+
decodedInstruction.Values.Add("Curve Type", data.GetU8(66));
152152
//nothing to show for calculator unless hardcoding the switch stmt
153153
}
154154

0 commit comments

Comments
 (0)