Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(staker): add in-range staked liquidity tracker #438

Merged
merged 234 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 232 commits
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
f4e0254
fix: nipticks
notJoon Dec 12, 2024
59d1907
split staker file
notJoon Dec 13, 2024
2c32770
poolTiers
notJoon Dec 13, 2024
25c9777
poolIncentives
notJoon Dec 13, 2024
c35ecc6
incentives
notJoon Dec 13, 2024
16c1305
deposits
notJoon Dec 13, 2024
8254469
add tick cross hook, add staker side tracking
mconcat Dec 13, 2024
cdf960a
add more iter
notJoon Dec 13, 2024
16b2e63
save
notJoon Dec 13, 2024
78cd7b0
add tests
notJoon Dec 15, 2024
c37e0c4
add test for important functions
notJoon Dec 15, 2024
78ea459
refactor, test: calculateCollectReward
notJoon Dec 16, 2024
395492a
helper test
notJoon Dec 16, 2024
0edc86e
change getTokenPairBalanceFromPosition params
notJoon Dec 16, 2024
40fb74f
update doc
notJoon Dec 16, 2024
bad0c91
change emit param name
notJoon Dec 16, 2024
83da700
remove function prefix from panic
notJoon Dec 16, 2024
b10dfb7
fix
notJoon Dec 16, 2024
e645cda
fix
notJoon Dec 16, 2024
41804a6
Merge branch 'main' into refact-staker
notJoon Dec 16, 2024
e27eae4
fix
notJoon Dec 17, 2024
5b2c553
update test helper
notJoon Dec 17, 2024
96df3ab
pool tier reward cache, pool reward cache, halving, warmup
mconcat Dec 17, 2024
8b7b1dd
Merge branch 'main' into refact-staker
notJoon Dec 18, 2024
bb93d4c
Merge remote-tracking branch 'origin/main' into mconcat/refactor-emis…
mconcat Dec 18, 2024
adc3ce1
update for gnopls
mconcat Dec 18, 2024
8c917ff
chore: remove `Pool` prefix from pool's receiver getter (#423)
r3v4s Dec 15, 2024
ec2ac96
GSW-1838 test: swap_math unitest
r3v4s Dec 10, 2024
e048e5b
test: define test helper function
r3v4s Dec 10, 2024
0961749
test: remove unnecessary initialization
r3v4s Dec 10, 2024
430797e
refactor: Use Clone data in function calls to protect original data
onlyhyde Dec 15, 2024
b31b81e
GSW-1838 test: sqrt_price_math unitest (#425)
r3v4s Dec 16, 2024
168c7df
refactor: dry swap (#421)
notJoon Dec 16, 2024
7b62f12
GSW-1839 refactor: integrated helper and test code (#432)
onlyhyde Dec 16, 2024
6735233
GSW-1839 Refactor/position contract utils (#433)
onlyhyde Dec 16, 2024
96538fc
fix: run test code error (#441)
onlyhyde Dec 17, 2024
026d4cc
GSW-1968 feat: check emission is caller or not (#435)
r3v4s Dec 18, 2024
075aae0
Refactor/pool total (#442)
onlyhyde Dec 18, 2024
30610ae
update for gnopls
mconcat Dec 18, 2024
9dfd9b6
Merge remote-tracking branch 'origin/mconcat/refactor-emission-part-1…
mconcat Dec 18, 2024
f95d7d0
fix compile errors
mconcat Dec 18, 2024
877dc70
compile error fix WIP
mconcat Dec 19, 2024
4eb138e
fix errors
mconcat Dec 19, 2024
d135c73
add external incentive
mconcat Dec 19, 2024
ba7d799
Merge branch 'main' into refact-staker
notJoon Dec 20, 2024
982a34d
remove function name prefix from panic message
notJoon Dec 22, 2024
c753200
fix: no receiver getters
notJoon Dec 22, 2024
3151cec
fix some getter
notJoon Dec 22, 2024
46b409b
add testing
mconcat Dec 23, 2024
02a3e43
remove files
mconcat Dec 23, 2024
db35fbb
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 23, 2024
0529cc8
add testing suite
mconcat Dec 24, 2024
fa33c96
testing works
mconcat Dec 26, 2024
9a1d977
overflow
notJoon Dec 26, 2024
a77e810
add tests
mconcat Dec 26, 2024
7b3e789
Merge branch 'refact-staker' into feature/staker
notJoon Dec 27, 2024
0753ab5
test: file tests to test scenarios
r3v4s Dec 28, 2024
a5dfa40
add tests
mconcat Dec 29, 2024
9ea3305
Merge branch 'feature/staker' of github.com:gnoswap-labs/gnoswap into…
mconcat Dec 29, 2024
c27a074
fix syntax errors
mconcat Dec 29, 2024
5d79f60
compiles
mconcat Dec 29, 2024
24c5cd1
compiles
mconcat Dec 30, 2024
5732cbd
fix nil reference issue
mconcat Dec 30, 2024
270cd7c
remove duplicate file
mconcat Dec 30, 2024
f5d97c0
fix u256 error
mconcat Dec 30, 2024
12b8045
fix
mconcat Dec 30, 2024
e826332
fix
mconcat Dec 30, 2024
cc0b767
fix
mconcat Dec 30, 2024
d28ef7b
rm: reward_internal_emission, reward_manager
notJoon Dec 30, 2024
fd13bc2
rm: staker_type
notJoon Dec 30, 2024
2e5f4dd
rm: unnecessary test (staker_test)
notJoon Dec 30, 2024
f0bc238
rm: reward_recipient_store
notJoon Dec 30, 2024
4355d63
rm: function prefix from panic messages
notJoon Dec 30, 2024
06aac8b
rm: tier_ratio, warm_up
notJoon Dec 30, 2024
2fa8ed3
remove: min, max function
notJoon Dec 30, 2024
4849bff
rm: external_incentive_calculator
notJoon Dec 30, 2024
0d4e5bc
chore: change file name _GET_no_receiver -> getter
notJoon Dec 30, 2024
be45723
fix: getter error
onlyhyde Dec 30, 2024
475911e
add external
mconcat Dec 30, 2024
fd7d9dd
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 30, 2024
86f8831
fix multiple pools
mconcat Dec 30, 2024
f6f1c39
remove unused file
mconcat Dec 30, 2024
09aabee
remove more
mconcat Dec 30, 2024
13bfd75
test: GetPoolStakedLiquidityUpdates
notJoon Dec 30, 2024
a8371d1
fix
mconcat Dec 30, 2024
baa53f2
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 30, 2024
a57e240
test, fix: api_calculation
notJoon Dec 30, 2024
e8da8bd
modify external reward to be indexed by incentive id
mconcat Dec 30, 2024
659fb7f
test: more helpers
r3v4s Dec 30, 2024
15faa92
fix type
r3v4s Dec 30, 2024
bc7046c
fix (maybe): GetPrintInfo
notJoon Dec 30, 2024
cf77377
Merge branch 'mconcat/refactor-emission-part-1' of https://github.com…
notJoon Dec 30, 2024
a50ce35
fix ratio 0
mconcat Dec 30, 2024
08c4de1
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 30, 2024
fc5d629
make reward struct
mconcat Dec 30, 2024
fc9cecb
fix: 01.gnoA
r3v4s Dec 30, 2024
30e4225
fix penalty
mconcat Dec 30, 2024
f2691d0
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 30, 2024
aef34d9
fix
r3v4s Dec 30, 2024
7c7fe45
chore: exclude unittests
r3v4s Dec 30, 2024
a83aae1
add per warmup retrieval
mconcat Dec 30, 2024
ddbcb73
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 30, 2024
d70eaf2
fix: make 01 runnable
r3v4s Dec 30, 2024
573346c
add warmup test
mconcat Dec 30, 2024
34d956d
remove gnoa
mconcat Dec 30, 2024
937005f
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Dec 30, 2024
7c4919d
fix warmup
mconcat Dec 30, 2024
60fdddc
fix: nft transfer gnoa
onlyhyde Dec 30, 2024
f972e15
feat: getPrintInfo()
r3v4s Dec 30, 2024
16a61fe
fix: gnoVM panics
r3v4s Dec 30, 2024
8809793
fix: internal 01 test
r3v4s Dec 30, 2024
94a34f3
fix: divide by zero
r3v4s Dec 30, 2024
3bac6b1
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Dec 30, 2024
e41e0b0
refactor: use grc20reg
r3v4s Dec 31, 2024
d8eae02
fix: WIP (intertnal_01 + external_10)
r3v4s Dec 31, 2024
3845a89
fix: parameter ordering
r3v4s Dec 31, 2024
43f660d
fix: update deposit's lastCollectHeight when reward collected
r3v4s Dec 31, 2024
ae9b9dd
fix: IsExternallyIncentivizedPool
r3v4s Dec 31, 2024
51c1813
test(feat): mint and distribute gns
r3v4s Dec 31, 2024
0402512
fixme: new emission pool reward being 0
r3v4s Dec 31, 2024
8b40272
feat: gnft.MustOwnerOf
r3v4s Dec 31, 2024
85ef73b
fix: qa getter and warmup external 10 test
onlyhyde Dec 31, 2024
3f3895f
feat: UnitTree, RewardCacheTree Size Support
onlyhyde Dec 31, 2024
d69a0ce
fix: duplicated test code
onlyhyde Dec 31, 2024
d98779f
fix: nil pointer uint256
r3v4s Dec 31, 2024
de425c3
chore: gofmt
r3v4s Dec 31, 2024
ede2db1
fix:
r3v4s Dec 31, 2024
f269b3d
reimplement pooltier
mconcat Dec 31, 2024
b391b76
remove unused files
mconcat Dec 31, 2024
c99e7de
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 31, 2024
83654e0
fix: panic with actual error to bypass VM panic
r3v4s Dec 31, 2024
74b9b83
chore: remove print
r3v4s Dec 31, 2024
ce21c50
(fixme) test: pool with no staked position should send reward to comm…
r3v4s Dec 31, 2024
4be2b37
chore: remove duplicated tests
r3v4s Dec 31, 2024
37f5f0b
chore: remove fixed
r3v4s Dec 31, 2024
b682b59
fix: small liq // internal
r3v4s Dec 31, 2024
951587e
save: __TEST_staker_short_wramup_period_staker_external_test
notJoon Dec 31, 2024
f58e271
Merge branch 'mconcat/refactor-emission-part-1' of https://github.com…
notJoon Dec 31, 2024
84379fc
fix: change pool tier // internal
r3v4s Dec 31, 2024
39e5269
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Dec 31, 2024
0953c97
pool tier refactor
mconcat Dec 31, 2024
155c50a
fix: u256 nil
r3v4s Dec 31, 2024
6d67bc5
fix: type error for __TEST_staker_short_wramup_period_staker_external…
notJoon Dec 31, 2024
2d24f08
Merge branch 'mconcat/refactor-emission-part-1' of https://github.com…
notJoon Dec 31, 2024
b117097
fix: remove pool tier
r3v4s Dec 31, 2024
cae79db
test: changePoolTier helper
r3v4s Dec 31, 2024
fc4d377
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Dec 31, 2024
200d8d1
add unclaimed
mconcat Dec 31, 2024
e830de0
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Dec 31, 2024
93564b2
add unclaimable refund
mconcat Dec 31, 2024
5610b7e
fix: type error for __TEST_staker_short_warmup_period_internal_08_pos…
notJoon Dec 31, 2024
11dd6d2
Merge branch 'mconcat/refactor-emission-part-1' of https://github.com…
notJoon Dec 31, 2024
7c95d67
remove unused lines
mconcat Dec 31, 2024
5c66a51
!fixme: processing unclaimable reward in same height
r3v4s Jan 2, 2025
015c405
chore: move internal gnoA tests
r3v4s Jan 2, 2025
79985ca
fix: must update pools avl for default pool
r3v4s Jan 3, 2025
08067c7
!fixme: unclaimable reward too much
r3v4s Jan 3, 2025
e689c7a
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Jan 5, 2025
799a33e
refactor: add unit test code and clean up source code
onlyhyde Jan 5, 2025
3b87a66
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Jan 5, 2025
95999b1
fix test
mconcat Jan 5, 2025
57d9850
fix test
mconcat Jan 5, 2025
bb72dbb
fix: panic testcase
r3v4s Jan 5, 2025
6ac0ed3
refactor: remove unused file
onlyhyde Jan 5, 2025
6ea8f4e
wip gnoA
r3v4s Jan 6, 2025
4d37962
wip gnoA
r3v4s Jan 6, 2025
768184d
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Jan 6, 2025
8147449
test: gnoA testcases
r3v4s Jan 6, 2025
0b3e3b7
fixme: when pool has only external incentive
r3v4s Jan 6, 2025
8642a37
chore: rename
r3v4s Jan 6, 2025
372e741
fixme: swap panic
r3v4s Jan 6, 2025
bb69ab7
fix: external 10, 12
notJoon Jan 6, 2025
9c55bd9
fix: external 13
notJoon Jan 6, 2025
04ead9d
save
notJoon Jan 6, 2025
f927f26
chore: rename
r3v4s Jan 6, 2025
717a25d
FIXME leftExternalIncentive
r3v4s Jan 6, 2025
c65c7f4
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Jan 6, 2025
3cecaf8
chore: remove dummy test
r3v4s Jan 6, 2025
25297d0
fix compile errors
notJoon Jan 6, 2025
5ece457
chore
r3v4s Jan 6, 2025
577fe18
fixme: router panic
r3v4s Jan 6, 2025
5313def
fixme: bit more seconds
r3v4s Jan 6, 2025
82ce932
fix tests
mconcat Jan 6, 2025
4087a04
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Jan 6, 2025
fdc099d
fix: collectreward wrap/unwrap
r3v4s Jan 6, 2025
c7baa88
chore
r3v4s Jan 6, 2025
6e94806
fix: tc
r3v4s Jan 6, 2025
519b137
fix: swap tickCrossHook (suggestion by @onlyhyde)
r3v4s Jan 6, 2025
c5faba2
chore
r3v4s Jan 6, 2025
e50a79a
fix: filetests
r3v4s Jan 6, 2025
b0a8479
fix: (re-implement) pool tier and warm up setter for governance to ca…
r3v4s Jan 6, 2025
ed51fef
fix: test code running error
onlyhyde Jan 6, 2025
dacaa0e
fix: type and func name
r3v4s Jan 6, 2025
944fa18
refactor: code cleanup and api, getter implement
onlyhyde Jan 6, 2025
86b88d8
fix: filetest requries SetPoolTierByAdmin
r3v4s Jan 6, 2025
23bc2e8
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Jan 6, 2025
45796b3
fix: addTier, removeTier
r3v4s Jan 6, 2025
e173d3b
remove unnecessary comment in gnoa test
notJoon Jan 6, 2025
e2298fb
Merge branch 'mconcat/refactor-emission-part-1' of https://github.com…
notJoon Jan 6, 2025
3146bd6
chore: remove meaningless test
r3v4s Jan 6, 2025
58912e6
fix: test
r3v4s Jan 6, 2025
809a231
Merge remote-tracking branch 'refs/remotes/origin/mconcat/refactor-em…
r3v4s Jan 6, 2025
a5afb14
test: fix one click stake native coin
r3v4s Jan 6, 2025
5de9cab
fix: typo
r3v4s Jan 6, 2025
7404e82
fix(and still fixme): permission problem
r3v4s Jan 6, 2025
04d5b87
refactor: getter
onlyhyde Jan 6, 2025
1ae4f49
test: wip
onlyhyde Jan 6, 2025
0d789a5
Merge branch 'main' into mconcat/refactor-emission-part-1
onlyhyde Jan 7, 2025
7a038f8
test: UintTree start key comparing
notJoon Jan 7, 2025
d85c254
test: reward calculation tick
notJoon Jan 7, 2025
4a5dae8
fix: internal_external_91
notJoon Jan 7, 2025
57b5dae
tidy up
notJoon Jan 7, 2025
4cbb841
fix staker
mconcat Jan 7, 2025
6b53a2d
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Jan 7, 2025
9134a2e
test(fixme) skip with block start height
r3v4s Jan 8, 2025
d780f76
fix: change SetWarmUp type for governance to call
r3v4s Jan 8, 2025
d8330fe
Merge branch 'main' into mconcat/refactor-emission-part-1
notJoon Jan 9, 2025
62531b3
rewrite pooltier logic
mconcat Jan 10, 2025
822661e
add emission side modification
mconcat Jan 10, 2025
ac46554
external reward tip
mconcat Jan 10, 2025
d1e143f
external reward fixed
mconcat Jan 10, 2025
bea90bb
fix: build error
onlyhyde Jan 10, 2025
8cf4ca0
fix filetest
mconcat Jan 12, 2025
f9a61e7
Merge branch 'mconcat/refactor-emission-part-1' of github.com:gnoswap…
mconcat Jan 12, 2025
b661fd9
wip for staker
onlyhyde Jan 12, 2025
52516e2
wip for staker internal reward
onlyhyde Jan 12, 2025
8a6d742
chore: more print for debugging
r3v4s Jan 12, 2025
87242c5
test(2 fixme includes) more scenario tests
r3v4s Jan 12, 2025
a78be47
fix: typo
r3v4s Jan 12, 2025
0752faa
remove redundant loop
notJoon Jan 13, 2025
620d461
fix: test 04 insufficient balance panic
notJoon Jan 13, 2025
01f0cd0
fix: calculate to emission end block per year in gns
onlyhyde Jan 14, 2025
a4cddf9
revert: test 04
notJoon Jan 15, 2025
1382836
delete emission.txt
notJoon Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
module gno.land/r/g1er355fkjksqpdtwmhf5penwa82p0rhqxkkyhk5/v2/register_gnodev

require (
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/foo20 v0.0.0-latest
gno.land/r/demo/wugnot v0.0.0-latest
gno.land/r/gnoswap/v1/community_pool v0.0.0-latest
gno.land/r/gnoswap/v1/gns v0.0.0-latest
gno.land/r/gnoswap/v1/gov/staker v0.0.0-latest
gno.land/r/gnoswap/v1/launchpad v0.0.0-latest
gno.land/r/gnoswap/v1/pool v0.0.0-latest
gno.land/r/gnoswap/v1/protocol_fee v0.0.0-latest
gno.land/r/gnoswap/v1/router v0.0.0-latest
gno.land/r/gnoswap/v1/staker v0.0.0-latest
gno.land/r/onbloc/bar v0.0.0-latest
gno.land/r/onbloc/baz v0.0.0-latest
gno.land/r/onbloc/foo v0.0.0-latest
gno.land/r/onbloc/obl v0.0.0-latest
gno.land/r/onbloc/qux v0.0.0-latest
gno.land/r/onbloc/usdc v0.0.0-latest
)
module gno.land/r/g1er355fkjksqpdtwmhf5penwa82p0rhqxkkyhk5/v2/register_gnodev
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/bar/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/bar

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/bar
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/baz/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/baz

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/baz
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/foo/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/foo

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/foo
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/obl/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/obl

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/obl
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/qux/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/qux

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/qux
11 changes: 1 addition & 10 deletions __local/grc20_tokens/onbloc/usdc/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/r/onbloc/usdc

require (
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
gno.land/r/demo/grc20reg v0.0.0-latest
)
module gno.land/r/onbloc/usdc
6 changes: 3 additions & 3 deletions _deploy/r/gnoswap/common/address_and_username.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// AddrToUser converts a type from address to AddressOrName.
// It panics if the address is invalid.
func AddrToUser(addr std.Address) pusers.AddressOrName {
assertValidAddr(addr)
AssertValidAddr(addr)
return pusers.AddressOrName(addr)
}

Expand All @@ -20,9 +20,9 @@ func UserToAddr(user pusers.AddressOrName) std.Address {
return users.Resolve(user)
}

// assertValidAddr checks if the given address is valid.
// AssertValidAddr checks if the given address is valid.
// It panics with a detailed error message if the address is invalid.
func assertValidAddr(addr std.Address) {
func AssertValidAddr(addr std.Address) {
if !addr.IsValid() {
panic(newErrorWithDetail(errInvalidAddr, addr.String()))
}
Expand Down
4 changes: 2 additions & 2 deletions _deploy/r/gnoswap/common/address_and_username_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ func TestAssertValidAddr(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
if tt.shouldPanic {
uassert.PanicsWithMessage(t, tt.panicMsg, func() {
assertValidAddr(tt.addr)
AssertValidAddr(tt.addr)
})
} else {
uassert.NotPanics(t, func() {
assertValidAddr(tt.addr)
AssertValidAddr(tt.addr)
})
}
})
Expand Down
43 changes: 43 additions & 0 deletions _deploy/r/gnoswap/common/strings.gno
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package common

import (
"strconv"
"strings"

"gno.land/p/demo/ufmt"
Expand All @@ -14,3 +15,45 @@ func Split(input string, sep string, length int) ([]string, error) {

return result, nil
}

// EncodeUint converts an uint64 number into a zero-padded 20-character string.
//
// Parameters:
// - num (uint64): The number to encode.
//
// Returns:
// - string: A zero-padded string representation of the number.
//
// Example:
// Input: 12345
// Output: "00000000000000012345"
func EncodeUint(num uint64) string {
// Convert the value to a decimal string.
s := strconv.FormatUint(num, 10)

// Zero-pad to a total length of 20 characters.
zerosNeeded := 20 - len(s)
return strings.Repeat("0", zerosNeeded) + s
}

// DecodeUint converts a zero-padded string back into a uint64 number.
//
// Parameters:
// - s (string): The zero-padded string.
//
// Returns:
// - uint64: The decoded number.
//
// Panics:
// - If the string cannot be parsed into a uint64.
//
// Example:
// Input: "00000000000000012345"
// Output: 12345
func DecodeUint(s string) uint64 {
num, err := strconv.ParseUint(s, 10, 64)
if err != nil {
panic(err)
}
return num
}
18 changes: 18 additions & 0 deletions _deploy/r/gnoswap/gnft/gnft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ func OwnerOf(tid grc721.TokenID) (std.Address, error) {
return ownerAddr, nil
}

// MustOwnerOf returns the current owner's address of a specific token ID
// Parameters:
// - tid: The token ID to check ownership of
//
// Returns:
// - std.Address: The address of the token owner
//
// Panics:
// - If the token ID is invalid
func MustOwnerOf(tid grc721.TokenID) std.Address {
ownerAddr, err := OwnerOf(tid)
if err != nil {
panic(err.Error())
}

return ownerAddr
}

// SetTokenURI sets the metadata URI using a randomly generated SVG image
// Parameters:
// - tid (grc721.TokenID): The token ID for which the URI will be updated.
Expand Down
2 changes: 1 addition & 1 deletion _deploy/r/gnoswap/gns/_helper_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ func resetHalvingRelatedObject(t *testing.T) {
startHeight = std.GetHeight()
startTimestamp = time.Now().Unix()

initializeHalvingData()
emissionState = GetEmissionState()
setEndTimestamp(startTimestamp + consts.TIMESTAMP_YEAR*HALVING_END_YEAR)
}
2 changes: 1 addition & 1 deletion _deploy/r/gnoswap/gns/errors.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var (
errNoPermission = errors.New("[GNOSWAP-GNS-001] caller has no permission")
errInvalidYear = errors.New("[GNOSWAP-GNS-001] invalid year")
errTooManyEmission = errors.New("[GNOSWAP-GNS-002] too many emission reward")
)

Expand Down
Loading
Loading