You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,3 +73,28 @@ The architecture is as follows:
73
73
- Each destination is expected to be a PDA that then distributes the yield to the climate project
74
74
according to their own rules. For example, the Offset Bridge bridges the funds to Polygon, buys
75
75
NCT etc.
76
+
77
+
## Usage (latest version -- Yield Router)
78
+
There is a state account owned by the yield controller program which stores the following data:
79
+
-`sunrise_state`: public key of a state account; from which the input yield account, which holds funds to be sent to PDAs that will transfer fund to various climate projects (e.g. the offset bridge), can be derived
80
+
-`update_authority`: public key of the account having the authority to update the state account
81
+
-`output_yield_accounts`: a vector holding public keys of the PDAs that will transfer funds to various climate project
82
+
-`spend_proportions`: a vector holding the proportions of funds to be sent to each elements in `output_yield_accounts`, the proportions must sum up to 100
83
+
-`spend_threshold`: minimum amount of fund existing in `sunrise_state` account before transfer of funds to `output_yield_accounts` is allowed
84
+
-`total_spent`: total amount of fund sent to various climate projects
85
+
86
+
This state account needs to be first registered on chain, this only needs to be performed once for a yield controller program. To do so, one can use the `register_state` instruction by calling the `packages/yield-router/registerState.ts` script as follow:
where `state_address` is the public key of the state account from which the input yield account can ebe derived and `output_yield_address` is the address of the public key of the first PDA of a climate project.
89
+
90
+
When using the `packages/yield-router/registerState.ts` script to register the state, currently it only supports registering the state first with only one output yield account address. To update it with multiple output yield accounts (or any other updates in terms of removing certain yield accounts or changing the proportions between the various output yield accounts), one can use the `update_state` instruction by calling the `packages/yield-router/updateState.ts` script as follow:
one will first be prompted to enter a new update authority address, this is to be skipped when it is not wished to update the update authority. Afterwards, the new output yield addresses and the associated spending proportions will be prompted to be input one by one, the proportions must sum up to 100.
93
+
94
+
To send funds from the input yield account (`sunrise_state`) to the `output_yield_accounts` with the specified `spend_threshold`, one needs to simply use the `allocate_yield` instruction by calling `packages/yield-router/allocateYield.ts` script as follow:
This script contains various instructions and will return the state account address, the state account data, the balance of the input yield account and the balance of the output yield account.
0 commit comments