Summary

In this documentation, you will able to explore smart contracts functionalities on SOS Chain project.

Donation

This contract does donation related jobs such as minting, depositing the donated amount of assets, and recording the donation.

Function Calls

Donation Contract Function Calls

FunctionsDefinitons
donateThis function takes a fund ID, token address and donation amount. Ask _depositToSafe function with _getDepositAddress function with the parameters to safely deposit the amount with related token address. Returns true if it is completed successfully.
getRecordThis function takes an ID and returns the related donation record from mapping. Record is a struct in Donations.sol. Please refer it for detailed information.
_getDepositAddressReturns the address of the ERC721 minter contract. Asks FundManager.sol for the wallet address of that _fundId if that fund accepts deposit with related _tokenAddress. Other case reverts.
_recordDonationAuto increments the previous donation ID produced by using OpenZeppelin’s Counters.sol contract. Records it into donations mapping with donator, fundId, amount and token data. Returns the incremented donationId.
_depositToSafeMints NFT for donator with fund specific id and returns the NFT id with tokenId parameter. Uses mint function of OpenZeppelin.
_mintMints NFT for donator with fund specific id and returns the NFT id with tokenId parameter. Uses mint function of OpenZeppelin.
EventsDefinitions
DonatedEvent will be emitted from donate function to record donator, donation id, fund id, donated amount and token address.

Inheritance Flow

Donation Contract Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
DonationImplementationRegistered, Ownable
Public ❗️🛑NO❗️
donateExternal ❗️🛑NO❗️
getRecordExternal ❗️NO❗️
_getDepositAddressInternal 🔒
_recordDonationInternal 🔒🛑
_depositToSafeInternal 🔒🛑
_mintInternal 🔒🛑

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

DynamicChecks

Function Calls

DynamicChecks Contract Function Calls

FunctionsDefinitons
getCheckasa sds
allChecksdef
addCheckdef
removeCheckdef
allChecksdef
_setChecksdef
NoZeroChecksdef
_shiftPopdef

Inheritance Flow

DynamicChecks Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
DynamicChecksImplementationAccessControl
getCheckPublic ❗️NO❗️
allChecksPublic ❗️NO❗️
addCheckPublic ❗️🛑onlyRole
removeCheckPublic ❗️🛑onlyRole
_setChecksInternal 🔒🛑
_shiftPopInternal 🔒🛑

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

FundManager

This contract does management related jobs such as controlling fund addresses, checks and gets allowed tokens for a fund, calls FundV1 contract to create clones for each different funds.

Function Calls

FundManager Contract Function Calls

FunctionsDefinitons
getFundMetaGets unique identifier of the fund as parameter get a fund's name and focus and returns them.
getFundsGets all fund addresses and return them.
getDepositAddressForGets unique identifier of the fund as parameter and address of token tracker and return the address of the fund.
getFundAddressGets unique identifier of a fund as parameter and returns the fund’s deposit address.
getAllowedTokensGets unique identifier of a fund as parameter and returns list of allowed tokens for a fund.
isTokenAllowedGets unique identifier of a fund and token address as parameter and check id token is allowed to this fund.
createFundGets name of the fund, focus of the fund, description of the fund, address of underlying Gnosis Safe, Array of allowed token addresses, a Boolean indicating if fund is requestable and a list of checks if fund is requestable as parameters, create a clone of FundV1 contract, and emits an event to blockchain.
createFundWithSafeSimilar to createFund but has 2 additional parameters as address array of owners of the safe and uint256 threshold value. If threshold value is greater than owner’s length than it reverts.
setImplementationGets address of underlying Gnosis Safe sets implementation address and returns Boolean indicating operation result.
_setupSafe?
_encodeSetupGets a list of safe owners, number of required confrimations for a Safe transaction, contract address for optional delegate call, data payload for optional delegate call, a handler for fallback calls to this contract, a token that should be used for the payment, a value sthat should be paid, an address that should receive the payment as parameters and returns encoded bytes representation of the parameters with setup signature.

Creating Clones of FundV1 for Each Fund

FundV1 Clone Creation by FundManager

Inheritance Flow

FundManager Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
FundManagerImplementationAccessControl, Registered
Public ❗️🛑NO❗️
getFundMetaPublic ❗️NO❗️
getFundsPublic ❗️NO❗️
getDepositAddressForPublic ❗️NO❗️
getFundAddressPublic ❗️NO❗️
getAllowedTokensPublic ❗️NO❗️
isTokenAllowedPublic ❗️NO❗️
createFundExternal ❗️🛑onlyRole
createFundWithSafeExternal ❗️🛑onlyRole
setImplementationExternal ❗️🛑onlyRole
_setupSafeInternal 🔒🛑
_encodeSetupInternal 🔒

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

FundV1

This contract does controls over a fund such as pausing, resuming, closing it, and checking its balance, adding checks, removing checks, listing checks, watching balances.

Function Calls

FundV1 Contract Function Calls

FunctionsDefinitons
initializeCalled once by the factory at time of deployment any subsequent calls will revert. Checks for requestable fund and if a fund is requestable.
getMetaGets and returns metadata (name and focus) of a fund.
getBalancesGets and returns safe balances with addresses of balances of a fund. Different addresses for each different allowed token types.
getDepositAddressForGets and returns deposit address of an allowed token.
isOpenChecks if a fund is open for donation and returns a Boolean indicating status.
isWhiteListedChecks id if it's address is whitelisted and returns a Boolean indicating status.
pausePauses an open fund and returns a Boolean indicating result of the operation.
resumeResumes a fund if it is paused already and returns a Boolean indicating result of the operation.
closeCloses a fund if it is not closed already and returns a Boolean indicating result of the operation.
_setStatusSets status of a fund and returns a Boolean indicating result of the operation.
_batchSetImplements a batch set insertion.
getCheckGets and returns a specific check from check array.
allChecksGets and returns all checks.
addCheckAdds a check to check array and returns a Boolean indicating result of the operation.
_setChecksSets initial checks.
_shiftPopPops the top element of an array.
EventsDefinitons
`StatusChangedef

FundV1 Usage

FundV1 Usage

Inheritance Flow

FundV1 Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
FundV1ImplementationAccessControl, TokenControl
initializeExternal ❗️🛑NO❗️
getMetaExternal ❗️NO❗️
getBalancesExternal ❗️NO❗️
getDepositAddressForExternal ❗️NO❗️
isOpenExternal ❗️NO❗️
isWhitelistedExternal ❗️NO❗️
pauseExternal ❗️🛑onlyRole
resumeExternal ❗️🛑onlyRole
closeExternal ❗️🛑onlyRole
_setStatusInternal 🔒🛑
_batchSetInternal 🔒🛑
getCheckPublic ❗️NO❗️
allChecksPublic ❗️NO❗️
addCheckPublic ❗️🛑onlyRole
removeCheckPublic ❗️🛑onlyRole
_setChecksInternal 🔒🛑
_shiftPopInternal 🔒🛑

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

Governor

This contract sets up message sender's role as default administrator and sets Registry mapping.

Function Calls

Governor Contract Function Calls

FunctionsDefinitons
_setRegistrySets Registry mapping with contract addresses.#####
_setupRoleSets message sender's role as default administrator role.

Inheritance Flow

Governor Contract Inheritance Relations

Sūrya's Description Report

Files Description Table

File NameSHA-1 Hash
.\contracts\Governor.solaa54ecad0307045e99ca54571fda57f1d4dc1d9a

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
GovernorImplementationAccessControl, DynamicChecks, Registered, RequestManager
Public ❗️🛑NO❗️

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

NFTDescriptor

This contract does description of NFTs with required parameters such as side text, token id color informations, title and so on.

Function Calls

NFTDescriptor Contract Function Calls

FunctionsDefinitons
encodeSVGEncodes bytes returned from _buildSVG function and returns a memory string.
buildSVGCasts bytes returned from _buildSVG function to string and returns this string.
_buildSVGReturns bytes value of NFT
addressToStringGets an address value and converts it to a string value.
tokenToColorHexGets a token address and an offset and generates and returns a hexcode of a color with bytes value.

Inheritance Flow

NFTDescriptor Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
NFTDescriptorImplementationSVGConstants, SVGComponents
encodeSVGPublic ❗️NO❗️
buildSVGPublic ❗️NO❗️
_buildSVGPublic ❗️NO❗️
addressToStringInternal 🔒
tokenToColorHexInternal 🔒

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

Registered

This contract gets contract address from registry and inserts new addresses to registry.

Function Calls

Register Contract Function Calls

FunctionsDefinitons
_getAddressGet an address from registry that matches with the input and return the address.
_setRegistrySets registry.

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
RegisteredImplementation
_getAddressInternal 🔒
_setRegistryInternal 🔒🛑

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

Registry

This contract includes functions to read and update registries.

Function Calls

Registry Contract Function Calls

FunctionsDefinitons
registeredReturns a list of registered contract names.
getGets a name parameter as an input and return address of the contract with the same name.
batchGetGets an array of names parameter as an input and return addresses of the contracts with these names.
registerGets contract name and contract address as parameters, registers contract address into registry. Returns a Boolean indicating result of the operation.
batchRegisterGets contract names from an array and contract addresses from an array as parameters, registers contract addresses into registry. Returns a Boolean indicating result of the operation.
updateGets contract name and contract address as parameters, checks if a contract exists with this name. If exists updates the address of the contract. Else reverts. Returns a Boolean indicating result of the operation.
batchUpdate Gets contract’s names and contract addresses as parameters. Updates the address of the contract if name already exist in registry. Else continues with next contract name. Returns a Boolean indicating result of the operation.

Inheritance Flow

Registry Contract Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
RegistryImplementationOwnable
registeredPublic ❗️NO❗️
getPublic ❗️NO❗️
batchGetPublic ❗️NO❗️
registerPublic ❗️🛑onlyOwner
batchRegisterPublic ❗️🛑onlyOwner
updatePublic ❗️🛑onlyOwner
batchUpdatePublic ❗️🛑onlyOwner

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

RequestManager

This contract manages things related to fund requests such as role controls, reguest location controls, approval checks, creating the request and so on.

Function Calls

RequestManager Contract Function Calls

functiondefinition
createRequestInitiates a request with requested amount from the fund, token address, ultimate recipient of the funds requested, id of the funds requested from, a short description of the request, coordinates pointing to request location. Returns the id of the initiated request which is a _createRequest function call.
approveCheckChecks if fund is approvable or if fund is open. If not reverts. Checks for approver role. If not reverts. Checks if request’s pending check count 0, if so sets the status of request with one of Pending, Approved, Finalized, Excuted. If status is executed at the beginning of the function, it reverts. If status is Approved at the end of function request will be finalized. Returns a Boolean indicating the result of the operation.
getStatusGets a request id as an input parameter and returns the status of request with this id.
getPendingChecksCountGets a request id as an input parameter and returns pending check count parameter’s value. It shows remaining checks for a request.
getSignerGets a request id and check id as input parameters and returns the signer address of that check for this request.
callOracleXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
_isApprovableReturns true if a request’s status is Pending and approval status of request’s signature for a specific check is false.
_isFundOpenGets a FundV1 clone as an input parameter and returns the result of isOpen function of clone. It is a Boolean indicator shows that if a fund is donatable or not.
_hasFundRoleGets a clone contracts and a role as input parameters and returns a Boolean indicator that shows if message.sender account has been granted role input.
_createRequestGets parameters from createRequest function. Allocates storage location for the new request and assign new request with parameters to the storage location. Emits a RequestCreated event with parameters and request checks. Returns request id.
_approveCheckGets a request, check id and success as input parameters, requires pending check count is greater than 0. If success is true, decreases pending check count value by 1. Signs the request for that specific check.
_bumpStatusChecks if status of request is reached at maximum index, which is executed. If not, increases the status index, pending-to-approved, approved-to-finalized or finalized-to-executed.
_getFundGets a fund id as an input parameter. Initialize a fund address value for fund manager. Returns a clone of FundV1 contract that has a fund address as an input parameter.
_copyChecksFromFundGets a FundV1 contract as an input parameter. Returns all checks for that fund.
_patchRequestWithCheckGets request id and check id as input parameters and returns encoded request id, status, location informations, recipient of request, fund id, amount and token.
Modifiers
RequestCreateddef
Signeddef
OracleRequestdef
StatusChangedef

Inheritance Flow

RequestManager Contract Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
RequestManagerImplementationAccessControl, Registered
createRequestPublic ❗️🛑NO❗️
approveCheckPublic ❗️🛑NO❗️
getStatusExternal ❗️NO❗️
getPendingChecksCountExternal ❗️NO❗️
getSignerExternal ❗️NO❗️
callOracleExternal ❗️🛑NO❗️
_isApprovableInternal 🔒
_isFundOpenInternal 🔒
_hasFundRoleInternal 🔒
_createRequestInternal 🔒🛑
_approveCheckInternal 🔒🛑
_bumpStatusInternal 🔒🛑
_getFundInternal 🔒
_copyChecksFromFundInternal 🔒
_packRequestWithCheckPublic ❗️NO❗️

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

SOS

Function Calls

SOS Contract Function Calls

functionsdefinitions
constructorGets registry and minter address as input parameters. Sets message sender’s role as admin, minter address’s role as minter and sets registry.
supportsInterfaceXXXXXXXXXXXXXXXXXXXXXXXXX
SVGGets a token id as an input parameter. Pass token id, owner of token id, donation amount and type, fund name and fund focus parameters to buildSVG function of NFTDescriptor contract. Returns the result of NFTDescriptor contract’s buildSVG function, a string value.
tokenURIgets a token id as an input parameter. Fetches donation record information of that token id. Fetches fund name and focus. Creates an image string by using NFTDescriptor contract’s encodeSVG function with token id, owner of token id, donation amount, donated token, fund name and fund focus informations. Returns packed-encoded string with a name and image.
mintGets recipient address and donation ID as input parameters mints an NFT and returns the id of the minted ERC721.
_getDonationRecordGets a token id as an input parameter. Returns the record of donation matches with the input token id.
_getFundMetaGets a fund id as an input parameter. Returns the name and the focus of the fund.

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
SOSImplementationAccessControl, ERC721, Registered
Public ❗️🛑ERC721
supportsInterfacePublic ❗️NO❗️
SVGPublic ❗️NO❗️
tokenURIPublic ❗️NO❗️
mintPublic ❗️🛑onlyRole
_getDonationRecordInternal 🔒
_getFundMetaInternal 🔒

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

Inheritance Flow

SOS Chain Inheritance Relation

SVG Components

NFTDescriptor generates an SVG on the fly as the NFT representation, rather than linking to an URI

Function Calls

SVGComponents Contract Function Calls

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
SVGComponentsImplementation
colorToGridAnimInternal 🔒
stopTagInternal 🔒
sideTextInternal 🔒
titleStackInternal 🔒

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

TokenControl

does blablabla...

Function Calls

TokenControl Contract Function Calls

FunctionsDefinitons
getAllowedTokenGets an address array as an input parameter and returns a list of allowed token contract address with respect to input.
isTokenAllowedGets a tracker address of a token as an input parameter and returns a Boolean indicating value if a token is allowed for deposit.
addTokenGets a token address as an input parameter and add that token to the list of allowed tokens. Returns a Boolean indicating value.
removeTokenGets a token address as an input parameter and remove that token from the list of allowed tokens. Returns a Boolean indicating value.

Inheritance Flow

TokenControl Contract Inheritance Relations

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
TokenControlImplementationAccessControl
getAllowedTokensPublic ❗️NO❗️
isTokenAllowedPublic ❗️NO❗️
addTokenPublic ❗️🛑onlyRole
removeTokenPublic ❗️🛑onlyRole

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

OracleArgcis

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
OracleArgcisImplementationChainlinkRequestInterface, OracleInterface, Ownable, LinkTokenReceiver, WithdrawalInterface
Public ❗️🛑Ownable
oracleRequestExternal ❗️🛑onlyLINK checkCallbackAddress
fulfillOracleRequestExternal ❗️🛑onlyAuthorizedNode isValidRequest
fulfillArgcisRequestExternal ❗️🛑onlyAuthorizedNode isValidRequest
getAuthorizationStatusExternal ❗️NO❗️
setFulfillmentPermissionExternal ❗️🛑onlyOwner
withdrawExternal ❗️🛑onlyOwner hasAvailableFunds
withdrawableExternal ❗️onlyOwner
cancelOracleRequestExternal ❗️🛑NO❗️
getChainlinkTokenPublic ❗️NO❗️

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable

OracleConsumer

Contracts Description Table

ContractTypeBases
Function NameVisibilityMutabilityModifiers
OracleConsumerImplementationChainlinkClient, ConfirmedOwner, Registered
setOraclePublic ❗️🛑onlyOwner
setFeePublic ❗️🛑onlyOwner
Public ❗️🛑ConfirmedOwner
tryApprovePublic ❗️🛑onlyOwner
approveCheckPublic ❗️🛑recordChainlinkFulfillment
getChainlinkTokenPublic ❗️NO❗️
withdrawLinkPublic ❗️🛑onlyOwner
cancelRequestPublic ❗️🛑onlyOwner

Legend

SymbolMeaning
🛑Function can modify state
💵Function is payable