Skip to content

Commit

Permalink
[APP-781] Update neutron vesting amount calculating (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwonhyukjoon authored Jun 28, 2023
1 parent 86f323a commit 2473ef5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cosmostation/Controller/Main/MainTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ class MainTabViewController: UITabBarController, UITabBarControllerDelegate, Acc
}
if let response = try? Cosmwasm_Wasm_V1_QueryClient(channel: channel).smartContractState(req, callOptions: BaseNetWork.getCallOptions()).response.wait() {
let neutronVesting = try? JSONDecoder().decode(Cw20NeutronVestingRes.self, from: response.data)
BaseData.instance.mNeutronVesting = NSDecimalNumber(string: neutronVesting?.allocated_amount)
BaseData.instance.mNeutronVesting = neutronVesting?.getNeutronVestingAmount() ?? NSDecimalNumber.zero
BaseData.instance.mNeutronDuration = neutronVesting?.schedule?.getVestingDuration()
}
try channel.close().wait()
Expand Down
7 changes: 7 additions & 0 deletions Cosmostation/Dao/Cw20NeutronVestingRes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public struct Cw20NeutronVestingRes : Codable {
var allocated_amount: String?
var withdrawn_amount: String?
var schedule: VestingSchedule?

func getNeutronVestingAmount() -> NSDecimalNumber {
if (allocated_amount != nil && withdrawn_amount != nil) {
return NSDecimalNumber(string: allocated_amount).subtracting(NSDecimalNumber(string: withdrawn_amount))
}
return NSDecimalNumber.zero
}
}

public struct VestingSchedule : Codable {
Expand Down

0 comments on commit 2473ef5

Please sign in to comment.