-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract out cross contract interface
- Loading branch information
Showing
17 changed files
with
354 additions
and
27 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,2 @@ | ||
package common | ||
|
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,105 @@ | ||
# Gnoswap Contract Communication Entrypoints | ||
|
||
This document lists the contract-to-contract communication points in the Gnoswap system, showing which contracts call functions of other contracts. | ||
|
||
## Contract-to-Contract Calls | ||
|
||
### Governance Contract → Multiple Contracts | ||
- Calls functions on various contracts through parameter registry system | ||
- Registry allows execution of parameter changes across protocol | ||
- Each registered contract must implement parameter handlers | ||
- Used during proposal execution phase | ||
|
||
### Governance Contract → Common Contract | ||
- Calls `IsHalted` to check system state | ||
- Calls `MustRegistered` to validate token paths | ||
|
||
### Governance Contract → Pool Contract | ||
- Calls `SetFeeProtocol` through parameter registry | ||
- Calls `CollectProtocol` through parameter registry | ||
|
||
### Governance Contract → Emission Contract | ||
- Calls `MintAndDistributeGns` during proposal operations | ||
|
||
### Position Contract → Pool Contract | ||
- Calls `Mint` to add liquidity to a pool | ||
- Calls `Burn` to remove liquidity from a pool | ||
- Calls `Collect` to collect accumulated fees | ||
|
||
### Staker Contract → Position Contract | ||
- Calls `SetPositionOperator` to update position operators during staking operations | ||
|
||
### Staker Contract → GNFT Contract | ||
- Calls `TransferFrom` to transfer NFT ownership during staking/unstaking | ||
- Calls `MustOwnerOf` to verify token ownership | ||
|
||
### Staker Contract → GNS Contract | ||
- Calls `Transfer` to distribute rewards and penalties | ||
|
||
### Router Contract → Emission Contract | ||
- Calls `MintAndDistributeGns` during swap operations | ||
|
||
### Protocol Fee Contract → Common Contract | ||
- Calls `ListRegisteredTokens` to get list of tokens | ||
- Calls `BalanceOf` to check token balances | ||
- Calls `GetTokenTeller` to get token interfaces | ||
- Calls `AdminOnly` and `GovernanceOnly` for permission checks | ||
|
||
### Community Pool Contract → Common Contract | ||
- Calls `IsHalted` to check system state | ||
- Calls `AdminOnly` and `GovernanceOnly` for permission checks | ||
- Calls `GetTokenTeller` to get token interfaces | ||
|
||
### Community Pool Contract → Token Contracts | ||
- Calls `Transfer` on token contracts through TokenTeller interface | ||
- Transfers tokens to specified addresses via governance proposals | ||
|
||
### Protocol Fee Contract → Token Contracts | ||
- Calls `Transfer` on token contracts through TokenTeller interface | ||
- Distributes fees to DevOps and Governance/Staker addresses | ||
|
||
### Launchpad Contract → Common Contract | ||
- Calls `IsRegistered` to validate token paths | ||
- Calls `GetTokenTeller` to get token interfaces | ||
- Calls `AdminOnly` for permission checks | ||
|
||
### Launchpad Contract → Emission Contract | ||
- Calls `MintAndDistributeGns` during project operations | ||
|
||
### Governance Staker Contract → XGNS Contract | ||
- Calls `Mint` to create governance tokens | ||
- Calls `Burn` to remove governance tokens | ||
- Calls `BalanceOf` to check token balances | ||
|
||
### Governance Staker Contract → GNS Contract | ||
- Calls `BalanceOf` to check token balances | ||
- Calls `Transfer` and `TransferFrom` for token operations | ||
|
||
### Governance Staker Contract → Common Contract | ||
- Calls `IsHalted` to check system state | ||
- Calls `MustRegistered` to validate token paths | ||
- Calls `GetTokenTeller` to get token interfaces | ||
|
||
### Governance Staker Contract → WUGNOT Contract | ||
- Calls `Withdraw` for native token operations | ||
|
||
### Governance Staker Contract → Emission Contract | ||
- Calls `MintAndDistributeGns` during reward operations | ||
|
||
### Launchpad Contract → GNS Contract | ||
- Calls `GetAvgBlockTimeInMs` for timing calculations | ||
- Calls `TransferFrom` and `Transfer` for token operations | ||
|
||
### Router Contract → WUGNOT Contract | ||
- Calls `BalanceOf` to check wrapped token balances | ||
- Interacts with wrap/unwrap functions for native token handling | ||
|
||
### Emission Contract → GNS Contract | ||
- Calls `MintGns` to create new GNS tokens | ||
- Calls `Transfer` to distribute tokens to: | ||
- Staker contract | ||
- DevOps address | ||
- Community Pool address | ||
- Governance Staker address | ||
- Calls `GetHalvingBlocksInRange` for emission rate updates | ||
- Calls `GetEmission` to calculate distribution amounts |
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
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
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
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,86 @@ | ||
package governance | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/gnoswap/v1/emission" | ||
"gno.land/r/gnoswap/v1/community_pool" | ||
"gno.land/r/gnoswap/v1/pool" | ||
"gno.land/r/gnoswap/v1/protocol_fee" | ||
"gno.land/r/gnoswap/v1/router" | ||
"gno.land/r/gnoswap/v1/staker" | ||
) | ||
|
||
type EmissionI struct { | ||
MintAndDistributeGns func() uint64 | ||
ChangeDistributionPct func( | ||
target01 int, | ||
pct01 uint64, | ||
target02 int, | ||
pct02 uint64, | ||
target03 int, | ||
pct03 uint64, | ||
target04 int, | ||
pct04 uint64, | ||
) | ||
GetDistributedToGovStaker func() uint64 | ||
} | ||
|
||
var en EmissionI = EmissionI{ | ||
MintAndDistributeGns: emission.MintAndDistributeGns, | ||
ChangeDistributionPct: emission.ChangeDistributionPct, | ||
GetDistributedToGovStaker: emission.GetDistributedToGovStaker, | ||
} | ||
|
||
type CommunityPoolI struct { | ||
TransferToken func(pkgPath string, to std.Address, amount uint64) | ||
} | ||
|
||
var cp CommunityPoolI = CommunityPoolI{ | ||
TransferToken: community_pool.TransferToken, | ||
} | ||
|
||
type PoolI struct { | ||
SetFeeProtocol func(feeProtocol0 uint8, feeProtocol1 uint8) | ||
SetPoolCreationFee func(poolCreationFee uint64) | ||
SetWithdrawalFee func(withdrawalFee uint64) | ||
} | ||
|
||
var pl PoolI = PoolI{ | ||
SetFeeProtocol: pool.SetFeeProtocol, | ||
SetPoolCreationFee: pool.SetPoolCreationFee, | ||
SetWithdrawalFee: pool.SetWithdrawalFee, | ||
} | ||
|
||
type ProtocolFeeI struct { | ||
SetDevOpsPct func(devOpsPct uint64) | ||
} | ||
|
||
var pf ProtocolFeeI = ProtocolFeeI{ | ||
SetDevOpsPct: protocol_fee.SetDevOpsPct, | ||
} | ||
|
||
type RouterI struct { | ||
SetSwapFee func(swapFee uint64) | ||
} | ||
|
||
var rr RouterI = RouterI{ | ||
SetSwapFee: router.SetSwapFee, | ||
} | ||
|
||
type StakerI struct { | ||
SetDepositGnsAmount func(depositGnsAmount uint64) | ||
SetPoolTier func(poolId string, poolTier uint64) | ||
ChangePoolTier func(poolId string, poolTier uint64) | ||
RemovePoolTier func(poolId string) | ||
SetUnStakingFee func(unstakingFee uint64) | ||
SetWarmUp func(percent int64, block int64) | ||
} | ||
|
||
var sr StakerI = StakerI{ | ||
SetDepositGnsAmount: staker.SetDepositGnsAmount, | ||
SetPoolTier: staker.SetPoolTier, | ||
ChangePoolTier: staker.ChangePoolTier, | ||
RemovePoolTier: staker.RemovePoolTier, | ||
SetUnStakingFee: staker.SetUnStakingFee, | ||
} |
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
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
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
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,35 @@ | ||
package staker | ||
|
||
import ( | ||
"gno.land/p/demo/avl" | ||
"gno.land/r/gnoswap/v1/emission" | ||
"gno.land/r/gnoswap/v1/protocol_fee" | ||
) | ||
|
||
// EmissionI defines the interface for emission realm interactions | ||
type EmissionI struct { | ||
MintAndDistributeGns func() uint64 | ||
GetDistributedToGovStaker func() uint64 | ||
ClearDistributedToGovStaker func() | ||
} | ||
|
||
// ProtocolFeeI defines the interface for protocol_fee realm interactions | ||
type ProtocolFeeI struct { | ||
DistributeProtocolFee func() | ||
GetAccuTransferToGovStaker func() *avl.Tree | ||
ClearAccuTransferToGovStaker func() | ||
} | ||
|
||
// en is the emission interface instance | ||
var en EmissionI = EmissionI{ | ||
MintAndDistributeGns: emission.MintAndDistributeGns, | ||
GetDistributedToGovStaker: emission.GetDistributedToGovStaker, | ||
ClearDistributedToGovStaker: emission.ClearDistributedToGovStaker, | ||
} | ||
|
||
// pf is the protocol_fee interface instance | ||
var pf ProtocolFeeI = ProtocolFeeI{ | ||
DistributeProtocolFee: protocol_fee.DistributeProtocolFee, | ||
GetAccuTransferToGovStaker: protocol_fee.GetAccuTransferToGovStaker, | ||
ClearAccuTransferToGovStaker: protocol_fee.ClearAccuTransferToGovStaker, | ||
} |
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,15 @@ | ||
package launchpad | ||
|
||
import ( | ||
"gno.land/r/gnoswap/v1/emission" | ||
) | ||
|
||
// EmissionI defines the interface for emission realm interactions | ||
type EmissionI struct { | ||
MintAndDistributeGns func() uint64 | ||
} | ||
|
||
// en is the emission interface instance | ||
var en EmissionI = EmissionI{ | ||
MintAndDistributeGns: emission.MintAndDistributeGns, | ||
} |
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,27 @@ | ||
package position | ||
|
||
import ( | ||
"gno.land/r/gnoswap/v1/pool" | ||
u256 "gno.land/p/gnoswap/uint256" | ||
) | ||
|
||
// PoolI defines the interface for pool operations | ||
type PoolI struct { | ||
GetPoolFromPoolPath func(poolPath string) *pool.Pool | ||
PoolGetSlot0SqrtPriceX96 func(poolPath string) string | ||
PoolGetSlot0Tick func(poolPath string) int32 | ||
PoolGetFeeGrowthGlobal0X128 func(poolPath string) string | ||
PoolGetFeeGrowthGlobal1X128 func(poolPath string) string | ||
PoolGetTickFeeGrowthOutside0X128 func(poolPath string, tick int32) string | ||
PoolGetTickFeeGrowthOutside1X128 func(poolPath string, tick int32) string | ||
} | ||
|
||
var pl PoolI = PoolI{ | ||
GetPoolFromPoolPath: pool.GetPoolFromPoolPath, | ||
PoolGetSlot0SqrtPriceX96: pool.PoolGetSlot0SqrtPriceX96, | ||
PoolGetSlot0Tick: pool.PoolGetSlot0Tick, | ||
PoolGetFeeGrowthGlobal0X128: pool.PoolGetFeeGrowthGlobal0X128, | ||
PoolGetFeeGrowthGlobal1X128: pool.PoolGetFeeGrowthGlobal1X128, | ||
PoolGetTickFeeGrowthOutside0X128: pool.PoolGetTickFeeGrowthOutside0X128, | ||
PoolGetTickFeeGrowthOutside1X128: pool.PoolGetTickFeeGrowthOutside1X128, | ||
} |
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
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,14 @@ | ||
package router | ||
|
||
import ( | ||
"gno.land/r/gnoswap/v1/emission" | ||
) | ||
|
||
// EmissionI defines the interface for emission operations | ||
type EmissionI struct { | ||
MintAndDistributeGns func() uint64 | ||
} | ||
|
||
var emission EmissionI = EmissionI{ | ||
MintAndDistributeGns: emission.MintAndDistributeGns, | ||
} |
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
Oops, something went wrong.